File processing method and electronic equipment

CN119836627APending Publication Date: 2025-04-15HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202380064000.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-09-05
Filing Date
2023-09-04
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

The file management efficiency in electronic devices is low, resulting in excessive storage space usage. Existing technology is difficult to accurately determine whether a file has been modified, resulting in misjudgment and waste of resources.

Method used

By introducing an indication field (U field) into the file system, it tries to modify its value within a specific period of time, and determines whether the file has been modified based on the modification situation, thereby optimizing file management and storage space utilization.

Benefits of technology

It achieves efficient judgment of file modification status without continuously monitoring the file modification status, reduces resource consumption, avoids misjudgments, and improves file management accuracy and storage space release efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119836627A_ABST
    Figure CN119836627A_ABST
Patent Text Reader

Abstract

A file processing method and an electronic device, relating to the technical field of terminals, can reduce the occupation of storage space, the method is applied to the electronic device, the electronic device stores an indication field of a first file, the initial value of the indication field is a first value, and the initial value of the indication field is a second value. The indication field is modified to a second value by the electronic equipment when the first file is modified; the method comprises the following steps: attempting to modify the value of an indication field of a first file into a third value at a first moment; the third value is different from the first value; the third value is different from the second value; if the value of the indication field of the first file is successfully modified into the third value, acquiring the value of the indication field at a second moment; and according to the value of the indication field of the first file at the second moment, judging whether the first file is modified within the time period from the first moment to the second moment.
Need to check novelty before this filing date? Find Prior Art

Description

File processing method and electronic equipment

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on September 5, 2022, with application number 202211095247.7 and invention name “File Processing Method and Electronic Device”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of terminal technology, and in particular to a file processing method and an electronic device. Background Art

[0003] Currently, many electronic devices use file systems within their operating systems to manage files. With the rapid increase in the number of files stored in electronic devices, file system management has become a bottleneck. In some scenarios, files in electronic devices can occupy a large amount of storage space, resulting in a low available storage space.

[0004] Summary of the Invention

[0005] This application provides a file processing method and electronic device that can efficiently manage files.

[0006] In order to achieve the above objectives, the embodiments of the present application provide the following technical solutions:

[0007] In a first aspect, a file processing method is provided, which is applied to an electronic device or a component supporting a function of the electronic device (such as a chip system). The electronic device stores an indication field of a first file, the indication field having an initial value of a first value, and the indication field being modified by the electronic device to a second value when the first file is modified. The method includes:

[0008] At a first moment, attempting to modify a value of an indication field of a first file to a third value; the third value is different from the first value; and the third value is different from the second value;

[0009] If the value of the indicator field of the first file is successfully modified to the third value, then at the second moment, the value of the indicator field is obtained;

[0010] According to the value of the indication field of the first file at the second moment, it is determined whether the first file is modified during a period from the first moment to the second moment.

[0011] For example, as shown in Figure 13, at time t1 (an example of the first time), the mobile phone successfully modifies the value of the U field (an example of the indicator field) of English grammar 3 (an example of the first file) to V1 (an example of the third value). At time t5 (an example of the second time), the mobile phone queries the value of the U field. Based on the value of the U field of English grammar 3 at time t5, the mobile phone can determine whether English grammar 3 was modified between t1 and t5.

[0012] In an embodiment of the present application, the modification status of the first file can be determined by the value of the indicator field of the first file, and then the first file can be managed accordingly according to the modification status of the first file. Among them, the electronic device does not need to continuously monitor the modification status of the first file from the first moment to the second moment, but can stop monitoring at other moments other than the first moment and the second moment to reduce the resource consumption of the electronic device for monitoring. For example, at the first moment, the electronic device can try to modify the value of the indicator field of the first file to V1 through the first application, and after the first moment, the electronic device can exit the first application. At the second moment, the electronic device opens the first application again, obtains the value of the indicator field of the first file, and determines whether the first file has been modified between the first moment and the second moment based on the value of the indicator field. It can be seen that in an embodiment of the present application, when the first application does not need to be resident, the electronic device can also determine whether the first file has been modified within a certain period of time, which can reduce the occupancy of storage space.

[0013] Moreover, this solution has nothing to do with the system time, so even if the user modifies the system time, it will not lead to misjudgment.

[0014] In one possible design, attempting to modify the value of the indication field of the first file to a third value includes:

[0015] If the first condition is met, the value of the indication field is modified to a third value; under the first condition, the file system of the electronic device can detect the modification operation on the first file during the period from the first moment to the second moment.

[0016] In this way, once the file is modified between the first moment and the second moment, the file system can ensure that the modification is perceived and the value of the indicator field of the file is modified to a non-V1 value (such as the second value V2). Subsequently, the electronic device can query the value of the indicator field of the file. If the value of the indicator field is modified to a non-V1 value, the electronic device determines that the file was modified between the first moment and the second moment. Conversely, if the value of the indicator field remains V1, it is determined that the file was not modified between the first moment and the second moment.

[0017] In one possible design, after the first moment, the method further includes:

[0018] It is detected that the first file is modified, and the value of the indication field of the first file is modified to a second value.

[0019] Determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0020] If the value of the indication field of the first file at the second moment is the second value, it is determined that the first file is modified during the period from the first moment to the second moment; or, if the value of the indication field of the first file at the second moment is not the third value, it is determined that the first file is modified during the period from the first moment to the second moment.

[0021] For example, as shown in Figure 12, after time t1 (an example of the first time), at time t3, it is detected that English grammar 2 has been modified (this modification is the first memory write after time t1), and the mobile phone modifies the value of the U field of English grammar 2 to V2 (an example of the second value). At time t5 (an example of the second time), the mobile phone queries the value of the U field of English grammar 2 and finds that the value of the U field of English grammar 2 at time t5 is V2 (no longer V1), thus determining that English grammar 2 was modified during the period t1-t5.

[0022] In one possible design, determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0023] If the value of the indication field of the first file at the second moment is the third value, it is determined that the first file has not been modified during the period from the first moment to the second moment; or, if the value of the indication field of the first file at the second moment is not the second value, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0024] For example, as shown in Figure 13, after the mobile phone manager application scans for duplicate files (e.g., performing a binary comparison) and before displaying the scan results to the user, at time t5, the mobile phone manager application queries the value of the U field in the English Grammar 3 file and learns that the field value is V1 (an example of a third value). Since the field value of the U field in English Grammar 3 at time t5 is the same as the field value at time t1, both are V1, the mobile phone manager application can determine that the English Grammar 3 file has not been modified between time t1 and time t5.

[0025] In one possible design, attempting to modify the value of the indication field of the first file to the third value includes: if the first condition is not satisfied, not modifying the indication field to the third value;

[0026] The method further includes: when the value of the indication field of the first file cannot be successfully modified to the third value, determining that the first file is modified within a period from the first moment to the second moment.

[0027] For example, as shown in Figure 15, assuming that before time t1, the mobile phone performed an overwrite memory operation on Computer Technology 1 in the candidate duplicate files, then after the initial screening of duplicate files is completed, at time t1, because the first condition is not met, the mobile phone manager application cannot successfully modify the value of the U field of Computer Technology 1 to V1 (the value of the U field remains V0). In this case, the mobile phone manager application treats Computer Technology 1 as a modified file (no longer a duplicate file) and no longer performs deduplication on Computer Technology 1 to avoid incorrect deduplication.

[0028] In one possible design, the first condition includes one or more of the following conditions: before the first moment, the first file is not mapped to the memory; before the first moment, the first file is mapped to the memory, but the electronic device has not performed a write operation on the memory.

[0029] For a certain file, if the file is not mapped to the memory before the first moment, then once the mobile phone performs one or more memory write operations on the file between the first moment and the second moment, the first memory write operation will definitely cause the mobile phone to execute the relevant code of the file system. In other words, at least the first memory write operation between the first moment and the second moment will be detected by the file system. In this way, the file system can determine that the file has been modified based on at least the first memory write operation between the first moment and the second moment, and accordingly modify the value of the U field of the file to V2. Subsequently, the application can query the value of the U field of the file, and determine whether the file has been modified between the first moment and the second moment based on the value of the U field. It can be seen that in the embodiment of the present application, the file system does not need to detect every memory write operation. Even if the file system misses the memory write operation, the file system can determine that the file has been modified based on at least the first memory write operation detected within a period of time. In this way, the detection accuracy of the electronic device can be improved.

[0030] Similarly, for a file, if the file was mapped to memory before a first moment, but the electronic device had not performed any write operations on the memory, then if the mobile phone subsequently performs one or more write operations on the file between the first moment and the second moment, the first write operation will inevitably cause the mobile phone to execute the relevant code of the file system. In other words, if the file is modified between the first moment and the second moment, the modification will be detected by the file system.

[0031] Based on this principle, if a file is mapped to memory before a first moment, but the electronic device has not performed a write operation on the memory, the electronic device can modify the value of the U field of the file to V1 at the first moment. Subsequently, if the file is modified between the first moment and the second moment, the value of the U field of the file will be modified by the file system to a non-V1 value (such as V2). The electronic device can determine whether the file has been modified between the first moment and the second moment based on the value of the U field of the file.

[0032] It can be seen that this solution can reduce the misjudgment of mmap scenarios.

[0033] In one possible design, the method further includes:

[0034] Scanning and obtaining duplicate files in the electronic device, the duplicate files including a first file and a second file; the first file is stored in a first storage space, and the second file is stored in a second storage space;

[0035] Determining that the first file and the second file have not been modified during a period from the first moment to the second moment;

[0036] The first interface is displayed; the first interface includes information about the first file and information about the second file.

[0037] For example, if the scan reveals that English grammars 1-4 are a set of duplicate files, and these four duplicate files are stored in storage spaces 1-4, respectively, if it is determined that English grammar 2 was modified between the first and second moments, and English grammars 1, 3, and 4 were not modified between the first and second moments, then English grammars 1, 3, and 4 still constitute duplicate files. As shown in FIG10A (c), the mobile phone may display a first interface 906, which includes information about the duplicate files of English grammars 1, 3, and 4.

[0038] In one possible design, a first operation input by a user in a first interface is detected;

[0039] The first file and the second file are compressed into the same storage space.

[0040] For example, as shown in FIG10A (c), upon detecting that the user clicks the compress button 907 (an example of a first operation), the mobile phone compresses a group of duplicate files (English grammars 1, 3, and 4) selected by the user. After compression, English grammars 1, 3, and 4 are allocated to the same storage space. This frees up storage space.

[0041] In one possible design, after scanning the electronic device for duplicate files, the method further includes:

[0042] The identifier of the first file and the identifier of the second file are stored. For example, in FIG11 , the electronic device stores the identifier of the duplicate file in the duplicate file information library.

[0043] In one possible design, the identifier of the first file includes a first index node number of the first file; and the identifier of the second file includes a second index node number of the second file.

[0044] Subsequently, when the user opens the mobile manager and clicks the "Clean and Accelerate" button, the phone can detect that the first and second files have historically been duplicates based on the stored duplicate file identifiers. The phone can then query the values ​​of the U fields in the first and second files to determine whether the first and second files are still duplicates. This eliminates the need for the phone to rescan the contents of the first and second files, helping to reduce phone operating costs.

[0045] In one possible design, determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0046] If the value of the indicator field of the first file at the second moment is the third value, and the index node number of the first file is the first index node number, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0047] In a second aspect, a file processing method is provided, which is applied to an electronic device or a component (such as a chip system) that supports the functions of the electronic device, and the method includes:

