A method to read and write NTFS disks using the user-mode file system that comes with the macOS system
By introducing the middle layer of the user-mode file system into the macOS system, the problem that macOS NTFS disk reading and writing cannot take into account convenience, security and stability is solved, and NTFS disk reading and writing on macOS without additional installation of drivers is realized, improving Improve user experience and system stability.
Patent Information
- Application Number
- CN202410873659.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-07-02
AI Technical Summary
The macOS system cannot simultaneously take into account convenience, system security, and stability to implement native reading and writing of NTFS disks, resulting in difficulties in data exchange between Mac and Windows.
By introducing an intermediate user-mode file system into the macOS system, the system's own file system interface is used to perform read and write operations on NTFS disks, including user initiation of read and write requests, system checking of parameter validity, and unified interface callback instructions converted to Disk read and write underlying interface, complete read and write operations and return results.
It realizes convenient, stable and fast reading and writing operations of NTFS disks in macOS system without installing additional drivers or extensions, and improves the convenience of users in processing NTFS disk files.
Smart Images

Figure CN118410014B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of disk reading and writing, and specifically is a method for reading and writing NTFS disk using a user-mode file system provided by a macOS system. Background Art
[0002] Currently, the market share of Mac computers is increasing day by day, and they are favored by more and more users in the fields of office, design, program development, etc. Since macOS cannot read and write disks with NTFS file system by default, and NTFS is a common disk format for Windows system, many users cannot use NTFS disk format in data exchange between Mac and Windows, so it is very necessary to implement a simple, easy-to-use, stable and driver-free NTFS read and write disk solution on macOS platform.
[0003] At present, the conventional methods of reading and writing NTFS disks on Mac are: modifying the / etc / fstab file, adding an NTFS disk mounting record, using the rw and nobrowse parameters, so that the system can force the read and write functions to be enabled when mounting the corresponding NTFS disk. Use the terminal under macOS to execute the mount command, specify the device name, mount point, rw and nobrowse parameters of the disk to mount, so that the system can force the read and write functions to be enabled when mounting the corresponding NTFS disk. Use the NTFS read and write driver and system extension implemented by a third party. After the installation is completed, the native reading and writing of NTFS disks on macOS can be basically realized, and the disk can be read and written after being inserted.
[0004] In the existing technology, the native reading and writing of NTFS disks of macOS cannot take into account convenience, system security and stability at the same time. Summary of the invention
[0005] The purpose of the present invention is to provide a method for reading and writing NTFS disks using the user-mode file system of the macOS system, so as to solve the problem in the prior art proposed in the background technology that the native reading and writing of NTFS disks of macOS cannot take into account convenience, system security and stability at the same time.
[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0007] A method for reading and writing NTFS disks using the user-mode file system provided by the macOS system includes the following steps:
[0008] Step S1, the user initiates a read or write request for a file;
[0009] Step S2, the system receives a read / write request from the user;
[0010] Step S3, the system checks the validity of the read / write request parameters. If valid, the system finds the file system that takes over the path in the file system list registered with the system according to the path of the file that the user needs to read in step S1; if the request parameters are invalid, the system returns directly and displays an error to the user;
[0011] Step S4, the system middle layer receives the unified interface callback instruction from the file system list through the user-mode file system;
[0012] Step S5, the unified interface callback instruction in step S4 will call the underlying interface of disk reading and writing, and convert it into corresponding disk reading and writing according to different callback types;
[0013] Step S6, calling the file read / write interface of the system to write the file data to the disk. After the call is completed, the system informs the user whether the call is successful and the specific data written;
[0014] Step S7, after the disk read-write bottom layer reads the return result of the system read-write in step S6, it encapsulates and packages the result according to the returned result to the unified interface implementation;
[0015] Step S8: The system calls back to return the read and write results.
[0016] According to the above technical solution, in step S4, the unified interface calls back instructions to the disk read and write bottom layer to perform specific read and write operations.
[0017] According to the above technical solution, in step S4, the unified interface callback instructions of the file system include reading and writing data, opening files, setting attributes, creating files, deleting files, and setting access permissions.
[0018] According to the above technical solution, in step S5, the unified interface callback instruction from the user-mode file system will be parsed and decomposed into specific disk reads and writes.
[0019] According to the above technical solution, in step S4, specifically:
[0020] Step S401, the system reads the unified interface callback instruction of the file system;
[0021] Step S402, decomposing the read unified interface callback instruction into reading and writing tasks of NTFS sector data;
[0022] Step S403, traversing the reading and writing tasks of the NTFS sector data decomposed in step S402 to complete the reading and writing of the data;
[0023] Step S404, after reading and writing are completed, the result is returned to the registered file system callback function.
[0024] Compared with the prior art, the present invention has the following beneficial effects:
[0025] The method of the present invention allows users to perform read and write operations on NTFS disks in a macOS system, and access to NTFS disks is achieved through an intermediate user-mode file system.
[0026] The method of the present invention can enable users to process files on NTFS disks more conveniently in macOS systems, without installing additional system extensions and drivers, and can conveniently, stably and quickly read and write NTFS disks on macOS without reducing system security. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 The flowchart of the method for reading and writing NTFS disk of the present invention. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0029] Embodiment 1
[0030] like Figure 1 As shown, a method for reading and writing NTFS disks using the user-mode file system provided by the macOS system is characterized in that it includes the following steps:
[0031] Step S1, the user initiates a read or write request for a file;
[0032] Step S2, the system receives a read / write request from the user;
[0033] Step S3, the system checks the validity of the read / write request parameters. If valid, the system finds the file system that takes over the path in the file system list registered with the system according to the path of the file that the user needs to read in step S1; if the request parameters are invalid, the system returns directly and displays an error to the user;
[0034] Step S4, the system middle layer receives the unified interface callback instruction from the file system list through the user-mode file system;
[0035] Step S5, the unified interface callback instruction in step S4 will call the underlying interface of disk reading and writing, and convert it into corresponding disk reading and writing according to different callback types;
[0036] Step S6, the file read / write interface of the system returns the corresponding result to the disk read / write; specifically: calling the file read / write interface of the system to write the file data to the disk, after the call is completed, the system informs the user whether the call is successful and the specific data written;
[0037] The system IO direct read / write interface returns the result of reading and writing the disk. For example, if you call the system IO write interface to write data with a byte length of 4096 to the disk offset 0x10EF84DF, after the call is completed, the system will tell the caller whether it is successful and how many bytes were successfully written.
[0038] Step S7, after the disk read-write bottom layer reads the return result of the system read-write in step S6, it encapsulates and packages the result according to the returned result to the unified interface implementation;
[0039] For example, when the bottom layer reads and writes file B, it analyzes the sector location of file B stored on the disk, and then writes the corresponding data to these sector locations. The system IO can only complete these sector read and write requests in batches. After all IO read and write are completed, the bottom layer will re-package according to these IO read and write results, so that the upper layer's unified interface can obtain the assembled results.
[0040] Step S8: The system calls back to return the read and write results.
[0041] The method of the present invention allows users to perform read and write operations on NTFS disks in a macOS system, and access to NTFS disks is achieved through an intermediate user-mode file system.
[0042] The method of the present invention can enable users to process files on NTFS disks more conveniently in macOS systems, without installing additional system extensions and drivers, and can conveniently, stably and quickly read and write NTFS disks on macOS without reducing system security.
[0043] Embodiment 2
[0044] This embodiment is a further refinement of the first embodiment.
[0045] In step S4, the unified interface calls back instructions to the disk read and write bottom layer to perform specific read and write operations.
[0046] In step S4, the unified interface callback instructions of the file system include reading and writing data, opening files, setting attributes, creating files, deleting files, and setting access permissions.
[0047] In step S5, the unified interface callback instruction from the user-mode file system is parsed and decomposed into specific disk reads and writes.
[0048] For example, if 4096 bytes are written to the end of file A, after receiving the callback request, the bottom layer will read the disk data and find the location of sector #100 where file A is stored on the NTFS disk, and the bottom layer will write the data at sector #100.
[0049] In step S4, specifically:
[0050] Step S401, the system reads the unified interface callback instruction of the file system;
[0051] Step S402, decomposing the read unified interface callback instruction into reading and writing tasks of NTFS sector data;
[0052] Step S403, traversing the reading and writing tasks of the NTFS sector data decomposed in step S402 to complete the reading and writing of the data;
[0053] Step S404, after reading and writing are completed, the result is returned to the registered file system callback function.
[0054] Embodiment 3
[0055] This embodiment provides a specific implementation method.
[0056] See also Figure 1 , a flowchart of implementing NTFS disk reading and writing using the system's own user-mode file system in macOS. This figure shows the process from user request to NTFS reading and writing.
[0057] Step 1: The user initiates a read or write request for a file.
[0058] Step 2: The system receives a request from the user to read or write a file.
[0059] Step 2-1: The system will check the validity of the request parameters in the kernel. If valid, it will find the file system that takes over this path in the file system list (VFS layer) registered with the system based on the current file path. The VFS layer is an abstract layer that provides a set of unified interfaces for different file systems (such as read, write, open, create, etc.). The kernel will convert user read and write requests into callbacks of the unified interface of the VFS layer to achieve unified processing of different file system types.
[0060] Step 3: The middle layer registers and uses user-mode file systems such as livefs and nfs to receive unified interface callbacks from the kernel VFS layer. Although the file system callback interface is unified in the kernel-mode VFS abstraction layer, the callbacks of these file systems in user mode are still not unified (nfs relies on network protocols, and livefs relies on local services).
[0061] Step 3-1: Because of the problem of inconsistent user-mode file system callbacks, the middle layer also needs to implement a unified file system interface (such as read, write, open, create, etc.) to call the NTFS disk read and write bottom layer. The middle layer needs to convert the different callbacks of various user-mode file systems into a unified callback interface.
[0062] Step 4: The converted system callback from step 3 will call the underlying disk read / write interface, and convert it into real disk read / write according to the callback type. For example, if the user needs to modify the last modification time of a file, step 3 will call the unified interface utime, and the parameters will include the file and the last modification time, and then the underlying disk utime interface will be called.
[0063] Step 4-1: After receiving the interface call, the disk bottom layer processes according to the called interface, the passed file information and parameters, calculates the actual saved offset of the current file in the disk, and calls the system's file read and write interface to directly read and write the offset position of the disk.
[0064] Step 5: The system's file read and write interface returns the corresponding results for disk reading and writing (the read and write requests are separate, returning either the read or write results).
[0065] Step 6: The bottom-level read result is returned to the unified interface implementation (synchronously returning the result to the call from step 3-1. For example, if the user modifies the most recent time, it returns to step 3-1 whether the modification is successful).
[0066] Step 6-1: The unified interface implementation returns to the file system callback (returns to step 3, the call from the kernel VFS also needs to return a result).
[0067] Step 7: The system callback returns the read and write results.
[0068] Step 8: The user obtains the read and write results.
[0069] Embodiment 4
[0070] This implementation provides a method for mounting or inserting an NTFS disk, by which the user-mode file system provided by the macOS system can be used to read and write the NTFS disk.
[0071] The user accesses the NTFS disk by inserting or directly mounting it; if the NTFS disk is accessed by inserting it, go to step A; if the NTFS disk is accessed by directly mounting it, go to step B.
[0072] Step A:
[0073] Step A1, after the system reads the NTFS disk, it searches for the filesystem that takes over the NTFS disk by sending a probe command;
[0074] Step A2, determining whether the user-mode NTFS file system has registered the filesystem plug-in service of macOS; if yes, proceeding to step A2011; if no, proceeding to step A2021;
[0075] Step A2011, the user-mode NTFS file system takes over the corresponding NTFS disk;
[0076] Step A2012, sending a mount instruction to the system NTFS mount program;
[0077] Step A2013, determining whether the NTFS disk is successfully loaded, if successful, proceeding to the next step, if not, returning a failure to the system and displaying an error;
[0078] Step A2014, the user-mode NTFS file system registers and mounts the NTFS disk with macOS;
[0079] Step A2015, the system loading is complete, the disk icon appears, and normal reading and writing access is possible.
[0080] Step A2021, the system's own NTFS file system takes over the NTFS disk;
[0081] Step A2022, sending a mount instruction to the system NTFS mount program;
[0082] Step A2023, determine whether the user-mode NTFS service intercepts the read-only mount; if so, forward the mount instruction to the user-mode NTFS, and return to step A2013 for determination; if not, perform a check and determination of the NTFS disk mount;
[0083] Step A2024, determining whether the NTFS disk mount check has passed, if yes, proceeding to the next step, if no, returning a mount failure to the system and displaying an error;
[0084] Step A2025, the system's own NTFS disk is registered with macOS to mount the NTFS disk;
[0085] Step A2026, system loading is completed, the disk icon appears, and read-only access is available.
[0086] Step B:
[0087] Step B1, determine whether the NTFS disk is mounted in the user mode NTFS file system mode; if yes, proceed to step B1011, if not, proceed to step B1021;
[0088] Step B1011, sending a mount instruction to the system NTFS mount program;
[0089] Step B1012, determine whether the NTFS disk pre-mounting check passes; if yes, continue; if not, return a mount failure to the system and display an error;
[0090] Step B1013, the user-mode NTFS file system registers and mounts the NTFS disk with macOS;
[0091] Step A2015, the system loading is complete, the disk icon appears, and normal reading and writing access is possible.
[0092] Step B1021, determine whether the user-mode NTFS file system has registered the filesystem plug-in service of macOS; if yes, return to step B1011; if no, continue;
[0093] Step B1022, sending a mount instruction to the system NTFS mount program;
[0094] Step B1023, determine whether the user-mode NTFS service intercepts the read-only mount; if so, forward the mount instruction to the user-mode NTFS, and return to step B1012 for determination; if not, perform a check and determination of the NTFS disk mount;
[0095] Step B1024, determining whether the NTFS disk mount check is passed, if yes, proceeding to the next step, if no, returning a mount failure to the system and displaying an error;
[0096] Step A2025, the system's own NTFS disk is registered with macOS to mount the NTFS disk;
[0097] Step A2026, system loading is completed, the disk icon appears, and read-only access is available.
[0098] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0099] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method to read and write NTFS disks using the user-mode file system that comes with the macOS system. Features: The following steps are involved: Step S1, the user initiates a read or write request for a file; Step S2, the system receives a read / write request from the user; Step S3, the system checks the validity of the read / write request parameters. If valid, the system finds the file system that takes over the path in the file system list registered with the system according to the path of the file that the user needs to read in step S1; If the request parameters are invalid, the system will return directly and display an error to the user; Step S4, the system middle layer receives the unified interface callback instruction from the file system list through the user-mode file system; Step S5, the unified interface callback instruction in step S4 will call the underlying interface of disk reading and writing, and convert it into corresponding disk reading and writing according to different callback types; Step S6, calling the file read / write interface of the system to write the file data to the disk. After the call is completed, the system informs the user whether the call is successful and the specific data written; Step S7, after the disk read-write bottom layer reads the return result of the system read-write in step S6, it encapsulates and packages the result according to the returned result to the unified interface implementation; Step S8: The system calls back to return the read and write results.
2. According to claim 1, a method for reading and writing NTFS disks using the user-mode file system provided by the macOS system, Features: In step S4, the unified interface calls back instructions to the disk read and write bottom layer to perform specific read and write operations.
3. According to claim 2, a method for reading and writing NTFS disks using the user-mode file system provided by the macOS system, Features: In step S4, the unified interface callback instructions of the file system include reading and writing data, opening files, setting attributes, creating files, deleting files, and setting access permissions.
4. According to claim 1, a method for reading and writing NTFS disks using the user-mode file system provided by the macOS system, Features: In step S5, the unified interface callback instruction from the user-mode file system is parsed and decomposed into specific disk reads and writes.
5. According to claim 1, a method for reading and writing NTFS disks using the user-mode file system provided by the macOS system, Features: In step S4, specifically: Step S401, the system reads the unified interface callback instruction of the file system; Step S402, decomposing the read unified interface callback instruction into reading and writing tasks of NTFS sector data; Step S403, traversing the reading and writing tasks of the NTFS sector data decomposed in step S402 to complete the reading and writing of data; Step S404, after reading and writing are completed, the result is returned to the registered file system callback function.
Citation Information
Patent Citations
Cross-platform data security protection method compatible with BitLocker encrypted disk
CN112231779A
Disk drive executing a preemptive multitasking operating system comprising tasks of varying priority
US7082494B1
