Flash memory partition data processing method, device, computer equipment and storage medium
By detecting file changes in an embedded system and backing up data when the timer triggers, the problem of flash partition data being lost when the system is powered down is solved, and system stability and data integrity are improved.
Patent Information
- Application Number
- CN202110254531.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-09
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2041-03-09
AI Technical Summary
In embedded systems, data from flash partitions are easily lost when the system is powered off abnormally, resulting in abnormal system startup.
By detecting that there is an incremental file in the target subdirectory of the mount temporary file system, the timer is triggered to time. When the timing value reaches the preset value, the file is compressed and written to the logical erase block of the application partition, and generate Back up the file and back up the data in the second logical erase block to ensure that the data is written before powering down.
It effectively avoids data loss in flash partitions, improves system stability and data integrity, and ensures that even if the system powers down during the update process, data loss will not be caused.
Smart Images

Figure CN113050887B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of embedded technology, and in particular to a partition data processing method, device, computer equipment and storage medium. Background Art
[0002] With the development of source code and the maturity of technology, Linux system is widely used in embedded design. The configuration data and log information of embedded system are generally stored in flash memory. Linux system directly mounts some partitions in nandflash to the corresponding directory, and then the user program modifies the files in the corresponding directory, and the files are stored in nandflash in the form of binary data.
[0003] However, currently when user programs read and write files in a specified directory, data is copied from the kernel cache to the user program during a read operation, and data is copied from the user program to the kernel cache during a write operation, and then the kernel writes the data to the flash. If power is lost before the kernel has written the data back to the flash, the data in the kernel cache will be lost and the system will start abnormally. Summary of the invention
[0004] Based on this, it is necessary to provide a flash partition data processing method, device, computer equipment and storage medium to address the above technical problems, which can avoid the loss of important data in the flash partition when the system loses power abnormally, resulting in system abnormality.
[0005] A flash memory partition data processing method, the method comprising:
[0006] When it is detected that the first incremental file exists in the target subdirectory of the mounted temporary file system, the timer is triggered to start timing from the initial preset value;
[0007] When the timing value of the timer reaches a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file;
[0008] Generate a file write instruction; the file write instruction carries file write strategy data;
[0009] Based on the file writing strategy data, writing the compressed file into a first backup directory of a first logical erase block of an application partition to obtain a first backup file;
[0010] The first backup file is written into the second backup directory of the second logical erase block of the application partition to obtain the second backup file, thereby completing the processing of the flash memory partition data.
[0011] In one embodiment, the method further comprises:
[0012] When the timing value of the timer is not the target preset value and it is detected that there is a second incremental file in the target subdirectory, the timer is reset and the initial preset value is updated; the updated initial preset value is less than the initial preset value;
[0013] Triggering the timer to start timing from the updated initial preset value;
[0014] When the timing value of the timer reaches the target preset value, the file carrying the second incremental file is compressed and the timer is reset, and the step of generating a file write instruction is executed.
[0015] In one embodiment, the flash memory includes a system partition and an application partition, and before the timer is triggered to count from an initial preset value when the first incremental file is detected to exist in the target subdirectory of the mounted temporary file system, the method further includes:
[0016] Start the application after mounting the system partition;
[0017] The application partition is mounted, and when an abnormal mounting of the application partition is detected, the application partition is formatted, and the application partition is initialized according to an initial configuration file in an initial backup directory of the root file system to obtain a first backup directory of the application partition.
[0018] In one embodiment, the method further comprises:
[0019] When the system is detected to be running, obtaining a first MD5 value of a first backup directory in the application partition;
[0020] The first MD5 value is verified, and when the verification passes, the first backup directory is decompressed and copied to the target subdirectory.
[0021] In one embodiment, the method further comprises:
[0022] When the first MD5 value verification fails, obtaining a second MD5 value of the second backup directory in the application partition;
[0023] The second MD5 value is verified, and when the verification passes, the second backup directory is decompressed and copied to the target subdirectory.
[0024] In one embodiment, the method further comprises:
[0025] When a system status control instruction is received, the incremental files in the target subdirectory are compressed and the step of generating a file write instruction is executed.
[0026] A flash memory partition data processing device, the device comprising:
[0027] A detection module, configured to trigger a timer to start timing from an initial preset value when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system;
[0028] A compression module, used for compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file when the timing value of the timer is a target preset value;
[0029] A generating module, used for generating a file writing instruction; the file writing instruction carries file writing strategy data;
[0030] A first writing module, configured to write the compressed file into a first backup directory of a first logical erase block of an application partition based on the file writing strategy data, to obtain a first backup file;
[0031] The second writing module is used to write the first backup file into the second backup directory of the second logical erase block of the application partition to obtain the second backup file and complete the processing of the flash memory partition data.
[0032] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0033] When it is detected that the first incremental file exists in the target subdirectory of the mounted temporary file system, the timer is triggered to start timing from the initial preset value;
[0034] When the timing value of the timer reaches a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file;
[0035] Generate a file write instruction; the file write instruction carries file write strategy data;
[0036] Based on the file writing strategy data, writing the compressed file into a first backup directory of a first logical erase block of an application partition to obtain a first backup file;
[0037] The first backup file is written into the second backup directory of the second logical erase block of the application partition to obtain the second backup file, thereby completing the processing of the flash memory partition data.
[0038] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0039] When it is detected that the first incremental file exists in the target subdirectory of the mounted temporary file system, the timer is triggered to start timing from the initial preset value;
[0040] When the timing value of the timer reaches a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file;
[0041] Generate a file write instruction; the file write instruction carries file write strategy data;
[0042] Based on the file writing strategy data, writing the compressed file into a first backup directory of a first logical erase block of an application partition to obtain a first backup file;
[0043] The first backup file is written into the second backup directory of the second logical erase block of the application partition to obtain the second backup file, thereby completing the processing of the flash memory partition data.
[0044] The above-mentioned flash memory partition data processing method, device, computer equipment and storage medium, when detecting the existence of the first incremental file in the target subdirectory, that is, detecting the writing of the first incremental file in the memory, triggers the timer to start timing from the initial preset value, and when the timing value of the timer reaches the target preset value, compresses the file carrying the first incremental file and resets the timer; writes the compressed file into the first backup directory of the first logical erase block and the second backup directory of the second logical erase block of the application partition according to the file write instruction, obtains the first backup file and the second backup file, and completes the processing of the flash memory partition data; that is, by writing the incremental file into the memory, and storing the file of the target subdirectory into the flash memory by delaying the timer, and backing up the file, it is ensured that when the power is off during the file update process, the file is not written into the flash memory, and the data loss in the flash memory is avoided to avoid system startup abnormality, thereby improving the stability of the system and the integrity of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A schematic diagram of a process flow of a flash memory partition data processing method in one embodiment;
[0046] Figure 2 A schematic diagram of a process for handling application partition mounting exceptions in one embodiment;
[0047] Figure 3 A schematic diagram of a flow chart of a flash memory partition data processing method in another embodiment;
[0048] Figure 4 A schematic diagram of an application scenario of application partition mounting exception handling in one embodiment;
[0049] Figure 5 is a structural block diagram of a flash memory partition data processing device in an embodiment;
[0050] Figure 6FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0052] In one embodiment, Figure 1 As shown, a flash memory partition data processing method is provided. This embodiment takes the method applied to a terminal as an example for illustration. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0053] Step 102, when it is detected that there is a first incremental file in the target subdirectory of the mounted temporary file system, a timer is triggered to start timing from an initial preset value.
[0054] The temporary file system is a memory-based file system, i.e., a tmpfs file system; the first incremental file refers to the file whose target subdirectory is modified, i.e., the added file, which can be a user data file or a system configuration file. The initial preset value can be, but is not limited to, 10 seconds, 8 seconds, and 5 seconds.
[0055] Specifically, when the terminal is turned on, the system partition is automatically mounted to the directory and then the application is started. The user partition is mounted through the mount point. When the user partition is mounted successfully, the user program runs normally. When the terminal service detects that the file in the target subdirectory of the mounted temporary file system is modified, the timer is triggered to start, and the timer starts timing according to the initial preset value, and can be a countdown according to the initial preset value.
[0056] Step 104: When the timing value of the timer reaches the target preset value, the file carrying the first incremental file is compressed and the timer is reset to obtain a compressed file.
[0057] The target preset value refers to a preset value, which may be, but is not limited to, 0. For example, it may also be 1 or 2.
[0058] Specifically, when the timer counts according to the initial preset value and the timing value is the target preset value, all files under the target subdirectory are compressed, that is, the file set carrying the first incremental file is compressed to obtain a compressed file corresponding to the target subdirectory; and the timer is initialized, that is, reset to the initial preset value. For example, when the timer counts down according to the initial preset value 10 and the timing value is the target preset value 0, all files under the target subdirectory are compressed to obtain a compressed file.
[0059] Step 106: Generate a file write instruction.
[0060] The file write instruction is a command to write a target file into a target storage area. The target storage area may be a UBI volume that is mapped to a user partition. The UBI volume is a series of logical erase blocks. The file write instruction carries file write policy data.
[0061] Step 108: Based on the file writing policy data, write the compressed file into the first backup directory of the first logical erase block of the application partition to obtain a first backup file.
[0062] The file writing strategy data may be, but is not limited to, first writing the file into the first backup directory of the first logical erase block of the application partition to obtain the first backup file; then copying the first backup file into the second backup directory of the second logical erase block of the application partition to obtain the second backup file. The data of the first backup file and the second backup file are the same. When the first backup file is lost, the second backup file can be obtained from the second backup directory of the second logical erase block to avoid file loss and ensure data integrity.
[0063] Step 110, writing the first backup file into the second backup directory of the second logical erase block of the application partition to obtain the second backup file, thereby completing the processing of the flash memory partition data.
[0064] Specifically, based on the file writing strategy data, after backing up the compressed file in sequence to the first backup directory of the first logical erase block of the application partition and the second backup directory of the second logical erase block of the application partition, the data writing of the flash memory application partition is completed according to the mapping relationship between the logical erase block and the application partition. For example, when the system loses power abnormally, it is possible but not limited to obtain the first backup file from the first backup directory, and update the application program of the application partition according to the first backup file. When the first backup file is damaged, obtain the second backup file from the second backup directory, and update the application program of the application partition according to the second backup file.
[0065] In the above-mentioned flash memory partition data processing method, the first incremental file in the target subdirectory is first written into the memory, and the timer is triggered to count according to the initial preset value. When the timing value of the timer is the target preset value, the file carrying the first incremental file is compressed and the timer is reset; according to the file write instruction, the compressed file is written into the first backup directory of the first logical erase block and the second backup directory of the second logical erase block of the application partition to obtain the first backup file and the second backup file, and the processing of the flash memory partition data is completed; that is, by writing the incremental file into the memory, and delaying the storage of the file of the target subdirectory into the flash memory through the timer, and backing up the file, it is ensured that when the power is off during the file update process, the file is not written into the flash memory, so as to avoid the loss of data in the flash memory causing the system startup abnormality, thereby improving the stability of the system and the integrity of the data.
[0066] In one embodiment, Figure 2 As shown, a method for handling application partition mounting exceptions is provided. This embodiment uses the method applied to a terminal as an example. In this embodiment, the method includes the following steps:
[0067] Step 202: when an abnormal mounting of the application partition is detected, the application partition is formatted, and the application partition is initialized according to the initial configuration file in the initial backup directory of the root file system to obtain a first backup directory of the application partition.
[0068] The root file system is a file system based on the system partition in the flash memory, and the flash memory is divided into a system partition and an application partition.
[0069] Specifically, when the terminal detects an abnormal mounting of the application partition, it formats the application partition, and based on the root file system of the system partition, initializes the application partition according to the initial configuration file in the initial backup directory in the root file system to obtain the first backup directory of the application partition, that is, restores the initial settings of the application partition, which can also be understood as restoring the application partition to its factory state.
[0070] Step 204, determine whether the first MD5 value of the first backup directory in the application partition has passed the verification. If so, execute step 206, otherwise execute step 208.
[0071] The MD5 value refers to the Message Digest Algorithm (MD5), which treats the entire file as a large text message and generates a unique MD5 information digest through its irreversible string transformation algorithm.
[0072] Step 206: decompress the first backup directory and copy it to the target subdirectory.
[0073] Step 208: Obtain a second MD5 value of the second backup directory in the application partition.
[0074] Step 210, verify the second MD5 value to determine whether the second MD5 value passes the verification, if so, execute step 212, otherwise, execute step 214.
[0075] Step 212: decompress and copy the second backup directory to the target subdirectory.
[0076] Step 214: Copy the initial backup directory in the system partition to obtain a third backup directory, and copy the third backup directory to the target subdirectory.
[0077] Among them, the first, second, and third are used to distinguish the backup directories obtained from different locations. The first backup directory refers to the backup directory of the first logical erase block in the first logic in the application partition; the second backup directory refers to the backup directory of the second logical erase block in the second logic in the application partition; the third backup directory refers to the root file system based on the system partition, which is obtained by copying the initial backup directory in the root file system.
[0078] In the above-mentioned application partition mounting exception handling method, when the application partition is mounted abnormally, the application partition is formatted, and the application partition is initialized according to the initial configuration file in the initial backup directory of the root file system to obtain the first backup directory of the application partition; when the first MD5 value of the first backup directory in the application partition passes the verification, the first backup directory is decompressed and copied to the target subdirectory; when the first MD5 value of the first backup directory in the application partition fails to pass the verification, the directory in the target subdirectory is determined by verifying whether the second MD5 value of the second backup directory in the application partition is correct, to ensure the normal operation of the system and the normal reading and writing of the target subdirectory data.
[0079] In another embodiment, Figure 3 As shown, a flash memory partition data processing method is provided. This embodiment takes the method applied to a terminal as an example for illustration. In this embodiment, the method includes the following steps:
[0080] Step 302: When it is detected that there is a first incremental file in the target subdirectory of the mounted temporary file system, a timer is triggered to start timing from an initial preset value.
[0081] Optionally, in one embodiment, the flash memory includes a system partition and an application partition. When the first incremental file is detected in the target subdirectory of the mounted temporary file system, the application is started by mounting the system partition before the timer is triggered to start timing from the initial preset value; the application partition is mounted, and when an application partition mounting abnormality is detected, the application partition is formatted, and the application partition is initialized according to the initial configuration file in the initial backup directory of the root file system to obtain the first backup directory of the application partition; by detecting whether the application partition is mounted abnormally, the application partition with the mounting abnormality is formatted and initialized to ensure that data can be written normally.
[0082] Optionally, in one embodiment, after the application partition is initialized to obtain the first backup directory of the application partition, when the system is detected to be running, the first MD5 value of the first backup directory in the application partition is obtained; the first MD5 value is verified, and when the verification passes, the first backup directory is decompressed and copied to the target subdirectory; when the first MD5 value verification fails, the second MD5 value of the second backup directory in the application partition is obtained; the second MD5 value is verified, and when the verification passes, the second backup directory is decompressed and copied to the target subdirectory, when the second MD5 value verification fails, the initial backup directory in the system partition is copied to obtain a third backup directory, the third backup directory is copied to the target subdirectory, and the backup directory is verified according to the MD5 value to ensure the integrity and accuracy of the backup directory.
[0083] Step 304, when the timing value of the timer is not the target preset value, check whether there is a second incremental file in the target sub-directory, if so, execute step 306, otherwise, execute step 310.
[0084] Step 306, resetting the timer and updating the initial preset value, wherein the updated initial preset value is smaller than the initial preset value.
[0085] Step 308: trigger the timer to start timing from the updated initial preset value.
[0086] Specifically, when there is a first incremental file in the target subdirectory, the timer is triggered to count down from the initial preset value. During the countdown, it is detected that there is a second incremental file in the target subdirectory, that is, a file in the target subdirectory has been modified again. The timer is reset and the initial preset value is updated. The updated initial preset value is smaller than the initial preset value. The timer is triggered to count from the updated initial preset value. When the timing value of the timer is the target preset value, the file carrying the first incremental file is compressed and the timer is reset to obtain a compressed file. During the countdown, it is detected that a file in the target subdirectory has been modified again. By resetting the timer and updating the initial preset value, frequent writing is avoided to cause data errors, thereby improving data accuracy.
[0087] Step 310: When the timing value of the timer reaches the target preset value, the file carrying the first incremental file is compressed and the timer is reset to obtain a compressed file.
[0088] Step 312, generating a file writing instruction; the file writing instruction carries file writing policy data.
[0089] Step 314: based on the file writing policy data, write the compressed file into the first backup directory of the first logical erase block of the application partition to obtain a first backup file.
[0090] Step 316, write the first backup file into the second backup directory of the second logical erase block of the application partition to obtain the second backup file, and complete the processing of the flash memory partition data.
[0091] Optionally, in one embodiment, when a system status control instruction is received, the incremental files in the target subdirectory are compressed and the step of generating a file write instruction is executed, that is, the system status control instruction can be any one of a shutdown or restart instruction; the files in the target subdirectory are backed up and compressed to avoid data loss when the system is shut down or restarted.
[0092] like Figure 4 As shown, the following is an application scenario diagram of flash memory partition data processing in an embodiment.
[0093] After the terminal is powered on and the system partition is mounted, the application is started and the application partition is mounted. When an abnormal mounting of the application partition is detected, the application partition is formatted, and the application partition is initialized according to the initial configuration file in the initial backup directory of the root file system to obtain the first backup directory A of the application partition. When the system is detected to be running, the first MD5 value of the first backup directory A in the application partition is obtained; the first MD5 value is verified, and when the verification passes, the first backup directory is decompressed and copied to the target subdirectory; when the first MD5 value verification fails, the second MD5 value of the second backup directory B in the application partition is obtained; the second MD5 value is verified, and when the verification passes, the second backup directory B is decompressed and copied to the target subdirectory.
[0094] The background service process (for example, process A, process B, process C) monitors all files under directory D and monitors whether the files in the target subdirectory are modified. When it is detected that there is a first incremental file in the target subdirectory of the mounted temporary file system, the timer is triggered to start timing from the initial preset value; when the timing value of the timer is the target preset value, the file carrying the first incremental file is compressed and the timer is reset to obtain a compressed file; when the timing value of the timer is not the target preset value and it is detected that there is a second incremental file in the target subdirectory, the timer is reset and the initial preset value is updated; the updated initial preset value is less than the initial preset value; the timer is triggered to start timing from the updated initial preset value; when the timing value of the timer is the target preset value, the file carrying the second incremental file is compressed and the timer is reset, and the step of generating a file write instruction is executed.
[0095] Generate a file write instruction; the file write instruction carries file write strategy data; based on the file write strategy data, write the compressed file into the first backup directory of the first logical erase block of the application partition to obtain a first backup file; write the first backup file into the second backup directory of the second logical erase block of the application partition to obtain a second backup file, and complete the processing of the flash partition data; ensure the integrity of the file by verifying the MD5 value of the file in the application partition, and on the basis of ensuring the integrity of the file, when it is detected that the first incremental file exists in the target subdirectory, trigger the timer to start timing from the initial preset value, and delay the storage of the file in the target subdirectory; during the timing process of the timer, it is detected that the file in the target subdirectory is modified again, and the timer is reset and the initial preset value is updated to avoid frequent writing, resulting in data errors, thereby improving data accuracy.
[0096] In the above-mentioned flash memory partition data processing method, when it is detected that there is a first incremental file in the target subdirectory of the mounted temporary file system, the timer is triggered to count from the initial preset value. If it is detected that the file in the target subdirectory is modified again, the timer is reset and the initial preset value is updated, and the updated initial preset value is less than the initial preset value, the timer is triggered to count from the updated initial preset value. When the timing value of the timer is the target preset value, the file carrying the first incremental file is compressed and the timer is reset to obtain a compressed file; based on the file write strategy data, the compressed file is written into the first logical erase block and the second logical erase block of the application partition in sequence to obtain the first backup file and the second backup file, and the processing of the flash memory partition data is completed; according to the mapping relationship between the logical erase block and the application partition, the data writing of the flash memory application partition is completed to ensure that when the terminal system loses power abnormally, the incremental file is first written into the memory to avoid data loss in the flash memory causing system startup abnormality, thereby improving the stability of the system and the integrity of the data.
[0097] It should be understood that although Figure 1-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-3 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0098] In one embodiment, Figure 5 As shown, a flash memory partition data processing device is provided, including: a detection module 502, a compression module 504, a generation module 506, a first writing module 508 and a second writing module 510, wherein:
[0099] The detection module 502 is used to trigger the timer to start timing from an initial preset value when it is detected that the first incremental file exists in the target subdirectory of the mounted temporary file system.
[0100] The compression module 504 is used to compress the file carrying the first incremental file and reset the timer to obtain a compressed file when the timing value of the timer reaches a target preset value.
[0101] The generating module 506 is used to generate a file writing instruction; the file writing instruction carries the file writing strategy data.
[0102] The first writing module 508 is used to write the compressed file into the first backup directory of the first logical erase block of the application partition based on the file writing policy data to obtain a first backup file.
[0103] The second writing module 510 is used to write the first backup file into the second backup directory of the second logical erase block of the application partition to obtain the second backup file and complete the processing of the flash memory partition data.
[0104] In the above-mentioned flash memory partition data processing device, the first incremental file in the target subdirectory is first written into the memory, and the timer is triggered to count according to the initial preset value. When the timing value of the timer is the target preset value, the file carrying the first incremental file is compressed and the timer is reset; according to the file write instruction, the compressed file is written into the first backup directory of the first logical erase block and the second backup directory of the second logical erase block of the application partition to obtain the first backup file and the second backup file, and the processing of the flash memory partition data is completed; that is, by writing the incremental file into the memory, and delaying the storage of the file of the target subdirectory into the flash memory through the timer, and backing up the file, it is ensured that when the power is off during the file update process, the file is not written into the flash memory, so as to avoid the loss of data in the flash memory causing the system startup abnormality, thereby improving the stability of the system and the integrity of the data.
[0105] In another embodiment, a flash memory partition data processing device is provided, which includes, in addition to a detection module 502, a compression module 504, a generation module 506, a first writing module 508 and a second writing module 510, a mounting module, an initialization module, an acquisition module, a verification module and a reset module, wherein:
[0106] The mount module is used to start the application after mounting the system partition.
[0107] The initialization module is used to mount the application partition. When an abnormal mounting of the application partition is detected, the application partition is formatted, and the application partition is initialized according to the initial configuration file in the initial backup directory of the root file system to obtain the first backup directory of the application partition.
[0108] The acquisition module is used to acquire the first MD5 value of the first backup directory in the application partition when detecting that the system is running.
[0109] The verification module is used to verify the first MD5 value, and when the verification passes, the first backup directory is decompressed and copied to the target subdirectory.
[0110] In one embodiment, the verification module is also used to obtain the second MD5 value of the second backup directory in the application partition when the first MD5 value verification fails; verify the second MD5 value, and when the verification passes, decompress and copy the second backup directory to the target subdirectory.
[0111] A reset module is used to reset the timer and update the initial preset value when the timing value of the timer is not the target preset value and a second incremental file is detected in the target subdirectory; the updated initial preset value is less than the initial preset value.
[0112] The detection module includes a trigger submodule, and the trigger submodule is used to trigger the timer to count from the updated initial preset value.
[0113] In one embodiment, the compression module 504 is further configured to compress the file carrying the second incremental file and reset the timer when the timing value of the timer reaches a target preset value.
[0114] In one embodiment, the compression module 504 is further configured to compress the incremental files in the target subdirectory upon receiving a system status control instruction.
[0115] In one embodiment, after the terminal is powered on and the system partition is mounted, the application is started and the application partition is mounted. When an abnormality in the mounting of the application partition is detected, the application partition is formatted, and the application partition is initialized according to the initial configuration file in the initial backup directory of the root file system to obtain the first backup directory of the application partition. When the system is detected to be running, the first MD5 value of the backup directory A in the application partition is obtained; the first MD5 value is verified, and when the verification passes, the first backup directory is decompressed and copied to the target subdirectory; when the first MD5 value verification fails, the second MD5 value of the backup directory B in the application partition is obtained; the second MD5 value is verified, and when the verification passes, the second backup directory is decompressed and copied to the target subdirectory.
[0116] The background service process (for example, process A, process B, process C, process D) monitors all files under directory D and monitors whether the files in the target subdirectory are modified. When it is detected that there is a first incremental file in the target subdirectory of the mounted temporary file system, the timer is triggered to start timing from the initial preset value; when the timing value of the timer is the target preset value, the file carrying the first incremental file is compressed and the timer is reset to obtain a compressed file; when the timing value of the timer is not the target preset value and it is detected that there is a second incremental file in the target subdirectory, the timer is reset and the initial preset value is updated; the updated initial preset value is less than the initial preset value; the timer is triggered to start timing from the updated initial preset value; when the timing value of the timer is the target preset value, the file carrying the second incremental file is compressed and the timer is reset, and the step of generating a file write instruction is executed.
[0117] Generate a file write instruction; the file write instruction carries file write policy data; based on the file write policy data, write the compressed file into the first backup directory of the first logical erase block of the application partition to obtain a first backup file; write the first backup file into the second backup directory of the second logical erase block of the application partition to obtain a second backup file, and complete the processing of the flash memory partition data; store the files of the target subdirectory into the flash memory by delaying the storage through a timer, and back up and store the files, to ensure that the power is off during the file update process and the files are not written into the flash memory, to avoid data loss in the flash memory causing system startup abnormality, and to improve the stability of the system and the integrity of the data.
[0118] For the specific definition of the flash partition data processing device, please refer to the definition of the flash partition data processing method above, which will not be repeated here. Each module in the above-mentioned flash partition data processing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0119] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a flash memory partition data processing method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0120] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0121] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0122] When it is detected that the first incremental file exists in the target subdirectory of the mounted temporary file system, the timer is triggered to start timing from the initial preset value;
[0123] When the timing value of the timer reaches the target preset value, the file carrying the first incremental file is compressed and the timer is reset to obtain a compressed file;
[0124] Generate a file write instruction; the file write instruction carries file write strategy data;
[0125] Based on the file writing strategy data, the compressed file is written into a first backup directory of a first logical erase block of the application partition to obtain a first backup file;
[0126] The first backup file is written into the second backup directory of the second logical erase block of the application partition to obtain the second backup file, thereby completing the processing of the flash memory partition data.
[0127] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0128] When the timing value of the timer is not the target preset value and it is detected that there is a second incremental file in the target subdirectory, the timer is reset and the initial preset value is updated; the updated initial preset value is less than the initial preset value;
[0129] The trigger timer starts timing from the updated initial preset value;
[0130] When the timing value of the timer reaches the target preset value, the file carrying the second incremental file is compressed and the timer is reset, and the step of generating a file write instruction is executed.
[0131] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0132] Start the application after mounting the system partition;
[0133] Mount the application partition. When an abnormal mounting of the application partition is detected, format the application partition. Initialize the application partition according to the initial configuration file in the initial backup directory of the root file system to obtain the first backup directory of the application partition.
[0134] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0135] When the system is detected to be running, the first MD5 value of the first backup directory in the application partition is obtained;
[0136] The first MD5 value is verified, and when the verification passes, the first backup directory is decompressed and copied to the target subdirectory.
[0137] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0138] When the first MD5 value verification fails, obtaining a second MD5 value of the second backup directory in the application partition;
[0139] The second MD5 value is verified, and when the verification passes, the second backup directory is decompressed and copied to the target subdirectory.
[0140] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0141] When a system status control instruction is received, the incremental files in the target subdirectory are compressed and the step of generating a file write instruction is executed.
[0142] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0143] When it is detected that the first incremental file exists in the target subdirectory of the mounted temporary file system, the timer is triggered to start timing from the initial preset value;
[0144] When the timing value of the timer reaches the target preset value, the file carrying the first incremental file is compressed and the timer is reset to obtain a compressed file;
[0145] Generate a file write instruction; the file write instruction carries file write strategy data;
[0146] Based on the file writing strategy data, the compressed file is written into a first backup directory of a first logical erase block of the application partition to obtain a first backup file;
[0147] The first backup file is written into the second backup directory of the second logical erase block of the application partition to obtain the second backup file, thereby completing the processing of the flash memory partition data.
[0148] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0149] When the timing value of the timer is not the target preset value and it is detected that there is a second incremental file in the target subdirectory, the timer is reset and the initial preset value is updated; the updated initial preset value is less than the initial preset value;
[0150] The trigger timer starts timing from the updated initial preset value;
[0151] When the timing value of the timer reaches the target preset value, the file carrying the second incremental file is compressed and the timer is reset, and the step of generating a file write instruction is executed.
[0152] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0153] Start the application after mounting the system partition;
[0154] Mount the application partition. When an abnormal mounting of the application partition is detected, format the application partition. Initialize the application partition according to the initial configuration file in the initial backup directory of the root file system to obtain the first backup directory of the application partition.
[0155] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0156] When the system is detected to be running, the first MD5 value of the first backup directory in the application partition is obtained;
[0157] The first MD5 value is verified, and when the verification passes, the first backup directory is decompressed and copied to the target subdirectory.
[0158] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0159] When the first MD5 value verification fails, obtaining a second MD5 value of the second backup directory in the application partition;
[0160] The second MD5 value is verified, and when the verification passes, the second backup directory is decompressed and copied to the target subdirectory.
[0161] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0162] When a system status control instruction is received, the incremental files in the target subdirectory are compressed and the step of generating a file write instruction is executed.
[0163] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0164] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0165] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A flash memory partition data processing method, characterized in that: The method comprises: When it is detected that the first incremental file exists in the target subdirectory of the mounted temporary file system, the timer is triggered to start timing from the initial preset value; When the timing value of the timer reaches a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file; Generate a file write instruction; the file write instruction carries file write strategy data; Based on the file writing strategy data, writing the compressed file into a first backup directory of a first logical erase block of an application partition to obtain a first backup file; Writing the first backup file into the second backup directory of the second logical erase block of the application partition to obtain a second backup file, thereby completing the processing of the flash memory partition data; The method further comprises: When the system is detected to be running, obtaining a first MD5 value of a first backup directory in the application partition; Verify the first MD5 value, and when the first MD5 value passes the verification, decompress and copy the first backup directory to the target subdirectory; When the first MD5 value verification fails, obtaining a second MD5 value of the second backup directory in the application partition; Verify the second MD5 value, and when the second MD5 value passes the verification, decompress and copy the second backup directory to the target subdirectory; When the second MD5 value check fails, copying the initial backup directory in the system partition to obtain a third backup directory, and copying the third backup directory to the target subdirectory, wherein the third backup directory refers to a root file system based on the system partition, and is obtained by copying the initial backup directory in the root file system; The method further comprises: When the timing value of the timer is not the target preset value and it is detected that there is a second incremental file in the target subdirectory, the timer is reset and the initial preset value is updated; the updated initial preset value is less than the initial preset value; Triggering the timer to start timing from the updated initial preset value; When the timing value of the timer reaches the target preset value, the file carrying the second incremental file is compressed and the timer is reset, and the step of generating a file write instruction is executed.
2. The method according to claim 1, characterized in that: The flash memory includes a system partition and an application partition. When the first incremental file is detected to exist in the target subdirectory of the mounted temporary file system, before the timer is triggered to start timing from the initial preset value, the method further includes: Start the application after mounting the system partition; The application partition is mounted, and when an abnormal mounting of the application partition is detected, the application partition is formatted, and the application partition is initialized according to an initial configuration file in an initial backup directory of the root file system to obtain a first backup directory of the application partition.
3. The method according to claim 1, characterized in that The method further comprises: When a system status control instruction is received, the incremental files in the target subdirectory are compressed and the step of generating a file write instruction is executed.
4. The method according to claim 1, characterized in that: The root file system is a file system based on a system partition in a flash memory, and the flash memory is divided into the system partition and the application partition.
5. The method according to claim 1, characterized in that The first backup directory refers to the backup directory of the first logical erase block in the first logic in the application partition; the second backup directory refers to the backup directory of the second logical erase block in the second logic in the application partition.
6. A flash memory partition data processing device, characterized in that: The device comprises: A detection module, configured to trigger a timer to start timing from an initial preset value when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system; A compression module, used for compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file when the timing value of the timer is a target preset value; A generating module, used for generating a file writing instruction; the file writing instruction carries file writing strategy data; A first writing module, configured to write the compressed file into a first backup directory of a first logical erase block of an application partition based on the file writing strategy data, to obtain a first backup file; A second writing module, used for writing the first backup file into a second backup directory of a second logical erase block of the application partition to obtain a second backup file, and complete the processing of the flash memory partition data; The device also includes: An acquisition module, configured to acquire a first MD5 value of a first backup directory in the application partition when detecting that the system is running; a verification module, configured to verify the first MD5 value, and when the first MD5 value is verified, decompress and copy the first backup directory to the target subdirectory; when the first MD5 value is verified, obtain a second MD5 value of the second backup directory in the application partition; verify the second MD5 value, and when the second MD5 value is verified, decompress and copy the second backup directory to the target subdirectory; when the second MD5 value is verified, copy the initial backup directory in the system partition to obtain a third backup directory, and copy the third backup directory to the target subdirectory, wherein the third backup directory refers to a root file system based on the system partition, and is obtained by copying the initial backup directory in the root file system; The device also includes: A detection loop module, used for resetting the timer and updating the initial preset value when the timing value of the timer is not the target preset value and a second incremental file is detected in the target subdirectory; the updated initial preset value is less than the initial preset value; A triggering module, used for triggering the timer to start timing from an updated initial preset value; The compression module is also used to compress the file carrying the second incremental file and reset the timer when the timing value of the timer is a target preset value.
7. The device according to claim 6, characterized in that The device also includes: Mounting module, used to start the application after mounting the system partition; The initialization module is used to mount the application partition. When an abnormal mounting of the application partition is detected, the application partition is formatted, and the application partition is initialized according to the initial configuration file in the initial backup directory of the root file system to obtain the first backup directory of the application partition.
8. The device according to claim 6, characterized in that The compression module is also used to compress the incremental files in the target subdirectory and execute the step of generating a file write instruction when receiving a system status control instruction.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