[0048] Displaying a second interface, the second interface including a plurality of duplicate files scanned in the electronic device; the plurality of duplicate files are respectively stored in a plurality of storage spaces of the electronic device;

[0049] In response to an operation input by the user on the second interface, at a third moment, obtaining an indication field of each duplicate file in the plurality of duplicate files, wherein a value of the indication field of the duplicate file is used to indicate whether the duplicate file has been modified;

[0050] According to the values ​​of the indication fields of the multiple duplicate files at the third moment, some duplicate files among the multiple duplicate files are compressed into the same storage space.

[0051] For example, as shown in (c) of FIG10A , the mobile phone displays an interface 906 (an example of the second interface), which includes multiple duplicate files obtained by scanning (a group of duplicate files of English grammar 1, 3, and 4, and a group of duplicate files of computer 2 and 3).

[0052] In response to the user clicking the compression button 907 on the interface 906, at the third moment, the mobile phone obtains the indication fields of the duplicate files of English grammar 1, 3, and 4 selected by the user, and compresses some of the files in English grammar 1, 3, and 4 into the same storage space according to the values ​​of the respective indication fields of English grammar 1, 3, and 4 at the third moment.

[0053] In this solution, the indication field of the duplicate files in the second interface can be obtained according to the user's operation, and some of the duplicate files can be compressed according to the indication field of each duplicate file. On the one hand, the storage space of the electronic device can be released. On the other hand, instead of compressing all the duplicate files selected by the user, it is checked whether the duplicate files really need to be compressed according to the value of the indication field of the duplicate file selected by the user, so as to reduce the probability of miscompression and prevent miscompression from affecting the normal operation of the electronic device. It can be seen that this solution can achieve accurate file compression, and thus can accurately release the storage space of the electronic device. Moreover, it can effectively avoid the problem of misdeduplication caused by the deduplication program not sensing the modification of the duplicate files because other processes have modified the duplicate files before deduplication is performed.

[0054] In one possible design, the initial value of the indication field of each duplicate file is the first value.

[0055] In one possible design, before displaying the second interface, the method further includes:

[0056] Scanning to obtain multiple candidate duplicate files; the multiple candidate duplicate files include multiple duplicate files;

[0057] At a first moment, attempting to modify a value of an indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value;

[0058] The multiple candidate duplicate files are compared to determine multiple duplicate files from the multiple candidate duplicate files.

[0059] For example, as shown in Figure 10B, after the user clicks the "Clean Up" button, the phone initially screens and obtains multiple candidate duplicate files. English grammar 1-5 constitutes a group of candidate duplicate files, and computer technology 1-4 constitutes a group of candidate duplicate files. At time t1 (an example of the first time), the phone attempts to modify the value of the indicator field of each of the multiple candidate duplicate files to V1 (an example of the third value).

[0060] In a possible design, multiple candidate duplicate files are obtained by scanning, including:

[0061] Displaying a third interface, where the third interface includes the first control;

[0062] A user operation on the first control is detected, and a plurality of candidate duplicate files are obtained by scanning.

[0063] For example, as shown in FIG10A(a), a mobile phone displays interface 901 (an example of the third interface), which includes a cleaning acceleration button 902 (a first control). Upon detecting that a user clicks on cleaning acceleration button 902, the mobile phone scans for multiple candidate duplicate files (e.g., English grammars 1-5 shown in FIG10B ), and then obtains multiple duplicate files (e.g., English grammars 1-4 shown in FIG10B ) based on the multiple candidate duplicate files.

[0064] In a possible design, multiple candidate duplicate files are obtained by scanning, including:

[0065] When the electronic device is idle, multiple candidate duplicate files are scanned, for example, at night, or after the screen is locked for a certain period of time.

[0066] By performing a pre-scan when the phone is idle, the time required for subsequent file deduplication can be saved, the efficiency of file deduplication can be improved, and the efficiency of human-computer interaction between users and electronic devices can be improved.

[0067] In one possible design, after the first moment, the method further includes:

[0068] At a second moment, obtaining a value of an indication field of at least one duplicate file and an inode number of at least one duplicate file;

[0069] When the third condition is met, the second interface is displayed; the third condition includes: the value of the indication field of at least one duplicate file at the second moment is the third value, and the index node number of at least one duplicate file is consistent with the index node number stored in the database.

[0070] For example, as shown in FIG10B , at time t5 (an example of the second time), the mobile phone queries the values ​​of the U fields (indicator fields) of English grammars 1-4. The value of the U field of English grammar 2 is V0 (not V1), and the values ​​of the U fields of English grammars 1, 3, and 4 are all V1. Therefore, the mobile phone can determine that English grammars 1, 3, and 4 have not been modified during the period t1-t5. The mobile phone can display the information of English grammars 1, 3, and 4 on interface 906 (the second interface) as shown in FIG10A (c).

[0071] In one possible design, attempting to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value includes:

[0072] If at least one candidate duplicate file among multiple candidate duplicate files meets the first condition, the value of the indication field of at least one candidate duplicate file is modified to a third value; under the first condition, the file system of the electronic device can detect the modification operation on at least one candidate duplicate file within the time period from the first moment to the second moment.

[0073] In one possible design, obtaining, at the second moment, a value of an indication field of at least one duplicate file includes: obtaining, at the second moment, a value of an indication field of a target duplicate file in the at least one duplicate file as a third value;

[0074] The method further includes: when the value of the indication field of the target duplicate file at the second moment is a third value, determining that the target duplicate file is not modified during a period from the first moment to the second moment.

[0075] In one possible design, the plurality of candidate duplicate files include a third file;

[0076] After the first moment, the method further includes: detecting that the third file is modified, and modifying the value of the indication field of the third file to a second value;

[0077] At the second moment, the value of the indication field of the third file obtained is not the third value;

[0078] It is determined that the third file is modified during a period from the first time to the second time.

[0079] In one possible design, the plurality of candidate duplicate files include a fourth file;

[0080] At the first moment, attempting to modify the value of the indicator field of each candidate duplicate file in the plurality of candidate duplicate files to a third value includes: if the fourth file does not meet the first condition, not modifying the indicator field of the fourth file to the third value;

[0081] The method further includes: when the value of the indication field of the fourth file cannot be successfully modified to the third value, determining that the fourth file is modified within a time period from the first moment to the second moment.

[0082] In a possible design, compressing some of the duplicate files into the same storage space according to the values ​​of the indication fields of the multiple duplicate files at the third moment includes:

[0083] If the value of the indicator field of the first file among the multiple duplicate files at the third moment is a third value, compressing the first file;

[0084] Alternatively, if the value of the indication field of the first file among the multiple duplicate files at the third moment is not the third value, compression is not performed on the first file.

[0085] Exemplarily, if the value of the indicator field of the first file among the multiple duplicate files at the third moment is a third value, compression is performed on the first file;

[0086] Alternatively, if the value of the indication field of the first file among the multiple duplicate files at the third moment is not the third value, compression is not performed on the first file.

[0087] For example, as shown in Figure 19, after the user clicks the "Compress" button and before the phone performs deduplication, at time t9 (the third time), the mobile phone manager application again queries the value of the U field of each duplicate file (English Grammar 1, 3, 4, Computer Technology 1, 2). After judgment, the value of the U field of English Grammar 3 was successfully set to V1 at time t1, but the value of the U field at time t9 was V0. The mobile phone manager application can determine that English Grammar 3 was modified between time t1 and time t9. Similarly, the mobile phone manager application determines whether other duplicate files have been modified between time t1 and time t9.

[0088] As shown in Figure 19, since English grammar 3 was modified between t1 and t9, it no longer constitutes a duplicate file with English grammars 1 and 4. Therefore, the Mobile Manager app does not perform deduplication on English grammar 3. Conversely, if English grammars 1 and 4 were not modified between t1 and t9, they are still duplicate files. The Mobile Manager app can perform deduplication on English grammars 1 and 4 at t10.

[0089] In this way, by verifying whether the file is a duplicate file before actual compression and deduplication, the probability of false deduplication can be reduced and the accuracy of deduplication can be improved.

[0090] In one possible design, the method further includes:

[0091] The information of the multiple duplicate files is stored in a database, where the information of the duplicate files includes any one or more of the following information: an index node number of the duplicate file, a path of the duplicate file, and a name of the duplicate file.

[0092] In one possible design, when the value of the indicator field of the target duplicate file at the second moment is the third value, determining that the target duplicate file is not modified during the period from the first moment to the second moment includes:

[0093] When the value of the indicator field of the target duplicate file is the third value, if the index node number of the target duplicate file has not changed, it is determined that the target duplicate file has not been modified during the period from the first moment to the second moment.

[0094] In a third aspect, a file processing device is provided, which is applied to an electronic device or a chip system. For example, the electronic device stores an indication field of a first file, where the initial value of the indication field is a first value and the indication field is modified to a second value by the electronic device when the first file is modified. The device includes:

[0095] Processing module for:

[0096] At a first moment, attempting to modify a value of an indication field of a first file to a third value; the third value is different from the first value; and the third value is different from the second value;

[0097] If the value of the indicator field of the first file is successfully modified to the third value, then at the second moment, the value of the indicator field is obtained;

[0098] According to the value of the indication field of the first file at the second moment, it is determined whether the first file is modified during a period from the first moment to the second moment.

[0099] In one possible design, attempting to modify the value of the indication field of the first file to a third value includes:

[0100] If the first condition is met, the value of the indication field is modified to a third value; under the first condition, the file system of the electronic device can detect the modification operation on the first file during the period from the first moment to the second moment.

[0101] In one possible design, the processing module is further configured to detect, after the first moment, that the first file is modified, and modify the value of the indication field of the first file to a second value.

[0102] Determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0103] If the value of the indication field of the first file at the second moment is the second value, it is determined that the first file is modified during the period from the first moment to the second moment.

[0104] In one possible design, determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0105] If the value of the indication field of the first file at the second moment is the third value, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0106] In one possible design, attempting to modify the value of the indication field of the first file to the third value includes: if the first condition is not satisfied, not modifying the indication field to the third value;

[0107] The processing module is further configured to determine that the first file is modified within a period from the first moment to the second moment when the value of the indication field of the first file cannot be successfully modified to the third value.

[0108] In one possible design, the first condition includes one or more of the following conditions: before the first moment, the first file is not mapped to the memory; before the first moment, the first file is mapped to the memory, but the electronic device has not performed a write operation on the memory.

[0109] In a possible design, the processing module is further configured to:

[0110] Scanning and obtaining duplicate files in the electronic device, the duplicate files including a first file and a second file; the first file is stored in a first storage space, and the second file is stored in a second storage space;

[0111] Determining that the first file and the second file have not been modified during a period from the first moment to the second moment;

[0112] The device also includes a display module, which is used to display a first interface; the first interface includes information about the first file and information about the second file.

[0113] In one possible design, the device further includes an input module, the input module being configured to detect a first operation input by a user in the first interface;

[0114] The processing module is configured to compress the first file and the second file into the same storage space according to the first operation detected by the input module.

[0115] In one possible design, the device further includes a storage module, which is configured to store the identifier of the first file and the identifier of the second file after scanning the electronic device for duplicate files.

[0116] In one possible design, the identifier of the first file includes a first index node number of the first file; and the identifier of the second file includes a second index node number of the second file.

[0117] In one possible design, determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0118] If the value of the indicator field of the first file at the second moment is the third value, and the index node number of the first file is the first index node number, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0119] In a fourth aspect, a file processing device is provided, which is applied to an electronic device or a chip system, and includes:

