Messages in this thread |  | | Subject | Getting the nfs_fh of a specific file/dir from the kernel | Date | Thu, 8 Feb 2007 18:38:48 +0200 | From | "Menny Hamburger" <> |
| |
Hi,
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 *) arg;
files = current->files; if (files) { spin_lock(&files->file_lock); 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))) } } } } spin_unlock(&files->file_lock); }
Best Regards, Menny
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |