Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, a device, and a storage medium for system upgrade, so as to implement a scheme for upgrading a partition table and a system based on an over-the-air technology.
In a first aspect, an embodiment of the present invention provides a system upgrade method, where the method includes:
acquiring original user data partition information stored in an original partition table, wherein the original user data partition information comprises an original starting address and an original ending address of a user data partition, and the original user data partition information is located at the starting position of the original partition table;
acquiring new user data partition information stored in a new partition table, wherein the new user data partition information comprises a new start address and a new end address of the user data partition, and the new user data partition information is located at the start position of the new partition table;
and if the original starting address is the same as the new starting address and the original ending address is different from the new ending address, upgrading the system according to the new partition table.
Further, the acquiring of the new user data partition information stored in the new partition table includes:
acquiring a system upgrading data packet based on an over-the-air downloading mode;
and analyzing the new partition table in the system upgrading data packet to obtain the new user data partition information.
Further, after the new user data partition information stored in the new partition table is obtained, the method further includes:
determining a preset storage space of the user data partition corresponding to the new partition table based on the new starting address and the new ending address;
comparing the data occupation space in the user data partition corresponding to the original partition table with the preset storage space;
and if the occupied space of the data is larger than the preset storage space, terminating the system upgrading according to the new partition table.
Further, still include: and if the data occupation space is smaller than or equal to the preset storage space, comparing whether the original starting address is the same as the new starting address.
Further, comparing whether the original start address is the same as the new start address comprises:
and if the original starting address is different from the new starting address, terminating the system upgrading according to the new partition table.
Further, still include: if the original starting address is the same as the new starting address, the original starting address of the user data partition is stored and unchanged, and the original ending address of the user data partition is updated to be the new ending address.
Further, after parsing the new partition table in the system upgrade data packet, the method further includes:
acquiring the partition information of other data partitions in the new partition table;
and updating the starting address and the ending address of the other data partitions according to the information of the other partitions.
Further, the upgrading the system according to the new partition table includes:
loading the new partition table;
and writing the upgrade partition data in the system upgrade data packet obtained by analysis into the other updated data partitions.
In a second aspect, an embodiment of the present invention provides a system upgrading apparatus, where the apparatus includes:
a first obtaining module, configured to obtain original user data partition information stored in an original partition table, where the original user data partition information includes an original start address and an original end address of a user data partition, and the original user data partition information is located at a start position of the original partition table;
a second obtaining module, configured to obtain new user data partition information stored in a new partition table, where the new user data partition information includes a new start address and a new end address of the user data partition, and the new user data partition information is located at a start position of the new partition table;
and the upgrading module is used for upgrading the system according to the new partition table if the original starting address is the same as the new starting address and the original ending address is different from the new ending address.
In a third aspect, an embodiment of the present invention provides an electronic device, including: a memory, a processor; wherein the content of the first and second substances,
the memory is configured to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of system upgrade as described in the first aspect.
In a fourth aspect, an embodiment of the present invention provides a computer storage medium for storing a computer program, where the computer program is used to make a computer implement the method for upgrading a system according to the first aspect when executed.
In the system upgrading method provided by the embodiment of the invention, when the partition table is set, the original user data partition information of the user data partition is stored at the initial position of the original partition table; and when the system is upgraded subsequently, the new user data partition information in the new partition table in the system upgrade data packet is also positioned at the initial position. Meanwhile, the new start address of the user data partition in the new partition table is the same as the original start address of the user data partition in the original partition table, and if the original end address is different from the new end address, system upgrading is carried out according to the new partition table. By the technical scheme, based on the over-the-air download technology, the upgrading of the system and the partition table can be realized without carrying out data backup on the user data partition, and meanwhile, the user data partition is not cleared; the partition table upgrading process is simplified, and the system and partition table upgrading efficiency are improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the invention and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, and "the plural" typically includes at least two, but does not exclude the presence of at least one.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter associated objects are in an "or" relationship.
The words "if", as used herein, may be interpreted as "at \8230; \8230when" or "when 8230; \823030, when" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrase "if determined" or "if detected (a stated condition or event)" may be interpreted as "upon determining" or "in response to determining" or "upon detecting (a stated condition or event)" or "in response to detecting (a stated condition or event)", depending on the context.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a good or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such good or system. Without further limitation, an element defined by the phrases "comprising one of 8230; \8230;" 8230; "does not exclude the presence of additional like elements in articles of commerce or systems including such elements.
It should be noted that the original partition table may be understood as a partition table currently in use in the device, and the new partition table may be understood as a partition table to be used soon.
In the existing system upgrade scheme, the storage order of each partition information in the partition table is not fixed, for example, under the condition of factory setting, the user data partition information in the initial partition table is located at the last position of the partition table, and after one upgrade is performed, the user data partition information may be stored at the initial position of the partition table. Since the location of the user data partition information in the partition table changes, the user data partition information may also be modified, which may result in data loss in the user data partition. In addition, data loss may also occur if the storage address of the user data partition changes, specifically, if the start address of the user data partition changes, the content in the user data partition is lost or completely erased. If the user data is not lost due to the upgrade of the partition table, it is necessary to ensure that the position of the user data partition information in the partition table is not modified and the initial address of the user data partition is not changed.
Fig. 1 is a schematic flow chart of a system upgrading method according to an embodiment of the present invention, where the method mainly includes the following steps:
101: the method comprises the steps of obtaining original user data partition information stored in an original partition table, wherein the original user data partition information comprises an original starting address and an original ending address of a user data partition, and the original user data partition information is located at the starting position of the original partition table.
In the original partition table, many data partition information, such as user data partition (userdata) information, kernel partition information, system partition information, and the like, are stored at the same time. In the original user data partition information, an original start address (e.g., original user data partition start header number, sector number, etc.), an original end address (e.g., original user data partition end header number, sector number, etc.), a file system flag, and the like may be included. The original user data partition information is located at the start position of the original partition table, and it is understood that the original user data partition information is located at a position earlier than the positions of other partition information in the partition table, in other words, the user data partition information is located at the first position in all partition information. When other partition information is changed or the storage sequence of other partition information in the partition table is changed, the original user data partition information is stored in the initial position of the original partition table in order that the original user data partition information is not changed.
102: acquiring new user data partition information stored in a new partition table, wherein the new user data partition information comprises a new start address and a new end address of the user data partition, and the new user data partition information is located at the start position of the new partition table.
In practical applications, the new partition table is parsed from the system upgrade data packet obtained by Over The Air (OTA) technique. When the operating system and the partition table are upgraded subsequently, it is necessary to ensure that the new user data partition information is located at the initial position of the new partition table. The new user data partition information is located at the start position of the new staging table, which is understood to mean that the new user data partition information is located at a position earlier than the other partition information in the partition table, in other words, the user data partition information is located at the first position in all the partition information. The storage locations of the partition information in the original partition table and the new partition table are shown in fig. 2.
It should be noted that the order of steps 101 and 102 is not limited strictly, that is, step 101 may be executed first and then step 102 may be executed, or step 102 may be executed first and then step 101 may be executed.
103: and if the original starting address is the same as the new starting address and the original ending address is different from the new ending address, upgrading the system according to the new partition table.
After the original partition table and the new partition table are obtained, the start address and the end address are compared. Specifically, the original start address and the new start address are compared, and if the original start address is the same as the new start address, the original end address and the new end address may be further compared.
If the original starting address is the same as the new starting address and the original ending address is the same as the new ending address, the user data partition information in the partition table is not changed, and the data in the user data partition and the user data partition information in the partition table do not need to be upgraded. For example, if the user data partition does not need to be upgraded, part of the upgrade may be performed when the system upgrade data packet is generated, and the system upgrade data packet may not include user data partition data, user data partition information, and the like; therefore, the upgrading operation can be simplified, and the upgrading efficiency is improved.
If the original starting address is the same as the new starting address and the original ending address is different from the new ending address, the partition table is changed, and the size of the corresponding partition storage space is also changed. The partition table and operating system need to be upgraded simultaneously.
In one or more embodiments of the present invention, the obtaining of the new user data partition information stored in the new partition table may specifically include: acquiring a system upgrading data packet based on an over-the-air downloading mode; and analyzing the new partition table in the system upgrading data packet to obtain the new user data partition information.
For example, assuming that the operating system to be upgraded is a mobile phone terminal operating system, when a new system version exists, the server pushes a new system upgrade prompt message to each mobile phone terminal. If the user wants to upgrade the system, the user can select to download the corresponding system upgrade data packet. The mobile phone terminal device analyzes the system upgrading data packet to obtain a new partition table (of course, other data to be written in the upgrading packet) contained in the upgrading packet, so that the new user data partition information in the new partition table can be determined.
In one or more embodiments of the present invention, after obtaining the new user data partition information stored in the new partition table, the method may further include: determining a preset storage space of the user data partition corresponding to the new partition table based on the new starting address and the new ending address; comparing the data occupation space in the user data partition corresponding to the original partition table with the preset storage space; and if the occupied space of the data is larger than the preset storage space, terminating the system upgrading according to the new partition table.
For example, according to the new start address and the new end address, the preset storage space of the user data partition corresponding to the new partition table is determined to be 1G space, where the preset storage space may be understood as a storage space set when the system upgrade data packet is made. The data occupation space stored in the user data partition corresponding to the original partition table is 1.2G, and it can be known that the data occupation space 1.2G is significantly larger than the size of the preset storage space 1G, and if the ending address of the user data partition is changed according to the new partition table, the user data is lost, so that the upgrade of the operating system according to the new partition table needs to be terminated. Since the size of the preset storage space cannot satisfy the requirement of storing the existing user data, the comparison between the original start address and the new start address is not required.
In one or more embodiments of the present invention, the method may further include: and if the data occupation space is smaller than or equal to the preset storage space, comparing whether the original starting address is the same as the new starting address.
For example, if the occupied space of the data is 1G and the preset storage space is 1.2G, the occupied space of the data is significantly smaller than the preset storage space, and the comparison between the original start address and the new start address can be continued. So that it can be further judged whether the partition table and the system can be upgraded based on the new partition table.
In one or more embodiments of the present invention, comparing whether the original start address is the same as the new start address may further include: and if the original starting address is different from the new starting address, terminating the system upgrading according to the new partition table.
If the original starting address in the original partition table is different from the new starting address in the new partition table, it indicates that the partition table and the actual storage address of the corresponding user data partition have changed, and if the operation of system upgrade is continuously executed according to the new partition table, the user data in the user data partition will be deleted. Therefore, if the original start address is different from the new start address according to the comparison, the original end address and the new end address do not need to be compared, and the operation of upgrading the system according to the new partition table can be terminated.
In one or more embodiments of the present invention, the method may further include: if the original starting address is the same as the new starting address and the original ending address is different from the new ending address, the original starting address of the user data partition is kept unchanged, and the original ending address of the user data partition is updated to be the new ending address.
In practical application, if the comparison shows that the original start address is the same as the new start address and the original end address is different from the new end address, the end address of the user data partition is updated to the new end address under the condition that the current start address of the user data partition (the current start address is the same as the original start address and the new start address) is kept unchanged in order to avoid the data in the user data partition from being erased. For example, the Resize2fs instruction may be used to adjust the user data partition end address to an end address in the new partition table.
In one or more embodiments of the present invention, after parsing the new partition table in the system upgrade data packet, the method may further include: acquiring the partition information of other data partitions in the new partition table; and updating the starting address and the ending address of the other data partitions according to the information of the other partitions.
In practical application, if the operating system needs to be upgraded, it may be necessary to upgrade multiple data partitions and corresponding partition information in the partition table at the same time. Therefore, other data partitions and corresponding partition information also need to be acquired. Other data partitions as referred to herein may be understood as data partitions in the system other than user data partitions. If the information of other data partitions changes, the upgrading operation of each data partition needs to be further performed according to the information of other data partitions.
In one or more embodiments of the present invention, the performing system upgrade according to the new partition table may specifically include: loading the new partition table; and writing the upgrade partition data in the system upgrade data packet obtained by analysis into the other updated data partitions.
And after the new partition table is confirmed to be available, loading the new partition table and refreshing the corresponding block device. And writing the data corresponding to each data partition contained in the system upgrading data packet into the corresponding updated other data partitions.
Based on the same idea, as shown in fig. 3, a schematic structural diagram of a system upgrading apparatus provided in an embodiment of the present invention is shown. The embodiment of the present invention further provides a system upgrading apparatus, including:
a first obtaining module 31, configured to obtain original user data partition information stored in an original partition table, where the original user data partition information includes an original start address and an original end address of a user data partition, and the original user data partition information is located at a start position of the original partition table;
a second obtaining module 32, configured to obtain new user data partition information stored in a new partition table, where the new user data partition information includes a new start address and a new end address of the user data partition, and the new user data partition information is located at a start position of the new partition table;
and the upgrading module 33 is configured to, if the original start address is the same as the new start address and the original end address is different from the new end address, upgrade the system according to the new partition table.
Further, the first obtaining module 31 is configured to obtain a system upgrade data package based on an over-the-air download manner;
and analyzing the new partition table in the system upgrading data packet to obtain the new user data partition information.
Further, still include: a comparing module 34, configured to determine, based on the new start address and the new end address, a preset storage space of the user data partition corresponding to the new partition table;
comparing the data occupation space in the user data partition corresponding to the original partition table with the preset storage space;
and if the occupied space of the data is larger than the preset storage space, terminating the system upgrading according to the new partition table.
Further, the method also comprises the following steps: after the comparison by the comparison module 34, if the occupied space of the data is smaller than or equal to the preset storage space, comparing whether the original start address is the same as the new start address.
Further, comprising: after the comparison by the comparison module 34, if the original start address is different from the new start address, the system upgrade according to the new partition table is terminated.
Further, still include: after comparison by the comparison module 34, if the original start address is the same as the new start address, the original start address of the user data partition is saved and the original end address of the user data partition is updated to the new end address.
Further, the upgrading module 33 is configured to obtain partition information of other data partitions in the new partition table;
and updating the starting address and the ending address of the other data partitions according to the information of the other partitions.
Further, the upgrading module 33 is configured to load the new partition table; and writing the upgrade partition data in the system upgrade data packet obtained by analysis into the other updated data partitions.
Based on the same idea, as shown in fig. 4, an embodiment of the present invention further provides an electronic device, which is characterized by including: a memory 41, a processor 42; wherein, the first and the second end of the pipe are connected with each other,
the memory 41 is used for storing one or more computer instructions, wherein the one or more computer instructions, when executed by the processor 42, implement the method for system upgrade as described in the above embodiments.
Based on the same idea, an embodiment of the present invention further provides a computer storage medium for storing a computer program, where the computer program enables a computer to implement the method for upgrading a system according to the above embodiment when executed.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course, can also be implemented by a combination of hardware and software. With this understanding in mind, the above-described solutions and/or portions thereof that are prior art may be embodied in the form of a computer program product, which may be embodied on one or more computer-usable storage media having computer-usable program code embodied therein (including but not limited to disk storage, CD-ROM, optical storage, etc.).
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable coordinate determination device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable coordinate determination device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable coordinate determination apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable coordinate determination device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer implemented process such that the instructions which execute on the computer or other programmable device provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, and not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.