[0120] A display module is configured to display a second interface, wherein the second interface includes a plurality of duplicate files scanned in the electronic device; the plurality of duplicate files are respectively stored in a plurality of storage spaces of the electronic device;

[0121] a processing module, configured to, in response to an operation input by a user on the second interface, obtain, at a third moment, an indication field of each duplicate file in the plurality of duplicate files, wherein a value of the indication field of the duplicate file is used to indicate whether the duplicate file has been modified;

[0122] The processing module is further configured to compress some of the duplicate files into the same storage space according to the values ​​of the indication fields of the multiple duplicate files at a third moment.

[0123] In one possible design, the initial value of the indication field of each duplicate file is the first value.

[0124] In one possible design, the processing module is further configured to scan and obtain a plurality of candidate duplicate files before displaying the second interface; the plurality of candidate duplicate files include a plurality of duplicate files;

[0125] The processing module is further configured to, at a first moment, attempt to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value.

[0126] In a possible design, multiple candidate duplicate files are obtained by scanning, including:

[0127] Controlling the display module to display a third interface, where the third interface includes the first control;

[0128] A user operation on the first control is detected, and a plurality of candidate duplicate files are obtained by scanning.

[0129] In a possible design, multiple candidate duplicate files are obtained by scanning, including:

[0130] When the electronic device is idle, multiple candidate duplicate files are scanned and obtained.

[0131] In one possible design, the processing module is further configured to obtain, at a second moment after the first moment, a value of an indication field of at least one duplicate file;

[0132] The display module is also used to display a second interface according to the value of the indication field of at least one duplicate file at the second moment; the multiple duplicate files in the second interface are files whose modification status is unmodified during the period from the first moment to the second moment.

[0133] In one possible design, attempting to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value includes:

[0134] If at least one candidate duplicate file among multiple candidate duplicate files meets the first condition, the value of the indication field of at least one candidate duplicate file is modified to a third value; under the first condition, the file system of the electronic device can detect the modification operation on at least one candidate duplicate file within the time period from the first moment to the second moment.

[0135] In one possible design, obtaining, at the second moment, a value of an indication field of at least one duplicate file includes: obtaining, at the second moment, a value of an indication field of a target duplicate file in the at least one duplicate file as a third value;

[0136] The processing module is further configured to determine, when the value of the indicator field of the target duplicate file at the second moment is a third value, that the target duplicate file has not been modified during a period from the first moment to the second moment.

[0137] In one possible design, the plurality of candidate duplicate files include a third file;

[0138] The processing module is also used to:

[0139] After the first moment, it is detected that the third file is modified, and the value of the indication field of the third file is modified to a second value;

[0140] At the second moment, the value of the indication field of the third file obtained is not the third value;

[0141] It is determined that the third file is modified during a period from the first time to the second time.

[0142] In one possible design, the plurality of candidate duplicate files include a fourth file;

[0143] At the first moment, attempting to modify the value of the indicator field of each candidate duplicate file in the plurality of candidate duplicate files to a third value includes: if the fourth file does not meet the first condition, not modifying the indicator field of the fourth file to the third value;

[0144] The processing module is further configured to determine that the fourth file is modified within a period from the first moment to the second moment when the value of the indication field of the fourth file cannot be successfully modified to the third value.

[0145] In a possible design, compressing some of the duplicate files into the same storage space according to the values ​​of the indication fields of the multiple duplicate files at the third moment includes:

[0146] If the value of the indicator field of the first file among the multiple duplicate files at the third moment is a third value, compressing the first file;

[0147] Alternatively, if the value of the indication field of the first file among the multiple duplicate files at the third moment is not the third value, compression is not performed on the first file.

[0148] In a possible design, the storage module is used to store identifiers of multiple duplicate files, where the identifiers of the duplicate files include index node numbers of the duplicate files.

[0149] In one possible design, when the value of the indicator field of the target duplicate file at the second moment is the third value, determining that the target duplicate file is not modified during the period from the first moment to the second moment includes:

[0150] When the value of the indicator field of the target duplicate file is the third value, if the index node number of the target duplicate file has not changed, it is determined that the target duplicate file has not been modified during the period from the first moment to the second moment.

[0151] In any possible design of any of the above aspects, the indication field is stored in a metadata area of ​​the electronic device.

[0152] In any possible design of any of the above aspects, the identifier of the first file includes a first index node number of the first file; and the identifier of the second file includes a second index node number of the second file.

[0153] In any possible design of any of the above aspects, the first condition includes one or more of the following conditions: before the first moment, the duplicate file was not mapped to the memory; before the first moment, the duplicate file was mapped to the memory, but the electronic device did not perform a write operation on the memory. BRIEF DESCRIPTION OF THE DRAWINGS

[0154] FIG1A is an example diagram of a duplicate file scanning process provided by an embodiment of the present application;

[0155] FIG1B is an example diagram of the i-mtime field provided in an embodiment of the present application;

[0156] FIG2 is a schematic diagram of a write operation of a write interface method provided in an embodiment of the present application;

[0157] FIG3 is a schematic diagram of a write operation of a write memory method provided in an embodiment of the present application;

[0158] FIG4 and FIG5 are further schematic diagrams of the write operation provided in the embodiments of the present application;

[0159] FIG6 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0160] FIG7 is a schematic diagram of the software structure of the electronic device provided in an embodiment of the present application;

[0161] FIG8 is a schematic diagram of a data area and a metadata area provided in an embodiment of the present application;

[0162] FIG9 is a schematic diagram of a file processing method provided in an embodiment of the present application;

[0163] FIG10A is a schematic diagram of an interface provided in an embodiment of the present application;

[0164] Figures 10B and 10C are schematic diagrams of scenarios provided in embodiments of the present application;

[0165] FIG11 is a schematic diagram of a database provided in an embodiment of the present application;

[0166] FIG12 is a schematic diagram of a scenario in which a file is modified according to an embodiment of the present application;

[0167] FIG13 is a schematic diagram of a scenario in which a file provided in an embodiment of the present application is not modified;

[0168] FIG14 is a schematic diagram of an interface provided in an embodiment of the present application;

[0169] FIG15 is a schematic diagram of a scenario in which V1 setting fails according to an embodiment of the present application;

[0170] FIG16 is a schematic diagram of a scenario in which a file is modified according to an embodiment of the present application;

[0171] FIG17 is a schematic diagram of a scenario in which a file provided in an embodiment of the present application is not modified;

[0172] FIG18 is a schematic diagram of a scenario in which V1 setting fails according to an embodiment of the present application;

[0173] FIG19 is a schematic diagram of a scenario provided by an embodiment of the present application;

[0174] FIG20 is a schematic diagram of an interface provided in an embodiment of the present application;

[0175] Figures 21 and 22 are schematic structural diagrams of the device provided in the embodiments of the present application. DETAILED DESCRIPTION

[0176] The terms "including," "having," and any variations thereof mentioned in the description of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to the process, method, product, or apparatus.

[0177] It should be noted that in the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being more preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0178] In this application, unless otherwise specified, "plurality" means two or more. "And / or" in this document is simply a description of an association between related objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone.

[0179] To facilitate understanding, the following first introduces relevant terms and concepts that may be involved in the embodiments of this application.

[0180] 1. File deduplication

[0181] In some scenarios, multiple duplicate files exist in a file system. These duplicate files originally occupied multiple storage spaces, but after deduplication, they now occupy only one storage space. Duplicate files are files with identical content. For example, as shown in Figure 1A, File 1 and File 2 constitute duplicate files. Before deduplication, File 1 and File 2 occupied Storage Space 1 and Storage Space 2, respectively. After the electronic device performs deduplication on File 1 and File 2, File 1 and File 2 point to the same Storage Space 1, significantly freeing up storage space on the electronic device. In some scenarios, the electronic device can scan for stored duplicate files. Scanning for duplicate files may include preliminary screening and binary comparison. During the preliminary screening, the electronic device selects a portion of the content from the file and reads this portion to obtain a value. If the values ​​of the selected content of the two files are the same, the electronic device preliminarily determines that the two files may be duplicates. The electronic device then performs a binary comparison on the two files, comparing their entire contents byte by byte. If the binary comparison results are consistent, the two files are considered duplicates.

[0182] In other scenarios, binary comparison can also be replaced by other steps for determining duplicate files, such as hash value comparison, etc. The embodiment of the present application does not limit the specific implementation of the duplicate file scanning process.

[0183] 2. i-mtime field

[0184] According to whether the file has been modified within a period of time, the modification status of the file can be divided into two types: one is modified within a period of time, and the other is not modified within a period of time.

[0185] In some schemes, the electronic device can set an i-mtime field, and the i-mtime field can be used to indicate the time when the file was last modified. Optionally, the i-mtime field can generally be stored in the metadata area of ​​the file system. Specifically, the i-mtime field can be stored in the index node (inode) area of ​​the metadata area. For example, file 1 has been modified three times in history, and the modification times are 2022-8-22 (8:00), 2022-8-23 (10:00), and 2022-8-23 (18:00), as shown in Table 1, the field value of the i-mtime field of file 1 can be 2022-8-23 (18:00). Similarly, file 2 has been modified twice in history, and the modification times are 2022-8-22 (18:00) and 2022-8-23 (10:00), as shown in Table 1, the field value of the i-mtime field of file 2 can be 2022-8-23 (10:00).

[0186] Table 1

[0187] In some solutions, an application in an electronic device can query the file's i-mtime field to determine whether the file has been modified within a period of time. As a possible implementation method, the application queries the file's i-mtime field at time point 1 and time point 2 respectively. If the field values ​​of the i-mtime field obtained in the two queries are consistent, it means that the file has not been modified between time point 1 and time point 2. Conversely, if the field values ​​of the i-mtime field obtained in the two queries are inconsistent, it means that the file has been modified between time point 1 and time point 2.

[0188] For example, as shown in Figure 1B (a), the application queries the i-mtime field of File 1 at 10:00 and learns that File 1 was last modified at 8:00. The application then queries the i-mtime field of File 1 again at 12:00 and learns that File 1 was last modified at 8:00. In this case, the field values ​​(indicating the time the file was last modified) obtained from the two queries are the same, and the application can determine that File 1 was not modified between 10:00 and 12:00.

[0189] For example, as shown in Figure 1B (b), the application queries the i-mtime field of File 1 at 10:00 and learns that File 1 was last modified at 8:00. The application then queries the i-mtime field of File 1 again at 12:00 and learns that File 1 was last modified at 11:00. In this case, the field values ​​obtained from the two queries are different, and the application can determine that File 1 was modified between 10:00 and 12:00.

[0190] 3. Write interface

[0191] As a way of writing files, an electronic device can perform a file writing operation through a write interface. In this way of writing files, each write operation will execute a section of code in the file system, and the file system can modify the i-mtime field of the file to record the time when the file was last modified. For example, as shown in Figure 2, when the write interface is called at time t1 (10:00) to modify file 1, the electronic device will execute the code in the file system, and the file system can modify the i-mtime field of file 1 to indicate that the time when file 1 was last modified was 10:00. Similarly, when the write interface is called at time t2 (12:00) to modify file 1, the electronic device will execute the code in the file system, and the file system can modify the i-mtime field of file 1 to indicate that the time when file 1 was last modified was 12:00.

[0192] 4. mmap

