Path analysis method, device and equipment, computer readable storage medium and vehicle
By parsing file system paths in shared memory, the system overhead problem caused by traditional file system layer path replication is solved, and more efficient path resolution and IPC performance improvement of microkernel systems is achieved.
Patent Information
- Application Number
- CN202310806997.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-03
- Publication Date
- 2025-01-03
AI Technical Summary
The traditional file system layer has path replication in path management, which leads to an increase in system overhead, especially in the IPC overhead of microkernel systems.
By receiving file access requests from the client, extracting and storing the path to shared memory, and parsing it in shared memory, avoiding path copying between the virtual file system and the specific file system, and directly reading the path from shared memory to obtain resolution result.
Reduces system overhead, reduces IPC overhead of microkernel systems, and improves file system performance.
Smart Images

Figure CN119248173A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of vehicles, and in particular to the field of path resolution technology. Background Art
[0002] At present, the traditional file system layer is very confusing for path management. The main problem is that the current path resolution scheme repeatedly copies paths between different file systems, which greatly increases the system overhead, especially the IPC (Inter-Process Communication) overhead of the microkernel system. Summary of the invention
[0003] The present disclosure provides a path parsing method, apparatus, device, computer-readable storage medium, and vehicle.
[0004] According to a first aspect of the present disclosure, a path resolution method is provided. The method comprises:
[0005] Receive a file access request from a client;
[0006] Extracting the path in the file access request and storing the path in the shared memory;
[0007] The virtual file system and / or the specific file system are called to parse the path in the shared memory to obtain a path parsing result.
[0008] According to the above aspects and any possible implementation manner, an implementation manner is further provided, wherein extracting the path in the file access request and storing the path in a shared memory includes:
[0009] Determining whether the file access request contains an absolute path;
[0010] If included, extract the absolute path and store the absolute path in the shared memory;
[0011] The parsing of the path in the shared memory includes:
[0012] The absolute path in the shared memory is parsed.
[0013] According to the above aspects and any possible implementation manner, an implementation manner is further provided, before storing the path in the shared memory, the method further includes:
[0014] Determine whether the path is already stored in the shared memory;
[0015] If the path is not stored, the path is stored in the shared memory.
[0016] According to the above aspects and any possible implementation manner, an implementation manner is further provided, where before calling the virtual file system and / or the specific file system to parse the path in the shared memory, the method further includes:
[0017] If the path is stored, calling the correspondence between the pre-stored path and the path resolution result;
[0018] The path is matched with the corresponding relationship to obtain a path resolution result corresponding to the path.
[0019] According to the above aspects and any possible implementation manner, an implementation manner is further provided, before storing the path in the shared memory, the method further includes:
[0020] Determine whether the path meets the preset path specification; wherein the preset path specification includes at least one of the following: whether the path has a trailing slash, whether the path is an absolute path, whether the path has extra slashes, whether the path has extra symbols, and whether the path has an error symbol;
[0021] If the preset path specification is met, an operation of storing the path in the shared memory is performed.
[0022] According to the above aspects and any possible implementation manner, an implementation manner is further provided, if the preset path specification is not met, the path is discarded.
[0023] According to the above aspects and any possible implementation manner, an implementation manner is further provided, wherein the path includes an absolute path, and the calling of the virtual file system and / or the specific file system to parse the path in the shared memory to obtain a path parsing result includes:
[0024] Calling the virtual file system and / or the specific file system to match the absolute path with the directory under the mount point managed by itself;
[0025] If there is a match, determining the device identifier of the device where the file to be accessed is located according to the target directory in the directory that matches the absolute path;
[0026] The device identifier of the device where the to-be-accessed file is located is determined as the path resolution result of the absolute path.
[0027] According to the above aspects and any possible implementation manner, an implementation manner is further provided, after determining the device identification of the device where the to-be-accessed file is located, and before determining the device identification of the device where the to-be-accessed file is located as the path resolution result of the absolute path, the method further includes:
[0028] Obtaining a file index carried in the file access request;
[0029] According to the order of available file handles in the file handle array, the file handle currently at the top of the order is determined as the file handle allocated for the absolute path;
[0030] The device identifier, the file index and the file handle are combined to obtain a path triplet corresponding to the absolute path; wherein the path triplet is used to uniquely identify the file to be accessed corresponding to the absolute path;
[0031] The path parsing result of determining the device identifier of the device where the file to be accessed is located as the absolute path includes:
[0032] The path triplet is determined as a path resolution result of the absolute path.
[0033] According to the above aspects and any possible implementation manner, an implementation manner is further provided, wherein calling the virtual file system and / or the specific file system to match the absolute path in the shared memory with the directory under the mount point managed by itself includes:
[0034] Calling the virtual file system to match the absolute path with the directory under the mount point managed by itself;
[0035] If it is determined that the absolute path does not match any directory under the mount point managed by the virtual file system, the virtual file system is controlled to send a query request to the specific file system, so that the specific file system reads the absolute path from the shared memory according to the path tag of the absolute path carried in the query request, and then matches the absolute path with the directory under the mount point managed by itself.
[0036] According to the above aspect and any possible implementation manner, an implementation manner is further provided, before controlling the virtual file system to send a query request to the specific file system, the method further includes:
[0037] Controlling the virtual file system to determine a corresponding file system based on the path component of the absolute path;
[0038] If the corresponding file system includes a root file system, the root file system is determined as the specific file system, wherein after receiving the query request, if the root file system determines that there are other path components under the path component, the virtual file system is notified to re-determine the corresponding file system;
[0039] If the corresponding file system includes a common file system, the common file system is determined to be the specific file system.
[0040] According to a second aspect of the present disclosure, a path resolution device is provided. The device comprises:
[0041] A receiving module, used for receiving a file access request from a client;
[0042] A processing module, used for extracting the path in the file access request and storing the path in a shared memory;
[0043] The parsing module is used to call the virtual file system and / or the specific file system to parse the path in the shared memory to obtain a path parsing result.
[0044] According to a third aspect of the present disclosure, an electronic device is provided, which includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the program, the method described above is implemented.
[0045] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method according to the first aspect of the present disclosure is implemented.
[0046] According to a fifth aspect of the present disclosure, a vehicle is provided, the vehicle comprising the path resolution device as described in the second aspect and / or the electronic device as described in the third aspect.
[0047] In the present disclosure, after receiving a file access request from a client, the path in the file access request can be extracted and the path can be stored in a shared memory so as to automatically call the virtual file system and / or the specific file system, and then the path in the shared memory is parsed to obtain a path parsing result. In this way, since the shared memory is shared by the virtual file system and / or the specific file system, these file systems can all access it. Therefore, when performing path parsing, it is not necessary to repeatedly copy the path, but only to directly read the path from the shared memory, thereby reducing system overhead. Even for a microkernel system, since the path does not need to be copied and transferred between file systems, the IPC overhead of the microkernel system can be reduced.
[0048] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, among which:
[0050] Figure 1 A flow chart of a path resolution method according to an embodiment of the present disclosure is shown;
[0051] Figure 2 A schematic diagram of path resolution according to an embodiment of the present disclosure is shown;
[0052] Figure 3 A block diagram of a path resolution device according to an embodiment of the present disclosure is shown;
[0053] Figure 4 A block diagram of an exemplary electronic device capable of implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0055] In addition, the term "and / or" in this article is only a description of the association relationship between the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0056] Figure 1 FIG. 1 is a flow chart of a path resolution method 100 according to an embodiment of the present disclosure. Figure 1 As shown, the execution subject of method 100 may be an operating system or a CPU (central processing unit). Method 100 is particularly applicable to a microkernel operating system. The method may include:
[0057] Step 110, receiving a file access request from a client;
[0058] The file access request contains a path, which can be an absolute path or a relative path.
[0059] An absolute path refers to the absolute location under a directory, directly reaching the target location. It is usually a path starting from a drive letter, such as: c: / website / index.htm, c: / website / img / photo.jpg.
[0060] A relative path refers to the path relationship between the path of this file and other files (or folders). Using a relative path can bring a lot of convenience, such as img / photo.jpg.
[0061] The client is any upper-layer application running in the operating system, such as a chat application, entertainment application, etc.
[0062] A file access request may be a file read request or a file write request.
[0063] The request parameter passed in the file access request is generally a path, and sometimes includes the file handle (fd) of the currently opened file. For example,
[0064] int open(const char*pathname,int flags); pathname is the path, flags is the opening mode flag, which refers to the opening mode of the file corresponding to the path to be parsed, including opening in read-only mode, opening in write-only mode, or opening in readable and writable mode.
[0065] open() is a system call function used to open files. It is mainly used to create, open and operate files in the file system.
[0066] -pathname is the pathname of the file to be opened, which can be an absolute or relative path.
[0067] -flags is an integer parameter that specifies how to open the file and the mode of operation. Common flags include:
[0068] -'O_RDONLY': Open the file in read-only mode
[0069] -'O_WRONLY': Open the file for writing only
[0070] -'O_RDWR': open the file in both readable and writable mode
[0071] - 'O_CREAT': Create a new file if it does not exist
[0072] - `O_TRUNC`: truncate the file to 0, i.e. clear the file contents
[0073] -'O_APPEND': Append the content at the end of the file
[0074] int openat(int dirfd,const char*pathname,int flags), the explanation of the request parameters corresponding to this command is the same as above, except that compared with the previous command, there is one more file handle dirfd, specifically:
[0075] The openat() function is also used to open a file, but compared to open(), it provides more flexibility and can open a file by specifying a relative path based on a directory, where:
[0076] - 'dirfd' is a file handle that indicates the directory to which relative paths are to be resolved.
[0077] - 'pathname' is the relative pathname of the file to be opened.
[0078] - The meaning of the 'flags' parameter is the same as in the `open()` function.
[0079] Step 120, extracting the path in the file access request and storing the path in the shared memory;
[0080] Shared memory refers to a large-capacity memory that can be accessed by different central processing units (CPUs) in a multi-processor computer system; it allows two unrelated processes to access the same logical memory. Shared memory is a very efficient way to share and transfer data between two running processes.
[0081] The shared memory is a memory that can be directly accessed by both the virtual file system and the specific file system. To ensure the security of the shared memory, the virtual file system and the specific file system share the memory in a read-only manner.
[0082] Virtual file systems are VFS, and specific file systems are various FS (File Systems), including the root file system and the next level file system under the root file system, namely the ordinary file system.
[0083] Step 130: calling the virtual file system and / or the specific file system to parse the path in the shared memory to obtain a path parsing result.
[0084] In the embodiment of the present disclosure, the path resolution result can be a device identifier, wherein the device identifier is obtained after parsing the path in the shared memory, and the device identifier is used to indicate which disk the target file is located on, such as C drive, D drive, external U disk, external disk, etc.
[0085] In order to ensure that the client can access the target file more accurately and quickly, the path resolution result can also be a triplet, the three elements of which are the file handle, the device identifier and the file index.
[0086] The file handle is fd. At the operating system level, the file system also has a concept similar to FILE. In Linux, this is called a file descriptor, and in Windows, it is called a handle.
[0087] The file index is inode. Each file has a unique inode, which is used to store basic information of files and directories, including time, file name, user and group, etc.
[0088] The file index is carried in the file access request. The file handle is allocated by the virtual file system for the absolute path after the client sends the file access request to the virtual file system. Finally, the device identifier needs to be resolved based on the path in the shared memory. After the device identifier is resolved, it is combined with the file index and file handle to obtain the final path resolution result.
[0089] For example, a sample VFS triple might look like this:
[0090] (2,1,10)
[0091] In the above example, the VFS triplet describes the target file corresponding to a file access request on the file system. In the triplet, 2 is the file handle, which is allocated by VFS, 1 is the device identifier, and the file index 10 is the inode.
[0092] After receiving the file access request from the client, the path in the file access request can be extracted and stored in the shared memory so as to automatically call the virtual file system and / or the specific file system, and then the path in the shared memory is parsed to obtain the path parsing result. In this way, since the shared memory is shared by the virtual file system and / or the specific file system, these file systems can access it. Therefore, when performing path parsing, it is not necessary to repeatedly copy the path, but only need to directly read the path from the shared memory, thereby reducing system overhead. Even for a microkernel system, since the path does not need to be copied and transferred between file systems, the IPC overhead of the microkernel system can be reduced.
[0093] In some embodiments, extracting the path in the file access request and storing the path in a shared memory includes:
[0094] Determining whether the file access request contains an absolute path;
[0095] If included, extract the absolute path and store the absolute path in the shared memory;
[0096] The parsing of the path in the shared memory includes:
[0097] The absolute path in the shared memory is parsed.
[0098] Storing only the absolute path in the shared memory ensures that only the absolute path is accepted and resolved. If the absolute path is not included, no response is given to the file access request, so as to avoid confusing and inaccurate path resolution.
[0099] Of course, if the file access request does not contain an absolute path, that is, the file access request only contains a relative path, the relative path can be returned to the client, and then the client converts the relative path into an absolute path. The conversion process can be: after the relative path is decomposed, the decomposed relative path is converted into an absolute path using the getcwd interface and the chdir interface, where:
[0100] getcwd() will copy the absolute path of the current working directory to the memory space pointed to by the parameter buffer. The parameter maxlen is the size of the buffer space.
[0101] chdir is a system call function in C language (same as cd), which is used to change the current working directory. Its parameter is the Path target directory, which can be an absolute directory or a relative directory.
[0102] In some embodiments, before storing the path in the shared memory, the method further includes:
[0103] Determine whether the path is already stored in the shared memory;
[0104] Various parsed historical paths are pre-stored in the shared memory.
[0105] If the path is not stored, the path is stored in the shared memory.
[0106] By determining whether the path is already stored in the shared memory, the path can be stored in the shared memory only when the path is not stored. Otherwise, there is no need to store the path in the shared memory to avoid repeatedly storing the same path in the shared memory.
[0107] In some embodiments, before calling the virtual file system and / or the specific file system to parse the path in the shared memory, the method further includes:
[0108] If the path is stored, calling the correspondence between the pre-stored path and the path resolution result;
[0109] The path is matched with the corresponding relationship to obtain a path resolution result corresponding to the path.
[0110] The corresponding relationship between the path and the path resolution result may be stored or cached in any other location other than the shared memory.
[0111] If a path is stored, the correspondence between the pre-stored path and the path resolution result is called, and then the path is matched with the correspondence, so as to find the same path from the correspondence to obtain the path resolution result corresponding to the path as the final path resolution result. In this way, repeated parsing of the same path can be avoided, and the efficiency of obtaining the path resolution result can be improved, which can reduce system overhead.
[0112] In some embodiments, before storing the path in the shared memory, the method further includes:
[0113] Determine whether the path meets the preset path specification; wherein the preset path specification includes at least one of the following: whether the path has a trailing slash, whether the path is an absolute path, whether the path has extra slashes, whether the path has extra symbols, and whether the path has error symbols.
[0114] For example:
[0115] Determine whether the path in the file access request is an absolute path (for example, a / b / c is not standard)
[0116] Determine whether the path has a trailing slash (for example, / a / b / c / is not canonical)
[0117] Determine whether there are extra slashes in the path (for example, / a / b / / c is not standard)
[0118] Determine whether there are extra symbols such as "." in the path (for example, / a / . / b / c is not standard)
[0119] Determine whether there are any extra symbols such as ".." components in the path (for example, / a / b / .. / c is not standard)
[0120] If the preset path specification is met, an operation of storing the path in the shared memory is performed.
[0121] In some embodiments, if the preset path specification is not met, the path is discarded.
[0122] By judging whether the path meets the preset path specification, the path can be directly discarded if it does not meet the preset path specification, and the path can be directly stored in the shared memory if it meets the preset path specification. In this way, it can be ensured that only the path that meets the preset path specification is stored and parsed, which can further solve the confusion and inaccuracy of path parsing, improve the efficiency of path parsing, and reduce system overhead.
[0123] In some embodiments, the path includes an absolute path, and the calling of the virtual file system and / or the specific file system to parse the absolute path in the shared memory to obtain a path parsing result includes:
[0124] Calling the virtual file system and / or the specific file system to match the absolute path with the directory under the mount point managed by itself;
[0125] Among them, the mount point is actually the entry directory of the disk file system in Linux, similar to the drive letters such as C:, D:, E: used to access different partitions in Windows.
[0126] Secondly, no matter it is a virtual file system or a specific file system, the number of mount points it manages may be one or more, and the number of directories under each mount point may also be one or more.
[0127] Since there are many directories under the mount point, and each directory is essentially composed of an absolute path, and the absolute path starts from the root directory and points to the device where each file is located, therefore, matching the absolute path with the directory under the mount point managed by itself can accurately determine the device identifier of the device where the file to be accessed is located, which lays the foundation for obtaining an accurate path triple.
[0128] If there is a match, determining the device identifier of the device where the file to be accessed is located according to the target directory in the directory that matches the absolute path;
[0129] The device identifier of the device where the to-be-accessed file is located is determined as the path resolution result of the absolute path.
[0130] After calling the virtual file system and / or the specific file system, the virtual file system and / or the specific file system can automatically match the absolute path with the directory under the mount point managed by itself. If there is a match, the device identifier of the device where the file to be accessed is located is accurately determined based on the target directory in the directory under the mount point that matches the absolute path, and the device identifier of the device where the file to be accessed is located is determined as the path resolution result of the absolute path, thereby achieving the ability to use the virtual file system and / or the specific file system to accurately obtain the path resolution result.
[0131] In some embodiments, after determining the device identifier of the device where the to-be-accessed file is located and before determining the device identifier of the device where the to-be-accessed file is located as the path resolution result of the absolute path, the method further includes:
[0132] Obtaining a file index carried in the file access request;
[0133] According to the order of available file handles in the file handle array, the file handle currently at the top of the order is determined as the file handle allocated for the absolute path;
[0134] The device identifier, the file index and the file handle are combined to obtain a path triplet corresponding to the absolute path; wherein the path triplet is used to uniquely identify the file to be accessed corresponding to the absolute path;
[0135] In the embodiment of the present disclosure, in order to access the target file more accurately and quickly, the path resolution result can also be a triplet, the three elements of which are the file handle, the device identifier and the file index, respectively.
[0136] The device identifier includes, but is not limited to, a unique identifier such as a drive letter that can represent the device where the file to be accessed is located.
[0137] The file index is carried in the file access request;
[0138] Among them, according to the order of available file handles in the file handle array, the file handle that is currently at the top of the order can be determined as the file handle allocated for the absolute path;
[0139] For example, the file handle array is [1, 2, 3, 4, 5, 6, 7, 8, 9]. When the first path triplet is created, the file handle is 1. When the second path triplet is created, the file handle is 2. When the third path triplet is created, the file handle is 3. However, if the first path triplet is destroyed, the file handle 1 becomes available, and the next time a path triplet is created, the file handle can be 1.
[0140] After obtaining the device identifier, file index and file handle, in order to obtain the path triplet corresponding to the absolute path, the device identifier, file index and file handle are combined. Specifically, when combining, the combination order of these three elements is not limited by this disclosure and can be freely combined.
[0141] The file index is carried in the file access request, and the file handle is allocated by the virtual file system to the absolute path after the client sends the file access request to the virtual file system.
[0142] The path parsing result of determining the device identifier of the device where the file to be accessed is located as the absolute path includes:
[0143] The path triplet is determined as a path resolution result of the absolute path.
[0144] Since there are many directories under the mount point, and each directory is essentially composed of absolute paths, and the absolute path starts from the root directory and points to the device where each file is located, after determining the target directory, the device identifier of the device where the file to be accessed is located can be accurately determined, and then combined with the file index and file handle, the accurate path triplet can be obtained, and the path triplet is used as the final path resolution result.
[0145] In some embodiments, calling the virtual file system and / or the specific file system to match the absolute path in the shared memory with the directory under the mount point managed by itself includes:
[0146] Calling the virtual file system to match the absolute path with the directory under the mount point managed by itself;
[0147] If it is determined that the absolute path does not match any directory under the mount point managed by the virtual file system, the virtual file system is controlled to send a query request to the specific file system, so that the specific file system reads the absolute path from the shared memory according to the path tag of the absolute path carried in the query request, and then matches the absolute path with the directory under the mount point managed by itself.
[0148] The query request may be a notification rather than a message, thereby reducing the number of communications between the virtual file system and the specific file system, thus reducing system overhead.
[0149] When matching, the virtual file system can be called first to match the absolute path with the directory under the mount point managed by itself. If the virtual file system determines that the absolute path does not match the directory under the mount point managed by the virtual file system, it means that the virtual file system cannot resolve the absolute path. Therefore, the virtual file system can be controlled to send a query request to the specific file system, so that the specific file system reads the absolute path from the shared memory according to the path tag of the absolute path carried in the query request, and then matches the absolute path with the directory under the mount point managed by itself. In this way, the specific file system resolves the absolute path. Due to the existence of shared memory, the query request only needs to carry the path tag of the absolute path, and there is no need to repeatedly copy the absolute path. Therefore, the system overhead is reduced, especially the IPC overhead in the microkernel system is reduced, which also improves the performance of the file system layer.
[0150] In some embodiments, before controlling the virtual file system to send a query request to the specific file system, the method further includes:
[0151] Controlling the virtual file system to determine a corresponding file system based on the path component of the absolute path;
[0152] An absolute path is composed of many path components. For example, the path components of the absolute path c: / website / index.htm include: c:, / , website, / and index.htm. Of course, these path components can also be combined with each other, such as c: / , c: / website, c: / website / .
[0153] If the corresponding file system includes a root file system, the root file system is determined as the specific file system, wherein after receiving the query request, if the root file system determines that there are other path components under the path component, the virtual file system is notified to re-determine the corresponding file system;
[0154] For example, if an absolute path is: / mnt / path / to / file.txt, the file system corresponding to the path component / mnt is the root file system, and if the absolute path does not include mnt, the corresponding file system is a normal file system.
[0155] If the corresponding file system includes a common file system, the common file system is determined to be the specific file system.
[0156] When the absolute path is known, the virtual file system can determine all path components in the absolute path, and then determine the corresponding file system based on the path components. If the corresponding file system includes a root file system, the root file system is determined as the specific file system to facilitate parsing the absolute path through the root file system. Of course, if the root file system determines that there are other path components under the path component (such as the root file system finds that there are path components such as path under the / mnt path component), the root file system will notify the virtual file system to re-determine the corresponding file system in order to reduce the burden; of course, if the corresponding file system includes an ordinary file system, the ordinary file system can be directly determined as the specific file system to parse the absolute path through the ordinary file system.
[0157] The technical solution of the present disclosure is further described below:
[0158] The operating system of the present disclosure manages a buffer (PLB), which is a circular buffer for storing absolute paths to be resolved and historical absolute paths that have been resolved;
[0159] PLB is a shared memory that each specific file system service shares with VFS in read-only mode to avoid the need to repeatedly copy paths between VFS and multiple specific servers.
[0160] The following will be combined Figure 2 Further explain the technical solution of the present disclosure:
[0161] 1. The client's path access request is open(" / mnt / path / to / file.txt"). In the open function of libc, the received path name is sent to VFS. Among them, libc is the ANSI C function library under Linux.
[0162] 2. VFS calls the PLB insertion function based on the absolute path passed in and adds the absolute path to the above shared memory.
[0163] 3. Each service determines whether it needs to provide services based on the absolute path passed in and the directory under the mount point it controls. VFS itself handles a special mount point / . VFS checks whether the directory under the mount point / it manages matches the absolute path. If neither matches, the absolute path is forwarded to the corresponding specific file system service and ENOENT is returned (that is, there is no such file or directory).
[0164] 4. VFS finds that there is a path component / mnt in / mnt / path / to / file.txt, and the file system corresponding to / mnt is the root file system. Therefore, OUT_LOOKUP is called at this time to forward the query request carrying the path mark to the root file system for search. The root file system finds that there are other path components such as path under the above path component / mnt, so ENOENT is still returned.
[0165] 5. VFS forwards the query request to the remaining specific file systems (i.e., all ordinary file systems) based on the return message indicating that it still needs to search. Finally, among all ordinary file systems, if the file system ext4fs finds the absolute path in the directory under the mount point it manages, it returns EOK and a VFS triplet to indicate that the path search is complete. Of course, if all ordinary file systems do not find the absolute path in the directory under the mount point they manage, it returns ENOENT, indicating that a specific file system that can provide the service cannot be found, and returns errno to inform open() that the call to this path has failed.
[0166] Through the above scheme, the present disclosure reduces the amount of information in communication, thereby reducing system overhead, and can especially reduce the IPC overhead between file systems under the microkernel, thereby improving the performance of the file system.
[0167] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present disclosure is not limited by the order of the actions described, because according to the present disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0168] The above is an introduction to the method embodiment. The following is a further explanation of the scheme disclosed in the present invention through an apparatus embodiment.
[0169] Figure 3 FIG. 3 shows a block diagram of a path resolution device 300 according to an embodiment of the present disclosure. Figure 3 As shown, the device 300 includes:
[0170] Receiving module 310, used to receive a file access request from a client;
[0171] The processing module 320 is used to extract the absolute path in the file access request and store the path in the shared memory;
[0172] The parsing module 330 is used to call the virtual file system and / or the specific file system to parse the absolute path in the shared memory to obtain a path parsing result.
[0173] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the described module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0174] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device, including:
[0175] at least one processor; and
[0176] a memory communicatively connected to the at least one processor; wherein,
[0177] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform any of the above method embodiments.
[0178] According to an embodiment of the present disclosure, the present disclosure further provides a vehicle, comprising: a path parsing device as described in the above embodiment or an electronic device as described in the above embodiment.
[0179] According to an embodiment of the present disclosure, the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute any one of the above method embodiments.
[0180] Figure 4 A schematic block diagram of an electronic device 400 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0181] The device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0182] A number of components in the device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0183] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above, such as method 100. For example, in some embodiments, the method 100 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 404. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, one or more steps of the method 100 described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to perform the method 100 in any other appropriate manner (e.g., by means of firmware).
[0184] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0185] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0186] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0187] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0188] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0189] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0190] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0191] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A path resolution method, characterized in that: include: Receive a file access request from a client; Extracting the path in the file access request and storing the path in the shared memory; The virtual file system and / or the specific file system are called to parse the path in the shared memory to obtain a path parsing result.
2. The method according to claim 1, characterized in that The extracting the path in the file access request and storing the path in a shared memory includes: Determining whether the file access request contains an absolute path; If included, extract the absolute path and store the absolute path in the shared memory; The parsing of the path in the shared memory includes: The absolute path in the shared memory is parsed.
3. The method according to claim 1, characterized in that Before storing the path in the shared memory, the method further includes: Determine whether the path is already stored in the shared memory; If the path is not stored, the path is stored in the shared memory.
4. The method according to claim 3, characterized in that Before calling the virtual file system and / or the specific file system to parse the path in the shared memory, the method further includes: If the path is stored, calling the correspondence between the pre-stored path and the path resolution result; The path is matched with the corresponding relationship to obtain a path resolution result corresponding to the path.
5. The method according to claim 1, characterized in that Before storing the path in the shared memory, the method further includes: Determine whether the path meets the preset path specification; wherein the preset path specification includes at least one of the following: whether the path has a trailing slash, whether the path is an absolute path, whether the path has extra slashes, whether the path has extra symbols, and whether the path has an error symbol; If the preset path specification is met, an operation of storing the path in the shared memory is performed.
6. The method according to claim 5, characterized in that The method further comprises: If the preset path specification is not met, the path is discarded.
7. The method according to claim 1, characterized in that The path includes an absolute path, and the calling of the virtual file system and / or the specific file system to parse the path in the shared memory to obtain a path parsing result includes: Calling the virtual file system and / or the specific file system to match the absolute path with the directory under the mount point managed by itself; If there is a match, determining the device identifier of the device where the file to be accessed is located according to the target directory in the directory that matches the absolute path; The device identifier of the device where the to-be-accessed file is located is determined as the path resolution result of the absolute path.
8. The method according to claim 7, characterized in that After determining the device identifier of the device where the to-be-accessed file is located, and before determining the device identifier of the device where the to-be-accessed file is located as the path resolution result of the absolute path, the method further includes: Obtaining a file index carried in the file access request; According to the order of available file handles in the file handle array, the file handle currently at the top of the order is determined as the file handle allocated for the absolute path; The device identifier, the file index and the file handle are combined to obtain a path triplet corresponding to the absolute path; wherein the path triplet is used to uniquely identify the file to be accessed corresponding to the absolute path; The path parsing result of determining the device identifier of the device where the file to be accessed is located as the absolute path includes: The path triplet is determined as a path resolution result of the absolute path.
9. The method according to claim 7, characterized in that: The calling of the virtual file system and / or the specific file system to match the absolute path in the shared memory with the directory under the mount point managed by itself includes: Calling the virtual file system to match the absolute path with the directory under the mount point managed by itself; If it is determined that the absolute path does not match any directory under the mount point managed by the virtual file system, the virtual file system is controlled to send a query request to the specific file system, so that the specific file system reads the absolute path from the shared memory according to the path tag of the absolute path carried in the query request, and then matches the absolute path with the directory under the mount point managed by itself.
10. The method according to claim 9, characterized in that Before controlling the virtual file system to send a query request to the specific file system, the method further includes: Controlling the virtual file system to determine a corresponding file system based on the path component of the absolute path; If the corresponding file system includes a root file system, the root file system is determined as the specific file system, wherein after receiving the query request, if the root file system determines that there are other path components under the path component, the virtual file system is notified to re-determine the corresponding file system; If the corresponding file system is a common file system, the common file system is determined as the specific file system.
11. A path parsing device, characterized in that: include: A receiving module, used for receiving a file access request from a client; A processing module, used for extracting the path in the file access request and storing the path in a shared memory; The parsing module is used to call the virtual file system and / or the specific file system to parse the path in the shared memory to obtain a path parsing result.
12. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.
13. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-10.
14. A vehicle, characterized in that: include: The apparatus as claimed in claim 11, and / or the electronic device as claimed in claim 12, and / or the readable storage medium as claimed in claim 13.
