Linux Kernal FS-inode&dentry(2)

本文介绍了Linux内核中的Inode概念,每个文件都有一个Inode,包含文件操作所需的所有信息。Inode结构定义在fs.h中,并提供了用于内核和用户操作文件的基本数据。此外,文章还探讨了与Inode相关的函数,如create、lookup、link和unlink等。Dentry作为文件索引中的元素,与Inode关联,是用户在目录中看到的条目,包括文件和设备。文章最后提及了Dentry缓存及其与Inode的关系。
摘要由CSDN通过智能技术生成

2021SC@SDUSC

Inode

While superblocks stand for each file systems,Inodes stand for every file and each file has an inode which include all information for kernal to operate those files.Be aware that even every file being used has an inode block to operate, it will only be created while the file ever accessed.Only if a file being accessed will an inode been created in RAM.

So it's more like an inode is not a file but some 'basic-data' for operating the file, such as the call link() which aims to create a hard link of the file old_dentry in the directory dir with the new filename dentry is related to inode structure.If you have a glance at fs.h, you'll see huge number of functions needs such inode to be done.

The structure of inode is also in fs.h, that is:

struct inode {
	umode_t			i_mode;
	unsigned short		i_opflags;
	kuid_t			i_uid;
	kgid_t			i_gid;
	unsigned int		i_flags;

	struct posix_acl	*i_acl;
	struct posix_acl	*i_default_acl;

	const struct inode_operations	*i_op;
	struct super_block	*i_sb;
	struct address_space	*i_mapping;

	void			*i_security;

	union {
		const unsigned int i_nlink;
		unsigned int __i_nlink;
	};
	dev_t			i_rdev;
	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;
	u8			i_blkbits;
	u8			i_write_hint;
	blkcnt_t		i_blocks;

	/* 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 */

	struct list_head	i_lru;		/* inode LRU list */
	struct list_head	i_sb_list;
	struct list_head	i_wb_list;	/* backing dev writeback list */
	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	
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值