[0193] As another way to write a file, the electronic device can map the file to a certain memory through the mmap interface. Subsequently, when writing a file, the file can be written to the memory. Writing to the memory can be understood as writing content to the memory mapped to the file, which is equivalent to indirectly writing to the corresponding file. In this way of writing a file, after a file is mapped to the corresponding memory, the electronic device will execute the relevant code in the file system when writing to the memory for the first time. In some examples, when writing to the same memory later, the code in the file system may no longer be executed to avoid being trapped in the file system and generating additional overhead.

[0194] For example, as shown in Figure 3 (a), the electronic device maps File 2 to Memory 2. As shown in Figure 3 (b), at time t1 (10:00), the electronic device performs its first write operation to Memory 2 via the mmap interface. At this point, the electronic device executes the relevant code in the file system to write to Memory 2. Therefore, the file system detects that File 2 associated with Memory 2 has been modified and accordingly modifies File 2's i-mtime field to indicate that File 2 was last modified at 10:00.

[0195] Then, still as in Figure 3(b), at time t2, the electronic device performs a write operation on memory 2 through the mmap interface. Because a write operation has been performed on memory 2 in the past, to avoid the system overhead caused by frequent file system calls, the electronic device does not call the file system to perform the write operation on memory 2 at time t2.

[0196] As another example, as shown in Figure 4, at time t1, the electronic device maps a file to a certain block of memory. Later, at time t2 (10:05), the electronic device writes content to the memory, which is equivalent to writing the corresponding content to the memory-mapped file. Since this write is the first write to the memory, the relevant code in the file system will be executed. The file system can sense that the file has been modified and modify the i-mtime field of the file to indicate that the time the file was last modified is 10:05. Later, at time t3 (10:06), an application in the electronic device queries the i-mtime field of the file. At time t4 (10:07), the electronic device writes content to the same block of memory for the second time. In order to frequently trap the file system, the electronic device does not trap the code in the file system when writing to the memory this time. Therefore, the file system cannot sense that the file associated with the memory has been modified, and accordingly does not modify the i-mtime field of the file. At time t5, the application again queries the i-mtime field of the file. Since the field value of the i-mtime field queried at time t5 and t3 is both 10:05, the electronic device mistakenly believes that the file has not been modified during the time period t3-t5 (i.e., 10:05-10:07).

[0197] It can be seen that in some scenarios, when performing write operations through mmap, the electronic device will not fall into the file system, resulting in the file system being unable to perceive that the file has been modified, unable to track the modification of the file, and unable to update the field value of the i-mtime field in time, causing the electronic device to misjudge whether the file has been modified.

[0198] 5. Modifying the system time leads to misjudgment of file modification status

[0199] In some scenarios, whether the write operation is performed through the write interface or the mmap interface, the modification status of the file may be misjudged when the system time is modified. For example, as shown in Figure 5, at time t1 (10:00), the file is modified. Afterwards, at time t2, an application in the electronic device queries the i-mtime field of the file and learns that the last time the file was modified was 10:00. At time t3, the system time of the electronic device is modified, for example, from 10:30 to 9:30. Afterwards, at time t4 (10:00 after the system time is modified), the file is modified again. At time t5, the application queries the i-mtime field of the file again. Since the field value of the i-mtime field queried at times t5 and t3 is both 10:00, the electronic device mistakenly believes that the file has not been modified during the t3-t5 period (i.e., during 10:05-12:00).

[0200] Here, the system time can be modified by the user or automatically by the system.

[0201] It can be seen that since the system time has been modified, the system time may be the same when the file is modified twice, which may cause the electronic device to misjudge whether the file has been modified. This cannot meet the business needs of the electronic device to accurately determine whether the file has been modified. That is, it cannot reliably determine the modification status of the file, and the performance of the electronic device is low.

[0202] 6. inotify

[0203] In some solutions, you can also use the inotify mechanism to monitor file modifications. An application can use the inotify interface to notify the file system that it needs to monitor file modification status. Subsequently, the file system detects the file modification event and notifies the application of the file modification. This approach requires the application to be resident during the monitoring period, which consumes more system resources (such as memory resources) and incurs high overhead for electronic devices.

[0204] It can be seen that the above-mentioned solutions for determining whether a file has been modified cannot achieve good performance for the electronic device. To solve the above-mentioned technical problems, an embodiment of the present application provides a file processing method. This method can be applied to electronic devices. For example, the electronic device in the embodiment of the present application can be implemented by the electronic device in Figure 6. Figure 6 shows a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. The electronic device 200 includes at least one processor 201, a memory 202, and at least one transceiver 203.

[0205] The processor 201 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.

[0206] The above components may include communication lines for transmitting information between the above components.

[0207] Transceiver 203 is used to communicate with other devices. In the embodiments of the present application, the transceiver can be a module, circuit, bus, interface, or other device capable of implementing communication functions, used to communicate with other devices. Optionally, the transceiver can be a standalone transmitter that can be used to send information to other devices, or a standalone receiver that can be used to receive information from other devices. The transceiver can also be a component that integrates the functions of sending and receiving information. The embodiments of the present application do not limit the specific implementation of the transceiver.

[0208] The memory 202 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor via a communication line. The memory may also be integrated with the processor.

[0209] The memory 202 is used to store computer-executable instructions for implementing the solution of the present application, and the execution is controlled by the processor 201. The processor 201 is used to execute the computer-executable instructions stored in the memory 202, thereby implementing the various methods provided in the following embodiments of the present application.

[0210] Optionally, the computer-executable instructions in the embodiments of the present application may also be referred to as application code, instructions, computer programs or other names, which are not specifically limited in the embodiments of the present application.

[0211] In a specific implementation, as an embodiment, the processor 201 may include one or more CPUs.

[0212] In a specific implementation, as an embodiment, the electronic device 200 may include multiple processors. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. The processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).

[0213] FIG6 is a block diagram of an exemplary electronic device. It should be understood that the illustrated electronic device is merely an example, and in actual applications, the electronic device may have more or fewer components than those shown in FIG6 , may combine two or more components, or may have a different component configuration.

[0214] The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. For example, the software system of the electronic device can be The embodiment of the present invention takes the Android system with a layered architecture as an example to exemplify the software structure of the electronic device.

[0215] FIG7 is a block diagram of the software structure of the electronic device according to an embodiment of the present invention.

[0216] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers: from top to bottom: the application layer (referred to as the application layer), the application framework layer (referred to as the framework layer), the Android runtime and system libraries, the hardware abstraction layer (HAL), and the kernel layer.

[0217] (1) Application layer

[0218] The application layer can include a series of application packages. As shown in Figure 7, the application package may include camera, gallery, calendar, call, map, navigation, wireless local area network (WLAN), Bluetooth, music, video, short message and other applications.

[0219] In the embodiment of the present application, the application may also include settings, mobile phone management applications, etc. Taking the mobile phone management application as an example, the mobile phone management application can call the interface provided by the file system to modify the field value of the U field of the corresponding file. Subsequently, the mobile phone management application can determine whether the corresponding file has been modified within a period of time based on the field value of the U field.

[0220] Optionally, the application may determine the value of the U field in at least one of the following ways.

[0221] The first way: the application can call the first interface provided by the file system, and the first interface returns the U field value of the file.

[0222] The second method: the application calls the second interface provided by the file system. The file system determines the U field value of the file during execution and determines whether to continue executing the remaining steps of the second interface based on the U field value.

[0223] Optionally, the above application may be an application running in user mode.

[0224] Applications running in "user mode" are called "user-mode programs." For example, applications such as Changlian Communication and Smart Life are all user-mode programs. In some cases, user-mode programs need to use some functions provided by the operating system (such as reading file contents). In this case, the user-mode program will call the application programming interface (API) provided by the operating system, falling from user mode to kernel mode to execute functions provided by the operating system kernel.

[0225] (2) Framework layer

[0226] The framework layer provides APIs and programming frameworks for applications in the application layer. The framework layer includes some predefined functions.

[0227] As shown in FIG7 , the framework layer may include an activity manager, a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.

[0228] The activity manager is responsible for launching all app processes, launching the four major app components (e.g., activities, services, broadcast receivers, and content providers), switching between apps and within app interfaces, and managing the lifecycles of various components. The window manager manages window programs. It can obtain the display size, determine whether a status bar is present, lock the screen, take screenshots, and more. The content provider stores and retrieves data and makes it accessible to applications. This data can include video, images, audio, incoming and outgoing calls, browsing history and bookmarks, and the phone book. The view system includes visual controls, such as those for displaying text and images. The view system can be used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon can include a view for displaying text and a view for displaying images. The call manager provides communication functions for electronic devices, such as managing call states (including connected and ended calls). The resource manager provides applications with various resources, such as localized strings, icons, images, layout files, and video files. The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.

[0229] 3. Android Runtime and System Libraries

[0230] As shown in Figure 7, Android Runtime is responsible for scheduling and management of the Android system.

[0231] The system library can include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0232] The surface manager manages the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library supports a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG. The 3D graphics processing library implements 3D graphics drawing, image rendering, compositing, and layer processing. The 2D graphics engine is the drawing engine for 2D drawing.

[0233] (4) Kernel layer

[0234] The kernel layer is the layer between hardware and software.

[0235] In the embodiments of the present application, the kernel layer may include a file system. The file system is a core module of the operating system kernel, i.e., one of its main components. The file system is responsible for managing and storing file information, primarily creating files for users, storing, reading, modifying, and dumping files, controlling file access, and revoking files when they are no longer in use.

[0236] In some embodiments, the file system may run in kernel mode.

[0237] Applications running in "user mode" are called "user-mode programs." For example, applications such as Changlian Communication and Smart Life are all user-mode programs. In some cases, user-mode programs need to use some functions provided by the operating system (such as reading file contents). In this case, the user-mode program will call the application programming interface (API) provided by the operating system, falling from user mode to kernel mode to execute functions provided by the operating system kernel.

[0238] Data in a file system can include metadata and data. Metadata is used to describe the characteristics and attributes of a file. Optionally, metadata includes, but is not limited to, the following information: file system control information, data structure, and file description information, such as file length and file type. File types include, for example, regular files (regular inodes), directory files (directory inodes), symbol link inodes (symbol link inodes), and special files (special inodes).

[0239] Optionally, the metadata and data of the file can be stored in a storage device (such as a hard disk). As shown in Figure 8, the storage area of ​​the storage device may include a metadata area and a data area.

[0240] The data of a file can be stored in a data area of ​​a storage device. Optionally, the data stored in the data area can be data obtained by performing file-level compression processing based on lossless compression technology. The data in the data area is stored in the physical storage space of a storage medium (such as a disk, flash memory, etc.) as a collection of disk blocks. The data of the same file can be stored in consecutive disk blocks, or can be stored crosswise in discontinuous disk blocks.

[0241] It should be understood that the introduction of the concept of disk blocks in this application does not mean that the storage medium is limited to disks. Disk blocks can be used to represent small physical storage spaces obtained by dividing the physical storage space of the storage medium.

[0242] As shown in Figure 8 , the data storage location can be represented by the index of the block where the data is located. For example, in Figure 8 , a file is stored in blocks 909, 912, and 914. The metadata area can store the block indexes 909, 912, and 914 of the file. Later, when performing operations such as reading or writing on the file, the electronic device can read the index of the block where the file is located from the metadata area and, based on the index, access (e.g., read) the file at the corresponding block location.

[0243] In some embodiments, the file system can provide an interface for reading and writing files for user-mode programs. As a first possible implementation, the file system provides a read-write interface (e.g., read, write), and the user-mode program calls the read and write interfaces to read and write files.

