为什么不能通过inode操作文件? [英] Why can't files be manipulated by inode?
问题描述
这似乎是这样一个无害和有用的功能系统提供。为什么没有提供?
一些操作系统 do 有这个功能。例如,OS X需要它支持碳文件管理器,在Linux上可以使用 debugfs
。当然,你可以通过命令行通过 find -inum
在任何UNIX上执行,但是无法通过inode访问文件的真正原因是它不是'特别有用。它不会阻止文件权限,因为如果有一个文件,你可以在一个文件夹中读取你不能读取或执行,然后打开inode让你发现它。
它不是非常有用的原因是你需要通过 * stat()
调用找到一个inode号码, 有文件名(或打开的fd)...或者你需要猜测inum。
Why is it that you cannot access a file when you only know its inode, without searching for a file that links to that inode? A hard link to the file contains nothing but a name and a number telling you where to find the inode with all the real information about the file. I was surprised when I was told that there was no usermode way to use the inode number directly to open a file.
This seems like such a harmless and useful capability for the system to provide. Why is it not provided?
Some Operating Systems do have that facility. For example, OS X needs it to support the Carbon File Manager, and on Linux you can use debugfs
. Of course, you can do it on any UNIX from the command-line via find -inum
, but the real reason you can't access files by inode is that it isn't particularly useful. It does kindof circumvent file permissions, because if there's a file you can read in a folder you can't read or execute, then opening the inode lets you discover it.
The reason it isn't very useful is that you need to find an inode number via a *stat()
call, at which point you already have the filename (or an open fd)...or you need to guess the inum.
这篇关于为什么不能通过inode操作文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!