A virtual file system and a virtual file system operation method
By designing a virtual file system in an embedded device, using dual-copy redundant storage and encryption technology, the data storage reliability and security of existing file systems in an embedded device are solved, and higher fault tolerance and data confidentiality are achieved.
Patent Information
- Application Number
- CN202411285019.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-09-13
AI Technical Summary
Existing file systems have reliability and security issues in embedded devices, especially in terms of high hardware failure rates and cross-platform compatibility, resource usage, security, and fault tolerance.
A virtual file system is proposed, by treating the unused space of the storage device or the fixed-size files on the existing file system as continuous virtual files, and adopting dual-copy redundant storage and encryption methods, combining the SM3 algorithm for data protection and management.
It significantly improves the reliability and security of data storage, provides higher fault tolerance and data confidentiality, and is suitable for embedded systems in harsh operating environments.
Smart Images

Figure CN119166606B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of computer data storage, and in particular to a virtual file system and a method for operating the virtual file system. Background Art
[0002] The statements in this section merely provide background information related to the present disclosure and do not necessarily constitute prior art.
[0003] The file system is a subsystem in the operating system that manages persistent data. It provides operations such as creating, reading, writing, and deleting files. As the scope of computer applications continues to expand, users' demand for file management is growing. The file system has become a bridge between data and applications and an important part of the operating system.
[0004] SM3 is a message digest algorithm, a high-strength cryptographic hash algorithm with high anti-collision capability and security. It is widely used in cryptographic applications such as digital signatures and cryptographic certificates, providing effective protection for data integrity and security.
[0005] Different operating systems have developed a variety of file systems for different application scenarios, such as NTFS (New Technology File System) file system, EXT (Extended File System) file system, FAT (File Allocation Table) file system, etc. These file systems are directly built on physical storage devices and work well in most scenarios. However, some special-purpose embedded devices have harsh working environments and high failure rates of storage devices such as hard disks, so certain redundancy technologies are needed to protect data and improve overall reliability. At the same time, existing file systems have certain limitations in cross-platform compatibility, resource usage, security, fault tolerance, etc., which are not conducive to the application of certain special scenarios. Summary of the invention
[0006] In order to solve the above problems, the present disclosure proposes a virtual file system and a virtual file system operation method, which regards all or part of the unused space of the entire storage device, or a fixed-size file on the existing file system as a huge continuous virtual file, saves two copies of the data in the virtual file, and encrypts the stored data at the same time. The virtual file data is organized and accessed in a manner similar to the path and offset of the traditional file system, and the reliability and security of data storage are significantly improved through storage abstraction and multiple protection mechanisms.
[0007] According to some embodiments, the present disclosure adopts the following technical solutions:
[0008] A virtual file system, characterized in that it includes a continuous virtual file, using all or part of the unused space of the entire storage device, or a fixed-size file on an existing file system as the continuous virtual file, and the continuous virtual file includes ten functional areas, namely, a basic information area A, an index node bitmap area A, a data block bitmap area A, an index node A area, a data area A, a basic information area B, an index node bitmap area B, a data block bitmap area B, an index node B area and a data area B;
[0009] The continuous virtual file has a fixed size, and the total file size remains unchanged during use. It is a single, continuous virtual file and needs to be initialized before the first use. Initialization will erase all data and reconfigure the virtual file system.
[0010] Furthermore, the continuous virtual file is opened, read, written, relocated and closed through the operating system library function. The continuous virtual file organizes and accesses virtual file data using the path and offset of the file system, and organizes and manages various types of virtual file data by dividing a large continuous virtual file into different functional areas.
[0011] Furthermore, the entire continuous virtual file is divided into a number of blocks as basic units of data storage. The block has a fixed size, and the size can be set during initialization and cannot be changed after the initialization is completed.
[0012] Furthermore, the basic information area B, index node bitmap area B, data block bitmap area B, index node B area and data area B are mirror data of the basic information area A, index node bitmap area A, data block bitmap area A, index node A area and data area A. When part of the data is tampered with or damaged, it can be self-repaired according to the mirror data.
[0013] Furthermore, the ten functional areas organize data in blocks. The space ratio of each area is specified during initialization. By default, the basic information area occupies one block of space, and the index node area and the data area take a set ratio. Since 1 byte can represent the use or unused status of 8 data blocks, the size of the index node bitmap area and the data block bitmap area is calculated based on the total space size.
[0014] Furthermore, the basic information area is used to store three types of data; the first type of data is to store statistical summary information of the virtual file system, including block size, number of blocks, number of used blocks and number of unused blocks; the second type of data is to store the root directory index address of the directory entry, which serves as the starting point for file system path query; the third type of data is to use the SM3 algorithm to calculate the hash value of all the first two types of data and store a 32-byte hash value.
[0015] Furthermore, the index node bitmap area uses a bitmap to manage the free space in the index node area, and the data block bitmap area uses a bitmap to manage the free space in the data area. The bitmap uses a binary bit to represent the usage of a disk block in the disk. When the value is 0, it indicates that the corresponding data block is free, and when the value is 1, it indicates that the corresponding data block has been allocated.
[0016] Furthermore, the index node area is used to record the metadata of the file. The directory is a special file, and the index node is the unique identifier of the virtual file. They correspond one-to-one and are used to store two types of data. The first type of data includes file type, file size, access rights, creation time, modification time, data block location index, and the hash value obtained by using the SM3 algorithm for the data in each data block. When the file is large, there will be multiple data block location indexes and multiple data block SM3 hash values. For large files that use primary index data blocks, secondary index data blocks, and tertiary index data blocks, the SM3 hash value must also be stored for each recorded data block to ensure that the data block location index and the data block SM3 hash value correspond one-to-one. The second type of data uses the SM3 algorithm to calculate the hash value of the first type of data and stores the hash value of 32 bytes of metadata.
[0017] Furthermore, the data area stores the original data of the file in units of data blocks. For files whose file type is a directory, the file list information under the directory is stored. The file list information includes the file name, the file name SM3 hash value, the file index node address, the file type and the corresponding file data SM3 hash value. The file name SM3 hash value improves the file name query speed, and the corresponding file data SM3 hash value improves the reliability of the file.
[0018] According to some embodiments, the present disclosure adopts the following technical solutions:
[0019] A method for operating a virtual file system includes reading files and saving files in the virtual file system, wherein the step of reading files in the virtual file system includes: selecting a file reading path, reading data in a basic information area A, and performing an SM3 hash value check on the data; if the check fails, attempting to restore data from a mirror data area B of the basic information area A; if the check passes, obtaining a root directory index node address; obtaining root directory index node data according to the root directory index node address, performing an SM3 check on the root directory index node data; obtaining a root directory data block using a data block direct index address or an indirect index address after the root directory index node check passes, and performing an SM3 check on the data block content; obtaining all directory item information under the root directory after the check passes, matching the index node address of the file to be read according to the file name or the file name hash value; obtaining the index node of the file to be read according to the index node address of the file to be read, thereby obtaining a data block index of the file to be read; performing an SM3 value check on each data block of the file to be read and the entire file; and completing the file reading after the check passes.
[0020] Compared with the prior art, the present invention has the following beneficial effects:
[0021] The present invention discloses a virtual file system, which treats all or part of the unused space of the entire storage device (such as a hard disk, SSD, etc.), or a fixed-size file on the existing file system as a huge continuous virtual file, organizes and accesses virtual file data in a manner similar to the path and offset of the traditional file system, and adopts a dual-copy redundant storage and encryption method to enhance the reliability of the data; two copies of the data in the virtual file are saved to improve the fault tolerance of the data, and the stored data is encrypted to protect the confidentiality of the data. This storage abstraction hides the complexity of the underlying storage device and provides a unified access interface for upper-level applications, so that upper-level applications can manage and access storage space in a simpler and safer way. The virtual file system can be widely used in scenarios with harsh operating environments such as embedded systems, providing reliable and secure storage solutions for various types of important data. The core of the present invention is to significantly improve the reliability and security of data storage through storage abstraction and multiple protection mechanisms. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings constituting a part of the present disclosure are used to provide a further understanding of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure.
[0023] Figure 1 A schematic diagram of the structure of a virtual file system according to an embodiment of the present disclosure;
[0024] Figure 2A schematic diagram of the structure of the basic information area of the virtual file system according to an embodiment of the present disclosure;
[0025] Figure 3 A schematic diagram of the structure of a virtual file system data block bitmap area according to an embodiment of the present disclosure;
[0026] Figure 4 A schematic diagram of the virtual file system index node structure according to an embodiment of the present disclosure;
[0027] Figure 5 A schematic diagram of the contents of a virtual file system directory file according to an embodiment of the present disclosure;
[0028] Figure 6 A flowchart of a virtual file system reading a file according to an embodiment of the present disclosure;
[0029] Figure 7 The flowchart of writing a file to the virtual file system of the embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0030] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.
[0031] It should be noted that the following detailed descriptions are all illustrative and are intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present disclosure belongs.
[0032] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0033] Example 1
[0034] In order to solve the existing deficiencies, especially the problem that storage devices of embedded systems are prone to failure and data loss, the present disclosure proposes a high-reliability virtual file system by combining the advantages of the SM3 encryption algorithm. The virtual file system regards all or part of the unused space of the entire storage device (such as a hard disk, SSD, etc.) or a fixed-size file on the existing file system as a huge continuous virtual file, and organizes and accesses the virtual file data in a way similar to the path and offset of the traditional file system.
[0035] In order to enhance the reliability of data, the present disclosure adopts dual-copy redundant storage and encryption. Dual-copy redundant storage is a data storage strategy in which data is copied and stored in two different locations to ensure data availability and consistency, which is reflected in the fact that area A and area B in the ten functional areas are mirrored data of each other. Specifically, two copies of the data in the virtual file are saved to improve the fault tolerance of the data. At the same time, the stored data is encrypted to protect the confidentiality of the data. This storage abstraction hides the complexity of the underlying storage device and provides a unified access interface for upper-level applications, allowing upper-level applications to manage and access storage space in a simpler and safer way. The virtual file system can be widely used in scenarios with harsh operating environments such as embedded systems to provide reliable and secure storage solutions for various types of important data. The core of the present disclosure is to significantly improve the reliability and security of data storage through storage abstraction and multiple protection mechanisms. The details are as follows:
[0036] like Figure 1 As shown, the entire continuous virtual file is divided into ten functional areas, namely, basic information area A, index node bitmap area A, data block bitmap area A, index node A, data area A, basic information area B, index node bitmap area B, data block bitmap area B, index node B, and data area B. The basic information area B, index node bitmap area B, data block bitmap area B, index node B, and data area B are mirror data of the basic information area A, index node bitmap area A, data block bitmap area A, index node A, and data A. When part of the data is tampered with or damaged, it can be self-repaired according to the mirror data.
[0037] The smallest unit of physical disk reading and writing is usually a 512-byte sector. In order to improve the reading and writing efficiency, the file system usually groups multiple sectors into a larger logical block as the smallest reading and writing unit. The present disclosure divides the entire virtual file into several blocks as the basic unit of data storage. The block has a fixed size and can be set to 1K, 2K or 4K during initialization. The size cannot be changed after the initialization is completed. Blocks of fixed size can perform storage allocation and recycling operations more simply and efficiently, reduce fragmentation problems, and users can choose data blocks of appropriate sizes according to actual application requirements to balance storage utilization and access efficiency. The ten functional areas organize data in blocks. The space ratio occupied by each area can be specified during initialization. The default basic information area occupies one block space, and the index node area and data area take a ratio of 1:10. Since 1 byte can represent the use or unused status of 8 data blocks, the appropriate index node bitmap area and data block bitmap area size are calculated according to the total space size.
[0038] Furthermore, if Figure 2As shown, the basic information area mainly stores three types of data. The first type of data is the statistical summary information of the virtual file system, such as block size, number of blocks, number of used blocks, number of unused blocks, index node size, starting address of each functional area and other information. This information describes the overall usage of the virtual file system; the second type of data is the root directory index address of the storage directory item, which is the starting point of the virtual file system path query. Through this index address, the location of the storage file and directory structure can be quickly located; the third type of data is the hash value calculation of all the first two types of data using the national secret SM3 algorithm, and the storage of 32-byte hash values. The hash value can be used as the integrity verification of the basic information area data to ensure that the stored data has not been tampered with or damaged.
[0039] The index node bitmap area and the data block bitmap area play an important role in the virtual file system. The index node bitmap area uses a bitmap to manage the free space in the index node area, while the data block bitmap area uses a bitmap to manage the free space in the data area; Figure 3 As shown, the data block bitmap uses a binary bit to indicate the usage of a block in the virtual file data area. When the value of the bit is 0, it indicates that the corresponding data block is free, and when the value of the bit is 1, it indicates that the corresponding data block has been allocated. Through the index node bitmap area and the data block bitmap area, the virtual file system can effectively manage the allocation and release of disk space. When a new file or directory needs to be created, a free index node can be found through the index node bitmap area to store the meta information of the file or directory. At the same time, a free disk space can also be found through the data block bitmap area to store the actual data of the file. When a file or directory is deleted, the virtual file system will mark the corresponding bits in the index node bitmap area and the data block bitmap area as free, so that subsequent files or directories can reuse these spaces. The virtual file system manages the allocation and release of disk space in a bitmap manner, which can efficiently manage the utilization of disk space, reduce the fragmentation of disk space, and improve the writing efficiency of files.
[0040] The index node area is used to record the meta information of the file. The directory, as a special file, also has a corresponding index node. The index node is the unique identifier of the virtual file, and there is a one-to-one correspondence between them.
[0041] Specifically, the index node is mainly used to store two types of data; the first type of data in the index node includes file index number, file type, file size, access rights, creation time, modification time, data block location index, and the hash value obtained by performing the SM3 algorithm on the data in each data block. When the file is large, there will be multiple data block location indexes and multiple data block SM3 hash values.
[0042] Figure 4It is the basic structure of the index node. The data block location index is divided into direct index address, primary index address, secondary index address, and tertiary index address. For small files, multiple direct index addresses can contain all data block addresses; for larger files, the primary index address may be used, and the primary index address points to a primary index data block, which contains multiple data block index addresses and multiple data block SM3 values; larger files will use secondary index addresses, which point to a secondary index data block, which stores the address of the primary index data block; particularly large files will use tertiary index addresses, which point to a tertiary index data block, which stores the address of the secondary index data block. For large files that use primary index data blocks, secondary index data blocks, and tertiary index data blocks, the SM3 hash value must also be stored for each recorded data block to ensure that the data block location index and the data block SM3 hash value correspond one to one.
[0043] The second type of data in the index node uses the national secret SM3 algorithm to calculate the hash value of the first type of data and store the hash value of 32 bytes of meta information.
[0044] As an embodiment, the data area stores the original data of the file in units of data blocks. Even if the file size is smaller than the size of a single block, it still needs to occupy a complete block, and the remaining space in the block cannot be used. If the file is large, it may occupy multiple blocks. Except for the last block, which may have remaining space, the remaining blocks occupy the entire space of the block.
[0045] For files whose file type is directory, the data block content in the data area stores the file list information under the directory, such as Figure 5 As shown, the file list information includes the file name, the SM3 hash value of the file name, the file index node address, the file type, and the SM3 hash value of the corresponding file data. The storage of the SM3 hash value of the file name is to improve the speed of file name query. By converting the file name into a hash value, the virtual file system can quickly locate the target file by comparing the hash value without comparing the characters of the file name one by one, thereby improving the performance and efficiency of the virtual file system. The storage of the SM3 hash value of the corresponding file data is to improve the reliability of the file. By calculating the SM3 hash value of the file data and storing the hash value in the file list information, the virtual file system can perform integrity verification when reading the file.
[0046] The stored virtual file data will be read through two SM3 hash value checks. The first is a hash value check for each block of data, and the second is a hash value check for the entire file data. If the check fails, the mirror data will be used to promptly restore the damaged or tampered data.
[0047] As an embodiment, the basic process of reading a file using a virtual file system is as follows: Figure 6 As shown, taking the example of reading / file.txt file, the file path to be read is all based on the root directory " / " as the starting point. First, the data in the basic information area A is read, and the data is verified by the SM3 hash value. If the verification fails, the data is restored from the mirror data of the basic information area A, and the basic information area B is tried. If the verification passes, the root directory index node address is obtained; the root directory index node data is obtained according to the root directory index node address, and the root directory index node data is verified by SM3. After the root directory index node verification passes, the root directory data block is obtained using the data block direct index address or indirect index address, and the data block content is verified by SM3. After the verification passes, all directory item information under the root directory is obtained, and the file name or file name hash value is matched to the file.txt file index node address; the file.txt index node is obtained according to the file.txt file index node address, thereby obtaining the file.txt data block index, and the SM3 value verification is performed on each data block of the file.txt file and the entire file. After the verification passes, the reading of the / file.txt file is completed.
[0048] The basic process of saving files in the virtual file system is to save the / file.txt file as an example. Figure 7 As shown, the writing file path also takes the root directory " / " as the starting point. After the data is written to each functional area A in the following steps, the same data is synchronously saved to each functional area B. First, the basic information area data is obtained, and the number of blocks occupied by the current file is calculated according to the block size. Combined with the number of unused blocks stored in the basic information area, it is determined whether there is enough space to accommodate the new file. If there is insufficient space, the storage process is terminated. If there is enough space, enough data blocks are allocated from the data block bitmap area to save the original data of the file, and the SM3 hash value is calculated for each data block. The corresponding index node space is allocated from the index node bitmap area to save the metadata of the file.txt file, the data block index direct address, indirect address, and the data block SM3 hash value. After saving, the directory entry data of the root directory is updated and the root directory index node data is updated. Finally, the basic information area data is updated to complete the saving of the / file.txt file.
[0049] Example 2
[0050] An embodiment of the present disclosure provides a method for operating a virtual file system, including reading a file and saving the file by the virtual file system;
[0051] Among them, the file reading step of the virtual file system includes: selecting a file reading path, reading the data in the basic information area A, and performing an SM3 hash value check on the data. If the check fails, trying to restore the data from the mirror data basic information area B of the basic information area A, and if the SM3 hash value check passes, obtaining the root directory index node address; obtaining the root directory index node data according to the root directory index node address, performing an SM3 check on the root directory index node data, obtaining the root directory data block using the data block direct index address or indirect index address after the root directory index node check passes, and performing an SM3 check on the data block content, obtaining all directory item information under the root directory after the check passes, matching the index node address of the file to be read according to the file name or the file name hash value; obtaining the index node of the file to be read according to the index node address of the file to be read, thereby obtaining the data block index of the file to be read, performing an SM3 value check on each data block of the file to be read and the entire file, and completing the file reading after the check passes.
[0052] Further, taking the example of reading the / file.txt file, the file path to be read is all taken from the root directory " / " as the starting point. First, the data in the basic information area A is read, and the data is verified by the SM3 hash value. If the verification fails, the data is restored from the mirror data of the basic information area A, and the basic information area B is tried. If the verification passes, the root directory index node address is obtained; the root directory index node data is obtained according to the root directory index node address, and the root directory index node data is verified by SM3. After the root directory index node verification passes, the root directory data block is obtained using the data block direct index address or indirect index address, and the data block content is verified by SM3. After the verification passes, all directory item information under the root directory is obtained, and the file.txt file index node address is matched according to the file name or the file name hash value; the file.txt index node is obtained according to the file.txt file index node address, thereby obtaining the file.txt data block index, and the SM3 value verification is performed on each data block of the file.txt file and the entire file. After the verification passes, the reading of the / file.txt file is completed.
[0053] As an embodiment, the step of saving files of the virtual file system includes: writing the file path also takes the root directory " / " as the starting point. After the data is written to each functional area A in the following steps, the same data is synchronously saved to each functional area B. First, the data in the basic information area is obtained, the number of blocks occupied by the current file is calculated according to the block size, and the number of unused blocks stored in the basic information area is combined to determine whether there is enough space to accommodate the new file. If there is insufficient space, the storage process is terminated. If there is enough space, enough data blocks are allocated from the data block bitmap area to save the original data of the file, and the SM3 hash value is calculated for each data block, and the corresponding index node space is allocated from the index node bitmap area to save the file's meta information, data block index direct address, indirect address, and data block SM3 hash value. After saving, the directory entry data of the root directory and the root directory index node data are updated, and finally the basic information area data is updated to complete the file saving.
[0054] Further, take the example of saving the / file.txt file. The writing file path also uses the root directory " / " as the starting point. After the data is written to each functional area A in the following steps, the same data is synchronously saved to each functional area B. First, obtain the basic information area data, calculate the number of blocks occupied by the current file according to the block size, and combine the number of unused blocks stored in the basic information area to determine whether there is enough space to accommodate the new file. If there is insufficient space, terminate the storage process. If there is enough space, allocate enough data blocks from the data block bitmap area to save the original data of the file, and calculate the SM3 hash value for each data block, allocate the corresponding index node space from the index node bitmap area, save the metadata of the file.txt file, the data block index direct address, indirect address, and the data block SM3 hash value. After saving, update the directory entry data of the root directory and update the root directory index node data. Finally, update the basic information area data to complete the saving of the / file.txt file.
[0055] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0056] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0057] Although the above describes the specific implementation methods of the present disclosure in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present disclosure. Technical personnel in the relevant field should understand that on the basis of the technical solution of the present disclosure, various modifications or variations that can be made by those skilled in the art without creative work are still within the scope of protection of the present disclosure.
Claims
1. A virtual file system, characterized in that: The method comprises a continuous virtual file, wherein all or part of the unused space of the entire storage device or a fixed-size file on an existing file system is used as the continuous virtual file, and the continuous virtual file comprises ten functional areas, namely, a basic information area A, an index node bitmap area A, a data block bitmap area A, an index node A area, a data area A, a basic information area B, an index node bitmap area B, a data block bitmap area B, an index node B area and a data area B; The continuous virtual file has a fixed size, and the total size of the file remains unchanged during use. It is a single, continuous virtual file, and needs to be initialized before the first use. Initialization will erase all data and reconfigure the virtual file system. The basic information area B, the index node bitmap area B, the data block bitmap area B, the index node area B and the data area B are mirror data of the basic information area A, the index node bitmap area A, the data block bitmap area A, the index node area A and the data area A, and when part of the data is tampered with or damaged, it can be self-repaired according to the mirror data; The data area stores the original data of the file in units of data blocks. For files whose file type is a directory, the file list information under the directory is stored. The file list information includes the file name, the file name SM3 hash value, the file index node address, the file type and the corresponding file data SM3 hash value; The stored virtual file data will be read through two SM3 hash value checks. The first is a hash value check for each block of data, and the second is a hash value check for the entire file data. If the check fails, the mirror data will be used to promptly restore the damaged or tampered data.
2. A virtual file system as claimed in claim 1, characterized in that: The continuous virtual file is opened, read, written, relocated and closed through the operating system library function. The continuous virtual file organizes and accesses virtual file data using the path and offset of the file system. By dividing a large continuous virtual file into different functional areas, the organization and management of various virtual file data are completed.
3. A virtual file system as claimed in claim 1, characterized in that: The entire continuous virtual file is divided into several blocks as basic units of data storage. The blocks have a fixed size and can be set during initialization. The size cannot be changed after the initialization is completed.
4. A virtual file system as claimed in claim 1, characterized in that: The ten functional areas organize data in blocks. The space ratio of each area is specified during initialization. By default, the basic information area occupies one block of space, and the index node area and the data area take a set ratio. Since 1 byte can represent the use or unused status of 8 data blocks, the size of the index node bitmap area and the data block bitmap area is calculated based on the total space size.
5. A virtual file system as claimed in claim 1, characterized in that: The basic information area is used to store three types of data; the first type of data is to store the statistical summary information of the virtual file system, including block size, number of blocks, number of used blocks and number of unused blocks; the second type of data is to store the root directory index address of the directory entry, which serves as the starting point for file system path query; the third type of data is to use the SM3 algorithm to calculate the hash value of all the first two types of data and store a 32-byte hash value.
6. A virtual file system as claimed in claim 1, characterized in that: The index node bitmap area uses a bitmap to manage the free space in the index node area, and the data block bitmap area uses a bitmap to manage the free space in the data area. The bitmap uses a binary bit to represent the usage of a disk block. When the value is 0, it means that the corresponding data block is free, and when the value is 1, it means that the corresponding data block has been allocated.
7. A virtual file system as claimed in claim 1, characterized in that: The index node area is used to record the metadata of the file. The directory is a special file, and the index node is the unique identifier of the virtual file. They correspond one to one and are used to store two types of data. The first type of data includes file type, file size, access rights, creation time, modification time, data block location index, and the hash value obtained by the SM3 algorithm for the data in each data block. When the file is large, there will be multiple data block location indexes and multiple data block SM3 hash values. For large files that use primary index data blocks, secondary index data blocks, and tertiary index data blocks, the SM3 hash value must also be stored for each recorded data block to ensure that the data block location index and the data block SM3 hash value correspond one to one. The second type of data uses the SM3 algorithm to calculate the hash value of the first type of data and stores the hash value of 32 bytes of metadata.
8. A method for operating a virtual file system according to any one of claims 1 to 7, characterized in that: The invention comprises a virtual file system for reading files and saving files, wherein the file reading step of the virtual file system comprises: selecting a file reading path, reading data in a basic information area A, and performing an SM3 hash value check on the data; if the check fails, attempting to restore the data from a mirror data area B of the basic information area A; if the check passes, obtaining a root directory index node address; obtaining root directory index node data according to the root directory index node address, performing an SM3 check on the root directory index node data; obtaining a root directory data block using a data block direct index address or an indirect index address after the root directory index node check passes, and performing an SM3 check on the data block content; obtaining all directory item information under the root directory after the check passes, matching the index node address of the file to be read according to the file name or the file name hash value; obtaining an index node of the file to be read according to the index node address of the file to be read, thereby obtaining a data block index of the file to be read; performing an SM3 value check on each data block of the file to be read and the entire file; and completing the file reading after the check passes.
Citation Information
Patent Citations
Method and device for allocating storage space of file system
CN103714013A
Method for implementing virtual image optical disk and and its system hardware structure
CN1395246A