Summer_More_More_Tea
Summer_More_More_Tea

Reputation: 13356

How to get full pathname from struct dentry in Linux kernel

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?

Upvotes: 3

Views: 5975

Answers (1)

devnull
devnull

Reputation: 123468

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.

Upvotes: 6

Related Questions