From: "Menny Hamburger" <menny@exanet.com>
To: <linux-kernel@vger.kernel.org>
Subject: Getting the nfs_fh of a specific file/dir from the kernel
Date: Thu, 8 Feb 2007 18:38:48 +0200 [thread overview]
Message-ID: <A6FDE6B975803043804A49F12F49028E0F573A@hawk.exanet-il.co.il> (raw)
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
next reply other threads:[~2007-02-08 16:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-08 16:38 Menny Hamburger [this message]
2007-02-08 20:12 ` Getting the nfs_fh of a specific file/dir from the kernel J. Bruce Fields
2007-02-11 8:06 Menny Hamburger
2007-02-13 23:13 ` Trond Myklebust
2007-02-13 23:16 ` J. Bruce Fields
2007-02-13 23:19 ` Trond Myklebust
2007-02-13 23:36 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A6FDE6B975803043804A49F12F49028E0F573A@hawk.exanet-il.co.il \
--to=menny@exanet.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.