File system processing method and apparatus, electronic device, and medium
Patent Information
- Application Number
- CN202211721846.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2042-12-30
AI Technical Summary
本申请实施例对文件系统对应的目录结构进行了修改,以使文件系统支持超过255字节的文件名长度和实现文件名长度的扩展。
Smart Images

Figure CN116049108B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and medium for processing a file system. Background Technology
[0002] EXT (extended file system) is the default file system in Linux operating system distributions. EXT uses multiple locations to store backups of important data structures, giving it good recoverability.
[0003] Currently, EXT typically supports fixed-length filenames. For example, EXT2 (second extended file system), EXT3 (third extended file system), and EXT4 (fourth extended file system) currently support filenames of length 0-255 bytes.
[0004] In practical applications, a length of 0-255 bytes is usually sufficient for English filenames. However, since a single Chinese character often requires several bytes to represent, and users frequently need to use filenames to describe file content or characteristic information, a length of 0-255 bytes can often represent 64-128 Chinese characters. Summary of the Invention
[0005] This application provides a file system processing method that can increase filename length.
[0006] Accordingly, embodiments of this application also provide a file system processing device, an electronic device, and a machine-readable medium to ensure the implementation and application of the above methods.
[0007] To address the aforementioned problems, this application discloses a file system processing method. The directory structure corresponding to the file system includes: name length information and file type information; the data type of the name length information is an unsigned N-bit integer, where N is a multiple of 16; or, the data type of the name length information is an unsigned M-bit integer, and the data type of the file type information is an unsigned P-bit integer, wherein the combination of the M bits of the name length information and the high X bits of the file type information is used to represent the name length information; the method includes: Based on the file creation request, create the directory structure corresponding to the target file system; the file creation request includes: the file name of the file created by the user; Based on the filename of the user-created file, assign values to the N bits of the name length information; or, based on the filename of the user-created file, assign values to the M bits of the name length information and the high X bits of the file type information.
[0008] To address the aforementioned issues, this application discloses a file system processing apparatus. The directory structure corresponding to the file system includes: name length information and file type information. The data type of the name length information is an unsigned N-bit integer, where N is a multiple of 16. Alternatively, the data type of the name length information is an unsigned M-bit integer, and the data type of the file type information is an unsigned P-bit integer. The combination of the M bits of the name length information and the high X bits of the file type information is used to characterize the name length information. The device includes: a directory creation module and a first assignment module; or, the device includes: a directory creation module and a second assignment module. The directory creation module is used to create a directory structure corresponding to the target file system based on the file creation request; the file creation request includes: the filename of the file created by the user; The first assignment module is used to assign a value to N bits of the name length information based on the file name of the file created by the user; The second assignment module is used to assign values to the M bits of the name length information and the high X bits of the file type information according to the file name of the file created by the user.
[0009] Optionally, the device further includes: The concatenation module is used to concatenate the high X bits of the file type information before the M bits of the name length information in response to a directory retrieval request. The name length information determination module is used to determine the name length information based on the concatenation result.
[0010] Optionally, the device further includes: An interface function providing module is used to provide interface functions corresponding to the name length information and / or the file type information; The interface function call module is used to perform operations corresponding to the name length information and / or the file type information according to the interface function.
[0011] Optionally, the filename structure corresponding to the file system includes: filename length information; the data type of the filename length information is an unsigned N-bit integer.
[0012] Optionally, the file system type structure corresponding to the file system includes: file system name information; the content of the file system name information is a preset string.
[0013] Optionally, the device further includes: The file system creation module is used to create a file system using file system tools; the file system corresponds to a system directory structure; the maximum length parameter of the system directory structure is a first preset value, and the data type of the name length information contained in the system directory structure is an unsigned N-bit integer; the first preset value is determined based on the unsigned N-bit integer, or based on the combination of the M bits of the name length information and the high X bits of the file type information; the header length parameter of the system directory structure is a second preset value.
[0014] Optionally, the file system tool provides access functions corresponding to the system directory structure; the access functions include access methods for name length information and / or file type information in the system directory structure; the access methods are matched with the unsigned N-bit integer, or the access methods are matched with the combination of the M bits of the name length information and the high X bits of the file type information.
[0015] This application also discloses an electronic device, including: a processor; and a memory storing executable code thereon, which, when executed, causes the processor to perform the method described in this application.
[0016] This application also discloses a machine-readable medium storing executable code thereon, which, when executed, causes a processor to perform the method described in this application.
[0017] The embodiments of this application have the following advantages: This application's embodiments modify the directory structure corresponding to the file system to enable the file system to support filename lengths exceeding 255 bytes and to implement filename length extensions.
[0018] One modification involves changing the data type of the name length information from u8 (unsigned 8-bit) to an unsigned N-bit integer. When the data type of the name length information is an unsigned N-bit integer, this embodiment of the application can support (2) N -1) Filename length in bytes. Taking N=16 as an example, the filename length supported by this application embodiment is 65535 bytes. Therefore, this application embodiment can increase the filename length, that is, it can realize the expansion of the filename length.
[0019] Another modification is to use a combination of the M bits of the name length information and the high X bits of the file type information to represent the name length information. When using a combination of the M bits of the name length information and the high X bits of the file type information to represent the name length information, the embodiments of this application can support (2) (M+X)-1) Filename length in bytes. Taking M=8 and X=2 as examples, the filename length supported by this application embodiment is 1023 bytes. Therefore, this application embodiment can increase the filename length, that is, it can realize the expansion of the filename length. Attached Figure Description
[0020] Figure 1 This is a flowchart illustrating the steps of a file system processing method according to an embodiment of this application; Figure 2 This is a flowchart illustrating the steps of a file system processing method according to an embodiment of this application; Figure 3 This is a flowchart illustrating the steps of a file system processing method according to an embodiment of this application; Figure 4 This is a flowchart illustrating the steps of a file system processing method according to an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a file system processing device according to an embodiment of this application; Figure 6 This is a schematic diagram of the structure of a file system processing device according to an embodiment of this application; Figure 7 This is a schematic diagram of the structure of an apparatus provided in one embodiment of this application. Detailed Implementation
[0021] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0022] To address the technical problem of current filename length representation of finite-length Chinese filenames, embodiments of this application provide a file system processing method, wherein the directory structure corresponding to the file system specifically includes: name length information and file type information; The data type for this name length information can be an unsigned N-bit integer, where N is a multiple of 16; or The data type of the name length information can be an unsigned M-bit integer, and the data type of the file type information can be an unsigned P-bit integer. The combination of the M bits of the name length information and the high X bits of the file type information can be used to represent the name length information.
[0023] Currently, the directory structure corresponding to file systems such as EXT2, EXT3, and EXT4 can be represented by ext2_dir_entry_2, ext3_dir_entry_2, and ext4_dir_entry_2. The directory structure can serve as the access point for the file system.
[0024] The target structure corresponding to the EXT4 file system in traditional technology is as follows: struct ext4_dir_entry_2 { __le32 inode; / * Inode number (node ID) * / __le16 rec_len; / * Directory entry length (structure length) * / __u8 name_len; / *Name length (name length information)* / __u8 file_type; / * File type information * / char name[EXT4_NAME_LEN]; / * File name (filename) * / }; The directory structure mentioned above specifically includes structure fields such as name length and file type.
[0025] The embodiments of this application modify the directory structure corresponding to the file system so that the file system supports filename lengths exceeding 255 bytes.
[0026] One modification method involves changing the data type of the name length information. The data type is changed from u8 (unsigned 8-bit) to an unsigned N-bit integer, where N can be a multiple of 16, and examples of N include 16, 32, etc. With the name length information data type being an unsigned N-bit integer, this embodiment of the application can support (2... N -1) Filename length in bytes. Taking N=16 as an example, the filename length supported by this application embodiment is 65535 bytes, that is, it supports lengths from 0 to 65535 bytes. Therefore, this application embodiment can improve the filename length.
[0027] Another modification is to use a combination of the M bits of the name length information and the high X bits of the file type information to represent the name length information when the data type of the name length information is an unsigned M-bit integer and the data type of the file type information is an unsigned P-bit integer. When using a combination of the M bits of the name length information and the high X bits of the file type information to represent the name length information, the embodiments of this application can support (2) (M+X) -1) Filename length in bytes. Taking M=8 and X=2 as examples, the filename length supported by this application embodiment is 1023 bytes, that is, it supports lengths from 0 to 1023 bytes. Therefore, this application embodiment can improve the filename length.
[0028] Method Example 1 This embodiment modifies the data type of name length information in the directory structure and provides corresponding processing methods.
[0029] This application embodiment can support file creation.
[0030] refer to Figure 1 The diagram illustrates a step-by-step flowchart of a file system processing method according to an embodiment of this application. The method may specifically include the following steps: Step 101: Based on the file creation request, create the directory structure corresponding to the file system; this directory structure may contain name length information; the data type of this name length information may be an unsigned N-bit integer, where N is a multiple of 16; the file creation request may contain the filename of the file created by the user. Step 102: Assign a value to the N bits of the name length information based on the file name created by the user.
[0031] User-created files can have filenames in Chinese or English, and their length can vary. When a user-created filename is short, the most significant bit of the N bits in the name length information can be 0; conversely, when a user-created filename is long, the most significant bit of the N bits in the name length information can be non-zero. It is understood that the value of the N bits in the name length information can be determined based on the filename, and this embodiment does not impose any restrictions on the specific value of the N bits.
[0032] This application embodiment can snapshot the filename length based on existing file system drivers and file system tools to support filename lengths greater than 255 bytes. It is understood that this application embodiment can also support the original filename lengths of 0-255 bytes.
[0033] This application's embodiments can be applied to various computer systems, examples of which include PCs (Personal Computers), servers, or embedded systems. This application's embodiments can operate at the operating system's driver layer, which can be located between the hardware layer and the application layer. The driver layer can provide file system services to the upper application layer. This application's embodiments do not involve modifications to the file system's external interface, therefore they will not affect the existing operation of the application layer and hardware layer.
[0034] This application embodiment can support file access, which requires a directory structure retrieval process. For example, during the directory structure retrieval process, a node ID (identity) is obtained based on the filename, and then detailed information of the node (file) is obtained from the node table based on the node ID.
[0035] This application embodiment can abstract operations on the structure fields contained in the directory structure into interface functions; thus, operations on structure fields such as name length information and file type information will be executed through interface functions. Since direct code manipulation of structure fields can be avoided, code thrashing caused by operations on structure fields can be reduced to some extent. This code can be the code used by the file system processing method, that is, code used for file system processing.
[0036] Accordingly, the method in this application embodiment may further include: Provide interface functions corresponding to the name length information and / or the file type information; According to the interface function, perform the operation corresponding to the name length information and / or the file type information.
[0037] The interface functions corresponding to the name length information may include: a first interface function for obtaining the name length information, and a second interface function for setting the name length information, etc.
[0038] The interface functions corresponding to the file type information may include: a third interface function for obtaining file type information, and a fourth interface function for setting file type information, etc.
[0039] In this embodiment, the aforementioned interface functions can be used in the target code section involving operations on structure fields. In a specific implementation, the target code section related to the structure field variables can be located, and the structure field variables can be replaced with the corresponding interface functions.
[0040] For example, if the variable corresponding to the name length information is name_len, and the target code part A "name_len=123" is used to set the name length information, then the target code part A can be replaced with the second interface function.
[0041] The file system in this embodiment may also correspond to a filename structure. The filename structure is used to indicate the storage location of a directory's information before it is read into user space.
[0042] The following is an example of a filename structure in traditional techniques: struct fname { __u32 hash; / * Inode number (node ID) * / __ u32 minor_hash; / * Directory entry length (structure length) * / _struct rb_node rb_hash; struct fname *next; u32 inode; u8 name_len; u8 file_type; char name[0];}; In the filename structure described above, `name_len` represents the filename length information. Traditionally, the data type for filename length information is `u8`. If the data type of the filename length information is not modified, incorrect filename display will occur.
[0043] In this embodiment, the data type of the filename length information is modified to an unsigned N-bit integer. Since the unsigned N-bit integer corresponding to the filename length information matches the unsigned N-bit integer corresponding to the name length information, the filename can be displayed normally.
[0044] The file system in this application embodiment can correspond to a file system type structure file_system_type, which is registered in the operating system to represent the existence of the file system.
[0045] The file system type structure specifically includes: file system name information; in this embodiment, the content of the file system name information can be set to a preset string. The preset string can be different from the content of existing file system name information. For example, the file system name information in the file system type structure corresponding to the EXT4 file system is "ext4", and the preset string in this embodiment can be "ext4big" to distinguish it from the content of existing file system name information.
[0046] The file system in this application embodiment can correspond to a file system tool. This file system tool can be used to perform preset processes such as creation, formatting, defragmentation, and error checking on file systems with filenames exceeding 255 bytes. The file system tool can format disk partitions and create file systems on the formatted disk partitions. The created file system can be mounted to the operating system. Mounting is the process of connecting a disk's file system to the operating system's directory tree. After the file system is mounted, the data on the disk becomes a subtree of the operating system's directory tree. Users can then access the data on that disk.
[0047] The method in this application embodiment may include: using a file system tool to create a file system; the file system corresponds to a system directory structure; the maximum length parameter of the system directory structure is a first preset value, and the data type of the name length information contained in the system directory structure is an unsigned N-bit integer; the first preset value is determined based on the unsigned N-bit integer; and the header length parameter of the system directory structure is a second preset value.
[0048] For example, the system directory structure corresponding to the EXT2 file system is the ext2_dir_entry structure. The ext2_dir_entry structure can specifically include fields such as name length information and file type information.
[0049] struct ext2_dir_entry { __u32 inode; / * Inode number * / __u16 rec_len; / * Directory entry length * / __u8 name_len; / * Name length (name length information) * / u8 file_type; / * File type information * / char name[EXT2_NAME_LEN]; / * File name * / }; This application embodiment modifies the maximum length parameter of the system directory structure, changing it to a first preset value, so that the created file system can support (2). N -1) Filename length in bytes. The first preset value can be determined based on an unsigned N-bit integer, used to represent the maximum number of bytes corresponding to the filename length. Taking N=16 as an example, the first preset value can be 65535.
[0050] This application embodiment modifies the data type of the name length information contained in the system directory structure, changing it from an unsigned 8-bit integer to an unsigned N-bit integer, so that the created file system can support (2... N -1) bytes is the filename length.
[0051] This application embodiment modifies the header length parameter of the system directory structure, changing it to a second preset value so that the created file system can support filename lengths of (2N-1) bytes.
[0052] Taking N=16 as an example, the structure is usually aligned to four bytes. The name length information field in the system directory structure changes from _u8 to _u16, which adds one byte, so the header length parameter increases by four bytes. Assuming the original value of the header length parameter is P, the updated value of the header length parameter is (P+4).
[0053] The file system tool in this application embodiment provides access functions corresponding to the system directory structure; the access functions include access methods for name length information and / or file type information in the system directory structure; the access methods are matched with the unsigned N-bit integer so that the created file system can support (2 N -1) bytes is the filename length.
[0054] The aforementioned access functions specifically include: a first access function for obtaining name length information, a second access function for setting name length information, a third access function for obtaining file type information, and a fourth access function for setting file type information, etc.
[0055] Taking the first access function as an example, its return value can be the result of the AND operation between the numerical value of the name length information contained in the system directory structure and the third preset value. The third preset value can be determined based on the original 255 bytes; for example, the third preset value can be 0xFF.
[0056] It should be noted that one difference between the system directory structure and the directory structure in this application embodiment is that the system directory structure is used to create a file system, while the directory structure is used to create or access files in the created file system.
[0057] One difference between the access function and the interface function in this application embodiment is that the access function is used to create a file system, while the interface function is used to create or access files in the created file system.
[0058] refer to Figure 2 The diagram illustrates a step-by-step flowchart of a file system processing method according to an embodiment of this application. The method may specifically include the following steps: Step 201: Using file system tools, create a target file system; the file system corresponds to a system directory structure; the maximum length parameter of the system directory structure is a first preset value, and the data type of the name length information contained in the system directory structure is an unsigned N-bit integer; the first preset value is determined based on the unsigned N-bit integer; the header length parameter of the system directory structure is a second preset value; the target file system can be an improved file system based on file systems such as EXT2 to EXT4, but this application embodiment does not limit the specific target file system; Step 202: Mount the created target file system to the operating system directory tree; Step 203: Based on the file creation request, create the directory structure corresponding to the target file system; this directory structure may contain name length information; the file creation request may contain the filename of the file created by the user; Step 204: Assign a value to the N bits of the name length information based on the file name created by the user.
[0059] In summary, the file system processing method of this application embodiment modifies the data type of the name length information from u8 (unsigned 8-bit) to an unsigned N-bit integer. When the data type of the name length information is an unsigned N-bit integer, this application embodiment can support (2... N -1) Filename length in bytes. Taking N=16 as an example, the filename length supported by this application embodiment is 65535 bytes. Therefore, this application embodiment can increase the filename length, that is, it can realize the expansion of the filename length.
[0060] Furthermore, the embodiments of this application solve the technical problem that current file systems cannot support filenames longer than 255 bytes, allowing Chinese filenames to more accurately and comprehensively describe file content or file characteristics, and reducing the possibility of duplicate Chinese filenames.
[0061] Furthermore, when applied to operating systems such as Linux, the embodiments of this application can be better compatible with long filename files created under the Windows system (Windows currently supports a maximum path length of 260 characters, and a single character may contain multiple bytes depending on the encoding method).
[0062] Method Example 2 This embodiment modifies the representation method of name length information and correspondingly provides a processing method.
[0063] When the data type of the name length information is an unsigned M-bit integer and the data type of the file type information is an unsigned P-bit integer, the name length information is represented by a combination of the M bits of the name length information and the high X bits of the file type information. In the case of using a combination of the M bits of the name length information and the high X bits of the file type information to represent the name length information, the embodiments of this application can support (2) (M+X) -1) Filename length in bytes. Taking M=8 and X=2 as examples, the filename length supported by this application embodiment is 1023 bytes, that is, it supports lengths from 0 to 1023 bytes. Therefore, this application embodiment can improve the filename length.
[0064] Currently, file type information in file systems such as EXT4 is typically an unsigned 8-bit integer, and the lower 3 bits are usually used, while the higher 5 bits are unused. Therefore, this embodiment can use the higher X bits of the file type information to extend the filename length, where X can be between 1 and 5, i.e., the lower limit of X is 1 and the upper limit is 5. When X is 5, this embodiment can support filename lengths from 0 to 8191 bytes.
[0065] Assume a byte consists of 8 bits, arranged as follows (leftmost bit is the most significant bit, rightmost bit is the least significant bit): name_len: | bit 0 | bit 1 | bit 2 | bit 3 | bit 4 | bit 5 | bit 6 |bit 7| file_type: | bit 0 | bit 1 | bit 2 | bit 3 | bit 4 | bit 5 | bit 6 |bit 7| Bits 5, 6, and 7 of `file_type` are used to represent the file type. Bits 0, 1, 2, 3, and 4 can be added before bit 0 of `name_len`, resulting in 13 bits representing the name length information. The value range of these 13 bits is 0-8191. Of course, in this embodiment, all or some of bits 0, 1, 2, 3, and 4 can be used.
[0066] Since the implementation of this application does not modify the directory structure, incompatibility issues caused by modifications to the directory structure can be avoided to a certain extent.
[0067] This application embodiment can support file creation.
[0068] refer to Figure 3The diagram illustrates a step-by-step flowchart of a file system processing method according to an embodiment of this application. The method may specifically include the following steps: Step 301: Based on the file creation request, create the directory structure corresponding to the target file system; the file creation request may include: the file name of the file created by the user; the directory structure may include: name length information and file type information; the data type of the name length information is an unsigned M-bit integer, the data type of the file type information is an unsigned P-bit integer, and the combination of the M bits of the name length information and the high X bits of the file type information is used to represent the name length information; Step 302: Assign values to the M bits of the name length information and the high X bits of the file type information based on the file name created by the user.
[0069] User-created files can have filenames in Chinese or English, and the filenames can be of varying lengths. When a user-created filename is short, the high X bits of the file type information can be 0; conversely, when a user-created filename is long, the high X bits of the file type information may not be 0. It is understood that the value of the high X bits of the file type information can be determined based on the filename, and this embodiment does not impose any restrictions on the specific value of the high X bits of the file type information.
[0070] This application embodiment can support file access, and in the process of accessing files, it is necessary to access or retrieve the directory structure.
[0071] Therefore, in response to a directory retrieval request, the high X bits of the file type information can be appended to the M bits of the name length information, and the name length information can be determined based on the appending result.
[0072] This application embodiment can abstract operations on the structure fields contained in the directory structure into interface functions; thus, operations on structure fields such as name length information and file type information will be executed through interface functions. Since direct code manipulation of structure fields can be avoided, code thrashing caused by operations on structure fields can be reduced to some extent. This code can be the code used by the file system processing method, that is, code used for file system processing.
[0073] Accordingly, the method in this application embodiment may further include: Provide interface functions corresponding to the name length information and / or the file type information; According to the interface function, perform the operation corresponding to the name length information and / or the file type information.
[0074] The interface functions corresponding to the name length information may include: a first interface function for obtaining the name length information, and a second interface function for setting the name length information, etc.
[0075] The interface functions corresponding to the file type information may include: a third interface function for obtaining file type information, and a fourth interface function for setting file type information, etc.
[0076] In this embodiment, the aforementioned interface functions can be used in the target code section involving operations on structure fields. In a specific implementation, the target code section related to the structure field variables can be located, and the structure field variables can be replaced with the corresponding interface functions.
[0077] For example, if the variable corresponding to the name length information is name_len, and the target code part A "name_len=123" is used to set the name length information, then the target code part A can be replaced with the second interface function.
[0078] The file system in this embodiment may also correspond to a filename structure. The filename structure is used to indicate the storage location of a directory's information before it is read into user space.
[0079] The following is an example of a filename structure in traditional techniques: struct fname { __u32 hash; / * Inode number (node ID) * / __ u32 minor_hash; / * Directory entry length (structure length) * / _struct rb_node rb_hash; struct fname *next; u32 inode; u8 name_len; u8 file_type; char name[0];}; In the filename structure described above, `name_len` represents the filename length information. Traditionally, the data type for filename length information is `u8`. If the data type of the filename length information is not modified, incorrect filename display will occur.
[0080] The file system in this application embodiment can correspond to a file system type structure file_system_type, which is registered in the operating system to represent the existence of the file system.
[0081] The file system type structure specifically includes: file system name information; in this embodiment, the content of the file system name information can be set to a preset string. The preset string can be different from the content of existing file system name information. For example, the file system name information in the file system type structure corresponding to the EXT4 file system is "ext4", and the preset string in this embodiment can be "ext4big" to distinguish it from the content of existing file system name information.
[0082] The file system in this application embodiment can correspond to a file system tool. This file system tool can be used to perform preset processes such as creation, formatting, defragmentation, and error checking on file systems with filenames exceeding 255 bytes. The file system tool can format disk partitions and create file systems on the formatted disk partitions. The created file system can be mounted to the operating system. Mounting is the process of connecting a disk's file system to the operating system's directory tree. After the file system is mounted, the data on the disk becomes a subtree of the operating system's directory tree. Users can then access the data on that disk.
[0083] The method in this application embodiment may include: creating a file system using a file system tool; the file system corresponding to a system directory structure; the maximum length parameter of the system directory structure being a first preset value; the first preset value being determined based on a combination of the M bits of the name length information and the high X bits of the file type information. The system directory structure may specifically include fields such as name length information and file type information.
[0084] This application embodiment modifies the maximum length parameter of the system directory structure, changing it to a first preset value, so that the created file system can support (2). (M+X) -1) Filename length in bytes. The first preset value can be determined based on the combination of the M bits of the name length information and the high X bits of the file type information, and is used to represent the maximum number of bytes corresponding to the filename length. Taking M=8 and X=2 as an example, the first preset value can be 1023.
[0085] The file system tool in this application embodiment provides an access function corresponding to the system directory structure; the access function includes an access method for name length information and / or file type information in the system directory structure; the access method is matched with the combination of the M bits of the name length information and the high X bits of the file type information, so that the created file system can support (2 (M+X) -1) bytes is the filename length.
[0086] The aforementioned access functions specifically include: a first access function for obtaining name length information, a second access function for setting name length information, a third access function for obtaining file type information, and a fourth access function for setting file type information, etc.
[0087] Taking the first access function as an example, its access method can be: concatenating the high X bits of the file type information before the M bits of the name length information, and determining the name length information based on the concatenation result.
[0088] It should be noted that one difference between the system directory structure and the directory structure in this application embodiment is that the system directory structure is used to create a file system, while the directory structure is used to create or access files in the created file system.
[0089] One difference between the access function and the interface function in this application embodiment is that the access function is used to create a file system, while the interface function is used to create or access files in the created file system.
[0090] refer to Figure 4 The diagram illustrates a step-by-step flowchart of a file system processing method according to an embodiment of this application. The method may specifically include the following steps: Step 401: Use the file system tool to create the target file system; this file system has a corresponding system directory structure; the maximum length parameter of this system directory structure is a first preset value; this first preset value is determined based on the combination of the M bits of the name length information and the high X bits of the file type information; Step 402: Mount the created target file system to the operating system directory tree; Step 403: Based on the file creation request, create the directory structure corresponding to the target file system; this directory structure may contain name length information and file type information; the file creation request may contain the filename of the file created by the user; Step 404: Assign values to the M bits of the name length information and the high X bits of the file type information based on the file name created by the user.
[0091] In summary, the file system processing method of this application embodiment uses a combination of the M bits of the name length information and the high X bits of the file type information to represent the name length information. When using a combination of the M bits of the name length information and the high X bits of the file type information to represent the name length information, this application embodiment can support (2... (M+X) -1) Filename length in bytes. Taking M=8 and X=2 as examples, the filename length supported by this application embodiment is 1023 bytes. Therefore, this application embodiment can increase the filename length, that is, it can realize the expansion of the filename length.
[0092] Furthermore, the embodiments of this application solve the technical problem that current file systems cannot support filenames longer than 255 bytes, allowing Chinese filenames to more accurately and comprehensively describe file content or file characteristics, and reducing the possibility of duplicate Chinese filenames.
[0093] Furthermore, when applied to operating systems such as Linux, the embodiments of this application can be better compatible with long filename files created under the Windows system (Windows currently supports a maximum path length of 260 characters, and a single character may contain multiple bytes depending on the encoding method).
[0094] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.
[0095] Based on the above embodiments, this embodiment also provides a file system processing device, wherein the directory structure corresponding to the file system includes: name length information and file type information; The data type of the name length information is an unsigned N-bit integer, where N is a multiple of 16; or The data type of the name length information is an unsigned M-bit integer, the data type of the file type information is an unsigned P-bit integer, and the combination of the M bits of the name length information and the high X bits of the file type information is used to represent the name length information; The aforementioned device may specifically include: a directory creation module and a first assignment module; or, the device may include: a directory creation module and a second assignment module; The directory creation module is used to create a directory structure corresponding to the target file system based on the file creation request; the file creation request includes: the filename of the file created by the user; The first assignment module is used to assign a value to N bits of the name length information based on the file name of the file created by the user; The second assignment module is used to assign values to the M bits of the name length information and the high X bits of the file type information according to the file name of the file created by the user.
[0096] Optionally, the device may further include: The concatenation module is used to concatenate the high X bits of the file type information before the M bits of the name length information in response to a directory retrieval request. The name length information determination module is used to determine the name length information based on the concatenation result.
[0097] Optionally, the device may further include: An interface function providing module is used to provide interface functions corresponding to the name length information and / or the file type information; The interface function call module is used to perform operations corresponding to the name length information and / or the file type information according to the interface function.
[0098] Optionally, the filename structure corresponding to the file system may include: filename length information; the data type of the filename length information is an unsigned N-bit integer.
[0099] Optionally, the file system type structure corresponding to the file system may include: file system name information; the content of the file system name information is a preset string.
[0100] Optionally, the device may further include: The file system creation module is used to create a file system using file system tools; the file system corresponds to a system directory structure; the maximum length parameter of the system directory structure is a first preset value, and the data type of the name length information contained in the system directory structure is an unsigned N-bit integer; the first preset value is determined based on the combination of an unsigned N-bit integer or the M bits of the name length information and the high X bits of the file type information; the header length parameter of the system directory structure is a second preset value.
[0101] Optionally, the file system tool provides access functions corresponding to the system directory structure; the access functions include access methods for name length information and / or file type information in the system directory structure; the access methods are matched with the unsigned N-bit integer, or the access methods are matched with the combination of the M bits of the name length information and the high X bits of the file type information.
[0102] Reference Figure 5 The diagram shows a structural schematic of a file system processing apparatus according to an embodiment of this application. The apparatus may specifically include the following modules: The directory creation module 501 is used to create a directory structure corresponding to the target file system based on the file creation request; the file creation request includes: the file name of the file created by the user; The first assignment module 502 is used to assign N bits of the name length information according to the file name of the file created by the user.
[0103] Optionally, the device may further include: The file system creation module is used to create a file system using file system tools; the file system corresponds to a system directory structure; the maximum length parameter of the system directory structure is a first preset value, and the data type of the name length information contained in the system directory structure is an unsigned N-bit integer; the first preset value is determined based on the unsigned N-bit integer; the header length parameter of the system directory structure is a second preset value.
[0104] Optionally, the file system tool provides access functions corresponding to the system directory structure; the access functions include access methods for name length information and / or file type information in the system directory structure; the access methods are matched with the unsigned N-bit integer.
[0105] Reference Figure 6 The diagram shows a structural schematic of a file system processing apparatus according to an embodiment of this application. The apparatus may specifically include the following modules: The directory creation module 601 is used to create a directory structure corresponding to the target file system based on the file creation request; the file creation request includes: the file name of the file created by the user; The second assignment module 602 is used to assign values to the M bits of the name length information and the high X bits of the file type information according to the file name of the file created by the user.
[0106] Optionally, the device may further include: The concatenation module is used to concatenate the high X bits of the file type information before the M bits of the name length information in response to a directory retrieval request. The name length information determination module is used to determine the name length information based on the concatenation result.
[0107] Optionally, the device may further include: The file system creation module is used to create a file system using file system tools; the file system corresponds to a system directory structure; the maximum length parameter of the system directory structure is a first preset value; the first preset value is determined based on the combination of the M bits of the name length information and the high X bits of the file type information.
[0108] Optionally, the file system tool provides access functions corresponding to the system directory structure; the access functions include access methods for name length information and / or file type information in the system directory structure; the access methods are matched with the combination of the M bits of the name length information and the high X bits of the file type information.
[0109] In summary, the file system processing device of this application embodiment modifies the data type of the name length information from u8 (unsigned 8-bit) to an unsigned N-bit integer. When the data type of the name length information is an unsigned N-bit integer, this application embodiment can support (2... N -1) Filename length in bytes. Taking N=16 as an example, the filename length supported by this application embodiment is 65535 bytes. Therefore, this application embodiment can increase the filename length, that is, it can realize the expansion of the filename length.
[0110] Alternatively, embodiments of this application use a combination of the M bits of the name length information and the high X bits of the file type information to represent the name length information. When using a combination of the M bits of the name length information and the high X bits of the file type information to represent the name length information, embodiments of this application can support (2...). (M+X) -1) Filename length in bytes. Taking M=8 and X=2 as examples, the filename length supported by this application embodiment is 1023 bytes. Therefore, this application embodiment can increase the filename length, that is, it can realize the expansion of the filename length.
[0111] Furthermore, the embodiments of this application solve the technical problem that current file systems cannot support filenames longer than 255 bytes, allowing Chinese filenames to more accurately and comprehensively describe file content or file characteristics, and reducing the possibility of duplicate Chinese filenames.
[0112] Furthermore, when applied to operating systems such as Linux, the embodiments of this application can be better compatible with long filenames created under Windows (Windows currently supports a maximum path length of 260 characters, and a single character may contain multiple bytes depending on the encoding method).
[0113] This application also provides a non-volatile readable storage medium storing one or more modules (programs). When these modules are applied to a device, they enable the device to execute the instructions for the method steps in this application.
[0114] This application provides one or more machine-readable media storing instructions that, when executed by one or more processors, cause an electronic device to perform one or more of the methods described in the above embodiments. In this application, the electronic device includes various types of devices such as terminal devices and servers (clusters).
[0115] The embodiments of this disclosure can be implemented as an apparatus configured as desired using any suitable hardware, firmware, software, or any combination thereof, including electronic devices such as terminal devices and servers (clusters). Figure 7 An exemplary apparatus 1100 is schematically shown that can be used to implement the various embodiments described in this application.
[0116] In one embodiment, Figure 7 An exemplary device 1100 is shown, which includes one or more processors 1102, a control module (chipset) 1104 coupled to at least one of the processors 1102, a memory 1106 coupled to the control module 1104, a non-volatile memory (NVM) / storage device 1108 coupled to the control module 1104, one or more input / output devices 1110 coupled to the control module 1104, and a network interface 1112 coupled to the control module 1104.
[0117] Processor 1102 may include one or more single-core or multi-core processors, and processor 1102 may include any combination of general-purpose processors or special-purpose processors (e.g., graphics processors, application processors, baseband processors, etc.). In some embodiments, device 1100 can serve as a terminal device, server (cluster), or other device as described in the embodiments of this application.
[0118] In some embodiments, apparatus 1100 may include one or more computer-readable media (e.g., memory 1106 or NVM / storage device 1108) having instructions 1114 and one or more processors 1102 that are combined with the one or more computer-readable media and configured to execute instructions 1114 to implement a module thereby performing the actions described in this disclosure.
[0119] In one embodiment, the control module 1104 may include any suitable interface controller to provide any suitable interface to at least one of the processors 1102 and / or any suitable device or component communicating with the control module 1104.
[0120] The control module 1104 may include a memory controller module to provide an interface to the memory 1106. The memory controller module may be a hardware module, a software module, and / or a firmware module.
[0121] Memory 1106 may be used, for example, to load and store data and / or instructions 1114 for device 1100. In one embodiment, memory 1106 may include any suitable volatile memory, such as suitable DRAM. In some embodiments, memory 1106 may include double data rate type quad synchronous dynamic random access memory (DDR4 SDRAM).
[0122] In one embodiment, the control module 1104 may include one or more input / output controllers to provide interfaces to the NVM / storage device 1108 and (one or more) input / output devices 1110.
[0123] For example, NVM / storage device 1108 may be used to store data and / or instructions 1114. NVM / storage device 1108 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable (one or more) non-volatile storage devices (e.g., one or more hard disk drive (HDD), one or more optical disc (CD) drives, and / or one or more digital universal optical disc (DVD) drives).
[0124] NVM / storage device 1108 may include storage resources that are physically part of a device on which device 1100 is mounted, or that can be accessed by the device without being part of the device. For example, NVM / storage device 1108 may be accessed via a network via one or more input / output devices 1110.
[0125] One or more input / output devices 1110 may provide an interface for device 1100 to communicate with any other suitable device. Input / output devices 1110 may include communication components, audio components, sensor components, etc. A network interface 1112 may provide an interface for device 1100 to communicate via one or more networks. Device 1100 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, such as accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof.
[0126] In one embodiment, at least one of the processors 1102 may be logically packaged with one or more controllers (e.g., memory controller modules) of the control module 1104. In one embodiment, at least one of the processors 1102 may be logically packaged with one or more controllers of the control module 1104 to form a system-in-package (SiP). In one embodiment, at least one of the processors 1102 may be integrated with the logic of one or more controllers of the control module 1104 on the same die. In one embodiment, at least one of the processors 1102 may be integrated with the logic of one or more controllers of the control module 1104 on the same die to form a system-on-a-chip (SoC).
[0127] In various embodiments, device 1100 may be, but is not limited to, a server, desktop computing device, or mobile computing device (e.g., laptop computing device, handheld computing device, tablet computer, netbook, etc.). In various embodiments, device 1100 may have more or fewer components and / or different architectures. For example, in some embodiments, device 1100 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touchscreen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.
[0128] The detection device can use a main control chip as a processor or control module, and sensor data, position information, etc. can be stored in a memory or NVM / storage device. The sensor group can be used as an input / output device, and the communication interface can include a network interface.
[0129] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0130] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0131] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.
[0132] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more blocks of a block diagram.
[0133] These computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable terminal equipment, provide steps for implementing the functions specified in one or more flowcharts and / or one or more blocks of a block diagram.
[0134] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0135] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0136] The foregoing has provided a detailed description of a file system processing method and apparatus, an electronic device, and a machine-readable medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for processing a file system, characterized in that, The directory structure corresponding to the file system includes: name length information and file type information; the data type of the name length information is an unsigned M-bit integer, the data type of the file type information is an unsigned P-bit integer, and the combination of the M bits of the name length information and the high X bits of the file type information is used to represent the name length information; the method includes: Based on the file creation request, create the directory structure corresponding to the target file system; the file creation request includes: the file name of the file created by the user; Based on the filename of the user-created file, assign values to the M bits of the name length information and the high X bits of the file type information; wherein, based on the filename of the user-created file, the value of the high X bits of the file type information is dynamically determined.
2. The method according to claim 1, characterized in that, The method further includes: In response to a directory retrieval request, the high X bits of the file type information are appended to the M bits of the name length information, and the name length information is determined based on the appending result.
3. The method according to any one of claims 1 to 2, characterized in that, The method further includes: Provide interface functions corresponding to the name length information and / or the file type information; According to the interface function, perform the operation corresponding to the name length information and / or the file type information.
4. The method according to any one of claims 1 to 2, characterized in that, The filename structure corresponding to the file system includes: filename length information; the data type of the filename length information is an unsigned N-bit integer.
5. The method according to any one of claims 1 to 2, characterized in that, The file system type structure corresponding to the file system includes: file system name information; the content of the file system name information is a preset string.
6. The method according to any one of claims 1 to 2, characterized in that, The method further includes: A file system is created using file system tools; the file system corresponds to a system directory structure; the maximum length parameter of the system directory structure is a first preset value, and the data type of the name length information contained in the system directory structure is an unsigned N-bit integer; the first preset value is determined based on the combination of the M bits of the name length information and the high X bits of the file type information; the header length parameter of the system directory structure is a second preset value.
7. The method according to claim 6, characterized in that, The file system tool provides access functions corresponding to the system directory structure; the access functions include access methods for name length information and / or file type information in the system directory structure; the access methods are matched with the combination of the M bits of the name length information and the high X bits of the file type information.
8. A file system processing apparatus, characterized in that, The directory structure corresponding to the file system includes: name length information and file type information; the data type of the name length information is an unsigned M-bit integer, the data type of the file type information is an unsigned P-bit integer, and the combination of the M bits of the name length information and the high X bits of the file type information is used to represent the name length information. The device includes: a directory creation module and a second assignment module; The directory creation module is used to create a directory structure corresponding to the target file system based on the file creation request; the file creation request includes: the filename of the file created by the user; The second assignment module is used to assign values to the M bits of the name length information and the high X bits of the file type information according to the file name of the file created by the user; wherein, the value of the high X bits of the file type information is dynamically determined according to the file name of the file created by the user.
9. An electronic device, characterized in that, include: processor; and A memory having executable code stored thereon, which, when executed, causes the processor to perform the method as described in any one of claims 1-7.
10. A machine-readable medium having executable code stored thereon, which, when executed, causes a processor to perform the method as claimed in any one of claims 1-7.
Citation Information
Patent Citations
Linear adaptive file name length dispatching system and method
CN108108376A