Where does the file name exist in Linux?

Source: Internet
Author: User

The interview was asked where the file name of the Linux system was placed, not answered. :-(here summarized below:

We can divide a disk into one or more partitions. Each partition can contain a single file system.
The I node is a fixed-length record entry that contains most of the information about the file. But it just doesn't include the file name!

The inode contains meta information for the file, specifically the following:
* Number of bytes in the file
* User ID of the owner of the file
* The group ID of the file
* file read, write, execute permissions
* File timestamp, total three: CTime refers to the time when the inode was last changed, mtime refers to the time when the file content was last changed, atime refers to the time when the file was last opened.
* Number of links, that is, how many filenames point to this inode
* Location of File data block

You can use the Stat command to view inode information for a file:

stat example.txt**

In summary, all file information except the filename is present in the inode.

If you carefully observe the I-node and data-block portions of a cylinder group in the hard disk, you can see the situation.
1. There are two directory entries in the diagram that point to the same I node. There is a link count in each I node whose value is the number of directory entries that point to the I node. Only when the link count is reduced to 0 o'clock. Before you can delete the file (that is, you can free the hard disk space that the file occupies). This is why the "unlink a file" operation does not always mean "freeing the disk blocks that the file occupies". In the stat structure, the link count is included in the St_nlink member, and its base system data type is nlink_t. This type of link is called a hard link.
2. Another type of link is called a symbol type, and for such a link, the actual content of the file (in the data block) contains the name of the file that the symbolic link points to. In the following example:

17112:33lib -> usr/lib

The file name in the catalog entry is a 3-character string lib, which contains 7 data byte usr/lib. The file type of the I node is s_iflnk, so the system knows it is a symbolic link.
3. The I node contains most of the file-related information: file system, file access rights bits, file length, and so on. Most of the information in the stat structure is taken from the I node. only two items of data are stored in the catalog entry: The file name and the I node number.
4. Each filesystem individually numbers their I nodes, so the number of I nodes in the catalog entry points to the corresponding I node in the same file system, and cannot cause one directory entry to point to the I node of another file system. This is why the LN command cannot cross the file system.

Where does the file name exist in Linux?

Related Article

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.