如何从Linux内核的struct dentry中获得完整的路径名 [英] How to get full pathname from struct dentry in Linux kernel

查看:1184
本文介绍了如何从Linux内核的struct dentry中获得完整的路径名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写自己的内核模块,它捕获 vfs_mkdir(struct inode *,struct dentry *,int)内核函数调用,并尝试记录磁盘路径名

我想用 dentry_path 内核函数来转换 struct dentry * 到一个路径名。
当我插入模块时,出现错误


未知符号dentry_path

我的内核版本是2.6.32,它应该被导出。
我找不出原因。
是否有其他的选择?

解决方案

使用 dentry_path_raw dentry_path 未被导出。



从linux-fsdevel 档案

 在星期五,四月20, 2012 at 02:08:37 PM -0400,Theodore Ts'o写道:

>我想知道如果我们简单地导出dentry_path(),
>也许是EXPORT_SYMBOL_GPL,并且警告它只能用于
>出于调试的目的,或者其他的一些。我怀疑这是不值得改变
>所有的inode_ops接口都要传递一个
>的结构路径intead。结构dentry,如果它只是用于调试。或者,也许我应该
>只要继续做这些丑陋的事情,并证明它们,因为它只是
>用于调试(yelch)。
>
>你怎么看?

只要使用dentry_path_raw() - 它是被导出的,唯一的区别是
没有被删除。


I'm writing my own kernel module which captures vfs_mkdir(struct inode *, struct dentry *, int) kernel function invocation and tries to log the on-disk pathname where this invocation occurs.

I want to use the dentry_path kernel function to convert struct dentry * to a pathname. It's wired that when I insert the module, I get an error

Unknown symbol dentry_path

My kernel version is 2.6.32 and it is supposed to be exported. I can't figure out the reason. Is there any alternatives?

解决方案

Use dentry_path_raw. dentry_path isn't exported.

From linux-fsdevel archives:

On Fri, Apr 20, 2012 at 02:08:37PM -0400, Theodore Ts'o wrote:

> I wonder if we would be better off simply exporting dentry_path(),
> perhaps as EXPORT_SYMBOL_GPL, with a warning that it should only be used
> for debugging purposes, or some such.  I suspect it's not worth changing
> all of the inode_ops interfaces to pass in a struct path intead of a
> struct dentry if it's only to be used for debugging.  Or maybe I should
> just keep on doing these ugly things and justify them because it's only
> for debugging (yelch).
> 
> What do you think?

Just use dentry_path_raw() - it _is_ exported and the only difference is
the lack of //deleted for unlinked ones.

这篇关于如何从Linux内核的struct dentry中获得完整的路径名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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