内核维护了3 个数据结构:
• 进程级的文件描述符表。(为单个进程进行维护)
• 系统级的打开文件表。(为所有打开的文件维护,表名:open file descri)
• 文件系统的i-node 表。(inode---index node)
内核对所有打开的文件维护有一个系统级的描述表格(open file description table)。
有时, 也称之为打开文件表(open file table), 并将表中各条目称为打开文件句柄(open file handle)。
内核为每个进程维护一个打开文件的列表,该表被称为文件表(file table);
该表的每一条目都记录了单个文件描述符的相关信息;
• 控制文件描述符操作的一组标志;
• 对打开文件句柄的引用;
文件表通过非负整数fds(file descriptors)进行索引;
https://elixir.bootlin.com/linux/v5.7.8/source/include/linux/fdtable.h#L48
/* * Open file table structure 描述打开文件信息的结构体变量 */ struct files_struct { /* * read mostly part */ atomic_t count; bool resize_in_progress; wait_queue_head_t resize_wait; struct fdtable __rcu *fdt; struct fdtable fdtab; /* * written pa