File access method and system based on Gawan operating system
By establishing a virtual root directory and a virtual directory tree in the Hongmeng operating system, multiple parallel root directory scenarios of the file management system when the root directory is inaccessible, and adaptation and flexible configuration of the inaccessible file system are achieved.
Patent Information
- Application Number
- CN202411680703.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-14
AI Technical Summary
When the root directory is not accessible, the existing file management system cannot effectively handle multiple parallel root directory scenarios, resulting in the inability to access the files.
By establishing a virtual root directory and a virtual directory tree in the Hongmeng operating system, a mapping relationship table from subdirectories to real paths is generated, thereby realizing file access.
When the original system root directory is not accessible, the files in the lower directory can still be accessed, which enables adaptation to the inaccessible file system and provides more flexible file system configuration options.
Smart Images

Figure CN119621678A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of file system technology, and in particular, to a file access method and file system based on Hongmeng operating system. Background Art
[0002] As the basic software of PC system, file management system is mainly used for user file display, providing user file operation interaction, etc. The default rule of existing file management system is to load and display from the root directory ( / ), and users can access each directory level by level. However, when the access to the root directory ( / ) is restricted, the next level directory will become the root directory. At this time, multiple parallel root directories with no mutual dependence will exist but cannot be accessed. Therefore, the traditional single root directory method cannot meet the file access needs when the root directory is inaccessible.
[0003] For example, Figure 2 As shown, in the prior art, files are loaded and displayed from the system root directory by default, and the accessible file structure is a tree type. The root directory is set to / , and all files are obtained according to the hierarchical relationship.
[0004] In the openharmony system, different applications have different directories that they have access to, and often the root directory cannot be accessed. When the root directory ( / ) of the current system is inaccessible due to lack of permissions, it is impossible to list all accessible directories, that is, it is impossible to list all top-level directory (directory below the root directory) entries from the root directory. Since multiple top-level parallel directories have no parent-child relationship with each other, it is impossible to obtain all files from the root directory ( / ) level by level as in the default state. Summary of the invention
[0005] One of the purposes of the embodiments of the present invention is to provide a file access method and file system based on the Hongmeng operating system, so that when the original system root directory cannot be accessed, file access to the directories at the following levels can still be performed.
[0006] In order to solve the above technical problems, in a first aspect, an embodiment of the present invention provides a file access method based on the Hongmeng operating system, the method comprising:
[0007] When the application is started, a virtual directory tree corresponding to the application and a mapping relationship table from subdirectories of the virtual directory tree to real paths are obtained;
[0008] Obtaining a complete file access path for each file under the subdirectory according to the virtual directory tree and the mapping relationship table;
[0009] The file is accessed according to the complete file access path.
[0010] Furthermore, the method further comprises:
[0011] Before the application is started, the method further includes: for each application, establishing a virtual root directory corresponding to the application;
[0012] The highest level directory of the plurality of discrete directory trees that the application is allowed to access is used as a subdirectory of the virtual root directory, thereby generating a complete virtual directory tree;
[0013] The virtual directory tree is traversed to construct a mapping relationship table from each subdirectory of the virtual directory tree to a real path.
[0014] Furthermore, the method further comprises:
[0015] When the file system is updated, a file access error occurs, or a file is added or deleted, the virtual directory tree is updated, and the mapping relationship table from the subdirectories of the virtual directory tree to the real paths is updated.
[0016] Furthermore, the method further comprises:
[0017] According to user requirements, the highest-level directories of multiple discrete directory trees that the application is allowed to access are configured, and the configured highest-level directories are used as subdirectories of the virtual root directory.
[0018] In a second aspect, in order to solve the technical problem of the embodiment of the present invention, the embodiment of the present invention further provides a file system based on the Hongmeng operating system, and the system includes:
[0019] A virtual directory tree acquisition unit, used to acquire the virtual directory tree corresponding to the application and a mapping relationship table from subdirectories of the virtual directory tree to real paths when the application is started;
[0020] A path calculation unit, wherein the user obtains a complete file access path of each file under the subdirectory according to the virtual directory tree and the mapping relationship table;
[0021] The file access unit is used to access the file according to the complete file access path.
[0022] Furthermore, the system also includes:
[0023] A virtual root directory construction unit, used to establish a virtual root directory corresponding to each application before the application is started;
[0024] A virtual directory tree generating unit, used to use the highest level directory of a plurality of discrete directory trees that the application is allowed to access as a subdirectory of the virtual root directory, thereby generating a complete virtual directory tree;
[0025] The mapping unit is used to traverse the virtual directory tree and construct a mapping relationship table from each subdirectory of the virtual directory tree to a real path.
[0026] Furthermore, the system also includes:
[0027] The virtual directory tree updating unit is used to update the virtual directory tree and update the mapping relationship table from the subdirectories of the virtual directory tree to the real paths when the file system is updated, a file access error occurs, or a file is added or deleted.
[0028] Preferably, the virtual directory tree generation unit configures the highest-level directories of a plurality of discrete directory trees that the application is allowed to access according to user requirements, and uses the configured highest-level directories as subdirectories of the virtual root directory.
[0029] On the third aspect, in order to solve the technical problems of the embodiments of the present invention, the embodiments of the present invention also provide a computer device based on the Hongmeng operating system, the computer device includes a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions based on the Hongmeng operating system software, and the processor is configured to call the program instructions to execute the method as described above.
[0030] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions based on Hongmeng operating system software, and wherein the program instructions based on Hongmeng operating system software, when executed by a processor or a computer, enable the processor or the computer to execute the method as described above.
[0031] Compared with the prior art, a file access method and file system based on the Hongmeng operating system provided by an embodiment of the present invention have at least the following beneficial effects: file management supports the display of all accessible directories and files through a virtual root directory when there is no root directory due to non-standard or permission issues that cause the actual root directory to be inaccessible, thereby achieving a more general solution to adapt to scenarios where the file system cannot be accessed under different circumstances, and at the same time providing users with more flexible file system configuration options, namely, realizing personally preferred file management settings through customizing the virtual root directory. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The preferred implementation modes will be described below in a clear and understandable manner with reference to the accompanying drawings to further illustrate the above-mentioned characteristics, technical features, advantages and implementation methods of the present invention.
[0033] Figure 1 This is a flow chart of a file access method based on the Hongmeng operating system according to an embodiment of the present invention;
[0034] Figure 2 A schematic diagram of a tree-type file structure in which files are loaded and displayed from a system root directory by default in the prior art;
[0035] Figure 3 A schematic diagram of a system problem in the prior art causing the root directory and subdirectories to be inaccessible;
[0036] Figure 4 When the root directory ( / ) is inaccessible in the prior art, the highest-level directory that can be accessed;
[0037] Figure 5 This is a schematic diagram of file access results of a virtual root directory based on the Hongmeng operating system according to an embodiment of the present invention;
[0038] Figure 6 This is a flow chart of a file access method based on a virtual root directory of the Hongmeng operating system according to an embodiment of the present invention;
[0039] Figure 7 A schematic diagram of the structure of a file system based on the Hongmeng operating system according to an embodiment of the present invention;
[0040] Figure 8 A schematic diagram of the structure of a computer device that implements a file access method based on the Hongmeng operating system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the specific implementation methods of the present invention will be described below with reference to the accompanying drawings. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings and other implementation methods can be obtained based on these drawings without creative work.
[0042] In order to simplify the drawings, only the parts related to the invention are schematically shown in each figure, and they do not represent the actual structure of the product. In addition, in order to simplify the drawings and facilitate understanding, in some figures, only one of the parts with the same structure or function is schematically drawn or marked. In this article, "one" not only means "only one", but also means "more than one".
[0043] The following mainly takes some specific embodiments as examples to describe in detail the implementation of the technical solution of the present invention.
[0044] like Figure 1 As shown, in order to achieve the purpose of the invention, an embodiment of the present invention provides a file access method based on the Hongmeng operating system, and the method includes:
[0045] S1. When an application is started, a virtual directory tree corresponding to the application and a mapping relationship table from subdirectories of the virtual directory tree to real paths are obtained;
[0046] S2. Obtaining a complete file access path for each file under the subdirectory according to the virtual directory tree and the mapping relationship table;
[0047] S3. Access the file according to the complete file access path.
[0048] The following describes in detail the implementation principle and specific implementation method of the file access method based on the Hongmeng operating system in an embodiment of the present invention.
[0049] like Figure 2 As shown, for the file system of the prior art, an example is given by taking the general Linux system as a prototype. It is assumed that the following subdirectories / etc, / lib64, proc and / mnt / hmdfs / 100 / account currently exist. In the current case, the subdirectories under the root directory and their subordinate structure files are accessible. Currently, all subdirectories and their subordinate directories can be obtained by setting the directory relationship of the root directory.
[0050] like Figure 3 As shown in the figure, when the system switches or other reasons occur, the root directory and subdirectory / mnt / hmdfs / cannot be accessed.
[0051] At this time, if Figure 4 As shown, when all files cannot be listed by accessing the root directory ( / ), the / etc, / lib64, / proc, and / mnt / hmdfs / UserId directories become the highest-level directories currently accessible. However, since the prior art uses a fixed access entry, if an access path is set that can only be accessed from a certain highest-level directory, only files under the currently set access path can be obtained, and other top-level paths cannot be obtained. For example, if etc is set as the highest-level accessible directory, only files under the etc directory can be obtained.
[0052] like Figure 5 As shown, in the embodiment of the present invention, before the application is started, for each application, a virtual root directory corresponding to the application is established;
[0053] The highest level directory of the plurality of discrete directory trees that the application is allowed to access is used as a subdirectory of the virtual root directory, thereby generating a complete virtual directory tree;
[0054] The virtual directory tree is traversed to construct a mapping relationship table from each subdirectory of the virtual directory tree to a real path.
[0055] The creation of the above-mentioned virtual root directory and the generation of the virtual directory tree are generally created when the application is installed; they may also run silently in the background at some time after the installation.
[0056] The virtual root directory here is not a real directory, but a virtual file relationship constructed through the following logic: The file name is constructed to the real path mainly to piece together the complete path for subsequent access, in the form of {{"etc"," / etc"},{"UserId"," / mnt / hmdfs / UserId"}}.
[0057] by Figure 3 For example, the currently accessible highest-level parallel directories are / etc, / lib64, / proc, / mnt / hmdfs / UserId. You can also configure the highest-level directories of multiple discrete directory trees that the application is allowed to access based on user needs, and use the configured highest-level directories as subdirectories of the virtual root directory.
[0058] For example, Figure 3 As shown, by removing / lib64, the current top-level directories are / etc, / proc, and / mnt / hmdfs / UserId;
[0059] Create a virtual root directory and add each currently accessible highest-level parallel directory name as a child node of the virtual root directory.
[0060] For example, Figure 5 As shown, after loading, the child nodes under the root directory are etc, UserId, lib64, and proc.
[0061] When the application is started, the virtual directory tree corresponding to the application and the mapping relationship table from the subdirectories of the virtual directory tree to the real paths are obtained; the complete file access path of each file under the subdirectory is obtained according to the virtual directory tree and the mapping relationship table; and file access is performed according to the complete file access path.
[0062] In addition, when the file system is updated, a file access error occurs, or a file is added or deleted, the virtual directory tree is updated, and the mapping relationship table from the subdirectories of the virtual directory tree to the real paths is updated.
[0063] In one implementation of the embodiment of the present invention, before accessing a file, a mapping relationship is only established for the subdirectory, and a mapping relationship is not established for all files, that is:
[0064] In the construction of the mapping relationship between the subdirectory of each virtual root directory and the real path, when it is actually necessary to access a file under a certain subdirectory, a mapping relationship between all files under the subdirectory of the virtual root directory and the real path is constructed;
[0065] Then, according to the mapping relationship between all files in the subdirectories of each virtual root directory and the real path and the virtual root directory, the complete file access path of each file in the subdirectory is obtained, and the file is accessed according to the complete file access path.
[0066] In another implementation manner of the embodiment of the present invention, before accessing a file, in addition to establishing a mapping relationship for a subdirectory, it also includes constructing a mapping relationship from all files under the subdirectory to a real path; in this manner, when accessing a file, based on the mapping relationship from all files under the subdirectory of each virtual root directory to the real path and the virtual root directory, a complete file access path for each file under the subdirectory is obtained, and file access is performed based on the complete file access path.
[0067] The file access process flow is as follows Figure 6 As shown:
[0068] To access Figure 5 Taking the directory account as an example, the access path is Userld / account. The real path corresponding to the root node Userld obtained through the virtual root node path mapping is / mnt / hmdfs / UserId( Figure 3 For example). The complete access path of account is / mnt / hmdfs / UserId / account, which is used to access the account directory, read and display file data.
[0069] like Figure 7 As shown, in order to solve the technical problem of the embodiment of the present invention, the embodiment of the present invention further provides a file system based on the Hongmeng operating system, and the system includes:
[0070] A virtual directory tree acquisition unit, used to acquire the virtual directory tree corresponding to the application and a mapping relationship table from subdirectories of the virtual directory tree to real paths when the application is started;
[0071] A path calculation unit, wherein the user obtains a complete file access path of each file under the subdirectory according to the virtual directory tree and the mapping relationship table;
[0072] The file access unit is used to access the file according to the complete file access path.
[0073] Furthermore, the system also includes:
[0074] A virtual root directory construction unit, used to establish a virtual root directory corresponding to each application before the application is started;
[0075] A virtual directory tree generating unit, used to use the highest level directory of a plurality of discrete directory trees that the application is allowed to access as a subdirectory of the virtual root directory, thereby generating a complete virtual directory tree;
[0076] The mapping unit is used to traverse the virtual directory tree and construct a mapping relationship table from each subdirectory of the virtual directory tree to a real path.
[0077] Furthermore, the system also includes:
[0078] The virtual directory tree updating unit is used to update the virtual directory tree and update the mapping relationship table from the subdirectories of the virtual directory tree to the real paths when the file system is updated, a file access error occurs, or a file is added or deleted.
[0079] Preferably, the virtual directory tree generation unit configures the highest-level directories of a plurality of discrete directory trees that the application is allowed to access according to user requirements, and uses the configured highest-level directories as subdirectories of the virtual root directory.
[0080] The implementation of the file system based on the Hongmeng operating system corresponds one to one with the implementation method of the aforementioned file access method based on the Hongmeng operating system, and will not be repeated here.
[0081] Compared with the prior art, a file access method and file system based on the Hongmeng operating system provided by an embodiment of the present invention have at least the following beneficial effects: file management supports the display of all accessible directories and files through a virtual root directory when there is no root directory due to non-standard or permission issues that cause the actual root directory to be inaccessible, thereby achieving a more general solution to adapt to scenarios where the file system cannot be accessed under different circumstances, and at the same time providing users with more flexible file system configuration options, namely, realizing personally preferred file management settings through customizing the virtual root directory.
[0082] On the third aspect, in order to solve the technical problems of the embodiments of the present invention, the embodiments of the present invention also provide a computer device based on the Hongmeng operating system, the computer device includes a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions based on the Hongmeng operating system software, and the processor is configured to call the program instructions to execute the method as described above.
[0083] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions based on Hongmeng operating system software, and wherein the program instructions based on Hongmeng operating system software, when executed by a processor or a computer, enable the processor or the computer to execute the method as described above.
[0084] like Figure 8 As shown, a computer device provided in an embodiment of the present application, the computer device 1000 includes a processor or a calculator (not shown in the figure) 1001 and a memory 1002, and the processor or the calculator 1001 and the memory 1002 can be interconnected through a communication bus 1003. The communication bus 1003 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus 1003 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the memory 1002 is used to store a computer program, and the computer program includes program instructions. The processor 1001 is configured to call the program instructions, and the above program includes a method for executing some or all of the steps in the aforementioned method.
[0085] The processor 1001 may be a general purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the above program.
[0086] The memory 1002 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor via a bus. The memory may also be integrated with the processor.
[0087] The electronic device 1000 may further include a communication module 1004 and a display 1005. The communication module 1004 may be connected to the optical tracking device for communication. The communication module 1004 may be a wireless communication module (eg, a WiFi module, a Bluetooth module, etc.) or a wired communication module.
[0088] In addition, the electronic device 1000 may also include common components such as a communication interface (eg, a USB interface, a microphone interface, etc.), an antenna, etc., which will not be described in detail here.
[0089] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, 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 preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0090] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0091] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0092] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0093] In addition, the functional units in the various embodiments of the application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware or in the form of software program modules.
[0094] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0095] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, which can include: a flash drive, a read-only memory, a random access memory, a magnetic disk or an optical disk, etc.
[0096] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
[0097] It should be noted that the above embodiments can be freely combined as needed. The above are only preferred embodiments of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be regarded as the protection scope of the present invention.
Claims
1. A file access method based on Hongmeng operating system, characterized in that: The method comprises: When the application is started, a virtual directory tree corresponding to the application and a mapping relationship table from subdirectories of the virtual directory tree to real paths are obtained; Obtaining a complete file access path for each file under the subdirectory according to the virtual directory tree and the mapping relationship table; The file is accessed according to the complete file access path.
2. The file access method based on Hongmeng operating system as claimed in claim 1, characterized in that: Before the application is started, the method further includes: for each application, establishing a virtual root directory corresponding to the application; The highest level directory of the plurality of discrete directory trees that the application is allowed to access is used as a subdirectory of the virtual root directory, thereby generating a complete virtual directory tree; The virtual directory tree is traversed to construct a mapping relationship table from each subdirectory of the virtual directory tree to a real path.
3. The file access method based on Hongmeng operating system as claimed in claim 2, characterized in that: The method further comprises: When the file system is updated, a file access error occurs, or a file is added or deleted, the virtual directory tree is updated, and the mapping relationship table from the subdirectories of the virtual directory tree to the real paths is updated.
4. The file access method based on Hongmeng operating system as claimed in claim 2, characterized in that: The method further comprises: According to user requirements, the highest-level directories of multiple discrete directory trees that the application is allowed to access are configured, and the configured highest-level directories are used as subdirectories of the virtual root directory.
5. A file system based on Hongmeng operating system, characterized in that: The system comprises: A virtual directory tree acquisition unit, used to acquire the virtual directory tree corresponding to the application and a mapping relationship table from subdirectories of the virtual directory tree to real paths when the application is started; A path calculation unit, wherein the user obtains a complete file access path of each file under the subdirectory according to the virtual directory tree and the mapping relationship table; The file access unit is used to access the file according to the complete file access path.
6. The file system based on Hongmeng operating system as claimed in claim 5, characterized in that: The system further comprises: A virtual root directory construction unit, used to establish a virtual root directory corresponding to each application before the application is started; A virtual directory tree generating unit, used to use the highest level directory of a plurality of discrete directory trees that the application is allowed to access as a subdirectory of the virtual root directory, thereby generating a complete virtual directory tree; The mapping unit is used to traverse the virtual directory tree and construct a mapping relationship table from each subdirectory of the virtual directory tree to a real path.
7. The file system based on Hongmeng operating system as claimed in claim 5, characterized in that: The system further comprises: The virtual directory tree updating unit is used to update the virtual directory tree and update the mapping relationship table from the subdirectories of the virtual directory tree to the real paths when the file system is updated, a file access error occurs, or a file is added or deleted.
8. The file system based on Hongmeng operating system as claimed in claim 7, characterized in that: The virtual directory tree generation unit configures the highest-level directories of multiple discrete directory trees that the application is allowed to access according to user requirements, and uses the configured highest-level directories as subdirectories of the virtual root directory.
9. A computer device based on Hongmeng operating system, characterized in that: The computer device includes a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions based on Hongmeng operating system software, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which includes program instructions based on Hongmeng operating system software. When the program instructions based on Hongmeng operating system software are executed by a processor or a computer, the processor or the computer executes the method as described in any one of claims 1 to 4.