How to get the full path from struct dentry in the Linux kernel

I am writing my own kernel module, which captures the call to the vfs_mkdir(struct inode *, struct dentry *, int) function of the kernel and tries to write the path to the disk where this call occurs.

I want to use the dentry_path kernel dentry_path to convert a struct dentry * to a path. He plugged it in, when I insert the module, I get an error

Unknown dentry_path character

My kernel version is 2.6.32, and it is assumed that it will be exported. I can not understand the reason. Are there any alternatives?

+3
source share
1 answer

Use dentry_path_raw . dentry_path not exported.

From the 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 not worth changing > all of the inode_ops interfaces to pass in a struct path intead of a > struct dentry if it only to be used for debugging. Or maybe I should > just keep on doing these ugly things and justify them because it 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. 
+5
source

Source: https://habr.com/ru/post/944044/


All Articles