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 ()