如何在Linux上通过inode访问文件 [英] How can I access file by inode on Linux

查看:611
本文介绍了如何在Linux上通过inode访问文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有任何用户空间的API或第三方内核模块,可以帮助通过Linux上的inode访问文件?



我想实现一些像这样的事情:

  int read_file_by_ino (int ino,int pos,int size,char * buf); 
int write_file_by_ino(int ino,int pos,int size,const char * buf);
int readdir_by_ino(...);
int stat_by_ino(...);
...

该程序预计在root用户下运行,所以没有安全要求做权限检查。



谢谢!

解决方案

如果我正确地理解了你的问题,但是:
你可以从/目录开始,并且以子节点的形式递归地(或者任何循环)继续。将inode值与 strcut stat.ino_t 进行比较。一旦找到它,打开路径/文件。


is there any userspace API or thrid-party kernel module that can help to access file by inode on linux?

I'm trying to implement somethig like:

int read_file_by_ino(int ino, int pos, int size, char* buf);
int write_file_by_ino(int ino, int pos, int size, const char* buf);
int readdir_by_ino(...);
int stat_by_ino(...);
...

The program is expected to run under root user, so there's no security requirement to do permission checking.

Thanks!

解决方案

Not sure if I understood your problem correctly but:
You can start with "/" directory and proceed recursively (or any loop for that matter) with children. Compare the inode value with strcut stat.ino_t. Once you find it, open the path/file.

这篇关于如何在Linux上通过inode访问文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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