The present disclosure relates to data management, and particularly to a file storage device and a method for managing a file system thereof.
In a computing device, a file system is used to control how data is stored and includes a number of files and folders. Once a file or a folder has been changed in a file system, the file system needs to be traversed twice to find which file or folder has been changed.
Many aspects of the embodiments can be better understood with reference to the following drawings. The components in the drawings are not necessarily drawn to scale, the emphasis instead being placed upon clearly illustrating the principles of the present disclosure. Moreover, in the drawings, like reference numerals designate corresponding parts throughout the several views.
Before the detailed description of the present disclosure, there is a brief description of a storage mode of files or folders contained in a file system that is related to at least one embodiment of the present disclosure.
The storage unit 10 stores a file system, such as the file system 1 shown in
The processor 20 includes a traversal module 21, a monitoring module 22, a identification module 23, and a microprocessor 24.
The traversal module 21 traverses the file system in the storage unit 10 and creates a directory tree corresponding to the file system according to the traversal result. In at least one embodiment, the traversal module 21 traverses the file system in level-order. Each of the parent nodes of the directory tree corresponds to a folder of the file system, and each of the child nodes of the directory tree corresponds to a file of the file system. In one embodiment, the information of each of the nodes includes at least a node mark, an access path to the node, a node type, and node content. When the node is a parent node, the node content of the parent node includes information of all files and folders directly contained in the parent node. When the node is a child node, the content of the child node includes a file size, a file name, a file format, a creation time of the file, a modification time of the file, and data of the file.
In the embodiment, the node mark is a hashed value of the access path to the node and the node content. When the content of a file or the access path to the file is changed, all node marks in the parent nodes and child nodes associated with the file are changed accordingly.
In a first embodiment, the hashed value of a file is a message-digest (MD) algorithm value and is calculated by using a cryptographic hash function of MD based on the access path to the file and the content of the file. In a second embodiment, the hashed value of a file is a security hash algorithm (SHA) value and is calculated by using a cryptographic hash function of SHA based on the access path to the file and the content of the file.
The monitoring module 22 monitors all nodes of the directory tree to determine whether the directory tree changes. In the embodiment, the monitoring module 22 monitors nodes of the directory tree in post-order. The monitoring module 22 further determines which nodes of the directory have been changed.
The identification module 23 identifies the type of the changed node. When the changed node is a parent node, the traversal module 22 traverses the node mark of nodes contained in the changed node in post-order to find the files and/or folders whose content and/or access paths have been changed and contained in the changed parent node.
The microprocessor 24 extracts changed information of the file system. In a second embodiment, the microprocessor 24 creates relationships between the changed information and the changed node, and further updates the directory tree corresponding to the change information and the created relationships. For example, when a new file is added to the file system, the changed information of the file system includes the content of the added file and the access path to the added file. When a file or a folder is transferred from a first folder to a second folder, the changed information of the file system is a new access path to the transferred file.
The processor 20 further includes a display control module 25. The display control module 25 controls the display unit 40 to display the extracted changed information in response to a preview request signal of changed information generated by the input unit 30.
In block 401, the traversal module traverses the file system in the storage unit to create a directory tree corresponding to the file system. The parent node of the directory tree corresponds to a folder of the file system. The child node of the directory tree corresponds to a file of the file system.
In the embodiment, the traversal module traverses the file system in level-order.
In block 402, the monitoring module monitors all nodes of the directory tree to determine whether the directory tree changes. If the directory tree changes, the process goes to block 403. If the directory tree does not change, the process goes back to block 402.
In at least one embodiment, the monitoring module monitors the nodes of the directory tree in post-order. The monitoring module further determines which nodes of the directory tree have been changed.
In block 403, the identification module identifies the type of the changed node. If the changed node is a parent node, the process goes to block 404. If the changed node is a child node, the process goes to block 405.
In block 404, the traversal module traverses the files and/or folders contained in the changed node in post-order to find the changed files and/or folders whose content and/or access paths have been changed and contained in the changed parent node.
In block 405, the microprocessor extracts the changed information of the changed node. In an alternative embodiment, the microprocessor creates relationships between the changed information and the changed node, and further updates the directory tree according to the changed information and the created relationships.
In block 406, the display control module controls the display unit to display the extracted changed information in response to a preview request signal of changed information generated by the input unit.
Although the present disclosure has been described in considerable detail with reference to certain preferred embodiments thereof, the disclosure is not for limiting the scope of the disclosure. Persons having ordinary skill in the art may make various modifications and changes without departing from the scope and spirit of the disclosure. Therefore, the scope of the appended claims should not be limited to the description of the preferred embodiments described above.
Number | Date | Country | Kind |
---|---|---|---|
2013101326032 | Apr 2013 | CN | national |