Reputation: 1732
I've got "n" character device in one kernel driver. One read function referred to read pointer.
static struct file_operations fops;
fops.read = cd_read;
Now i need to know which character device referred when read called from userspace.
static ssize_t cd_read(struct file *filep, char *buffer, size_t len, loff_t *position)
{
filep->f_path;
}
I tried to get it by filep->f_path at least tried to print it but f_path refers to struct path in fs.h
struct file {
...
struct path f_path;
...
}
dentry and vfsmount in path in path.h refers to 2 undefined struct.
struct dentry;
struct vfsmount;
struct path {
struct vfsmount *mnt;
struct dentry *dentry;
};
and stuck in here. So how can i get the node name or path of the character device in kernel?
Upvotes: 1
Views: 1676
Reputation: 1732
I found the solution.
filp->f_path.dentry->d_iname
works as described in here:
Upvotes: 2