A method for making data non-deletable, a mobile terminal and a storage medium
By obtaining and judging the file location information in the storage device, and disconnecting the storage device from the terminal, the risk of files being modified or deleted after the storage device is connected to the terminal is solved, and data security and integrity are achieved.
Patent Information
- Application Number
- CN202011293647.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-18
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-11-18
AI Technical Summary
It is difficult with existing technology to ensure the security of files and prevent them from being modified or deleted after the storage device is connected to the terminal. Especially when the software or APP is cracked, there is a risk that the files will be modified or deleted.
By obtaining the file location information in the storage device, the command input by the user is received and its type is determined. If it is a command to modify or delete the file location information, the connection between the storage device and the terminal is disconnected to prevent any modification or deletion operations. Specific steps include reading sector data, parsing file system type and allocation table information, and judging the command type to determine whether to disconnect.
It effectively guarantees the integrity and security of data in the storage device, reduces the risk of files being modified or deleted when the software or APP is cracked, and ensures the undeletion of data.
Smart Images

Figure CN112446061B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data storage, and in particular to a method for making data indelible, a mobile terminal, and a storage medium. Background Art
[0002] Usually, files stored in storage devices can be modified and deleted. If you want to ensure that files are not deleted, you need to run software on the host or an app on the mobile device, and let the software and app control the modification and deletion permissions. In addition, once the software or app is cracked, there is also a risk that the files will be modified or deleted.
[0003] Therefore, how to ensure the security of files in the storage device and keep the original data from being modified and deleted after the storage device is connected to the terminal is an urgent problem to be solved. Summary of the invention
[0004] The purpose of this application is to ensure the data security of the storage device and to ensure that the original data is not deleted or modified after the storage device is connected to the terminal.
[0005] The above technical objectives of the present application are achieved through the following technical solutions: a method for making data non-deletable, which includes the steps of:
[0006] Obtain location information of files in a storage device;
[0007] Receive user input commands;
[0008] Determine the type of command entered by the user;
[0009] When the command input by the user is a normal command, it is processed according to the normal command processing flow;
[0010] When the command input by the user is a command to modify or delete the file location information, the connection between the storage device and the terminal is disconnected.
[0011] The above scheme of the present application discloses a method for making data non-deletable, which determines whether the command type input by the user is a command to modify or delete the file location information. If so, it indicates that the purpose of the command is to modify or delete the information in the file. Therefore, the connection between the storage device and the terminal is disconnected. Since the data is stored in the storage device, modification and deletion operations cannot be performed after the storage device is disconnected from the terminal, thereby ensuring the data integrity in the storage device.
[0012] Furthermore, in the method for making data non-deletable, the step of obtaining the location information of the file in the storage device includes:
[0013] Read sector data in storage devices and parse file system types;
[0014] Parse the address information of the file allocation table and store the last valid cluster number;
[0015] Retrieve the data table to store the location of the last valid directory entry.
[0016] The above scheme of the present application reads the sector data of the storage device to parse the type of the file system. Different file system types have the same general direction, but there are differences in specific parameters. Then the address information of the file allocation table in the storage device is parsed to store the last valid cluster number. The cluster number is the smallest unit. The file allocation table area stores two identical file allocation tables because the storage space (cluster chain) and free space management occupied by the file are all implemented through FAT. FAT is so important that two are saved so that when the first one is damaged, the second one is available. The file system divides and manages the storage space of the data area by clusters. The cluster is the basic unit of space allocation and recycling, that is, a file always occupies several whole clusters, and the remaining space of the last cluster used by the file is no longer used, but wasted. Therefore, storing the last valid cluster number facilitates knowing the last file location, and retrieving the data table is to store the location of the last valid directory entry.
[0017] Furthermore, in the method for making data non-deletable, the step of determining the type of command input by the user comprises:
[0018] Determine whether the command input by the user is a write command;
[0019] When the input command is not a write command, the input command is marked as a normal command.
[0020] The above scheme of the present application judges the command type for the command input by the user, and first judges whether it is a write command, because generally a read command does not involve data modification and deletion. Therefore, when the command input by the user is not a write command, the input command is marked as a normal command and processed according to the normal process.
[0021] Furthermore, in the method for making data non-deletable, the step of determining whether the command input by the user is a write command further comprises:
[0022] When the input command is a write command, determining the operation area of the write command;
[0023] Determine whether the write command is for operating the data area;
[0024] When the write command is to operate the data area, the write command is marked as a normal command.
[0025] The above-mentioned scheme of the present application mentions that when the command input by the user is not a write command, it is processed according to the normal process, and when the command input by the user is a write command, it is necessary to judge the operation area of the write command. Different operation areas have different permissions. For example, operating the data area and writing to the data area means adding file data and does not involve modification because the file directory has not changed. Therefore, it is carried out according to the normal command operation process.
[0026] Furthermore, in the method for making data non-deletable, the step of determining whether the write command is for operating the data area further comprises:
[0027] When the write command is not for operating a data area, determining whether the write command is for operating a directory entry;
[0028] When the write command is to operate a directory entry, determining whether the write command is a newly added directory entry;
[0029] When the write command is a newly added directory entry, marking the write command as a normal command;
[0030] The above-mentioned scheme of the present application mentions that when the command input by the user is to operate the data area, it is processed according to the normal process. When the command input by the user is not to operate the data area, it is necessary to determine whether the write command operates the directory item, and further, whether there is any new addition to the directory of the file. Among them, the newly added directory is a normal command and does not modify the original data. Therefore, it is a normal command and is processed according to the normal command process.
[0031] Furthermore, in the method for making data non-deletable, when the write command is to operate a directory entry, the step of determining whether the write command is a newly added directory entry further comprises:
[0032] When the write command is not a newly added directory entry, determining whether the write command has a deletion mark;
[0033] When the write command includes a delete mark, the write command is marked as a command to modify or delete file location information.
[0034] The above-mentioned scheme of the present application mentions that when the write command is to add a new directory entry, it is processed normally. When the write command is not to add a new directory entry, it is necessary to determine whether the write command has a deletion mark. If it has a deletion mark, mark the write command as a command to modify or delete the file location information, disconnect the device, and ensure data security.
[0035] Furthermore, in the method for making data non-deletable, when the write command is not a newly added directory entry, the step of determining whether the write command has a deletion mark further includes:
[0036] When the write command does not include a delete mark, determining whether the write command only modifies the access time;
[0037] If yes, the write command is marked as a normal command; if no, the write command is marked as a command to modify or delete file location information.
[0038] The above-mentioned scheme of the present application mentions that when the write command includes a deletion mark, the connection is disconnected, and when the write command does not include a deletion mark, it is necessary to judge the write command again to determine whether the write command only modifies the access time. Because the write command does not have a deletion mark, it indicates that the write command is a modification command. Therefore, it is necessary to determine whether the modification command modifies the file location information. When the access time is modified, the file information is not modified. Therefore, it is a normal command. When the write command does not modify the access time, it indicates that the write command is trying to modify the file data. Therefore, the connection between the device and the terminal is disconnected.
[0039] Furthermore, in the method for making data non-deletable, when the write command is not for operating a data area, the step of determining whether the write command is for operating a directory entry further comprises:
[0040] When the write command is not an operation directory entry, determining whether the write command modifies an old entry in the file table;
[0041] When the write command is to modify an old entry in the file table, marking the write command as a command to modify or delete file location information;
[0042] When the write command is not to modify an old entry in the file table, but to add new data, the write command is marked as a normal command.
[0043] The above scheme of the present application mentions how to judge whether the write command is an operation directory item. When the write command is neither an operation data area nor an operation directory item, it is necessary to judge whether the write command modifies the old table item of the file table, that is, to modify the data in the original table. If so, disconnect the device connection. If it is not to modify the old table item of the file table, it indicates that the user is adding new data, and mark the write command as a normal command.
[0044] Furthermore, the present application also discloses a mobile terminal, which includes a processor and a memory connected to the processor, wherein the memory stores a data non-erasable program, and when the data non-erasable program is executed by the processor, the steps of the data non-erasable method described above are implemented.
[0045] Furthermore, the present application also discloses a storage medium, wherein the storage medium stores a program for implementing data non-erasability, and when the storage medium is executed by a processor, the steps of the above-mentioned method for implementing data non-erasability are implemented.
[0046] In summary, the present application discloses a method for making data non-deletable, a mobile terminal and a storage medium, and relates to the field of data storage, wherein the method comprises the steps of: obtaining location information of a file in a storage device; receiving a command input by a user; judging the type of command input by the user; when the command input by the user is a normal command, processing it according to the normal command processing flow; when the command input by the user is a command to modify or delete the file location information, disconnecting the storage device from the terminal. The scheme described in the present application can judge the command input by the user, and when the command input by the user is to modify or delete the file information in the storage device, disconnecting the storage device from the terminal, thereby ensuring the security of the information in the storage device. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 It is a flowchart of the steps of the data non-deletable method described in this application.
[0048] Figure 2 It is a flowchart of step S1 of the data non-deletable method described in this application.
[0049] Figure 3 This is a flowchart of step S3 of the data non-deletable method described in this application.
[0050] Figure 4 It is a flowchart of step S31 of the data non-erasable method described in this application.
[0051] Figure 5 It is a flowchart of step S311 of the data non-deletable method described in this application.
[0052] Figure 6 It is a flowchart of step S3111 of the data non-erasable method described in this application.
[0053] Figure 7 It is a flowchart of step S31111 of the data non-erasable method described in this application.
[0054] Figure 8 It is a flowchart of step S311111 of the data non-erasable method described in this application.
[0055] Figure numerals. DETAILED DESCRIPTION
[0056] The present application is further described in detail below in conjunction with the accompanying drawings.
[0057] Usually, files stored in storage devices can be modified and deleted. If you want to ensure that files are not deleted, you need to run software on the host or an app on the mobile device, and let the software and app control the modification and deletion permissions. In addition, once the software or app is cracked, there is also a risk that the files will be modified or deleted.
[0058] Therefore, in response to the above problems, this application discloses a data non-deletable method, which can protect the file information in the storage device from being modified or deleted, and move the anti-modification operation from the previous software or APP implementation (upper layer implementation) to the storage device management algorithm implementation (lower layer implementation), which greatly reduces the risk of the solution being cracked.
[0059] The overall steps are as follows Figure 1 The figure is a flowchart of the steps of the data non-deletable method, which includes:
[0060] S1. Obtain the location information of the file in the storage device;
[0061] S2. Receive user input command;
[0062] S3. Determine the type of command input by the user;
[0063] S4. When the user inputs a normal command, it is processed according to the normal command processing flow;
[0064] S5. When the command input by the user is a command to modify or delete the file location information, disconnect the storage device from the terminal.
[0065] In order to implement the above steps, the file location information must first be determined. If the original data location information of the file changes, it indicates that the file data has been modified or deleted. This application makes a judgment based on the change of this parameter. Therefore, refer to Figure 2 , the step S1 comprises:
[0066] S11. Read the sector data in the storage device and parse the file system type;
[0067] S12. Parse the address information of the file allocation table and store the last valid cluster number;
[0068] S13. Search the data table to store the location of the last valid directory entry, which corresponds to the last data of the file and the last directory.
[0069] In a preferred embodiment of the present application, taking FAT as an example, when the storage device is powered on, the boot loader module will load a pre-burned management algorithm FTL from the storage chip, and the FTL (Flash Translation Layer) will manage the host's operations (reading and writing) on the storage device.
[0070] In this application, two new management modules are added to FTL: file system parsing module and write command preprocessing module. Their functions are as follows:
[0071] File system parsing module: After the device is powered on and the boot loader is executed, the management algorithm FTL is loaded into RAM (random access memory) and the initialization of FTL related tables and parameters is completed, FTL will first call the file system parsing module, pre-read the content of the file system and parse the key information (FAT table (file allocation table) and FDT (Function Data Table) related information, etc.), and save the parsed parameters in RAM.
[0072] Write command preprocessing module: When the host sends a write command, the FTL first calls the write command preprocessing module and passes the write command parameters sent by the host to the write command preprocessing module. The preprocessing module decides whether to write the data to the storage device.
[0073] Since the read command does not involve any modification to the data, no special processing is required for the read command.
[0074] Therefore, see Figure 3 After obtaining the command input by the user, step S3 specifically includes:
[0075] S31. Determine whether the input command is a write command;
[0076] S32. When the command input by the user is not a write command, mark the input command as a normal command, such as a read command or a search command, which does not involve changes to the data, and therefore is processed according to the normal processing flow;
[0077] When the input command is a write command, there are also many situations for write commands. Different write commands may modify file data or may not modify or delete data. Therefore, it is necessary to judge the command type again. Figure 4 , the step S31 further comprises:
[0078] S311. When the input command is a write command, the operation area of the write command is determined;
[0079] S312. When the write command is to operate the data area, mark the write command as a normal command.
[0080] The operation area is divided into data area and others, where the operation in the data area is a normal command, which means that the user inputs data, that is, adds data after the last cluster number mentioned above. For the addition operation, the original data is not modified or deleted, so it is processed according to the normal process.
[0081] When the written command is not for the operation data area, it is necessary to judge again, see Figure 5 , the step S311 comprises:
[0082] S3111. When the write command is not an operation data area, determining whether the write command operates a directory entry;
[0083] S3112. When the write command is to operate a directory entry, determine whether the write command is a newly added directory entry;
[0084] S3113. When the write command is a newly added directory entry, mark the write command as a normal command.
[0085] There are many situations in which the write command is not an operation directory item, among which adding a directory is a normal command. Therefore, it is necessary to determine whether the write command is a new directory item. If so, it is processed normally.
[0086] When the write command is not a new directory entry, it needs to be judged again, see Figure 6 , the step S3111 comprises:
[0087] S31111. When the write command is not a newly added directory entry, determine whether the write command has a deletion mark;
[0088] S31112. When the write command includes a delete mark, mark the write command as a command to modify or delete file location information.
[0089] When the write command has a delete mark, it indicates that the write instruction is a delete instruction, and therefore, the connection between the storage device and the terminal is disconnected.
[0090] When the write instruction does not have a delete mark, it indicates that the write instruction is a modification instruction. Figure 7 , the step S31111 also includes:
[0091] S311111. When the write command does not include a delete mark, determine whether the write command only modifies the access time;
[0092] S311112. When yes, mark the write command as a normal command; when no, mark the write command as a command to modify or delete file location information.
[0093] The modification instruction does not involve data modification if the modified content is only the access time. Therefore, it is processed according to the normal processing flow. When the write command is not to modify the access time, it means that the content that needs to be modified by the write command is the data in the file. Therefore, the connection between the storage device and the terminal is disconnected.
[0094] As mentioned above, when the write instruction is not to operate the data area, it is determined whether the write command operates the directory entry. When the write command is not to operate the directory entry, it is necessary to determine whether the write command is to modify the old entry of the file table. Figure 8 , is a flowchart of step S311111, which specifically includes:
[0095] S3111111. When the write command is not an operation directory entry, determine whether the write command modifies the old entry of the file table;
[0096] S3111112. When the write command is to modify an old entry in the file table, mark the write command as a command to modify or delete file location information;
[0097] S3111113. When the write command is not to modify the old table entry of the file table, it is to add new data, mark the write command as a normal command, that is, to modify the data in the old table. When it is to modify the old table entry data, disconnect the storage device from the terminal.
[0098] In summary, the present application discloses a method starting from obtaining the command input by the user, and then going through layers of judgment to ensure the accurate determination of the command type. When the write command is a normal command, it is processed according to the normal command processing flow. When the write command is a modification or deletion command, the connection between the storage device and the terminal is disconnected in time to ensure the security of the data in the file.
[0099] In the above statement of this application, FTL (Flash Translation Layer) is translated as Flash Translation Layer, which is the connection relationship between FlashMemory (storage medium) and Device Controller (device controller). In the entire storage system, FTL plays the role of a translator. It converts the logical address sent by Host (computer, mobile phone, etc.) to Device (eMMC, SSD) into the physical address written to Flash (address mapping management). While performing address conversion, FTL also takes into account the management of Flash. It not only needs to control the number of erase and write times of each Block on Flash (wear leveling), but also needs to manage useless data on Flash (garbage collection).
[0100] Let me briefly introduce these three points.
[0101] 1. Address mapping management concepts
[0102] Unlike mechanical hard disks, which read and write data directly with magnetic heads, SSDs or other hard disks that use Flash as storage media cannot directly read and write data. The solution to this problem is for the FTL layer to manage several logical mapping tables to do an intermediate conversion. The Host gives a logical address, and the FTL establishes a mapping relationship on the logical mapping table based on this logical address and connects it to the physical address on the Flash. Generally speaking, after the FTL processes the logical address, the established mapping relationship includes the Flash's Block number, Page number, etc. When reading data, it finds the data at the corresponding location in the Flash based on this information and transmits it to the Host.
[0103] 2. Wear leveling concept
[0104] When Flash is used as the storage medium, its programming times are the key point that must be considered. For example, the current solid state drives mostly use TLC Flash as the storage medium, and its programming times are between 1000-1500 times. If the number of erasures of some blocks on the TLC Flash exceeds the limit, bad blocks will be generated. Therefore, the FTL must implement wear leveling, coordinate the blocks on the entire Flash, and use the blocks with fewer uses to share the pressure of the blocks with more uses. In layman's terms, wear leveling is to make the erase times of each block on the Flash as similar as possible with the relatively optimal choice, so as to avoid the problem that some blocks are erased too many times and become bad blocks, resulting in a reduction in user available capacity.
[0105] 3. Garbage Collection Concept
[0106] Because of the different storage principles, when deleting data on a hard disk such as SSD that uses Flash as storage medium, only the logical address of the host is deleted, while the actual data exists on the physical address of the Flash and still occupies space (so don't think that your data is safe after being deleted, they can still be retrieved when garbage collection is not performed). Subsequent data can only be written to other Blocks (Pages), which may cause only 2M of the 8M data on a Block to be valid data, and the rest are "false data" whose logical addresses have been deleted. Over time, it will lead to insufficient empty blocks. To solve this problem, it depends on garbage collection (GC). Its function is to find an empty Block (destination Block), and then move the valid data on the Blocks (source Blocks) with more "false data" to it, and then release and erase the source Block. In this way, a destination Block can accommodate data from multiple source Blocks, achieving the purpose of forced one-for-many replacement, freeing up more space for users.
[0107] In another embodiment of the present application, a mobile terminal is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the memory stores data information and images of the logic control. The processor is used to provide computing and control capabilities, and when the processor executes the computer program, all steps in the aforementioned solution are implemented, so they are not described here in detail.
[0108] In another embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program that can be loaded by a processor and execute the above-mentioned logical control drag display method. When the computer program is executed by the processor, all the steps of the aforementioned scheme are implemented, so they are not repeated here.
[0109] The present application discloses a method for making data non-deletable, a mobile terminal and a storage medium, and relates to the field of data storage, wherein the method comprises the steps of: obtaining location information of a file in a storage device; receiving a command input by a user; judging the type of the command input by the user; when the command input by the user is a normal command, processing it according to a normal command processing flow; when the command input by the user is a command to modify or delete the file location information, disconnecting the connection between the storage device and the terminal. The scheme described in the present application can judge the command input by the user, and when the command input by the user is a command to modify or delete the file information in the storage device, disconnecting the connection between the storage device and the terminal, thereby ensuring the security of the information in the storage device.
[0110] The embodiments of this specific implementation method are all preferred embodiments of the present application, and are not intended to limit the protection scope of the present application. Therefore, all equivalent changes made based on the structure, shape, and principle of the present application should be included in the protection scope of the present application.
Claims
1. A method for making data undeletable, characterized in that: Includes steps: Obtain location information of files in a storage device; Receive user input commands; Determine the type of command entered by the user; When the command input by the user is a normal command, it is processed according to the normal command processing flow; When the command input by the user is a command to modify or delete the file location information, disconnecting the storage device from the terminal; The steps of obtaining the location information of the file in the storage device include: Read sector data in storage devices and parse file system types; Parse the address information of the file allocation table and store the last valid cluster number; Retrieve the data table to store the location of the last valid directory entry; The operation area is divided into data area and others, where the operation in the data area is a normal command, which means that the user inputs data, that is, adds data after the last cluster number mentioned above. For the addition operation, the original data is not modified or deleted, so it is processed according to the normal process.
2. The method for making data undeletable according to claim 1, characterized in that: The steps of determining the type of command input by the user include: Determine whether the command input by the user is a write command; When the input command is not a write command, the input command is marked as a normal command.
3. The method for making data undeletable according to claim 2, characterized in that: The step of determining whether the command input by the user is a write command also includes: When the input command is a write command, determining the operation area of the write command; Determine whether the write command is for operating the data area; When the write command is to operate the data area, the write command is marked as a normal command.
4. The method for making data undeletable according to claim 3, characterized in that: The step of determining whether the write command is for operating the data area also includes: When the write command is not for operating a data area, determining whether the write command is for operating a directory entry; When the write command is to operate a directory entry, determining whether the write command is a newly added directory entry; When the write command is a newly added directory entry, the write command is marked as a normal command.
5. The method for making data undeletable according to claim 4, characterized in that: When the write command is to operate a directory entry, the step of determining whether the write command is a newly added directory entry further includes: When the write command is not a newly added directory entry, determining whether the write command has a deletion mark; When the write command includes a delete mark, the write command is marked as a command to modify or delete file location information.
6. The method for making data undeletable according to claim 5, characterized in that: When the write command is not a newly added directory entry, the step of determining whether the write command has a deletion mark further includes: When the write command does not include a delete mark, determining whether the write command only modifies the access time; If yes, the write command is marked as a normal command; if no, the write command is marked as a command to modify or delete file location information.
7. The method for making data undeletable according to claim 6, characterized in that: When the write command is not for operating a data area, the step of determining whether the write command is for operating a directory entry further comprises: When the write command is not an operation directory entry, determining whether the write command modifies an old entry in the file table; When the write command is to modify an old entry in the file table, marking the write command as a command to modify or delete file location information; When the write command is not to modify an old entry in the file table, but to add new data, the write command is marked as a normal command.
8. A mobile terminal, characterized in that: It comprises a processor and a memory connected to the processor, wherein the memory stores a data non-erasable program, and when the data non-erasable program is executed by the processor, the steps of the data non-erasable method as described in claims 1-7 are implemented.
9. A storage medium, characterized in that: The storage medium stores a program for implementing data indelibility, and when the storage medium is executed by a processor, the steps of the method for implementing data indelibility as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Data storage method and device
CN106024046A
Data operation method of storage equipment and storage equipment
CN110321740A
Storage system and data management method of the same
US20110191302A1
Storage system and data management method of the same
WO2010122606A1
