gpt4 book ai didi

linux - 如何从 Linux 内核中的 struct dentry 获取完整路径名

转载 作者:可可西里 更新时间:2023-11-01 11:49:34 78 4
gpt4 key购买 nike

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

我想使用 dentry_path 内核函数将 struct dentry * 转换为路径名。有线,当我插入模块时,我得到一个错误

Unknown symbol dentry_path

我的内核版本是2.6.32,应该是导出的。我想不通原因。有没有其他选择?

最佳答案

使用dentry_path_raw . dentry_path 未导出。

来自 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 - 如何从 Linux 内核中的 struct dentry 获取完整路径名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17216856/

78 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com