[0244] As a second possible implementation, the file system provides a memory mapping interface (e.g., mmap). User-mode programs call the memory mapping interface to map files to memory and obtain the mapped memory address. The user-mode program can then access the file using memory access methods, for example, writing to the file using memory writes.

[0245] In some embodiments, for the first file access method described above, since each file access operation will call an interface provided by the file system, the file system can perceive each file access operation.

[0246] For the second file access method described above, the first file access after mapping is established (such as the first memory write) will cause a memory page fault. At this time, the file system function will be called, so the file system knows that the user-mode program has accessed the file. However, subsequent accesses (such as subsequent memory writes) do not necessarily cause a memory page fault, so the file system may not be aware that the user-mode program has modified the file.

[0247] In an embodiment of the present application, as shown in FIG8 , the file system may add an unmodified field (hereinafter referred to as a U field) in the metadata area. The U field may indicate whether the corresponding file has been modified. Each file has a corresponding U field.

[0248] Optionally, the file system can set the initial value of the U field. For example, the initial value is set to V0.

[0249] The file system can provide an interface to the application, and the application can call the interface to modify the field value of the U field (for example, to V1). Subsequently, the application can determine whether the corresponding file has been modified based on the field value of the U field.

[0250] As follows, the technical solution of the embodiment of the present application is described in detail by taking a mobile phone as an example of an electronic device.

[0251] Example 1

[0252] As shown in FIG9 , the technical solution of the embodiment of the present application may include the following steps:

[0253] S101. The file system sets the value of the U field of the first file to V0.

[0254] Optionally, the U field may be stored in the metadata area of ​​the file system.

[0255] S 102. At the first moment, the application program calls the interface of the file system and attempts to modify the value of the U field of the first file to V1.

[0256] For example, as shown in FIG10A (a), the mobile phone displays a mobile phone manager application interface 901, which may include a "Clean Up" button 902. After detecting that the user has clicked the "Clean Up" button 902, the mobile phone may scan the data stored in the mobile phone for cleanup. The data to be cleaned may include multiple duplicate files, i.e., multiple files with identical content.

[0257] In some embodiments, during the process of scanning multiple duplicate files by the mobile phone manager application, the mobile phone manager application calls the interface of the file system to attempt to modify the field value of the U field corresponding to each of the multiple duplicate files from the initial value V0 to V1. Optionally, the process of scanning duplicate files may include preliminary screening and binary comparison. After the mobile phone manager application obtains the files that are initially identified as duplicate files (which may be referred to as candidate duplicate files for short), it may call the interface of the file system before binary comparison to attempt to modify the value of the U field of each candidate duplicate file to V1.

[0258] For example, as shown in Figure 12, at time t6, after the user clicks the "Clean and Accelerate" button, the mobile phone can perform a preliminary screening of duplicate files. After the preliminary screening is completed, English grammars 1-4 are preliminarily identified as a group of candidate duplicate files, and computer technologies 1 and 2 are a group of candidate duplicate files. Taking the attempt to modify the U field value of English grammar 2 in the candidate duplicate file to V1 as an example, the user clicks the "Clean and Accelerate" button, and after the mobile phone performs a preliminary screening of duplicate files, at time t1 (the first moment), the mobile phone manager application calls the file system interface and attempts to modify the field value of the U field corresponding to English grammar 2 from V0 to V1. In the example of Figure 12, since the mobile phone has not executed mmap for English grammar 2 before time t1, the first condition is met, and the mobile phone manager application can successfully modify the value of the U field of English grammar 2 from V0 to V1.

[0259] Similarly, the mobile manager application can try to modify the value of the U field of other candidate duplicate files (ie, files initially identified as duplicate files) to V1.

[0260] As a possible implementation, when the application wants to set the U field of the first file to V1, it can call the file system interface to send a request message to the file system, which is used to request to modify the initial value of the U field of the first file to V1.

[0261] Optionally, V1 can be specified by the application or by the file system.

[0262] In some embodiments, after receiving the request message from the application, the file system determines whether a first condition for modifying the value of the U field of the first file is met. If the first condition is met, the file system may modify the value of the U field of the first file to V1. Conversely, if the first condition is not met, the file system does not modify the value of the U field of the first file to V1.

[0263] Optionally, the first condition includes: whether the file has been mapped to memory (for example, the application has mapped the file using mmap()).

[0264] For example, as shown in Figure 15, before time t1, the mobile phone has mapped the file Computer Technology 1 to the memory, and the first condition is not met. Then, at time t1, the mobile phone manager application will not successfully modify the field value of the U field of Computer Technology 1 from V0 to V1.

[0265] Figure 10B shows some of the candidate duplicate files obtained through the initial screening. After the initial screening, the mobile phone manager application preliminarily identified English Grammar 1-5 as a group of candidate duplicate files, and Computer Technology 1-4 as a group of candidate duplicate files. At time t1, the mobile phone manager application can call the file system interface to attempt to modify the value of the U field of each candidate duplicate file to V1. For example, Table 2 shows the field values ​​of the U field of each candidate duplicate file after time t1.

[0266] Table 2

[0267] As shown in Table 2, the U field value for Computer Technology 1 remains at its initial value, V0. This may be because the phone had already mapped Computer Technology 1 to memory before time t1. The U field values ​​for other files, such as English Grammar 1-4 and Computer Technology 2, were modified to V1 by the Mobile Manager app, indicating that the phone had not yet mapped these files to memory before time t1.

[0268] Optionally, when the first condition is met, the file system returns a setting success message to the application, and the application can determine that the value of the U field of the file has been modified to V1.

[0269] Optionally, when the first condition is not met, the file system returns a setting failure return message to the application, and the application can determine that the value of the U field of the file is not set to V1 (still V0).

[0270] S103: When it is detected that the first file is modified, the file system modifies the value of the U field of the first file to V2.

[0271] In some scenarios, users can modify files. For example, as shown in Figure 12, assume that before time t1, the phone had not performed a memory write operation on English grammar 2. At time t3, in response to the user's intention to modify English grammar 2, the phone performs the first memory write operation on English grammar 2. Specifically, the phone's first memory write operation on English grammar 2 will inevitably execute relevant code in the file system. Thus, at time t3, the file system can detect that English grammar 2 has been modified and changes the U field of English grammar 2 from V1 to V2.

[0272] Optionally, the file system can also store the file's modification time in the metadata area. As shown in Figure 12, the file system can store t3 in the metadata area. Subsequently, the application can determine the file's modification time based on the modification time stored in the metadata area.

[0273] S104. The application determines whether the value of the U field of the first file is successfully set to V1. If the value of the U field of the first file is set to V1, the application executes the following steps S106-S110. If the value of the U field of the first file is not set to V1, the application executes step S111.

[0274] Optionally, the application may receive a return message from the file system, where the return message is used to indicate whether the value of the U field of the first file is successfully set to V1.

[0275] It should be understood that when an application successfully sets the value of the U field of a duplicate file to V1, it means that the mobile phone has not mapped the file to the memory before time t1. In this case, the mobile phone can subsequently map the file to the memory, and if the file is modified by writing to the memory, the mobile phone will definitely execute the relevant code in the file system when the file is written to the memory for the first time. In this way, the file system can sense that the file has been modified and modify the value of the U field of the file (for example, from V1 to V2). The mobile phone can determine that the file has been modified based on the value of the U field of the file (V2). Conversely, if the mobile phone does not modify the file subsequently, the value of the U field of the file will still be V1. The mobile phone can determine that the file has not been modified based on the value of the U field of the file (V1).

[0276] Wherein, the value of V2 is different from that of V1. In some implementations, V2 may be equal to V0.

[0277] Alternatively, if the file is subsequently modified using the write interface, the phone will execute the file system's code each time a write operation is performed. The file system will still detect that the file has been modified and will modify the value of the file's U field (V2). Conversely, if the phone does not subsequently modify the file, the value of the file's U field will remain at V1. The phone can determine that the file has not been modified based on the value of the file's U field (V1).

[0278] In short, if the application can successfully set the value of the U field of the file to V1 at the first moment, regardless of whether the file is subsequently modified by writing to memory or using the write interface, the mobile phone can accurately determine whether the file has actually been modified based on whether the U field value of the file changes subsequently (for example, at the second moment).

[0279] On the contrary, if the application fails to successfully set the value of the U field of a certain file to V1 (still V0), it means that the mobile phone has previously mapped the file to the memory. In this case, if the file is subsequently modified by writing to the memory (not necessarily the first time writing to the memory), in order to reduce overhead, the mobile phone may not execute the relevant code in the file system. The file system cannot track the modification events of the file, and it cannot update the value of the U field of the file when the file is modified. For example, if the file is modified, the file system may not perceive that the file has been modified, so the value of the U field of the file is not updated. For another example, if the file has not been modified, the file system will not update the value of the U field of the file. In this way, regardless of whether the file is modified or not, the value of the U field of the file is V0 (it will not be updated to V2 by the file system), and the mobile phone cannot determine whether the file has been modified based on the value of the U field.

[0280] Considering that if the application fails to successfully set the value of the U field of a file to V1 at the first moment, the file system may not be able to perceive that the file has been modified, and the file system may not update the value of the U field of the file in a timely manner, resulting in the mobile phone being unable to determine whether the file has been modified based on the value of the U field at the second moment. In this case, to avoid data being mistakenly deduplicated, the mobile phone can execute the subsequent step S109 to determine that the first file is not a duplicate file, so as to avoid mistaken deduplication of the first file.

[0281] In some embodiments, when the application lacks the corresponding permission, it may also fail to successfully modify the value of the U field of the file from V0 to V1. In the embodiment of the present application, the system application authorized by the user has the permission to modify the U field to reduce the risk of misjudgment.

[0282] Alternatively, in some embodiments, when there is a lack of storage space, the application may not be able to successfully modify the value of the U field of the file to V1.

[0283] S105 , at the second moment, the application queries the value of the U field of the first file.

[0284] In some embodiments, if the value of the U field of some candidate duplicate files (files initially identified as duplicate files) is successfully modified to V1 at the first moment, the mobile phone can perform a binary comparison on these candidate duplicate files to determine the final duplicate file.

[0285] For example, as shown in Figure 10B, at time t6, the user clicks the "Clean Up Speed" button, triggering the mobile phone to perform a preliminary screening of candidate duplicate files. The candidate duplicate files obtained from the preliminary screening include the group of candidate duplicate files of English grammar 1-5, and the group of candidate duplicate files of computer technology 1-4. At time t1, the mobile phone manager application attempts to set the value of the U field of each candidate duplicate file to V1. Assuming that at time t1, the values ​​of the U fields of English grammar 1-4 and computer technology 2-4 are successfully set to V1, the mobile phone manager application can perform a binary comparison on the group of candidate duplicate files of application grammar 1-4 and the group of candidate duplicate files of computer technology 2-4 to determine the final duplicate files. After binary comparison, English grammar 1-4 constitutes a group of duplicate files. Computer technology 2-4 constitutes a group of duplicate files.

[0286] In some embodiments, the mobile phone can store the information of duplicate files in the duplicate file information library. Optionally, the identification of duplicate files can be stored in the duplicate file information library. As shown in Figure 11, the duplicate file information library can include the identification of each duplicate file in the group of duplicate files of English grammar 1-4, and the identification of each duplicate file in the group of duplicate files of computer technology 2-4. Optionally, the identification of duplicate files includes but is not limited to: the name of the duplicate file, the inode number (inode number) of the duplicate file, and whether the value of the U field of the duplicate file is successfully set to V1 at the first moment. Wherein, the inode number of the file is used to uniquely identify a file. Files with different contents have different inode numbers.

