1. Preface
The series of articles on document management is mainly about the Chen Li of the Document System management Knowledge lecture by teacher June.
Linux can support different file systems, which originate from UNIX file systems and are a feature of UNIX file systems.
This article will take a copy of the different file systems as an example to tell
2. Example: File copy
Figure a copy between different file systems
Image file copy corresponding C language fragment
3. Opening the File 3.1 open function
Open the file before you read and write the file, the prototype of the Open function is as follows:
3.2 Kernel implementations of open files
In terms of the overall process, the open kernel is implemented as follows:
The process obtains the path name from the user state to the kernel buffer;
The parent directory is then found, and if the O_CREAT flag is set, the last component of the path continues to be found
Finally get the open file structure of the corresponding file
This structure is linked to the Open file table of the current process and returns the corresponding FD.
4. Do_sys_open
4.1 Do_filp_open
When the kernel accesses a file, the first step is to find the file, which is done by Do_filp_open.
In Do_filp_open implementations, the Find files process is done by Path_init and Link_path_walk.
These two functions convert the file path represented by the user into a dentry structure, establish the corresponding inode, and store the results in the NAMEIDATA structure.
4.1.1 Nameidata_to_filp
- Nameidata Structural Body
4.1.2 Fd_install
5. Find Files
Introduction of 5.1 Dentry cache
Description of the 5.2 dentry cache
Linux file system 4--Open File