In Linux, how can I get the filename from the "struct file" structure, while stepping thru the kernel with kgdb?

You can get the filename from struct file *filp with filp->f_path.dentry->d_iname.

To get the full path call dentry_path_raw(filp->f_path.dentry,buf,buflen).


In the Linux kernel, the file structure is essentially how the kernel "sees" the file. The kernel is not interested in the file name, just the inode of the open file. This means that all of the other information which is important to the user is lost.


EDIT: This answer is wrong. You can get the dentry using filp->f_path.dentry. From there you can get the name of the dentry or the full path using the relevant FS flags.

Tags:

Linux Kernel