问题描述
由于文件路径,我怎样才能得到它的元数据。这是我的问题:我有真正隐藏文件(甚至与LS -a它不应该出现在任何地方),我DONOT需要gaurentee,这将具有相同的状态,当它回来。现在我虽然如果能只复制元数据,并存储在某个地方,只写回,当我需要,这将解决我的问题。
Given a file path, how can I get its meta data. Here is my problem: I have to truly hide a file (even with ls -a it should not show up anywhere) and I donot need to gaurentee that it will have the same state when it comes back. Now I though if can just copy the meta data and store it somewhere, only to write it back when I need to, It would solve my problem
- 我要创建元数据的副本,并将其存储在另一个地方。
- 我必须能够复制回它当过我想要的元数据。
所以,我怎样才能得到一个文件的元数据?如果有更好的方式来充分隐藏文件怎么可以?
So How can I get the meta-data of a file? If there is a better way to fully hide the file how can I?
这是一个个人项目,我不会有任何code上游。
This is a personal project and I wont have any code up-stream.
我在linux内核3.5.4v工作
I am working in linux kernel 3.5.4v
推荐答案
我想过这个问题更多一些。
I thought about the question some more.
有具体的文件系统的方法来创建真正隐藏的文件,当然,可能性,但我不是在探索那些感兴趣。然而,有一种不同的方法,一个变体,这可能满足您的需求。
There are filesystem-specific ways to create the possibility of truly hidden files, of course, but I'm not at all interested in exploring those. However, there is a different approach, a variant, that might suit your needs.
您可以通过截获仅打开
系统调用达到类似的效果(扩大现有的,以precise)。如果打开的文件解析到一个不存在的文件,但目录和文件名匹配,而不是失败构造一个特殊的路径隐藏文件,并打开该网址。
You could achieve a similar effect by intercepting only the open
syscall (extending the existing one, to be precise). If the opened file resolves to a nonexisting file, but the directory and the file name match, instead of failing you construct a special path to the "hidden" file, and open that instead.
现有的文件随后将是一个完全正常的文件,只是实际别处。当然,你可以把它放在一个根只访问的目录( drwx ------根:根
),并打开时,它省略了访问安全检查,让它隐藏。
The existing file would then be a perfectly normal file, just actually somewhere else. Of course, you can put it in a root-only accessible directory (drwx------ root:root
), and omit the access security check when opening it, to make it "hidden".
这篇关于如何获得在内核空间文件的元数据 - Linux的3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!