Relationship between file descriptors and open files in Linux

Source: Internet
Author: User

Relationship between file descriptors and open files in Linux

file Descriptor: is a non-negative integer in form. In fact, it is an index value that points to the record table in which the kernel opens a file for each process maintained by the process.

File types in Linux

The Linux system sees everything as files, including ordinary files.-, catalog filesd, character device filesc, Block device filesb, Symbolic Link filel。 File descriptors are indexes created by the kernel to efficiently manage files that have been opened (a nonnegative integer) used to refer to files that have been opened, and system calls to all I/O operations under Linux are performed through file descriptors. For example0Represents standard input,1Represents standard output,3Indicates a standard error
, the file descriptor is incremented on that basis.

The relationship between file descriptors, files, and processes
    • Each file descriptor points to an open file that corresponds to the
    • Different file descriptors may point to the same open file
    • The same file may be opened by a different process, or it can be opened multiple times by the same process

File descriptor Table: The process level list, which is part of the user area, creates a new file descriptor for each file opened, and can only be accessed through a function of the file descriptor, or the process cannot access it directly.
System Files Table: A system-wide list that is shared with all processes of the current system, each entry containing the file offset, access mode, and count of entries to its file descriptor
File System index node table: inode index node table (UID, GID, CTime, Mtime, Atime, read and write execution permissions, number of links, block location)


Record content


Example

Relationship between file descriptors and open files in Linux

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.