[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090616203921.4526.8438.stgit@warthog.procyon.org.uk>
Date: Tue, 16 Jun 2009 21:39:21 +0100
From: David Howells <dhowells@...hat.com>
To: torvalds@...l.org, akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org, linux-afs@...ts.infradead.org,
linux-fsdevel@...r.kernel.org,
Jacob Thebault-Spieker <summatusmentis@...il.com>,
David Howells <dhowells@...hat.com>
Subject: [PATCH 07/17] AFS: Implement the PGetFid pioctl
From: Jacob Thebault-Spieker <summatusmentis@...il.com>
Implement the PGetFID pioctl for AFS. This will get the FID of a specified
file and return it to userspace.
This can be tested with the OpenAFS userspace tools by doing:
fs getfid /afs
on a mounted AFS filesystem, which should return something like:
File /afs (1.1.0) contained in volume 1
Signed-off-by: Jacob Thebault-Spieker <summatusmentis@...il.com>
Signed-off-by: David Howells <dhowells@...hat.com>
---
fs/afs/pioctl.c | 30 ++++++++++++++++++++++++++++++
include/linux/afscall.h | 3 +++
include/linux/venus.h | 1 +
3 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/fs/afs/pioctl.c b/fs/afs/pioctl.c
index 6cac006..2e4f741 100644
--- a/fs/afs/pioctl.c
+++ b/fs/afs/pioctl.c
@@ -10,9 +10,35 @@
#include <linux/fs.h>
#include <linux/afscall.h>
#include <linux/pioctl.h>
+#include <linux/venus.h>
#include "internal.h"
/*
+ * Get the AFS file identifier of a file
+ */
+static long afs_PGetFID(struct dentry *dentry, struct vice_ioctl *arg,
+ struct key *key)
+{
+ struct afs_vnode *vnode;
+
+ _enter("");
+
+ vnode = AFS_FS_I(dentry->d_inode);
+
+ if (arg->out_size < sizeof(vnode->fid)) {
+ _leave(" = -EINVAL [%d < %zu]",
+ arg->out_size, sizeof(vnode->fid));
+ return -EINVAL;
+ }
+
+ memcpy(arg->out, &vnode->fid, sizeof(vnode->fid));
+ arg->out_size = sizeof(vnode->fid);
+
+ _leave(" = 0 [%d]", arg->out_size);
+ return 0;
+}
+
+/*
* The AFS path-based I/O control operation
*/
long afs_pioctl(struct dentry *dentry, int cmd, struct vice_ioctl *arg)
@@ -34,6 +60,10 @@ long afs_pioctl(struct dentry *dentry, int cmd, struct vice_ioctl *arg)
#define VIOC_COMMAND(nr) (_VICEIOCTL(nr) & ~IOCSIZE_MASK)
switch (cmd & ~IOCSIZE_MASK) {
+ case VIOC_COMMAND(PGetFID):
+ ret = afs_PGetFID(dentry, arg, key);
+ break;
+
default:
_debug("fallback to pathless: %x", cmd);
ret = afs_pathless_pioctl(cmd, arg);
diff --git a/include/linux/afscall.h b/include/linux/afscall.h
index 40cbfa5..cb006a2 100644
--- a/include/linux/afscall.h
+++ b/include/linux/afscall.h
@@ -13,4 +13,7 @@
#define AFSCALL_PIOCTL 0x14
+/* pioctl commands */
+#define PGetFID 22 /* get file ID */
+
#endif /* _LINUX_AFSCALL_H */
diff --git a/include/linux/venus.h b/include/linux/venus.h
index 19fe13e..ea896e4 100644
--- a/include/linux/venus.h
+++ b/include/linux/venus.h
@@ -17,5 +17,6 @@
/*
* pioctl commands (not usable as ioctls)
*/
+#define VIOCGETFID _VICEIOCTL(PGetFID)
#endif /* _LINUX_VENUS_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists