如何在vfs层的linux内核中检查文件对象是用于目录还是文件 [英] How to check in linux kernel at vfs layer whether the file object is for a directory or a file

查看:302
本文介绍了如何在vfs层的linux内核中检查文件对象是用于目录还是文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我发现有一个叫做$的函数

如何在vfs层的linux内核中检查文件对象是用于目录还是文件? c $ c> is_dx(dir)它检查了这个,但它存在于 ext3中 namei.c code>或 ext4 。我需要在 vfs层中独立于文件系统来执行此操作。 手中的初始目录的inode,代码

检查与名字匹配的条目以获取

对应的inode。

然后,从磁盘读取具有该节点的目录文件,并且匹配第二个名字的条目是

检查得到相应的inode的



q对于包含在路径中的每个名称重复此过程。

dentry缓存大大加快了程序的速度。

文件系统操作主要在dcache级别完成,所以他们都在内核锁。

How to check in linux kernel at vfs layer whether the file object is for a directory or a file?

I have found that there is a function called is_dx(dir) which checks for this but it is present in namei.c in ext3 or ext4. I need to do this at vfs layer that is independent of the file system.

解决方案

Having in hand the inode of the initial directory, the code

examines the entry matching the first name to get the

corresponding inode.

q Then the directory file having that node is read from disk and

the entry matching the second name is examined to derive the

corresponding inode.

q This procedure is repeated for each name included in the path.

The dentry cache considerably speeds up the procedure

File system operations are mostly done at the dcache level , so

they are all under kernel lock.

这篇关于如何在vfs层的linux内核中检查文件对象是用于目录还是文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