[lkml]   [2007]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectGetting the nfs_fh of a specific file/dir from the kernel

I have a piece of code in my 2.6 kernel that associates an ioctl
file_operation to nfs in file.c and dir.c.
This ioctl sends the nfs_fh to a userland application.
I have been trying to remove this ugly code by creating my own device
and implementing the ioctl but I keep getting junk instead.
Please tell me if I'm doing anything wrong here:

1) Define the I/O structure:
struct nfs_getfh {
int fd;
struct nfs_fh *fh;
2) Receive the fd of the wanted file/dir.
3) inside the ioctl function:

struct file *filp;
struct dentry *dentp;
struct inode *inop;
struct nfs_getfh getfh;
struct files_struct *files;
struct nfs_getfh __user *user_getfh = (struct nfs_getfh __user *)

files = current->files;
if (files) {
filp = fcheck(getfh.fd);
if (filp) {
dentp = dget(filp->f_dentry);
if (dentp) {
inop = dentp->d_inode;
if (inop) {
getfh.fh = NFS_FH(inop);
if (getfh.fh) {
copy_to_user((void*) user_getfh->fh, getfh.fh,
getfh.fh->size + ((int) &((struct nfs_fh*)0)->data)))

Best Regards,

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-02-08 17:41    [W:0.054 / U:1.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site