Linux2.4 a system call to open a file __linux

Source: Internet
Author: User

0.sys_open ()

(1) Find an idle item from the Open File table of the current process get_unused_fs ()

(2) Establish the context Filp_open () of file read and write (see 1)

(3) Install the context in the File open table


1.filp_open (): Creating a context for file reading and writing

(1) Get the Dentry and Vfsmount:open_namei () pointing to the filename.

If only open, search by Path_init () and Path_walk ()

If there is a requirement to create, then (see 3)


3. Get the Dentry and vfsmount that point to the filename, if not, create

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

(2) Find the dentry of the target file

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

(4) Judge Dentry:

In the case of an installation point, access to the installed file system

If a join symbol, expand the target node, go to 3-(1)

(5) The inode is calculated by Dentry

(6) Various inspection of the Inode

(7) If necessary, truncate the file

A. The content after the length of the cut

B. Modifying the Inode

C. Hooking the inode into a dirty queue


4.vfs_create (): Creating a dentry for a file

(1) Create a file on the storage device in the index node and in-memory Inode:ext2_new_inode ()

(2) write the filename of the target file and the index node number to the directory Ext2_add_entry ()

(3) Linking 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.