[0287] In some embodiments, after scanning and obtaining each duplicate file, before presenting the scan results of the duplicate files to the user, at a second moment, the application can query the value of the U field of each duplicate file, and determine whether each duplicate file has been modified between the first moment and the second moment based on the value of the U field of each duplicate file at the second moment.

[0288] As a possible implementation, the application can query the value of the U field of the file itself. Alternatively, the application can send a query request to the file system, which queries the value of the U field of the file and returns the value of the U field of the file to the application.

[0289] Taking the modification status of English grammar 2 in duplicate files as an example, as shown in Figure 12, after the initial screening is completed, at time t1, the value of the U field of English grammar 2, which is initially identified as a duplicate file (candidate duplicate file), is successfully set to V1. Afterwards, the mobile phone manager performs a binary comparison on each candidate duplicate file, and finally determines that English grammars 1-4 constitute a group of duplicate files, and the computer calculates that 2-4 constitute a group of duplicate files. After scanning each duplicate file, before displaying the scan results of the duplicate files to the user, at time t5, the mobile phone manager application can query the value of the U field of English grammar 2, and determine whether English grammar 2 has been modified during the period t1-t5 based on the value of the U field at time t5.

[0290] S106: The application determines whether the value of the U field of the first file is V1. If the value of the U field is V1, the application proceeds to step S107. If the value of the U field is not V1, the application proceeds to step S108.

[0291] S107: The application determines that the first file has not been modified.

[0292] For example, as shown in Figure 13, after the mobile phone manager application scans the duplicate files (binary comparison) and before displaying the scan results to the user, at time t5, the mobile phone manager application queries the field value of the U field of the duplicate file English Grammar 3 and learns that the field value is V1. Since the field value of the U field of English Grammar 3 at time t5 is the same as the field value at time t1, both are V1, the mobile phone manager application can determine that the file English Grammar 3 has not been modified between time t1 (at time t1, the mobile phone manager application calls the file system interface and attempts to change the field value of the U field of English Grammar 3 from V0 to V1) and time t5.

[0293] Similarly, the mobile phone manager app can query the field value of the U field of English grammars 1, 3, and 4. If the U field value of English grammars 1, 3, and 4 is all V1, it means that the file system has not detected that English grammars 1, 3, and 4 have been modified. Therefore, the mobile phone manager app can determine that English grammars 1, 3, and 4 have not been modified between time t1 and time t5. Therefore, English grammars 1, 3, and 4 still constitute duplicate files. Subsequently, the mobile phone manager app can deduplicate this set of duplicate files to reduce storage space usage.

[0294] In some embodiments, the application determines the index node number of the first file and the value of the U field of the first file at the second moment. If the index node number of the first file remains unchanged and the value of the U field of the first file at the second moment is V1, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0295] S108: The application determines that the first file is modified.

[0296] For example, as shown in Figure 12, after the mobile phone manager application performs a binary comparison and obtains the scan results of the duplicate files, before displaying the scan results to the user, at time t5, the mobile phone manager application can read the field value of the U field of English Grammar 2 from the metadata area and learn that the field value is V2. Since the field value of the U field of English Grammar 2 at time t5 is different from the field value at time t1, the mobile phone manager application can determine that the file English Grammar 2 may have been modified between time t1 (at time t1, the mobile phone manager application requests the file system to change the field value of the U field of English Grammar 3 from V0 to V1) and time t5. The mobile phone no longer regards English Grammar 2 as a duplicate file. In this way, the mobile phone manager application will not perform deduplication on English Grammar 2 subsequently.

[0297] Optionally, the metadata area may further store the modification time t3 of the English grammar 2. The mobile phone manager application may read the modification time from the metadata area and thereby learn that the modification time of the English grammar 2 is t3.

[0298] Compared to the scheme shown in Figure 4, where the file system misses detecting a second memory write operation, such as the second, and is unable to update the i-mtime field in a timely manner, causing the electronic device to mistakenly believe that the file has not been modified during the t3-t5 period, using the technical solution of the embodiment of the present application, for a certain file, if the file is not mapped to the memory before the first moment, then once the mobile phone subsequently performs one or more memory write operations on the file between the first moment and the second moment, the first memory write operation will inevitably cause the mobile phone to execute the relevant code of the file system. In other words, at least the first memory write operation between the first moment and the second moment will be detected by the file system. In this way, the file system can determine that the file has been modified based on at least the first memory write operation between the first moment and the second moment. It can be seen that in the embodiment of the present application, the file system does not need to detect every memory write operation. Even if the file system misses a memory write operation, the file system can determine that the file has been modified based on at least the first memory write operation detected within a period of time. In this way, the detection accuracy of the electronic device can be improved.

[0299] S109: The application determines that the first file is not a duplicate file.

[0300] As mentioned above, at the first moment, the value of the U field of the first file was not successfully set to V1. This means that between the first moment and the second moment, the first file may have been modified (and may no longer be a duplicate file), but the file system may not be able to detect that the first file has been modified. In this case, the application will treat the first file as a modified file and the first file will no longer be a duplicate file. In addition, the application will not perform deduplication on the first file to avoid mistakenly deduplicating the first file, which is actually a non-duplicate file.

[0301] For example, as shown in Figure 15, assuming that before time t1, the mobile phone has performed an overwrite memory operation on Computer Technology 1 in the candidate duplicate files, then after the initial screening of duplicate files is completed, at time t1, the mobile phone manager application cannot successfully modify the value of the U field of Computer Technology 1 to V1 (the value of the U field is still V0). In this case, the mobile phone manager application can no longer perform a binary comparison on Computer Technology 1. The mobile phone manager application can regard Computer Technology 1 as a modified file (no longer a duplicate file) and no longer perform deduplication on Computer Technology 1 to avoid performing erroneous deduplication.

[0302] In some embodiments, after the mobile manager application determines the modification status of each duplicate file during the period t1-t5, it can present one or more groups of unmodified duplicate files to the user. As shown in Figure 10B, during the period t1-t5, the unmodified files include: English Grammar 1, 3, and 4, and Computer Technology 2 and 3. That is, English Grammar 1, 3, and 4 still constitute duplicate files, and Computer Technology 2 and 3 still constitute duplicate files.

[0303] As shown in FIG10A(b), at time t2, the mobile phone may display interface 903. Interface 903 may include cards 905 corresponding to duplicate files in the mobile phone. As shown in FIG10A(b), card 905 indicates that the mobile phone has eight sets of duplicate files (including duplicate files for English Grammar 1, 3, and 4 and duplicate files for Computer Calculation 2 and 3), and the duplicate files occupy a total of 229MB of storage space.

[0304] In some examples, after detecting that the user clicks the "Lossless Compression" button 904, the mobile phone can display an interface 906 as shown in (c) of Figure 10A. Interface 906 can present detailed information of the above 8 groups of duplicate files. For example, as shown in (c) of Figure 10A, interface 906 presents information of the first group of duplicate files "English Grammar 1, English Grammar 3, English Grammar 4". Interface 906 also presents information of the second group of duplicate files "Computer Technology 2, Computer Technology 3". In response to user operations such as swiping up, interface 906 can also present information of other duplicate files. Multiple files in each group of duplicate files occupy multiple storage spaces respectively. For example, English Grammar 1-4 each occupy 24MB of storage space.

[0305] The user can select one or more groups of duplicate files and click the compression button 907. The mobile phone can deduplicate the one or more groups of duplicate files selected by the user based on the user's compression / deduplicate intention. For example, as shown in (c) of Figure 10A, if the user selects the duplicate file group "English Grammar", the mobile phone can deduplicate the group of files "English Grammar 1, 3, and 4" based on the user's compression intention. As shown in Figure 10C, after deduplication, English Grammar 1, 3, and 4 only occupy one storage space (24MB), which greatly frees up the storage space of the mobile phone.

[0306] In some embodiments, after deduplication, the electronic device can still display the set of files "English Grammars 1, 3, and 4" in the user interface, and the user can still open and use any file in this set normally. Compared to before deduplication, after deduplication, the storage space occupied by "English Grammars 1, 3, and 4" is reduced.

[0307] After performing deduplication processing using the Mobile Manager application, the user can close the Mobile Manager application.

[0308] Optionally, the above-mentioned file deduplication is a possible implementation method of file compression. File compression can also be implemented in other ways, which are not limited by the embodiments of this application.

[0309] The technical solution of the embodiment of the present application has different methods for determining whether a file has been modified within a period of time for different types of files, so as to meet the business needs of determining whether different types of files have been modified.

[0310] Specifically, for file 1 that has not been mapped to the memory before the first moment, the electronic device can modify the value of the U field of file 1 from the initial value V0 to V1 at the first moment. Afterwards, at the second moment, the electronic device can query the value of the U field of file 1 and determine whether the file 1 has been modified based on the value of the U field. In some cases, at the second moment, if the value of the U field of file 1 is a value other than V1 (such as V2), the electronic device can determine that the file 1 has been modified during the period from the first moment to the second moment. In other cases, at the second moment, if the value of the U field of file 1 is V1, the electronic device can determine that the file 1 has not been modified during the period from the first moment to the second moment.

[0311] For file 2 that has been mapped to the memory before the first moment, the electronic device does not modify the value of the U field of file 2 at the first moment (the value of the U field is still the initial value V0). This means that during the period from the first moment to the second moment, file 2 may be modified (may no longer be a duplicate file), but the file system may not be able to detect that file 2 has been modified. In this case, the electronic device regards file 2 as a modified file, and file 2 is no longer a duplicate file. In addition, the application does not perform deduplication processing on file 2 to avoid mistakenly deduplicating file 2, which is actually a non-duplicate file.

[0312] It should be noted that the above V2 can also be replaced by other values ​​other than V1 (such as V0). The embodiment of the present application does not limit the specific value to which the U field is modified when the file system senses that the file has been modified.

[0313] The above mainly uses the mobile phone manager application as an example to illustrate the method for determining the modification status of a file. It should be understood that the application can also be any other possible application. For example, the application can also be a file manager. The file manager can use the technical solution of the embodiment of the present application to determine whether the files in its directory have been modified within a period of time.

[0314] The above mainly takes the example of the user actively triggering the mobile phone to scan for duplicate files. In other embodiments, the mobile phone can scan the duplicate files in the mobile phone by itself, and deduplicate some duplicate files to reduce the storage space occupied. Taking the mobile phone actively scanning for duplicate files and performing deduplication as an example, for example, at time point 1, the application modifies the values ​​of the U fields of files A and B to V1. At time point 2, the application reads the contents of files A and B, and considers files A and B to be duplicate files. At time point 3, file A is modified, and the value of the U field of file A is modified to V2 by the file system. At time point 4, the application queries the values ​​of the U fields of files A and B, and learns that the value of the U field of file A is V1, and the value of the U field of file B is V2, which means that file A has been modified and file B has not been modified, and files A and B are no longer duplicate files. Therefore, the application does not perform deduplication on files A and B.

[0315] As another example, at time point 1, the application modifies the value of the U field in both files A and B to V1. At time point 2, the application reads the contents of files A and B and determines that files A and B are duplicates. At time point 3, the application queries the value of the U field in files A and B and learns that the value of the U field in both files A and B is V1. This means that since time point 1, neither file A or B has been modified and files A and B are still duplicates. Therefore, the application can perform deduplication on files A and B.

[0316] Example 2

