Linux file system 4--Open File

Source: Internet
Author: User
Tags file copy parent directory

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.