How to get the file's meta data in kernel space - linux 3.5

…衆ロ難τιáo~ 提交于 2019-12-13 10:12:53

问题


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

  1. I have to create a copy of that meta data and store it in another place.
  2. I have to be able to copy back that meta data when ever I want it to.

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?

This is a personal project and I wont have any code up-stream.

I am working in linux kernel 3.5.4v


回答1:


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.

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.

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".



来源:https://stackoverflow.com/questions/12886593/how-to-get-the-files-meta-data-in-kernel-space-linux-3-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!