[0317] The present application also provides a file processing method in which a file has been mapped to memory and can also include the following two situations: the file has been mapped to memory, but the electronic device has not written to the file-mapped memory; and the file has been mapped to memory, and the electronic device has written to the file-mapped memory. In these two situations, the electronic device can use different methods to determine whether the file has been modified. The following examples illustrate this.

[0318] For example, as shown in Figure 16, after the initial screening of candidate duplicate files, at time t1, the application wants to modify the value of the U field of the file "English Grammar 2" to V1. The application can call the file system interface to send a request message to the file system. After determining that the file has been mmap (i.e., mapped to memory), but no content has been written to the memory mapped to the file, the file system determines that the conditions for modifying the U field of the file are met and can then modify the value of the U field of the file from the initial value V0 to V1. Afterwards, the application can perform a binary comparison of English Grammar 3 and other candidate duplicate files to determine the final duplicate file.

[0319] Later, at time t3, the electronic device writes to the memory mapped to the file for the first time. The electronic device calls the file system's function, allowing the file system to detect this write operation. As shown in Figure 16, after the file system detects the write operation, it can modify the value of the file's U field from V1 to V2.

[0320] Then, as shown in Figure 16 , after scanning for multiple duplicate files (e.g., after binary comparison), and before displaying the duplicate file scan results to the user, at time t5, the application queries the value of the U field (V2) of the file. Since the value of the U field obtained at time t5 is different from the value of the U field at time t1, the application can determine that the file was modified between t1 and t5. Conversely, as shown in Figure 17 , at time t5, the application queries the value of the U field (V1) of the file. Since the value of the U field obtained at time t5 is the same as the value of the U field at time t1, the application can determine that the file was not modified between t1 and t5. The mobile phone can display the duplicate files that were not modified between t1 and t5 to the user. For example, if English grammars 1, 3, and 4 in the duplicate file were not modified between t1 and t5, the mobile phone can display the information of English grammars 1, 3, and 4 in the interface shown in (c) of Figure 10A .

[0321] As another example, as shown in Figure 18, after the initial screening of duplicate files is complete, at time t1, the application wants to modify the value of the U field of the file "Computer Technology 1" to V1. The application can call the file system interface to send a request message to the file system. Upon determination, the file has been mmaped (i.e., mapped to memory) and content has been written to the memory mapped to the file. In this case, the file system determines that the conditions for modifying the U field of the file are not met. Therefore, the file system does not modify the value of the U field of the file, and the value of the U field of the file remains V0.

[0322] If the value of a file's U field is not successfully set to V1 at time t1, it means that the file may have been modified (no longer a duplicate file) between time t1 and the display of the reconstructed file scan results, but the file system may not be able to detect the modification. In this case, the application will treat the file as modified and no longer a duplicate file. Furthermore, the application will not perform deduplication on the file to avoid mistakenly deduplicating files that are actually non-duplicate files.

[0323] In some embodiments, optionally, after the user clicks the compression button 907 as shown in (c) of Figure 10A, before the mobile phone performs deduplication, the mobile phone manager application sends a deduplication request to the file system, and the file system can check the value of the U field of each duplicate file again to further determine whether each duplicate file has been modified since the first moment. Exemplarily, as shown in Figure 19, after the user clicks the "Compress" button, before the mobile phone performs deduplication, at time t9, the file system again queries the value of the U field of each duplicate file (English Grammar 1, 3, 4, Computer Technology 1, 2). After judgment, the value of the U field of English Grammar 3 was successfully set to V1 at time t1, but the value of the U field at time t9 was V0, then the mobile phone can determine that English Grammar 3 was modified during the period from time t1 to time t9. Similarly, the mobile phone determines whether other duplicate files have been modified between times t1 and t9.

[0324] As shown in Figure 19, since English grammar 3 was modified between t1 and t9, it no longer constitutes a duplicate file with English grammars 1 and 4. Therefore, the Mobile Manager app does not perform deduplication on English grammar 3. Conversely, if English grammars 1 and 4 were not modified between t1 and t9, they are still duplicate files. The Mobile Manager app can perform deduplication on English grammars 1 and 4 at t10.

[0325] Optionally, after the user clicks the compression button 907, the file system checks the value of the U field of the file to ensure the atomicity of the U field value check and the deduplication operation, that is, the U field value is checked to determine whether the deduplication conditions are met. During the process of executing deduplication, the file will not be modified.

[0326] According to the technical solution of the embodiment of the present application, the application does not need to be resident running. In this way, the system overhead can be reduced while ensuring accurate judgment of the modification status of the file. Taking the above-mentioned deduplication scenario as an example, when it is necessary to clean up the duplicate files in the mobile phone, the user opens the mobile phone manager application and clicks the "clean up and speed up" button to trigger the mobile phone to execute the duplicate file scanning process. Afterwards, the user can close the mobile phone manager application. Subsequently, when the remaining storage space of the mobile phone is insufficient and there are phenomena such as freezing, the user can open the mobile phone manager application again and click the "clean up and speed up" button. The mobile phone can re-determine the duplicate files in the mobile phone based on the historical duplicate file scanning results and the modification status of some duplicate files to reduce the resource consumption caused by rescanning duplicate files.

[0327] For example, as shown in Figure 10A (c), after the user opens the mobile phone manager app, the mobile phone manager app scans and finds that English Grammar 1-4 is a duplicate file, and Computer Technology 1 and Computer Technology 2 are a duplicate file. The mobile phone can store the file identifiers of the duplicate files of English Grammar 2-4 and the duplicate files of Computer Technology 1 and Computer Technology 2 in the duplicate file information library shown in Figure 11.

[0328] Subsequently, when the storage space of the mobile phone is insufficient, the user opens the mobile phone manager application again and clicks the "Clean and Speed ​​Up" button 902. The mobile phone manager application can query the duplicate file information library shown in Figure 11 to obtain the historical duplicate files of the group of English Grammar 1-4 and the group of historical duplicate files of the group of Computer Technology 2-4, and query the U field values ​​of the duplicate files of English Grammar 1-4 and Computer Technology 2-4, so as to determine whether each duplicate file has been modified within a period of time based on the U field value of each duplicate file.

[0329] Assuming that English Grammar 1 and 2 have been modified, Computer 4 has been modified, and English Grammar 3, English Grammar 4, Computer Technology 3, and Computer Technology 2 have not been modified, the mobile manager application can determine that English Grammar 3 and English Grammar 4 still constitute duplicate files, and Computer Technology 3 and Computer Technology 2 still constitute duplicate files. As shown in Figure 14, at time t6, the mobile manager application can display these groups of duplicate files in interface 906.

[0330] It can be seen that when the mobile phone manager application is opened again to determine the duplicate files in the mobile phone, the mobile phone can reduce the scanning of some files (for example, there is no need to read the contents of historical duplicate files from the corresponding memory), which greatly reduces the operating consumption of the mobile phone.

[0331] In some embodiments, after the mobile phone manager application re-determines the duplicate files in the mobile phone, it can update the duplicate file information library such as that shown in FIG11 .

[0332] The above-mentioned first condition is only an example. It should be understood that any condition that can ensure that the write operation at time t1-t5 is perceived by the file system can be used as the first condition. On the contrary, as long as it cannot be guaranteed that the subsequent write is perceived by the file system, the first condition is not met. Exemplarily, as another feasible embodiment, it can be determined whether the file was mmap before the first moment and whether mmap has write permission. If the file was mmap before the first moment, but mmap does not have write permission, it is determined that the first condition is met. If the file was mmap before the first moment, but mmap has write permission, it is determined that the first condition is not met.

[0333] The above description mainly uses the deduplication scenario as an example. It should be understood that the technical solution of the embodiment of the present application can also be applied to other scenarios.

[0334] The above description uses the example of a mobile phone scanning for duplicate files after the user clicks the "Clean Up" button. In other embodiments, the mobile phone can also perform a pre-scan process to scan for duplicate files during idle time and store the scan results. In other words, the duplicate file scanning process in the above embodiment can also be performed when the mobile phone is idle (such as at night). For example, the initial screening and binary comparison process shown in Figure 12 can be pre-performed at night.

[0335] Exemplarily, the mobile phone can perform a scan for duplicate files at night. Assume that the scan results in English grammars 1-4 as a group of duplicate files, and during the scanning process, at time t1, an attempt can be made to modify the value of the U field of English grammars 1-4 to V1. Afterwards, as shown in (a) of Figure 10A, the user clicks the "Clean Up Speed" button 902 during the day, and the mobile phone can query the value of the U field of English grammars 1-4. Assuming that the values ​​of the U fields of English grammars 1-4 are all successfully set to V1 at time t1, and the values ​​of the U fields of English grammars 1, 3, and 4 are still V1, the mobile phone determines that English grammars 1, 3, and 4 have not been modified since time t1, and these three files still constitute duplicate files. The mobile phone can display the information of these three duplicate files in an interface such as that shown in (c) of Figure 10A.

[0336] By performing a pre-scan when the phone is idle, the time required for subsequent file deduplication can be saved, the efficiency of file deduplication can be improved, and the efficiency of human-computer interaction between users and electronic devices can be improved.

[0337] The embodiments of the present application do not limit the timing of the electronic device performing the duplicate file pre-scan. The electronic device can perform the duplicate file pre-scan process in appropriate scenarios. For example, at night, when the lock screen duration exceeds a threshold, a pre-scan is performed.

[0338] Alternatively, in some embodiments, the electronic device may also provide a settings entry, allowing the user to set the timing for performing a pre-scan. For example, as shown in FIG20 , a switch 201 is displayed in the settings interface 20 of the mobile phone. When switch 201 is turned on, the mobile phone may perform a pre-scan when idle. In other embodiments, the mobile phone may also provide a settings entry, allowing the user to set the timing for performing a pre-scan. For example, the user may set a pre-scan to be performed at night or when the lock screen exceeds a certain threshold.

[0339] The above one or more interfaces are exemplary, and there may be other interface design methods. This application does not limit the specific design method of the interface.

[0340] It should be noted that the above-mentioned multiple embodiments can be combined and the combined scheme can be implemented. Optionally, some operations in the process of each method embodiment are optionally combined, and / or the order of some operations is optionally changed. In addition, the execution order between the steps of each process is only exemplary and does not constitute a limitation on the execution order between the steps. There can also be other execution orders between the steps. It is not intended to indicate that the execution order is the only order in which these operations can be performed. Ordinary technicians in this field will think of many ways to reorder the operations described herein. In addition, it should be pointed out that the process details involved in a certain embodiment of this article are also applicable to other embodiments in a similar manner, or different embodiments can be used in combination.

[0341] Furthermore, some steps in the method embodiments may be equivalently replaced with other possible steps. Alternatively, some steps in the method embodiments may be optional and may be deleted in certain usage scenarios. Alternatively, other possible steps may be added to the method embodiments.

[0342] Furthermore, the above method embodiments may be implemented separately or in combination.

[0343] Optionally, the electronic device may also determine whether V1 is successfully set in other occasions or scenarios. For example, before querying the field value of a file each time, it may determine whether V1 is successfully set.

[0344] Some other embodiments of the present application provide a device, which may be the above-mentioned electronic device (such as a mobile phone, etc.) or a server. The device may include: a display screen, a memory, and one or more processors. The display screen, the memory, and the processor are coupled. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the device can perform the various functions or steps performed by the mobile phone in the above-mentioned method embodiment. The structure of the device can refer to the electronic device (such as a terminal) shown in Figure 6.

