Understanding file system inode The concept of

*
concept :inode It's the index node , It is used to store the basic information of files and directories , Include time , File name , Users and groups, etc

*
inode yes UNIX A data structure in operating system , Its essence is structure

*
stay Linux in , The index node structure exists in the system memory and disk , It can be divided into VFS inode With the actual file system inode.

*
VFS inode As a real file system inode The abstraction of , The structure is defined inode Operations related to it inode_operations
Linux in VFS inode include/linux/fs.h struct inode { ... const struct
inode_operations *i_op; // Inode operation unsigned long i_ino; // Index node number atomic_t
i_count; // Reference counter unsigned int i_nlink; // Number of hard links ... } struct inode_operations {
... int (*create) (struct inode *,struct dentry *,int, struct nameidata *); int
(*link) (struct dentry *,struct inode *,struct dentry *); int (*unlink) (struct
inode *,struct dentry *); int (*symlink) (struct inode *,struct dentry *,const
char *); int (*mkdir) (struct inode *,struct dentry *,int); int (*rmdir)
(struct inode *,struct dentry *);... }
*
Linux in VFS inode

* There are two counters per file :i_count And i_nlink, Reference count and hard link count
* i_count Used to track the number of files accessed , and i_nlink Is the above use ls -l The number of file hard links viewed by commands such as
* When a file is deleted , be i_nlink Set to 0
* These two counters of the file make Linux System upgrades or program updates become easier
* The system or program can be shut down without shutting down ( That is, documents i_count Not for 0), Replace the new file with the same file name , The new document has its own inode and data
block, Old files will be completely deleted after the related process is shut down
*
file system ext4 Medium inode
ext4 Medium inode struct ext4_inode { ... __le32 i_atime; // Last access time of file content __le32
i_ctime; // inode Modification time __le32 i_mtime; // Last modification time of file content __le16 i_links_count; //
Hard link count __le32 i_blocks_lo; // Block count __le32 i_block[EXT4_N_BLOCKS]; // Point to specific
block... };
*
The definition of three times can correspond to the command stat You can see three times in

*
i_links_count Not only for hard link count of files , Also used to track the number of subdirectories of a directory ( The directory does not show the number of hard links , command ls -ld What you see is the number of subdirectories )

*
file system ext3 Yes i_links_count There are limitations , The maximum number is :32000( This is limited to ext4 Was cancelled )

Technology
©2019-2020 Toolsou All rights reserved,
Final review of database : Summary of comprehensive application questions use Python Make simple games Laplance operator ( Second derivative ) Convert hard disk to GPT Partition format Python Implementation of Hanoi Tower code about String How to create objects vue3 Learning journey 1—— establish vue3 project java String from back to front _Java String String summary use Python Write a story about plants versus zombies 【 Greedy Algorithm 】 Huffman coding problem