Data protection method and device, electronic equipment, storage medium and program product
By detecting file operations and writing abnormal events in the vehicle computer system, and synchronously processing the first file and its copy data, the problem of data loss of sensitive file in the vehicle computer system is solved, and data protection is efficient and low cost is achieved.
Patent Information
- Application Number
- CN202411973752.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-28
- Publication Date
- 2025-06-10
AI Technical Summary
In vehicle computer systems, data loss or corruption of sensitive files can lead to business interruption. The existing technology relies on data protection mechanisms of storage hardware equipment and file systems, and there are problems of high cost and technical difficulty.
By detecting the trigger operation and writing exception events of files in the vehicle machine system, the first file and the data copied to the second file are processed simultaneously to ensure the integrity of the data when writing exceptions.
There is no need to rely on the data protection mechanism of storage hardware devices and file systems, which realizes the protection of file data when writing exceptions, ensures data integrity, and reduces the technical difficulty and development cost of data protection.
Smart Images

Figure CN120124092A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a data protection method, apparatus, electronic device, storage medium, and program product. Background Art
[0002] There are some sensitive files in a vehicle-mounted system. For example, critical keys or sensitive data stored securely. If the data of these sensitive files is lost or damaged, the services relying on the sensitive files cannot run.
[0003] In the related art, through the data protection mechanism of a hardware storage device or a file system, on the one hand, it is necessary to additionally set a non-volatile memory, increasing the cost; on the other hand, it depends on the file system itself. When the log recording mechanism of the file system fails or is damaged, it will lead to the loss of file data and the problem that the file system cannot be correctly mounted. Summary of the Invention
[0004] To overcome the problems in the related art, the present disclosure provides a data protection method, apparatus, electronic device, storage medium, and program product, so as to not rely on the data protection mechanism of a storage hardware device and a file system, not only ensuring the data integrity of the first file and the second file after a write exception event, but also reducing the technical difficulty and development cost of data protection.
[0005] According to a first aspect of an embodiment of the present disclosure, a data protection method is provided, including:
[0006] When a trigger operation for a first file in the vehicle-mounted system is detected and there is a write exception event before the trigger operation, synchronize the data written to the first file and the data copied to a second file when performing a write operation on the first file;
[0007] After completing the data synchronization of the first file and the second file, perform a processing operation on the first file after the data synchronization.
[0008] In some embodiments, the synchronizing the data written to the first file and the data copied to the second file when performing a write operation on the first file includes:
[0009] Obtain first check information generated based on the data in the first file before the write exception event, second check information generated based on the data in the first file after the write exception event, and third check information generated based on the data in the second file;
[0010] Verify the first file based on the first verification information and the second verification information to obtain a first verification result, and verify the second file based on the first verification information and the third verification information to obtain a second verification result;
[0011] Synchronize the data written to the first file and the data copied to the second file based on the first verification result and / or the second verification result.
[0012] In some embodiments, the synchronizing the data written to the first file and the data copied to the second file based on the first verification result and / or the second verification result includes:
[0013] When the first verification result indicates that the first file passes the verification, synchronize the data of the first file to the second file;
[0014] When the second verification result indicates that the second file passes the verification, synchronize the data of the second file to the first file.
[0015] In some embodiments, the synchronizing the data written to the first file and the data copied to the second file based on the first verification result and / or the second verification result includes:
[0016] When the first verification result indicates that the first file passes the verification and the second verification result indicates that the second file fails the verification, synchronize the data of the first file to the second file;
[0017] When the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file passes the verification, synchronize the data of the second file to the first file.
[0018] In some embodiments, the method further includes:
[0019] When the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file fails the verification, output a prompt message;
[0020] Wherein, the prompt message is used to prompt that the data of the first file is in a lost state.
[0021] In some embodiments, the method further includes:
[0022] Respond to a processing operation performed on the first file after data synchronization to obtain a processed first file;
[0023] Update the second file after data synchronization based on the difference information between the first file after processing and the second file after data synchronization.
[0024] In some embodiments, the write exception event at least includes: a power-off event of the in-vehicle system or a thread interception event when a write operation is performed on the first file.
[0025] According to a second aspect of the embodiments of the present disclosure, a data protection device is provided, including:
[0026] A synchronization module configured to synchronize the data written to the first file and the data copied to the second file when a trigger operation for the first file in the in-vehicle system is detected and there is a write exception event before the trigger operation;
[0027] An execution module configured to perform a processing operation on the first file after data synchronization after completing the data synchronization of the first file and the second file.
[0028] In some embodiments, the synchronization module includes:
[0029] An acquisition module configured to acquire first check information generated based on the data in the first file before the write exception event, second check information generated based on the data in the first file after the write exception event, and third check information generated based on the data in the second file;
[0030] A check module configured to check the first file based on the first check information and the second check information to obtain a first check result, and check the second file based on the first check information and the third check information to obtain a second check result;
[0031] A synchronization processing module configured to synchronize the data written to the first file and the data copied to the second file based on the first check result and / or the second check result.
[0032] In some embodiments, the synchronization processing module is specifically configured to:
[0033] Synchronize the data of the first file to the second file when the first check result indicates that the first file passes the check;
[0034] Synchronize the data of the second file to the first file when the second check result indicates that the second file passes the check.
[0035] In some embodiments, the synchronization processing module is further configured to:
[0036] When the first verification result indicates that the first file passes the verification and the second verification result indicates that the second file fails the verification, synchronize the data of the first file to the second file;
[0037] When the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file passes the verification, synchronize the data of the second file to the first file.
[0038] In some embodiments, the apparatus further includes:
[0039] An output module, configured to output a prompt message when the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file fails the verification;
[0040] Wherein, the prompt message is used to prompt that the data of the first file is in a lost state.
[0041] In some embodiments, the apparatus further includes:
[0042] An update module, configured to obtain a processed first file in response to performing a processing operation on the first file after data synchronization;
[0043] Update the second file after data synchronization based on the difference information between the processed first file and the second file after data synchronization.
[0044] In some embodiments, the write exception event at least includes: a power-off event of the in-vehicle system or a thread interception event when performing a write operation on the first file.
[0045] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including:
[0046] A processor;
[0047] A memory for storing computer programs or instructions;
[0048] Wherein, the processor executes the computer programs or instructions to implement the steps in any one of the data protection methods in the first aspect above.
[0049] According to a fourth aspect of the embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium, including:
[0050] When the computer programs or instructions in the storage medium are executed by the processor, the steps in any one of the data protection methods in the first aspect above are implemented.
[0051] According to a fifth aspect of the embodiments of the present disclosure, there is provided a computer program product including a computer program or instructions, which, when executed by a processor, implement the steps in any of the data protection methods in the first aspect above.
[0052] The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects:
[0053] In the embodiments of the present disclosure, when a trigger operation for a first file in the in-vehicle system is detected and there is a write anomaly event before the trigger operation, the data written to the first file and the data copied to a second file when performing a write operation on the first file are synchronously processed; after the data synchronization of the first file and the second file is completed, a processing operation is performed on the first file after the data synchronization.
[0054] In the embodiments of the present disclosure, without relying on the data protection mechanism of the storage hardware device and the file system, by synchronously processing the data of the first file and the data copied to the second file when performing a write operation on the first file, the protection function of the file data during write anomalies can be achieved, thereby not only ensuring the data integrity of the first file and the second file after the write anomaly event, but also reducing the technical difficulty and development cost of data protection.
[0055] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure and used together with the specification to explain the principles of the present disclosure.
[0057] Figure 1 is a flowchart illustration of a data protection method provided by an embodiment of the present disclosure Figure 1 ;
[0058] Figure 2 is a flowchart illustration of a data protection method provided by an embodiment of the present disclosure Figure 2 ;
[0059] Figure 3 is a flowchart illustration of a data protection method provided by an embodiment of the present disclosure Figure 3 ;
[0060] Figure 4 is a flowchart illustration of a data protection method provided by an embodiment of the present disclosure Figure 4 ;
[0061] Figure 5It is a block diagram of a data protection device provided by an embodiment of the present disclosure;
[0062] Figure 6 It is a structural block diagram of an electronic device 600 provided by an embodiment of the present disclosure. Specific embodiments
[0063] Here, exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are merely examples of devices consistent with some aspects of the present disclosure as detailed in the appended claims.
[0064] Figure 1 It is a flowchart of a data protection method provided by an embodiment of the present disclosure Figure 1 , such as Figure 1 shown, the data protection method mainly includes the following steps:
[0065] In step 101, when a trigger operation for a first file in the in-vehicle system is detected and there is a write anomaly event before the trigger operation, synchronize the data written to the first file and the data copied to a second file when performing a write operation on the first file;
[0066] In step 102, after completing the data synchronization of the first file and the second file, perform a processing operation on the first file after the data synchronization.
[0067] It should be noted that the data protection method proposed by the present disclosure can be applied to an electronic device. Here, the electronic device may include: a terminal device, for example, a mobile terminal or a fixed terminal. Among them, the mobile terminal may include: a mobile phone, a tablet computer, a notebook computer, a wearable electronic device, and other devices. The fixed terminal may include: a desktop computer, a smart TV, an in-vehicle device, and the like. In other embodiments, the data protection method may also be applied to an application installed on the electronic device.
[0068] In other embodiments, the data protection method in the embodiments of the present disclosure may be configured in a data protection device, and the data protection device may be set in the electronic device, and the embodiments of the present disclosure do not limit this. It should be noted that the execution subject of the embodiments of the present disclosure may be a central processing unit (CPU) in the electronic device in terms of hardware, and may be a related background service in the electronic device in terms of software, and this is not limited.
[0069] In some embodiments, the in-vehicle system is the core program for managing the hardware and software resources of the in-vehicle computer and is also the cornerstone of the vehicle computer system. The hardware of the in-vehicle system may include modules such as the in-vehicle unit itself, instrument panel, TBOX, mobile phone, and vehicle sensors. The operating system of the in-vehicle system may include Win CE, QNX, Linux, or Android, etc. These operating systems provide a stable operating environment for the in-vehicle system and support the development and operation of various applications.
[0070] Here, the first file in the in-vehicle system may be a conventional system file. Exemplarily, the first file is a series of system files generated during the installation and operation of the operating system, such as configuration files, log files, or system library files, etc.; Another exemplarily, the first file is a cache file generated during the installation and operation of an application. Among them, the application may include entertainment applications, navigation applications, or communication applications, etc.
[0071] The first file may also be a sensitive file. Exemplarily, the first file is sensitive data imported by the user from an external device (such as a USB flash drive, hard disk, etc.) or a network location, and these data are stored in the form of files; Another exemplarily, the first file is a sensitive file generated during the operation of an encryption software or encryption system, and these files contain sensitive information such as the user's personal information, core data, or encryption keys, etc. Here, the encryption system may include a key management system based on the file system or a trusted execution environment (TEE) security storage based on the local file system, etc.
[0072] It should be noted that when a trigger operation for the first file in the in-vehicle system is detected and there is a write anomaly event before the trigger operation, there will be a situation where the data of the first file is abnormal, resulting in the interruption of the service or business associated with the first file, which is not conducive to improving the user experience.
[0073] Here, the trigger operation indicates an open operation of the file. Data anomaly indicates data loss or data corruption.
[0074] Therefore, in the embodiments of the present disclosure, during the first write operation of the first file, the data when the first file is written is copied to the second file, so that after a write anomaly event is triggered, the data of the first file and the data of the second file are synchronized to implement the protection function of the data of the first file or the data of the second file in case of a write anomaly, thereby ensuring the integrity of the data.
[0075] Here, the second file is a backup file of the first file. The storage spaces of the first file and the second file may be the same or different.
[0076] It can be understood that since the data of the first file is consistent with the data of the second file, even if there is a subsequent write anomaly event that causes the data of the first file to be lost (or damaged), the data of the first file can be restored based on the data of the second file, so as to restore the data of the first file after the write anomaly event to the data of the first file before the write anomaly event, ensuring data integrity.
[0077] Here, a write anomaly event refers to a special situation that prevents data from being correctly and completely written to the target location during the data writing process. The write anomaly event can be triggered when performing a write operation on the first file, or can be triggered when copying the data of the first file to the second file. The embodiments of the present disclosure do not limit this.
[0078] In some embodiments, the write anomaly event is a vehicle infotainment system power-off event. For example, in the case of copying the data of the first file to the second file, due to reasons such as aging, poor connection, or short circuit of the power line of the vehicle infotainment system, a fault occurs in the power line, resulting in the interruption of the copy process, so that the data indicated by the copy operation and the original data of the second file are lost or damaged.
[0079] In other embodiments, the write anomaly event is a thread interception event. For example, when performing a write operation on the first file, due to situations such as the operating system crashing, the application crashing, or the first file being occupied by other processes, the process that is writing data is intercepted, so that the data indicated by the write operation and the original data of the first file are lost or damaged.
[0080] Here, synchronizing the data of the first file and the data of the second file can be understood as synchronizing the data of the first file to the data of the second file, or can be understood as synchronizing the data of the second file to the data of the first file. The embodiments of the present disclosure do not limit this.
[0081] In some embodiments, when a trigger operation of the first file is detected and there is a write anomaly event before the trigger operation, the data of the first file is directly synchronized to the data of the second file, or the data of the second file is directly synchronized to the data of the first file, thereby improving the efficiency of data synchronization.
[0082] In other embodiments, the data written to the first file and the data copied to the second file when performing a write operation on the first file can be first matched to determine the changed data in the first file or the changed data in the second file; then the changed data is synchronized, which can effectively reduce the data transmission volume and shorten the synchronization time.
[0083] In some other embodiments, to improve the reliability of data synchronization, the data of the first file and the data of the second file may be verified, the file with abnormal data may be determined from the first file and the second file, and then the file with abnormal data may be synchronized into a file with no abnormal data.
[0084] It can be understood that after the data synchronization of the first file and the second file is completed, a processing operation is performed on the first file after the data synchronization.
[0085] In some embodiments, to improve the reliability of data synchronization, after the data synchronization of the first file and the second file, the hash value of the first file after synchronization and the hash value of the second file after synchronization are calculated respectively; when the hash value of the first file after synchronization is the same as the hash value of the second file after synchronization, it is determined that the data synchronization of the first file and the second file is completed; when the hash value of the first file after synchronization is different from the hash value of the second file after synchronization, it is determined that the data synchronization of the first file and the second file is not completed, and then the data of the first file and the data of the second file continue to be synchronized.
[0086] Here, the processing operation includes but is not limited to read operation, write operation, rename operation, copy operation or move operation, etc., which are not limited in the embodiments of the present disclosure.
[0087] In some embodiments, in the case of performing a write operation on the first file after the data synchronization, the first file after the write operation is obtained; the data of the second file after the data synchronization may be synchronized to the data of the first file after the write operation, so as to ensure that the data of the first file is synchronized with the data of the second file, and to avoid the situation that when the data of the first file is damaged or lost due to a subsequent write exception event, the data of the first file cannot be obtained.
[0088] In the embodiments of the present disclosure, when a trigger operation for the first file in the in-vehicle system is detected and there is a write exception event before the trigger operation, the data written to the first file and the data copied to the second file when the write operation is performed on the first file are synchronously processed; after the data synchronization of the first file and the second file is completed, a processing operation is performed on the first file after the data synchronization.
[0089] In the embodiments of the present disclosure, without relying on the data protection mechanism of the storage hardware device and the file system, by synchronously processing the data of the first file and the data copied to the second file when the write operation is performed on the first file, the protection function of the file data in the case of a write exception can be realized, so that not only the data integrity of the first file and the second file after the write exception event is ensured, but also the technical difficulty and development cost of data protection are reduced.
[0090] Figure 2 It is a schematic flow of a data protection method provided by an embodiment of the present disclosure Figure 2 , as Figure 2 shown, the data protection method mainly includes the following steps:
[0091] In step 201, when a trigger operation for the first file in the in-vehicle system is detected and there is a write anomaly event before the trigger operation, synchronize the data written to the first file and the data copied to the second file when performing the write operation on the first file;
[0092] In step 202, obtain the first check information generated based on the data in the first file before the write anomaly event, the second check information generated based on the data in the first file after the write anomaly event, and the third check information generated based on the data in the second file;
[0093] In step 203, check the first file based on the first check information and the second check information to obtain the first check result, and check the second file based on the first check information and the third check information to obtain the second check result;
[0094] In step 204, synchronize the data written to the first file and the data copied to the second file based on the first check result and / or the second check result.
[0095] It should be noted that considering that when synchronizing data, there is a situation where a file with no data anomaly is synchronized to a file with data anomaly. Therefore, in order to improve the accuracy of data synchronization, the data of the first file and the data of the second file can be checked first to determine the file with data anomaly from the first file and the second file, and then the file with data anomaly can be synchronized to a file with no data anomaly.
[0096] It can be understood that the first file before the write anomaly event is a file with no data anomaly. Checking the first file and the second file after the write anomaly event based on the first file before the write anomaly event can improve the accuracy of data check. Therefore, the first check information generated based on the data in the first file before the write anomaly event can be obtained first, and based on the first check information, the first file and the second file after the write anomaly event can be checked.
[0097] Here, the ways to obtain the first check information include but are not limited to checksum, cyclic redundancy check (CRC), and message digest check, etc.
[0098] Taking the first check information as the checksum as an example, determine whether the data in the first file is of an odd number of byte lengths. If the data in the first file is of an odd number of byte lengths, one or more 0 bytes can be added at the end to make the odd number of byte lengths become an even number of byte lengths; then the data is grouped by a certain unit (such as 2 bytes, 4 bytes, etc.); then the bytes in each group are accumulated to obtain an accumulated sum; if the accumulated sum exceeds the representation range of the selected unit (such as 16 bits, 32 bits, etc.), the high bits and the low bits can be added until there is no carry; then the bitwise inversion (i.e., taking the one's complement) or taking the complement (i.e., finding the two's complement) operation is performed on the final accumulated sum to obtain the checksum.
[0099] Taking the first check information as the hash value as an example, use the selected HASH algorithm to calculate the original data. For example, if the MD5 algorithm is selected, the data in the first file needs to be divided into 512-bit data blocks according to the principle of the MD5 algorithm, and through a series of non-linear transformations and permutation operations, a 128-bit hash value is finally obtained. If the SHA-1 algorithm is selected, the data in the first file needs to be grouped by 512 bits and through a series of complex operations, a 160-bit hash value is finally obtained. Here, the HASH algorithm can also include the SHA-2 algorithm, the SHA-3 algorithm, and the MD3 algorithm, etc.
[0100] In some embodiments, after obtaining the first check information, the first check information and the second file can be stored in the same storage space so that when it is necessary to check the first file or the second file, the first check information can be obtained in a timely manner.
[0101] It should be noted that in order to improve the efficiency of checking the first file and the second file after a write exception event, after obtaining the first check information, the second check information generated based on the data in the first file and the third check information generated based on the data in the second file after the write exception event can be obtained; and based on the first check information and the second check information, the first check result of the first file after the write exception event is obtained; and based on the first check information and the third check information, the second check result of the second file after the write exception event is obtained; then based on the first check result or the second check result, the data synchronization operation of the first file and the second file is performed.
[0102] Here, the check order of the first file and the second file can be set arbitrarily according to requirements, and the embodiments of the present disclosure do not limit this.
[0103] The first check result is used to indicate whether the first file passes the check, and the second check result is used to indicate whether the second file passes the check.
[0104] In some embodiments, the first verification information and the second verification information may be compared to obtain a first verification result. When the first verification information is consistent with the second verification information, a first verification result indicating that the first file passes the verification is obtained, and then it is determined that the first file is a file with no data anomalies; when the first verification information is inconsistent with the second verification information, a first verification result indicating that the first file fails the verification is obtained, and then it is determined that the first file is a file with data anomalies.
[0105] In some other embodiments, the first verification information and the third verification information may be compared to obtain a second verification result. When the first verification information is consistent with the third verification information, a second verification result indicating that the second file passes the verification is obtained, and then it is determined that the second file is a file with no data anomalies; when the first verification information is inconsistent with the third verification information, a second verification result indicating that the second file fails the verification is obtained, and then it is determined that the second file is a file with data anomalies.
[0106] Here, when the first verification information is a checksum, both the second verification information and the third verification information are also checksums; when the first verification information is a hash value, both the second verification information and the third verification information are also hash values.
[0107] In some embodiments, in order to improve the efficiency of data synchronization, when the first verification result or the second verification result is obtained, the data of the first file and the data of the second file may be synchronized. For example, when the first verification result indicates that the first file fails the verification, there is no need to verify the second file, and the data of the first file is directly synchronized to the data of the second file. Another example is that when the second verification result indicates that the second file fails the verification, there is no need to verify the first file, and the data of the second file is directly synchronized to the data of the first file.
[0108] Here, the data of the first file and the data of the second file may also be synchronized based on the first verification result and the second verification result, thereby improving the reliability of data synchronization and reducing the situation of ineffective synchronization.
[0109] Exemplarily, when the first verification result indicates that the first file passes the verification and the second verification result indicates that the second file fails the verification, the data of the first file is synchronized to the second file. When the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file passes the verification, the data of the second file is synchronized to the first file.
[0110] In the embodiments of the present disclosure, by obtaining the first verification information based on the data in the first file before writing the abnormal event, verifying the first file and the second file after writing the abnormal event, determining the file with data anomalies from the first file and the second file, and then synchronizing the file with data anomalies to the file with no data anomalies, the accuracy of data synchronization is improved.
[0111] In some embodiments, based on the first verification result and / or the second verification result, synchronizing the data written to the first file and the data copied to the second file includes:
[0112] When the first verification result indicates that the verification of the first file passes, synchronize the data of the first file to the second file;
[0113] When the second verification result indicates that the verification of the second file passes, synchronize the data of the second file to the first file.
[0114] It can be understood that, in order to improve the efficiency of data synchronization, when the first verification result indicates that the verification of the first file passes, it is determined that the first file is a file with no data anomalies, and then the data of the first file is synchronized to the second file; when the second verification result indicates that the verification of the second file passes, it is determined that the second file is a file with no data anomalies, and then the data of the second file is synchronized to the first file.
[0115] In some embodiments, when the first verification result indicates that the verification of the first file fails, it is determined that the first file is a file with data anomalies, and then the second verification result is obtained; when the second verification result indicates that the verification of the second file passes, it is determined that the second file is a file with no data anomalies, and then the data of the second file is synchronized to the first file. Here, the second verification result can also be obtained first, and the embodiments of the present disclosure do not limit this.
[0116] In the embodiments of the present disclosure, when the first verification result indicates that the verification of the first file passes, the data of the first file is synchronized to the second file; and when the second verification result indicates that the verification of the second file passes, the data of the second file is synchronized to the first file, thereby ensuring that the data of the first file is consistent with the data of the second file while improving the efficiency of data synchronization.
[0117] In some embodiments, based on the first verification result and / or the second verification result, synchronizing the data written to the first file and the data copied to the second file includes:
[0118] When the first verification result indicates that the verification of the first file passes and the second verification result indicates that the verification of the second file fails, synchronize the data of the first file to the second file;
[0119] When the first verification result indicates that the verification of the first file fails and the second verification result indicates that the verification of the second file passes, synchronize the data of the second file to the first file.
[0120] It should be noted that considering the situation where both the first file and the second file are files with data anomalies after a write anomaly event, in this case, synchronizing the data of the first file and the data of the second file is an ineffective synchronization process. At the same time, there is also a situation where both the first file and the second file are files without data anomalies after a write anomaly event. In this case, synchronizing the data of the first file and the data of the second file is still an ineffective synchronization process.
[0121] Therefore, in the embodiments of the present disclosure, when the first verification result indicates that the first file passes the verification and the second verification result indicates that the second file fails the verification, it is determined that the first file is a file without data anomalies and the second file is a file with data anomalies, and then the data of the first file is synchronized to the second file to ensure the accuracy of the data of the first file and the second file after the synchronization process.
[0122] When the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file passes the verification, it is determined that the first file is a file with data anomalies and the second file is a file without data anomalies, and then the data of the second file is synchronized to the first file to improve the accuracy of data synchronization.
[0123] In the embodiments of the present disclosure, when the first verification result indicates that the first file passes the verification and the second verification result indicates that the second file fails the verification, the data of the first file is synchronized to the second file; and when the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file passes the verification, the data of the second file is synchronized to the first file. In this way, the situation of ineffective synchronization is avoided and the accuracy of data synchronization is improved.
[0124] In some embodiments, the method further includes:
[0125] When the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file fails the verification, a prompt message is output;
[0126] wherein the prompt message is used to prompt that the data of the first file is in a lost state.
[0127] It can be understood that when the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file fails the verification, it is determined that both the first file and the second file are files with data anomalies. To improve the user experience, an instant feedback can be provided to the user by outputting a prompt message, prompting that the data of the first file is in a lost state.
[0128] Here, the prompt information can be output in the form of voice. For example, through Text-to-Speech (TTS) technology, a voice prompt instruction of "The data of the first file is in a lost state" is output; it can also be output in the form of text. For example, a pop-up window of "The data of the first file is in a lost state" is output. The embodiments of the present disclosure do not limit this.
[0129] In the embodiments of the present disclosure, when the first verification result indicates that the verification of the first file fails and the second verification result indicates that the verification of the second file fails, prompt information is output to provide instant feedback to the user, thereby improving the quality of human-computer interaction.
[0130] In some embodiments, the method further includes:
[0131] In response to performing a processing operation on the first file after data synchronization, a processed first file is obtained;
[0132] Based on the difference information between the processed first file and the second file after data synchronization, the second file after data synchronization is updated.
[0133] It can be understood that in order to reduce the data that needs to be updated in the second file and shorten the update time, the processed first file can be compared with the second file after data synchronization to determine the difference information between the processed first file and the second file after data synchronization; then, based on the difference information, the second file is updated.
[0134] In some embodiments, when the processing operation performed on the first file after data synchronization is a read operation, the data of the first file after the processing operation remains unchanged; when comparing the processed first file with the second file after data synchronization, if it is determined that the data of the processed first file is consistent with the data of the second file after data synchronization, there is no need to update the second file after data synchronization to reduce the situation of invalid updates.
[0135] In the embodiments of the present disclosure, when a processing operation is performed on the first file after data synchronization, based on the difference information between the processed first file and the second file after data synchronization, the second file after data synchronization is updated. On the one hand, the update duration of the second file can be shortened, and the efficiency of data synchronization can be improved; on the other hand, when the data of the first file is updated, the second file will be synchronously updated, so that when the first file is damaged, the data of the first file can be restored based on the second file, thereby ensuring the integrity of the data.
[0136] In some embodiments, the write exception event at least includes: a power-off event of the vehicle-mounted system or a thread interception event when a write operation is performed on the first file.
[0137] Here, the write exception event may be a power-off event of the in-vehicle system, that is, an event in which a power line failure occurs due to reasons such as aging, poor connection, or short circuit of the power line of the in-vehicle system.
[0138] In some embodiments, during the process of copying the data of the first file to the second file, due to the power-off event of the in-vehicle system, the copy process is interrupted, resulting in the loss or damage of the data indicated by the copy operation and the original data of the second file. In this case, the data of the first file can be synchronized to the second file, so that the data of the first file is consistent with the data of the second file, avoiding the situation where the data of the first file cannot be obtained when the data of the first file is damaged or lost due to subsequent write exception events.
[0139] In other embodiments, during the process of performing a write operation on the first file, due to the power-off event of the in-vehicle system, the write process is interrupted, resulting in the loss or damage of the data indicated by the write operation and the original data of the first file. In this case, the data of the second file can be synchronized to the first file, so that the data of the first file after the write exception event is restored to the data of the first file before the write exception event, thereby reducing the situation of service interruption due to data anomalies.
[0140] Here, the write exception event may also be a thread interception event when performing a write operation on the first file. That is, an event in which the process of writing data is intercepted due to situations such as the operating system crashing, the application crashing, or the first file being occupied by other processes.
[0141] In some embodiments, during the process of performing a write operation on the first file, due to the thread interception event, the write process is interrupted, resulting in the loss or damage of the data indicated by the write operation and the original data of the first file. In this case, the data of the second file can be synchronized to the first file, so that the data of the first file after the write exception event is restored to the data of the first file before the write exception event, thereby ensuring the data integrity of the first file for facilitating the processing operation of the first file.
[0142] In the embodiments of the present disclosure, when a trigger operation for the first file in the in-vehicle system is detected and there is a power-off event of the in-vehicle system or a thread interception event when performing a write operation on the first file before the trigger operation, the data written to the first file and the data copied to the second file during the write operation on the first file are synchronized. In this way, without relying on the data protection mechanism of the storage hardware device and the file system, through ordinary file operation interfaces, the protection function of the file during anomalies can be realized, thereby reducing the technical difficulty and development cost of data protection.
[0143] Figure 3 It is a flowchart illustration of a data protection method provided by an embodiment of the present disclosure Figure 3 , as Figure 3 shown, the data protection method at least includes the following steps:
[0144] In step 301, a first file in the in-vehicle system is created.
[0145] Here, the first file can be manually created by the user, or can be created by a program or the operating system in the in-vehicle system during operation. The embodiments of the present disclosure do not limit this.
[0146] In step 302, a write operation for the first file is detected.
[0147] In step 303, the data indicated by the write operation is written into the first file.
[0148] In step 304, the data indicated by the write operation is stored in the disk.
[0149] Here, storing the data in the disk can be implemented by functions such as fsync or memory-mapped files.
[0150] In step 305, the first file is generated.
[0151] In step 306, first check information is generated based on the data of the first file.
[0152] In some embodiments, in the case of generating the first file and the first check information, the first check information and the first file can be stored in the same storage space, so that when it is necessary to check the first file or the second file, the first check information can be obtained in time.
[0153] In step 307, the data of the first file is copied.
[0154] In step 308, a second file is generated.
[0155] In some embodiments, in the case of generating the second file, the first check information can be copied to obtain fourth check information; and the fourth check information and the second file are stored in the same storage space, so that when the disk storing the first file is damaged and the first check information is lost, the fourth check information can be obtained in time from the storage space storing the second file, thereby improving the reliability of data verification.
[0156] In step 309, the first file is closed.
[0157] In an embodiment of the present disclosure, during the first write operation on a first file, the data during the write operation of the first file is copied to a second file, so that the data of the first file is consistent with the data of the second file. Therefore, even if there is a subsequent write exception event that causes the data of the first file to be lost (or damaged), the data of the first file can be restored based on the data of the second file, so as to restore the data of the first file after the write exception event to the data of the first file before the write exception event, ensuring data integrity.
[0158] Figure 4 is a schematic flow chart of a data protection method provided by an embodiment of the present disclosure Figure 4 , such as Figure 4 shown, the data protection method at least includes the following steps:
[0159] In step 401, after a write exception event, a trigger operation for a first file in the in-vehicle system is detected.
[0160] In step 402, the first file is verified based on first verification information and second verification information to obtain a first verification result.
[0161] In step 403, it is determined whether the first verification result indicates that the first file verification fails.
[0162] In some embodiments, when it is determined that the first verification result indicates that the first file verification fails, step 405 is executed.
[0163] In other embodiments, when it is determined that the first verification result indicates that the first file verification is successful, step 404 is executed.
[0164] In step 404, the second file is verified based on the first verification information and third verification information to obtain a second verification result.
[0165] In step 405, it is determined whether the second verification result indicates that the second file verification fails.
[0166] In some embodiments, when it is determined that the second verification result indicates that the second file verification fails, step 406 is executed.
[0167] In other embodiments, when it is determined that the second verification result indicates that the second file verification is successful, step 410 is executed.
[0168] In step 406, the data of the first file is synchronized to the second file.
[0169] In step 407, it is determined whether the second verification result indicates that the second file verification fails.
[0170] In some embodiments, when it is determined that the second verification result indicates that the verification of the second file fails, step 409 is executed.
[0171] In other embodiments, when it is determined that the second verification result indicates that the verification of the second file is successful, step 408 is executed.
[0172] In step 408, the data of the second file is synchronized to the first file.
[0173] In step 409, a prompt message is output.
[0174] In step 410, a processing operation is performed on the first file after data synchronization to obtain a processed first file.
[0175] In step 411, the data of the processed first file is stored in the disk.
[0176] In step 412, first verification information is generated based on the data of the processed first file.
[0177] In step 413, the second file after data synchronization is updated based on the difference information between the processed first file and the second file after data synchronization.
[0178] In step 414, the first file is closed.
[0179] In the embodiments of the present disclosure, without relying on the data protection mechanism of the storage hardware device and the file system, by synchronizing the data of the first file and the data copied to the second file when writing to the first file, the protection function of the file data during writing exceptions can be realized, thereby not only ensuring the data integrity of the first file and the second file after a writing exception event, but also reducing the technical difficulty and development cost of data protection.
[0180] Figure 5 is a block diagram of a data protection device provided by an embodiment of the present disclosure, as Figure 5 shown, the data protection device 500 includes:
[0181] A synchronization module 501, configured to synchronize the data written to the first file and the data copied to the second file when writing to the first file when a trigger operation for the first file in the in-vehicle system is detected and there is a writing exception event before the trigger operation;
[0182] An execution module 502, configured to perform a processing operation on the first file after data synchronization of the first file and the second file.
[0183] In some embodiments, the synchronization module 501 includes:
[0184] An acquisition module configured to acquire first verification information generated based on the data in the first file before the write exception event, second verification information generated based on the data in the first file after the write exception event, and third verification information generated based on the data in the second file;
[0185] A verification module configured to verify the first file based on the first verification information and the second verification information to obtain a first verification result, and verify the second file based on the first verification information and the third verification information to obtain a second verification result;
[0186] A synchronization processing module configured to synchronize the data written to the first file and the data copied to the second file based on the first verification result and / or the second verification result.
[0187] In some embodiments, the synchronization processing module is specifically configured to:
[0188] When the first verification result indicates that the first file passes the verification, synchronize the data of the first file to the second file;
[0189] When the second verification result indicates that the second file passes the verification, synchronize the data of the second file to the first file.
[0190] In some embodiments, the synchronization processing module is further configured to:
[0191] When the first verification result indicates that the first file passes the verification and the second verification result indicates that the second file fails the verification, synchronize the data of the first file to the second file;
[0192] When the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file passes the verification, synchronize the data of the second file to the first file.
[0193] In some embodiments, the apparatus 500 further includes:
[0194] An output module configured to output a prompt message when the first verification result indicates that the first file fails the verification and the second verification result indicates that the second file fails the verification;
[0195] wherein the prompt message is used to prompt that the data of the first file is in a lost state.
[0196] In some embodiments, the apparatus 500 further includes:
[0197] An update module, configured to perform a processing operation on a first file after data synchronization, to obtain a processed first file;
[0198] Based on the difference information between the processed first file and a second file after data synchronization, update the second file after data synchronization.
[0199] In some embodiments, the write exception event at least includes: a power-off event of the in-vehicle system or a thread interception event when performing a write operation on the first file.
[0200] Regarding the apparatus in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated herein.
[0201] Figure 6 It is a block diagram of a structure of an electronic device 600 provided by an embodiment of the present disclosure. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0202] Referring to Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602, a memory 604, a power supply component 606, a multimedia component 608, an audio component 610, an input / output (I / O) interface 612, a sensor component 614, and a communication component 616.
[0203] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with at least one of display, telephone call, data communication, camera operation, and recording operation. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0204] The memory 604 is configured to store various types of data to support the operation of the electronic device 600. Examples of such data include at least one of the following: instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, and videos. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0205] The power supply component 606 provides power to various components of the electronic device 600. The power supply component 606 can include at least one of the following: a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 600.
[0206] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
[0207] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC). When the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive external audio signals. The received audio signals can be further stored in the memory 604 or transmitted via the communication component 616. In some embodiments, the audio component 610 further includes a speaker for outputting audio signals.
[0208] The I / O interface 612 provides an interface between the processing component 602 and a peripheral interface module, which may be a keyboard, a click wheel, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a power button, and a lock button.
[0209] The sensor component 614 includes one or more sensors for providing an assessment of the state of the electronic device 600 in various aspects. For example, the sensor component 614 can detect the on / off state of the electronic device 600, the relative positioning of components, such as the display and keypad of the electronic device 600. The sensor component 614 can also detect a change in the position of the electronic device 600 or a component in the electronic device 600, the presence or absence of user contact with the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor component 614 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 614 can also include a light sensor, such as a complementary metal oxide semiconductor (CMOS) or a charge coupled device (CCD) image sensor, for use in imaging applications. In some embodiments, the sensor component 614 can further include at least one of the following, but is not limited to: an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, and a temperature sensor.
[0210] The communication component 616 is configured to facilitate communication between the electronic device 600 and other devices in a wired or wireless manner. The electronic device 600 can access a communication standard-based wireless network, such as Wi-Fi, 4G, 5G, or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra-Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0211] In an exemplary embodiment, the electronic device 600 can be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components.
[0212] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including executable instructions or a computer program, and the above instructions or computer program can be executed by a processor 620 of the electronic device 600 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a Random Access Memory (RAM), a Compact Disc Read-Only Memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0213] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute any one of the data protection methods in the embodiments of the present disclosure. For example, the data protection method includes:
[0214] When a trigger operation for a first file in the in-vehicle system is detected and there is a write anomaly event before the trigger operation, synchronize the data written to the first file and the data copied to a second file when performing the write operation on the first file;
[0215] After completing the data synchronization of the first file and the second file, perform a processing operation on the first file after the data synchronization.
[0216] Embodiments of the present disclosure provide a computer program product, which includes: a computer program or executable instructions, and the computer program or executable instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer program or executable instructions from the computer-readable storage medium, and the processor executes the computer program or executable instructions, so that the computer device executes any one of the above data protection methods in the embodiments of the present disclosure. Those skilled in the art will readily think of other implementations of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and embodiments are only regarded as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.
[0217] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.
Claims
1. A data protection method, characterized in that: The method comprises: When a trigger operation for a first file in the vehicle system is detected and there is a write abnormality event before the trigger operation, synchronously processing the data written to the first file and the data copied to the second file when the write operation is performed on the first file; After completing data synchronization of the first file and the second file, a processing operation is performed on the first file after data synchronization.
2. The method according to claim 1, characterized in that: The synchronous processing of the data written into the first file and the data copied into the second file when the write operation is performed on the first file includes: Acquire first verification information generated based on data in the first file before the write abnormal event, second verification information generated based on data in the first file after the write abnormal event, and third verification information generated based on data in the second file; Verifying the first file based on the first verification information and the second verification information to obtain a first verification result, and verifying the second file based on the first verification information and the third verification information to obtain a second verification result; Based on the first verification result and / or the second verification result, the data written into the first file and the data copied into the second file are synchronously processed.
3. The method according to claim 2, characterized in that The synchronously processing the data written into the first file and the data copied into the second file based on the first verification result and / or the second verification result includes: When the first verification result indicates that the first file has passed verification, synchronizing the data of the first file to the second file; When the second verification result indicates that the second file has passed verification, the data of the second file is synchronized to the first file.
4. The method according to claim 2, characterized in that: The synchronously processing the data written into the first file and the data copied into the second file based on the first verification result and / or the second verification result includes: When the first verification result indicates that the first file verification has passed, and the second verification result indicates that the second file verification has failed, synchronizing the data of the first file to the second file; When the first verification result indicates that the first file verification fails and the second verification result indicates that the second file verification passes, the data of the second file is synchronized to the first file.
5. The method according to claim 2, characterized in that: The method further comprises: When the first verification result indicates that the first file verification fails, and the second verification result indicates that the second file verification fails, outputting a prompt message; The prompt information is used to prompt that the data of the first file is in a lost state.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: In response to performing a processing operation on the first file after data synchronization, obtaining the processed first file; Based on the difference information between the processed first file and the second file after data synchronization, the second file after data synchronization is updated.
7. The method according to any one of claims 1 to 5, characterized in that: The abnormal write event at least includes: a power failure event of the vehicle system or a thread interception event when performing a write operation on the first file.
8. A data protection device, characterized in that: The device comprises: a synchronization module configured to, when a trigger operation on a first file in the vehicle system is detected and there is a write abnormality event before the trigger operation, synchronize the data written into the first file and the data copied into the second file when the write operation is performed on the first file; The execution module is configured to execute a processing operation on the first file after data synchronization is completed on the first file and the second file.
9. An electronic device, characterized in that: include: processor; Memory for storing computer programs or instructions; The processor executes the computer program or instructions to implement the steps of any one of the methods of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing a computer program or instruction, characterized in that: When the computer program or instructions in the storage medium are executed by a processor, the steps of the method of any one of claims 1 to 7 are implemented.
11. A computer program product, comprising a computer program or instructions, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.