[0345] The core structure of the device can be represented as the structure shown in FIG. 21 , and the device includes: a processing module 1301 , an input module 1302 , a storage module 1303 and a display module 1304 .

[0346] The processing module 1301 may include at least one of a central processing unit (CPU), an application processor (AP), or a communication processor (CP). The processing module 1301 may perform operations or data processing related to the control and / or communication of at least one of the other components of the user electronic device. Specifically, the processing module 1301 may be used to control the content displayed on the main screen based on certain trigger conditions. The processing module 1301 is also used to process input instructions or data and determine a display style based on the processed data.

[0347] Optionally, the processing module 1301 may be implemented as a processor 201 such as shown in FIG6 .

[0348] The input module 1302 is used to obtain user input instructions or data and transmit the obtained instructions or data to other modules of the electronic device. Specifically, the input method of the input module 1302 may include touch, gestures, proximity to the screen, etc., or voice input. For example, the input module can be the screen of the electronic device, obtain the user's input operation and generate an input signal based on the obtained input operation, and transmit the input signal to the processing module 1301.

[0349] The storage module 1303 may include a volatile memory and / or a non-volatile memory. The storage module is used to store at least one related instruction or data of other modules of the user terminal device.

[0350] Optionally, the storage module 1303 may be implemented as the memory 202 shown in FIG. 6 .

[0351] The display module 1304 may include, for example, a liquid crystal display (LCD), a light emitting diode (LED) display, an organic light emitting diode (OLED) display, a microelectromechanical system (MEMS) display, or an electronic paper display, and is used to display user-viewable content (e.g., text, images, videos, icons, symbols, etc.).

[0352] Optionally, a communication module 1305 is also included to support the personal terminal communicating with other personal terminals (via a communication network). For example, the communication module can be connected to a network via wireless communication or wired communication to communicate with other personal terminals or a network server. Wireless communication can adopt at least one of cellular communication protocols, such as Long Term Evolution (LTE), Advanced Long Term Evolution (LTE-A), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Universal Mobile Telecommunications System (UMTS), Wireless Broadband (WiBro), or Global System for Mobile Communications (GSM). Wireless communication may include, for example, short-range communication. Short-range communication may include at least one of Wireless Fidelity (Wi-Fi), Bluetooth, Near Field Communication (NFC), Magnetic Stripe Transmission (MST), or GNSS.

[0353] Optionally, the communication module 1305 may be implemented as a transceiver 203 such as shown in FIG6 .

[0354] It should be noted that each functional module of the device can execute one or more steps in the above method embodiment.

[0355] An embodiment of the present application also provides a chip system, as shown in Figure 22, which includes at least one processor 1401 and at least one interface circuit 1402. The processor 1401 and the interface circuit 1402 can be interconnected via lines. For example, the interface circuit 1402 can be used to receive signals from other devices (such as the memory of an electronic device). For another example, the interface circuit 1402 can be used to send signals to other devices (such as the processor 1401). Exemplarily, the interface circuit 1402 can read instructions stored in the memory and send the instructions to the processor 1401. When the instructions are executed by the processor 1401, the electronic device can perform the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, which is not specifically limited in the embodiment of the present application.

[0356] An embodiment of the present application further provides a computer storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes the various functions or steps executed by the mobile phone in the above-mentioned method embodiment.

[0357] The embodiment of the present application further provides a computer program product, which, when executed on a computer, enables the computer to execute the functions or steps executed by the mobile phone in the above method embodiment.

[0358] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0359] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0360] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0361] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0362] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0363] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A file processing method, characterized in that: The method is applied to an electronic device, wherein the electronic device stores an indication field of a first file, wherein an initial value of the indication field is a first value, and when the first file is modified, the indication field is modified by the electronic device to a second value; the method comprises: At a first moment, attempting to modify a value of an indication field of the first file to a third value; the third value is different from the first value; and the third value is different from the second value; If the value of the indication field of the first file is successfully modified to the third value, then at a second moment, obtaining the value of the indication field; According to the value of the indication field of the first file at the second moment, it is determined whether the first file is modified during a period from the first moment to the second moment.

2. The method according to claim 1, characterized in that The indication field is stored in a metadata area of ​​the electronic device.

3. The method according to claim 1 or 2, characterized in that The attempting to modify the value of the indication field of the first file to a third value includes: If the first condition is met, the value of the indication field is modified to the third value; under the first condition, the file system of the electronic device can detect the modification operation on the first file during the period from the first moment to the second moment.

4. The method according to any one of claims 1 to 3, characterized in that After the first moment, the method further includes: detecting that the first file is modified, and modifying the value of the indication field of the first file to the second value; Determining, according to a value of the indication field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes: If the value of the indication field of the first file at the second moment is the second value, it is determined that the first file is modified during the period from the first moment to the second moment; or, if the value of the indication field of the first file at the second moment is not the third value, it is determined that the first file is modified during the period from the first moment to the second moment.

5. The method according to any one of claims 1 to 3, characterized in that Determining, according to a value of the indication field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes: If the value of the indication field of the first file at the second moment is the third value, it is determined that the first file has not been modified during the period from the first moment to the second moment; or if the value of the indication field of the first file at the second moment is not the second value, it is determined that the first file has not been modified during the period from the first moment to the second moment.

6. The method according to claim 1 or 2, characterized in that The attempting to modify the value of the indication field of the first file to a third value includes: if the first condition is not satisfied, not modifying the indication field to the third value; The method further includes: when the value of the indication field of the first file cannot be successfully modified to the third value, determining that the first file is modified within a period from the first moment to the second moment.

7. The method according to claim 3 or 6, characterized in that The first condition includes one or more of the following conditions: before the first moment, the first file is not mapped to the memory; before the first moment, the first file is mapped to the memory, but the electronic device has not performed a write operation on the memory.

8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: Scanning to obtain duplicate files in the electronic device, the duplicate files including the first file and the second file; the first file is stored in a first storage space, and the second file is stored in a second storage space; Determining that the first file and the second file have not been modified during a period from the first moment to the second moment; A first interface is displayed; the first interface includes information about the first file and information about the second file.

9. The method according to claim 8, characterized in that Detecting a first operation input by a user in the first interface; The first file and the second file are compressed into the same storage space.

10. The method according to claim 8 or 9, characterized in that After scanning the electronic device for duplicate files, the method further includes: The identifier of the first file and the identifier of the second file are stored.

11. The method according to claim 10, characterized in that The identifier of the first file includes a first index node number of the first file; the identifier of the second file includes a second index node number of the second file.

12. The method according to claim 11, characterized in that Determining, according to a value of the indication field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes: If the value of the indicator field of the first file at the second moment is the third value, and the index node number of the first file is number is the first index node number, it is determined that the first file has not been modified during the period from the first moment to the second moment.

13. A file processing method, characterized in that: Applied to electronic equipment, the method includes: Displaying a second interface, the second interface including a plurality of duplicate files scanned in the electronic device; the plurality of duplicate files are respectively stored in a plurality of storage spaces of the electronic device; In response to an operation input by a user on the second interface, at a third moment, obtaining an indication field of each duplicate file in the plurality of duplicate files, wherein a value of the indication field of the duplicate file is used to indicate whether the duplicate file has been modified; According to the values ​​of the indication fields of the multiple duplicate files at the third moment, some duplicate files among the multiple duplicate files are compressed into the same storage space.

14. The method according to claim 13, characterized in that Compressing some of the duplicate files into the same storage space according to the values ​​of the indication fields of the multiple duplicate files at the third moment includes: If the value of the indication field of the first file among the multiple duplicate files is a third value at the third moment, compressing the first file; Alternatively, if the value of the indication field of the first file among the multiple duplicate files is not the third value at the third moment, compression is not performed on the first file.

15. The method according to claim 13 or 14, characterized in that The initial value of the indication field of each duplicate file is the first value.

16. The method according to any one of claims 13 to 15, characterized in that Before displaying the second interface, the method further includes: Scanning to obtain multiple candidate duplicate files; the multiple candidate duplicate files include the multiple duplicate files; At a first moment, attempting to modify a value of an indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value; The multiple candidate duplicate files are compared to determine the multiple duplicate files from the multiple candidate duplicate files.

17. The method according to claim 16, characterized in that After determining the plurality of duplicate files, the method further includes: The information of the multiple duplicate files is stored in a database, where the information of the duplicate files includes any one or more of the following information: an index node number of the duplicate file, a path of the duplicate file, and a name of the duplicate file.

18. The method according to claim 16 or 17, characterized in that The multiple candidate duplicate files obtained by scanning include: Displaying a third interface, wherein the third interface includes a first control; A user operation on the first control is detected, and the plurality of candidate duplicate files are obtained by scanning.

19. The method according to claim 16 or 17, characterized in that The multiple candidate duplicate files obtained by scanning include: When the electronic device is idle, the plurality of candidate duplicate files are obtained by scanning.

20. The method according to any one of claims 16 to 19, characterized in that: Attempting to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value includes: If at least one candidate duplicate file among the multiple candidate duplicate files meets the first condition, the value of the indication field of the at least one candidate duplicate file is modified to the third value; under the first condition, the file system of the electronic device can detect the modification operation on the at least one candidate duplicate file within the time period from the first moment to the second moment.

21. The method according to claim 20, characterized in that At the second moment, obtaining a value of the indication field of the at least one duplicate file includes: at the second moment, obtaining a value of the indication field of the target duplicate file in the at least one duplicate file as a third value; The method further includes: determining, when the value of the indication field of the target duplicate file at the second moment is a third value, that the target duplicate file is not modified during a period from the first moment to the second moment.

22. The method according to claim 20, characterized in that The plurality of candidate duplicate files include a third file; After the first moment, the method further includes: detecting that the third file is modified, and modifying the value of the indication field of the third file to a second value; At the second moment, the value of the indication field of the third file obtained is not the third value; It is determined that the third file is modified during a period from the first time to the second time.

23. The method according to any one of claims 16 to 19, characterized in that: The plurality of candidate duplicate files include a fourth file; Attempting to modify the value of the indicator field of each candidate duplicate file in the plurality of candidate duplicate files to a third value at the first moment includes: if the fourth file does not meet the first condition, not modifying the indicator field of the fourth file to the third value; The method further includes: when the value of the indication field of the fourth file cannot be successfully modified to the third value, determining that the fourth file is modified within a period from the first moment to the second moment.

24. The method according to any one of claims 20 to 23, characterized in that The first condition includes one or more of the following conditions: before the first moment, the duplicate file is not mapped to the memory; before the first moment, the duplicate file is mapped to the memory, but the electronic device has not performed a write operation on the memory.

25. The method according to any one of claims 16 to 24, characterized in that: After the first moment, the method further includes: At a second moment, obtaining a value of the indication field of the at least one duplicate file and an inode number of the at least one duplicate file; When a third condition is met, the second interface is displayed; the third condition includes: the value of the indication field of the at least one duplicate file at the second moment is a third value, and the index node number of the at least one duplicate file is consistent with the index node number stored in the database.

26. The method according to any one of claims 13 to 25, characterized in that The indication field is stored in a metadata area of ​​the electronic device.

27. An electronic device, characterized in that: include: processor and memory; The memory is used to store computer-executable instructions, and the processor is coupled to the memory. When the electronic device is running, the processor executes the computer-executable instructions stored in the memory to enable the electronic device to execute the method as described in any one of claims 1-12, or execute the method as described in any one of claims 13-26.

28. A computer-readable storage medium having instructions stored therein, characterized in that: When the instruction is executed on an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 12, or execute the method according to any one of claims 13 to 26.