Linux Source code reading note Find_entry Analysis

Source: Internet
Author: User
Buffer_head static struct * find_entry (struct m_inode * dir,         const char * name, int namelen, struct dir_entry * * Res_dir)

Find_entry is a more puzzling function in the Linux file system. Let's analyze it below.

Its first parameter is the M_inode type, which indicates the Inode node of the root directory where the function operation is located. That is, the starting node of the relative path.

Name is naturally the directory path you want to find, and Namelen is the length of the directory name.

The Res_dir is returned as a pointer to the catalog item you want to find.

The function return value is the buffer_head corresponding to the block that contains the catalog entry.

Why is there a two return value? We know that, under the Ext2 file system, directories exist as files, and the Inode is the index of the directory.

The Inode-directed block stores information about the files and subdirectories contained in the directory. It exists in the following structure.

dir_entry struct {141         unsigned short inode;142         

The name array stores the file name, and the Inode stores the inode number. So the directory file is actually a file, but the content of the file is a

Dir_entry structure, therefore, it may occupy a block or occupy multiple blocks as well as ordinary files.

The function of the Find_entry function is to find the block that stores the dir_entry of the name parameter corresponding to the file, and return it in buffer_head form, and

Returns the corresponding dir_entry of the file as a pointer.

Linux Source code reading note Find_entry Analysis

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.