// linux 5.4.85/include/linux/fs.h 取出super_block核心字段
struct super_block {
// 文件系统块大小
unsigned long s_blocksize;
//文件系统支持的最大文件
loff_t s_maxbytes; /* Max file size */
// 文件系统的类型
struct file_system_type *s_type;
// 超级块的操作函数
const struct super_operations *s_op;
// 文件系统根目录的指针
struct dentry *s_root;
// 文件系统所有的inode
struct list_head s_inodes; /* all inodes */
// 对应的块设备指针
struct block_device *s_bdev;
}
// linux 5.4.85/include/linux/dcache.h 取出dentry核心字段
struct dentry {
// d_hash是链接到dentry cache的hash链表
struct hlist_bl_node d_hash;
// 上层目录的dentry
struct dentry *d_parent;
// 目录名称
struct qstr d_name;
// dentry对应的indoe,用dentry和inode来描述文件或者目录
struct inode *d_inode;
// dentry的操作函数
const struct dentry_operations *d_op;
// 超级块的dentry树
struct super_block *d_sb;
// 文件系统私有数据
void *d_fsdata;
// d_child是dentry自身的链表头,需要链接到父dentry中的d_subdirs中
struct list_head d_child;
// 所有的子目录或者子文件都要链接到这个d_subdirs上
struct list_head d_subdirs;
} __randomize_layout;
// linux 5.4.85/include/linux/fs.h 取出inode核心字段
struct inode {
// 文件的权限信息
umode_t i_mode;
// 操作文件的uid
kuid_t i_uid;
// 操作文件的gid
kgid_t i_gid;
// inode标志,可以是S_SYNC,S_NOATIME,S_DIRSYNC等
unsigned int i_flags;
//如果inode代表设备,i_rdev表示该设备的设备号
dev_t i_rdev;
// 所属的超级块
struct super_block *i_sb;
//文件的长度
loff_t i_size;
// 文件的创建、修改、访问时间
struct timespec64 i_atime;
struct timespec64 i_mtime;
struct timespec64 i_ctime;
spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
// 文件中位于最后一个块的字节数
unsigned short i_bytes;
// 以bit为单位的块的大小
u8 i_blkbits;
// 文件使用块的数目
blkcnt_t i_blocks;
// inode的编号
unsigned long i_ino;
#ifdef __NEED_I_SIZE_ORDERED
seqcount_t i_size_seqcount;
#endif
/* Misc */
unsigned long i_state;
struct rw_semaphore i_rwsem;
unsigned long dirtied_when; /* jiffies of first dirtying */
unsigned long dirtied_time_when;
struct hlist_node i_hash;
struct list_head i_io_list; /* backing dev IO list */
#ifdef CONFIG_CGROUP_WRITEBACK
struct bdi_writeback *i_wb; /* the associated cgroup wb */
/* foreign inode detection, see wbc_detach_inode() */
int i_wb_frn_winner;
u16 i_wb_frn_avg_time;
u16 i_wb_frn_history;
#endif
// 当前inod lru链表
struct list_head i_lru; /* inode LRU list */
// i_sb_list用于链接到超级块中的inode链表
struct list_head i_sb_list;
// 同一个文件的多个dentry需要链接到i_dentry中
union {
struct hlist_head i_dentry;
struct rcu_head i_rcu;
};
atomic64_t i_version;
atomic64_t i_sequence; /* see futex */
atomic_t i_count;
atomic_t i_dio_count;
//记录有多少个进程以可写的方式打开此文件
atomic_t i_writecount;
//记录有多少个进程以可读的方式打开此文件
#if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING)
atomic_t i_readcount; /* struct files open RO */
#endif
// i_fop是一个file_operations类型指针,提供文件的读写函数和异步IO函数
union {
const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
void (*free_inode)(struct inode *);
};
//指向各种不同设备的指针
union {
//如果文件是一个管道则使用i_pipe
struct pipe_inode_info *i_pipe;
//如果文件是一个块设备则使用i_bdev
struct block_device *i_bdev;
//如果文件是一个字符设备这使用i_cdev
struct cdev *i_cdev;
char *i_link;
unsigned i_dir_seq;
};
// 文件系统的私有数据
void *i_private; /* fs or device private pointer */
} __randomize_layout;