Linux2.4 system call for opening a file

Source: Internet
Author: User

0. sys_open ()

(1) Find an idle item get_unused_fs () from the "open file table" of the current process ()

(2) Create the context filp_open () for file read/write: (see 1)

(3) install the context in the open file table

1. filp_open (): Create the context for file read/write

(1) Get the dentry and vfsmount: open_namei () pointing to the file name ()

If it is only enabled, search by path_init () and path_walk ()

If there is a requirement to create a non-existent domain name, see Figure 3)

3. Obtain the dentry and vfsmount pointing to the file name. If the file name does not exist, create

(1) Find the parent dentry of the node corresponding to path_name

(2) Find the dentry of the target file

(3) If not, create dentry: vfs_create () (see figure 4)

(4) Determine dentry:

If it is an installation point, enter the installed File System

If it is a connection symbol, expand the target node, go to 3-(1)

(5) Calculate inode by dentry

(6) Various inode checks

(7) If necessary, truncate the end Of the file

A. Remove the content after length

B. Modify inode

C. Mount inode to the dirty queue

4. vfs_create (): Create a dentry for the file

(1) Create an index node for the file on the storage device and inode in the memory: ext2_new_inode ()

(2) write the file name and index node number of the target file to its directory ext2_add_entry ()

(3) link the dentry structure of the target file with the inode structure d_instantiate ()

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.