博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
微视linux 释放文件节点流程
阅读量:4070 次
发布时间:2019-05-25

本文共 1804 字,大约阅读时间需要 6 分钟。

long do_unlinkat(int dfd, const char __user *pathname){	struct dentry *dentry;	struct nameidata nd;	struct inode *inode = NULL;	error = user_path_parent(dfd, pathname, &nd, &name);		dentry = lookup_hash(&nd);		inode = dentry->d_inode;	if (inode)		atomic_inc(&inode->i_count);	error = mnt_want_write(nd.path.mnt);		error = vfs_unlink(nd.path.dentry->d_inode, dentry);		mnt_drop_write(nd.path.mnt);		dput(dentry);		if (inode)		iput(inode);	/* truncate the inode here */		=>void iput(struct inode *inode)		{			if (inode) {				BUG_ON(inode->i_state == I_CLEAR);				if (atomic_dec_and_lock(&inode->i_count, &inode_lock))					iput_final(inode);					=>void iput_final(struct inode *inode)					{						const struct super_operations *op = inode->i_sb->s_op;						void (*drop)(struct inode *) = generic_drop_inode;						if (op && op->drop_inode)							drop = op->drop_inode;						drop(inode);						=>void generic_drop_inode(struct inode *inode)						{							if (!inode->i_nlink)								generic_delete_inode(inode);//Super.c (fs\ext2):	.delete_inode	= ext2_delete_inode,								=>void ext2_delete_inode (struct inode * inode)								{									if (!is_bad_inode(inode))										dquot_initialize(inode);									truncate_inode_pages(&inode->i_data, 0);									if (is_bad_inode(inode))										goto no_delete;									EXT2_I(inode)->i_dtime	= get_seconds();									mark_inode_dirty(inode);									__ext2_write_inode(inode, inode_needs_sync(inode));									inode->i_size = 0;									if (inode->i_blocks)										ext2_truncate (inode);									ext2_free_inode (inode);//真正释放文件节点									return;								no_delete:									clear_inode(inode);	/* We must guarantee clearing of inode... */								}							else								generic_forget_inode(inode);						}					}			}		}			path_put(&nd.path);	putname(name);	return error;}

 

转载地址:http://ytlji.baihongyu.com/

你可能感兴趣的文章
【leetcode】Sum Root to leaf Numbers
查看>>
【leetcode】Pascal's Triangle II (python)
查看>>
java自定义容器排序的两种方法
查看>>
如何成为编程高手
查看>>
本科生的编程水平到底有多高
查看>>
备忘:java中的递归
查看>>
Solr及Spring-Data-Solr入门学习
查看>>
python_time模块
查看>>
python_configparser(解析ini)
查看>>
selenium学习资料
查看>>
<转>文档视图指针互获
查看>>
从mysql中 导出/导入表及数据
查看>>
HQL语句大全(转)
查看>>
几个常用的Javascript字符串处理函数 spilt(),join(),substring()和indexof()
查看>>
javascript传参字符串 与引号的嵌套调用
查看>>
swiper插件的的使用
查看>>
layui插件的使用
查看>>
JS牛客网编译环境的使用
查看>>
9、VUE面经
查看>>
关于进制转换的具体实现代码
查看>>