Design method of domestic operating system compatible Windows drive
By identifying and mapping the registry files of Windows type disk partitions, it solves the problem of users not being able to find the C drive and D drive in domestic operating systems, enabling similar Windows drive letters to be displayed in domestic operating systems, reducing user switching costs. and risk of data loss.
Patent Information
- Application Number
- CN202411223615.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2024-10-01
AI Technical Summary
Users accustomed to the Windows operating system have difficulty finding the familiar C drive and D drive in domestic operating systems, leading to high learning costs and data loss problems.
By identifying the disk identifier, obtain the registry file of the Windows type disk partition, determine the mapping relationship between the disk partition and the drive letter, and store it in the drive letter mapping database to calculate the drive letter information of each disk partition for domestic operations. A drive letter similar to Windows is displayed on the system.
Correctly display the drive letters of Windows-type disk partitions in domestic operating systems, reducing user switching costs and discomfort. Even in unparalleled systems, the drive letters can be displayed according to Windows style.
Smart Images

Figure CN118733145A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a design method for making a domestic operating system compatible with Windows drive letters. Background Art
[0002] As the influence of domestic operating systems gradually expands, more and more users are beginning to choose domestic operating systems as their daily work systems. For ordinary users who are accustomed to Windows operating habits, the concepts of C drive and D drive are deeply rooted in the hearts of the people. In domestic operating systems, the file manager provides a graphical operation entrance for each partition. At present, in various domestic operating systems and other Linux distributions, each partition in the file manager is displayed as a custom label name, such as "data disk", "100 GB volume", etc. Because ordinary users do not know much about the difference between domestic operating systems and Windows and their habit of using Windows, they are accustomed to installing Windows and domestic operating systems at the same time and switching between them. However, because they cannot find the familiar C\D disk, the learning cost is high when they switch to the domestic operating system, and serious problems such as data loss when formatting the partition lead to a lot of complaints from users about the domestic operating system. Summary of the invention
[0003] To solve the above problems, the present invention provides a design method for making a domestic operating system compatible with Windows drive letters, which adopts the following technical solutions: A design method for making a domestic operating system compatible with Windows drive letters, comprising: At startup, identify the disk identifier and determine whether the device file system corresponding to each disk partition is of Windows type; Get the Windows registry file of the disk partition whose device file system is Windows type; Determine the mapping relationship between Windows-type disk partitions and drive letters in the domestic operating system based on the Windows registry file, and store the mapping relationship in a drive letter mapping database; The drive letter information corresponding to all disk partitions is calculated based on the drive letter mapping database.
[0004] In a possible implementation, at startup, a disk identifier is identified, and based on the disk identifier, it is determined whether the device file system corresponding to each disk partition is of the Windows type, including: At startup, identify the disk identifier through listWindowsDevicesAndPhysicalDisks and obtain the device information corresponding to each disk partition; Based on the device information, it is determined whether the device file system corresponding to each disk partition is of Windows type.
[0005] In a possible implementation, obtaining a Windows registry file of a disk partition whose device file system is of Windows type includes: The partition information corresponding to the disk partition whose device file system is Windows type is saved in the deviceWins data structure, wherein the partition information includes the device node and the sector starting point; Traverse and mount all Windows-type disk partitions through doDeviceMount; Traverse the mount paths of all mounted disk partitions to find the location of the Windows registry file, and obtain the Windows registry file based on the location of the Windows registry file.
[0006] In a possible implementation, the mapping relationship between the Windows-type disk partition and the drive letter in the domestic operating system is determined based on the Windows registry file, and the mapping relationship is stored in the drive letter mapping database, including: Step S301, loading the Windows registry file into the data table; Step S302, identifying HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices in the Windows registry file to obtain a mapping relationship between a mounted Windows-type disk partition and its assigned drive letter; Step S303, parsing the data table to determine the device node information of the persistent volumes corresponding to the Windows-type disk partitions in the domestic operating system; Step S304, based on step S302 and step S303, obtain the correspondence between the mounted Windows type disk partition and its assigned drive letter (such as C:D) and its device node under the domestic operating system, determine the mapping relationship between the Windows type disk partition and the drive letter in the domestic operating system from the corresponding relationship, and store the mapping relationship in the drive letter mapping database.
[0007] In a possible implementation, the drive letter information includes a drive letter and a partition name, and the drive letter corresponds to a drive letter count. The drive letter information corresponding to all disk partitions is calculated based on the drive letter mapping database, including: Step S401, sorting all the identified disk partitions according to preset rules in the domestic operating system to obtain a sorting result; Step S402, loading the drive letter mapping database; Step S403, based on the sorting result, a target child node is obtained from all child nodes under the Computer: / / / node. If the obtained result is empty, it is determined that there is no disk partition that needs to calculate the drive letter information. Each child node represents a disk partition and has a corresponding partition identifier. The partition identifier is a partition identifier identified in the domestic operating system. Step S404, matching the data recorded in the partition identifier corresponding to the target child node with the data in the drive letter mapping database, if the match succeeds, executing step S405, if the match fails, executing step S406; Step S405, determining the drive letter corresponding to the data in the drive letter database that successfully matches the partition identifier of the target subnode as the drive letter of the target subnode, and determining the drive letter count corresponding to the drive letter of the target subnode as the value of the global max variable, and proceeding to step S407; Step S406, obtaining the value of the global max variable in the current domestic operating system, and incrementing the value of the global max variable by 1 to obtain the drive letter count corresponding to the target child node, determining the drive letter count as the value of the global max variable and the drive letter corresponding to the drive letter count as the drive letter corresponding to the target child node, and continuing to execute step S407; Step S407, naming the target subnode, and obtaining the partition name corresponding to the target subnode; Step S408, integrating the drive letter obtained in step S405 or step S406 and the partition name obtained in step S407 to obtain the drive letter information of the disk partition represented by the target child node, and continuing to execute step S403.
[0008] In summary, this application includes the following beneficial technical effects: (1) In the case of dual system installation with Windows, in the domestic operating system, the drive letter of the Windows type disk partition is identified by parsing the Windows registry.
[0009] (2) In domestic operating systems, priority is given to ensuring that the drive letters of Windows-type disk partitions are correctly displayed, making it easier for Windows users to find their files in familiar locations, facilitating user operations and reducing switching costs.
[0010] (3) Even if there is no dual system installation, the domestic operating system will display the drive letter style of the Windows-type disk partition, reducing the user's discomfort when switching to the domestic operating system. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1It is a structural diagram of a design method for a domestic operating system compatible with Windows drive letters in an embodiment of the present application.
[0012] Figure 2 It is a flowchart of the Windows mapping table acquisition service in an embodiment of the present application.
[0013] Figure 3 It is a flowchart of the virtual file system service in an embodiment of the present application. DETAILED DESCRIPTION
[0014] The present application is further described in detail below in conjunction with the accompanying drawings.
[0015] After reading this specification, those skilled in the art may make non-creative modifications to this embodiment as needed, but such modifications are protected by patent law as long as they are within the scope of the claims of this application.
[0016] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0017] In addition, the term "and / or" in this article is only a description of the association relationship of 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, unless otherwise specified, generally means that the associated objects before and after are in an "or" relationship.
[0018] The embodiments of the present application are further described in detail below in conjunction with the drawings in the specification.
[0019] First, to facilitate understanding of this application, the abbreviations and key terms involved in this application are explained as follows: Partition: In domestic operating systems, a hard disk is usually partitioned, and each manufacturer has its own partitioning method. Partitions do not require drive letters, but are accessed through mount points. When the system starts, the administrator can choose to mount a specific partition to a specific location in the file system.
[0020] File manager: A program for viewing files and directories graphically in the Linux operating system. Common ones include caja, nemo, etc. The file manager of Kylin Desktop is peony.
[0021] GVFS: GVFS (GNOME Virtual File System) is a core component in a Linux-like desktop environment. It mainly provides a unified interface for applications to access various file systems, including local file systems and network file systems (such as FTP, SMB, SSH, etc.).
[0022] GIO: GIO is the interface layer of the GVFS (GNOME Virtual File System) framework, which aims to provide applications with a unified, high-performance I / O interface to access files and perform various I / O operations.
[0023] Windows Registry: Windows Registry is a core component of Windows operating system. It is a hierarchical database used to store operating system and application settings, user preferences, hardware configuration and other types of system and application data.
[0024] Drive letter: In Windows, hard disks are usually identified as "disk 0", "disk 1", etc., and partitions are represented by drive letters, such as C:, D:, E:, etc., starting from A: and B: (traditionally reserved for floppy disk drives) (but modern systems rarely see the actual use of A: and B:). The allocation of drive letters is linear, up to Z:. In this invention, C, D, E, F, etc. are all referred to as "drive letters". In programming, characters and integers can be converted to each other, such as C corresponds to 67, so the next drive letter can be calculated by incrementing.
[0025] Secondly, if Figure 1 As shown, this application is divided into three layers: service middle layer, application layer and service layer, among which, 1. Middle Layer The middle layer is the GIO library. The GIO library is used in this application, but its modification is not involved. In order to describe the implementation principle clearly, it is shown in the overall architecture.
[0026] 2. Application Layer Applications in the operating system that display the drive letter information of each disk partition in the system, such as file managers, partition editors, and USB disk management tools for external removable devices, obtain the drive letter information to be displayed through the middle layer GIO library. The actual drive letter information to be displayed is done in the service layer.
[0027] 3. Service Layer The service layer includes two startup services, each of which implements different functions. As follows: 1. Windows Mapping Table Acquisition Service This is a system-level boot-up service. When it starts, it mounts all Windows partitions by default, finds the mount directory where the Windows system is located, finds the Windows registry file, and parses the mapping relationship between the Windows disk partitions and their assigned drive letters (such as C: and D:, etc.). It is saved to the drive letter mapping database of the domestic system. In this application, this drive letter mapping database is named Windows.ini.
[0028] 2. Virtual File System Service correspond Figure 1 In the "gvfs computer backend" section, this is a session-level self-starting service. This service first parses the drive letter mapping database to find the disk partitions and their assigned drive letters in the Windows system. Assuming that there are C drive and D drive in the installed Windows, the drive letter mapping database stores two Windows-type partitions and their corresponding drive letters. Then the drive letter of the domestic operating system will be changed from D+1 (corresponding to Figure 1 In the end, the drive letter of the Windows system is still displayed as the drive letter of the Windows system in the domestic operating system. Other partitions of the domestic operating system are incremented based on the drive letter of the Windows system. Of course, if the user does not install the Windows system and there is no dual-system scenario, there is no need to obtain the drive letter mapping database. The drive letter of the domestic operating system starts from 0X43.
[0029] The important functions of this application are processed in the service layer. The specific implementation is as follows: 1. Windows Mapping Table Acquisition Service like Figure 2 As shown, the specific implementation process of Windows mapping table acquisition service is as follows: Step S1, at startup, identifying the disk identifier and determining whether the device file system corresponding to each disk partition is of Windows type.
[0030] For the embodiment of the present application, the disk identifier is identified through listWindowsDevicesAndPhysicalDisks, the device information corresponding to each disk partition is obtained, and then based on the device information, it is determined whether the device file system corresponding to each disk partition is of Windows type. Further, in the present application, the device file system of the disk partition may be of Linux type, Windows type, or swap type. Furthermore, when it is of swap type, the disk partition is directly skipped.
[0031] Step S2, obtaining a Windows registry file of a disk partition whose device file system is of Windows type.
[0032] For the embodiment of the present application, the Windows registry file is in binary format, generally a SYSTEM or SAM file name. Specifically, the Windows registry file is obtained through the following process: Step S201, save the partition information corresponding to the disk partition whose device file system is Windows type into the deviceWins data structure, where the partition information includes the device node and the sector start point.
[0033] Step S202: traverse and mount all Windows-type disk partitions through doDeviceMount.
[0034] For the embodiment of the present application, since the domestic operating system has the concept of multiple users, that is, after a user logs in, he can switch to another user. Consider such a scenario, after user test logs in, he mounts a partition to / media / test / label_name, and then switches to the kylin user. Since by default only the test user has access to the mount path " / media / test / ", the kylin user cannot access it. In order to ensure that each user can operate the data stored in these disk partitions, keep the same habits as Windows. In the embodiment of the present application, in step S201, the partition information corresponding to the linux type disk partition can be saved in the deviceLinus data structure at the same time, and then in step S202, all linux type disk partitions are traversed and mounted at the same time, and the permissions of all disk partitions are set to be readable and writable by everyone, so that even if the user is switched in the domestic operating system, the user can still operate in the disk partition (create files and delete files, etc.).
[0035] Step S203, traverse the mount paths of all mounted disk partitions, find the location of the Windows registry file, and obtain the Windows registry file based on the location of the Windows registry file.
[0036] For the embodiment of the present application, the location of the Windows registry file is generally in the directory Windows / System32 / config.
[0037] Step S3, determining the mapping relationship between Windows type disk partitions and drive letters in the domestic operating system based on the Windows registry file, and storing the mapping relationship in a drive letter mapping database.
[0038] In this application, Python's hivex is used to parse and determine the mapping relationship, which specifically includes the following process: Step S301, load the Windows registry file into the data table (corresponding to the attached Figure 2 in the Load Registry).
[0039] Step S302, identify HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices in the Windows registry file to obtain the mapping relationship between the mounted Windows type disk partition and its assigned drive letter (such as C:D). For example, the disk information is saved in the data table as follows: '\\DosDevices\\C:': (<WinDriverKindsEnum.KIND_FIXED_DISK: 0> ,[2502290984, 2048]).
[0040] Step S303, parse the data table to determine the device node information of the persistent volumes corresponding to the Windows-type disk partitions in the domestic operating system.
[0041] For the embodiment of the present application, the device node information refers to the identification of the disk partition in the domestic operating system, which is equivalent to its ID number. When the number of bytes of the disk information is different, the method of determining the device node information is different, specifically: When parsing the data table, the disk information read out is 12 bytes in total, then the first 4 bytes in reverse order are the id of the disk partition, and the last 4 bytes in reverse order are the offset of the disk partition, so as to find the device node information of the disk partition under the domestic operating system according to the id and offset of the disk partition; When the data table is parsed, the disk information read out is 24 bytes in total, indicating that it is in gpt format, that is, the first 8 bytes are in the order of DMIP:ID:, and the last 16 bytes are GUID. The so-called GUID is a string of 16 bytes of data. We cannot directly find the correspondence between this GUID and the disk partition under the domestic operating system, so we need to find it through the soft link file in the directory / dev / disk / by-partuuid / , so as to find the device node information of the disk partition under the domestic operating system.
[0042] Further, for ease of understanding, taking the dual system environment as an example, in the domestic operating system, load the installed Windows registry file, the data table is as follows: {'\\DosDevices\\C:': (<WinDriverKindsEnum.KIND_FIXED_DISK: 0>, [2502290984, 2048]), '\\DosDevices\\D:': (<WinDriverKindsEnum.KIND_FIXED_DISK: 0>, [2502290984, 180041336]), '\\DosDevices\\U:': (<WinDriverKindsEnum.KIND_OTHER: 6>, '{4aec0b92-859c-11ea-84ab-806e6f6e6963}#00000000366B5E00'), '\\DosDevices\\V:': (<WinDriverKindsEnum.KIND_OTHER: 6>, '{4aec0b92-859c-11ea-84ab-806e6f6e6963}#0000000766E0AE00'), '\\DosDevices\\J:': (<WinDriverKindsEnum.KIND_OTHER: 6>, '{ff2e5dc7-6fb4-11ed-867a-9c7e4c05722e}#0000000A7A400000'), '\\DosDevices\\G:': (<WinDriverKindsEnum.KIND_OTHER: 6>, '{ff2e5dc7-6fb4-11ed-867a-9c7e4c05722e}#0000000780200000'), '\\DosDevices\\H:': (<WinDriverKindsEnum.KIND_OTHER: 6>, '{ff2e5dc7-6fb4-11ed-867a-9c7e4c05722e}#000000089D700000'), '\\DosDevices\\I:': (<WinDriverKindsEnum.KIND_OTHER: 6>, '{ff2e5dc7-6fb4-11ed-867a-9c7e4c05722e}#00000009A9A00000'), '\\DosDevices\\K:': (<WinDriverKindsEnum.KIND_OTHER: 6> , '{ff2e5dc7-6fb4-11ed-867a-9c7e4c05722e}#0000000B2D000000'), '\\DosDevices\\L:': (<WinDriverKindsEnum.KIND_OTHER: 6> , '{ff2e5dc7-6fb4-11ed-867a-9c7e4c05722e}#0000000CCE400000'), '\\DosDevices\\F:': (<WinDriverKindsEnum.KIND_DMIO: 1> , '33b94737-8ec8-4eba-b952-0906fe03579d'), '\\DosDevices\\E:': (<WinDriverKindsEnum.KIND_OTHER: 6> , '{94ca41e3-8fbe-11ed-8684-9c11bc15f5d2}#0000000000100000')} Since the data of driver volumes such as WinDriverKindsEnum.KIND_OTHER is not very readable, we can eliminate the placeholders of driver components such as WinDriverKindsEnum.KIND_OTHER by identifying the two fields of hard disk KIND_FIXED_DISK or KIND_DMIO, leaving the following three: {'\\DosDevices\\C:': (<WinDriverKindsEnum.KIND_FIXED_DISK: 0> ,[2502290984, 2048]), '\\DosDevices\\D:': (<WinDriverKindsEnum.KIND_FIXED_DISK: 0> , [2502290984, 180041336]), … '\\DosDevices\\F:': (<WinDriverKindsEnum.KIND_DMIO: 1> , '33b94737-8ec8-4eba-b952-0906fe03579d'), …} Among them, [2502290984, 2048] is the id and offset of the disk partition. In the domestic operating system, according to the id and offset of the disk partition, the device node information corresponding to the disk partition can be found as follows: {'C': ' / dev / nvme0n1p1', 'D': ' / dev / nvme0n1p5', 'F': 'error'} Furthermore, since the F drive letter here is a placeholder in the Windows system, it recognizes a volume and plans to display it, but since the Windows system cannot recognize Linux-type disk partitions, it cannot be parsed. In fact, only the C drive and the D drive can be displayed in the Windows system. This is not related to this application, but just a brief mention.
[0043] Step S304, based on step S302 and step S303, obtain the correspondence between the mounted Windows type disk partition and its assigned drive letter (such as C:D) and its device node under the domestic operating system, determine the mapping relationship between the Windows type disk partition and the drive letter in the domestic operating system from the corresponding relationship, and store the mapping relationship in the drive letter mapping database.
[0044] For the embodiment of the present application, the device node information represents the mapping relationship between the disk partition and the drive letter in the domestic operating system. Continuing with the above example, the device node information parsed in step S303: {'C': ' / dev / nvme0n1p1', 'D': ' / dev / nvme0n1p5', 'F': 'error'} is saved to the drive letter mapping database Windows.ini. At this time, the content of the drive letter mapping database is as follows: C= / dev / nvme0n1p1 D= / dev / nvme0n1p5 2. Virtual File System Service Virtual File System Service, referred to as GVFS, has been introduced in the previous terminology. This is a session-level self-starting service. The gvfsd-computer mainly used in this application is part of the GVFS daemon, which is specifically responsible for managing and displaying the "Computer" view. In the desktop environment of domestic operating systems, when the user opens the file manager to view "Computer", gvfsd-computer will come into play. Its Computer: / / / node lists all available file system mount points, including local hard disks, removable devices, etc., providing users with an interface for centralized browsing and access to these resources. Among them, the local hard disk is the key to compatibility with Windows drive letters.
[0045] As mentioned above, this service first parses the system drive letter mapping database to find the drive letter relationship of each disk partition in the Window system in the domestic operating system. Assuming that there are C drive and D drive in the installed Windows, the drive letter mapping database saves two Windows type partitions and the corresponding drive letters. Then the drive letter of the domestic operating system will start from D+1, that is, from E. Display the Windows C drive and D drive. The more specific working process of the virtual culture system service is as follows: Step S4, calculating the drive letter information corresponding to all disk partitions based on the drive letter mapping database.
[0046] For the embodiment of the present application, the drive letter information includes the drive letter and the partition name, such as Figure 3 The step S4 shown specifically includes: Step S401, sorting all the identified disk partitions according to preset rules in the domestic operating system to obtain a sorting result.
[0047] For the embodiment of the present application, the preset rule is that Windows-type disk partitions are ranked first, followed by the root file system, then other Linux local partitions, and finally removable devices. Further, the file system type can be identified by the TYPE field of the blkid command, which is used as the basis for sorting. The distinction between local partitions and removable devices is based on the sys block information of the device, such as / sys / block / nvme0n1 / removable.
[0048] Step S402, loading the drive letter mapping database; Step S403, based on the sorting result, a target child node is obtained from all child nodes under the Computer: / / / node. If the obtained result is empty, it is determined that there is currently no disk partition that needs to calculate the drive letter information.
[0049] For the embodiment of the present application, each member under this node, that is, each child node is a ComputerFile (the order of all child nodes under this node is the sorting result obtained in step S401), corresponding to a disk partition. ComputerFile is a data structure, and the data structure has a member variable named unix-deivce. Unix-deivce is a partition identifier identified in the domestic operating system. It is of string type, and the stored data is such as " / dev / nvme0n1p1" or " / dev / nvme0n1p5" (that is, the device node determined in step S303 above). In this context, the logical representation of a disk partition corresponds to a variable of ComputerFile type, and its name is stored in unix-device. For example, the ComputerFile corresponding to the C drive file1, the string saved in file1->unix-device is " / dev / nvme0n1p1", the ComputerFile corresponding to the D drive file2, the string saved in file2->unix-device is " / dev / nvme0n1p5", which means that each child node represents a disk partition.
[0050] Step S404, matching the data recorded in the partition identifier corresponding to the target child node with the data in the drive letter mapping database, if the match is successful (corresponding Figure 3 ), then execute step S405. If the match fails (corresponding to Figure 3 ), execute step S406.
[0051] Step S405: determine the drive letter corresponding to the data in the drive letter database that successfully matches the partition identifier of the target child node as the drive letter of the target child node, and determine the drive letter count corresponding to the drive letter of the target child node as the value of the global max variable, and continue to execute step S407 (corresponding to Figure 3 "Read the drive letter number to get X, and assign the global max value"); Step S406, obtain the global max value in the current domestic operating system, and increment the value of the global max variable by 1 to obtain the drive letter count corresponding to the target child node, determine the drive letter count as the value of the global max variable, and determine the drive letter corresponding to the drive letter count as the drive letter corresponding to the target child node, and continue to execute step S407 (corresponding to Figure 3 "Global max++, get drive letter X"); For the embodiment of the present application, following the example in step S404 and step S304, / dev / nvme0n1p5 recorded in the unix-deivce of a ComputerFile node is compared with / dev / nvme0n1p5 recorded in the drive letter mapping database. C= / dev / nvme0n1p1 D= / dev / nvme0n1p5 Matching is performed. When the match is successful, it means that the drive letter of the disk partition represented by the target child node is the drive letter corresponding to the successfully matched data in the drive letter mapping database, that is, the drive letter of the target child node is determined to be D. After the drive letter is identified, the drive letter is saved so that it can be combined with the partition name to form drive letter information in the format of "Entertainment (D:)" in the future. At the same time, the drive letter count corresponding to the drive letter is determined as the value of the global max variable, so that it can be used in the subsequent determination of other child nodes under the Computer: / / / node as their drive letter count starting point; When the match fails, it means that the disk partition represented by the target subnode does not belong to the Windows type disk partition (at this time, all the target subnodes corresponding to the Windows type disk partition have been traversed), but is a disk partition under the domestic operating system. Therefore, the value of the global max variable in the current domestic operating system can be obtained at this time, and the value of the global max variable can be incremented by 1 to obtain the drive letter count corresponding to the target subnode, and then the currently determined drive letter count is determined as the value of the global max variable and the drive letter corresponding to the drive letter count is determined as the drive letter corresponding to the target subnode.
[0052] To facilitate understanding, the following example is used to further illustrate: When encoding, the drive letter count of the C drive can be expressed as 67, D as 68, and E as 69, increasing in sequence; for example, I installed Windows, which has C and D drives, and then I installed a domestic operating system, which adds up to two Windows partitions and one Linux partition, a total of three; when the domestic operating system and the Windows operating system coexist, in addition to displaying the drive letter of the Windows operating system, the drive letters of other partitions of the domestic operating system also need to be displayed. Assuming that the largest drive letter count of the Windows operating system identified corresponds to the D drive, the domestic operating system partitions start from the E drive. During specific execution, the virtual file system service gvfsd-computer will collect the ComputerFile objects of these three partitions under the Computer: / / / node. The upper-level application, such as the file manager, displays the partition represented by the node on the graphical interface through communication with the virtual file system.
[0053] Before the graphical interface is displayed, all nodes of the ComputerFile type are traversed first. For each node, the value of its unix-device member is used to query the drive letter mapping database Windows.ini. C= / dev / nvme0n1p1 D= / dev / nvme0n1p5 If a match is found to be C or D, the member will be marked with the drive letter when the graphic is displayed.
[0054] For Linux partitions, since they are not in the database, their drive letter count is calculated by adding 1 to the Windows maximum drive letter, which is E in this example.
[0055] Step S407, name the target subnode and obtain the partition name corresponding to the target subnode.
[0056] In the embodiment of the present application, under normal circumstances, in Windows systems, there are cases where users name disk partitions. In domestic operating systems, disk partitions also have corresponding partition names, called "Labels". If there is no name, then in domestic operating systems, it will be named according to the size of the disk partition, such as "100GB Volume". In the embodiment of the present application, in order to prevent users from being confused by such names, in the case where there is a partition name that has been named by the user, that is, when there is a Label, the original Label is maintained, that is, the partition name named by the user is used as the partition name of the target child node. The partition name obtained in this part corresponds to Figure 3 "Label(X:)" If the user does not name the partition, that is, the label does not exist, a more readable name is set according to whether it is a mobile device. Specifically, it is named according to the file content of " / sys / block / nvme0n1 / removable". When the file content is 0, the partition name is "Local Disk", and when the file content is 1, the partition name is "Removable Disk".
[0057] Step S408, integrating the drive letter obtained in step S405 or step S406 and the partition name obtained in step S407 to obtain the drive letter information of the disk partition represented by the target child node, and continuing to execute step S403.
[0058] For the embodiment of the present application, the obtained drive letter and partition name are integrated to obtain the drive letter information of the disk partition represented by the target child node, and the drive letter information is set to the display-name member of ComputerFile. The GIO interface layer has an interface to obtain the data of the display-name member. The file manager obtains the name such as "Entertainment (D:)" through this interface and can display it directly.
[0059] Further, in the embodiment of the present application, when steps S1 to S4 are dual-system scenarios, the disk partitioning method is displayed. When it is not a dual-system environment, that is, when there is only a domestic operating system, there is no process of obtaining Windows registry files and generating drive letter mapping data tables from steps S1 to S3. The drive letter of the domestic operating system starts from the C drive by default, that is, 0X43, which corresponds to the hexadecimal identifier of the integer number of C, that is, starting from the drive letter count of 67. (Corresponding Figure 3 In the upper left corner, "When there is no Windows system, changed = 0X43", and "The drive letter database starts from 0X43") It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0060] The above are only some implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A design method for making a domestic operating system compatible with Windows drive letters, characterized in that: include: At startup, identify the disk identifier and determine whether the device file system corresponding to each disk partition is of Windows type; Get the Windows registry file of the disk partition whose device file system is Windows type; Determine the mapping relationship between Windows-type disk partitions and drive letters in the domestic operating system based on the Windows registry file, and store the mapping relationship in a drive letter mapping database; The drive letter information corresponding to all disk partitions is calculated based on the drive letter mapping database.
2. The method for designing a domestic operating system compatible with Windows drive letters according to claim 1, characterized in that: At startup, the disk identifier is identified, and based on the disk identifier, it is determined whether the device file system corresponding to each disk partition is of the Windows type, including: At startup, identify the disk identifier through listWindowsDevicesAndPhysicalDisks and obtain the device information corresponding to each disk partition; Based on the device information, it is determined whether the device file system corresponding to each disk partition is of Windows type.
3. The method for designing a domestic operating system compatible with Windows drive letters according to claim 1, characterized in that: Get the Windows registry files of the disk partition whose device file system is Windows type, including: The partition information corresponding to the disk partition whose device file system is Windows type is saved in the deviceWins data structure, wherein the partition information includes the device node and the sector starting point; Traverse and mount all Windows-type disk partitions through doDeviceMount; Traverse the mount paths of all mounted disk partitions to find the location of the Windows registry file, and obtain the Windows registry file based on the location of the Windows registry file.
4. The method for designing a domestic operating system compatible with Windows drive letters according to claim 1, characterized in that: Based on the Windows registry file, the mapping relationship between the Windows type disk partition and the drive letter in the domestic operating system is determined, and the mapping relationship is stored in the drive letter mapping database, including: Step S301, loading the Windows registry file into the data table; Step S302, identifying HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices in the Windows registry file to obtain a mapping relationship between a mounted Windows-type disk partition and its assigned drive letter; Step S303, parsing the data table to determine the device node information of the persistent volumes corresponding to the Windows-type disk partitions in the domestic operating system; Step S304, based on step S302 and step S303, obtain the correspondence between the mounted Windows type disk partition and its assigned drive letter and its device node under the domestic operating system, determine the mapping relationship between the Windows type disk partition and the drive letter in the domestic operating system from the corresponding relationship, and store the mapping relationship in the drive letter mapping database.
5. The method for designing a domestic operating system compatible with Windows drive letters according to claim 1, characterized in that: The drive letter information includes a drive letter and a partition name. The drive letter corresponds to a drive letter count. The drive letter information corresponding to all disk partitions is calculated based on the drive letter mapping database, including: Step S401, sorting all the identified disk partitions according to preset rules in the domestic operating system to obtain a sorting result; Step S402, loading the drive letter mapping database; Step S403, based on the sorting result, a target child node is obtained from all child nodes under the Computer: / / / node. If the obtained result is empty, it is determined that there is no disk partition that needs to calculate the drive letter information. Each child node represents a disk partition and has a corresponding partition identifier. The partition identifier is a partition identifier identified in the domestic operating system. Step S404, matching the data recorded in the partition identifier corresponding to the target child node with the data in the drive letter mapping database, if the match succeeds, executing step S405, if the match fails, executing step S406; Step S405, determining the drive letter corresponding to the data in the drive letter database that successfully matches the partition identifier of the target subnode as the drive letter of the target subnode, and determining the drive letter count corresponding to the drive letter of the target subnode as the value of the global max variable, and proceeding to step S407; Step S406, obtaining the value of the global max variable in the current domestic operating system, and incrementing the value of the global max variable by 1 to obtain the drive letter count corresponding to the target child node, determining the drive letter count as the value of the global max variable and the drive letter corresponding to the drive letter count as the drive letter corresponding to the target child node, and continuing to execute step S407; Step S407, naming the target subnode, and obtaining the partition name corresponding to the target subnode; Step S408, integrating the drive letter obtained in step S405 or step S406 and the partition name obtained in step S407 to obtain the drive letter information of the disk partition represented by the target child node, and continuing to execute step S403.
Citation Information
Patent Citations
File access method of Linux virtual machine disk under Windows platform
CN101944043A
Method and device for displaying Windows disk letters
CN103135947A
Disc character correct allocation method and device based on disc under Linux
CN103150126A
Method and device for determining mapping relation between block device and virtual machine drive
CN115469964A
