lkml.org 
[lkml]   [2009]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 08/17] AFS: Implement the PGetFileCell pioctl
Date
From: Jacob Thebault-Spieker <summatusmentis@gmail.com>

Implement the PGetFileCell pioctl for AFS. This will get the name of the cell
to which a file belongs and return to userspace.

This can be tested with the OpenAFS userspace tools by doing:

fs whichcell /afs

on a mounted AFS filesystem, which should return something like:

File /afs lives in cell 'cambridge.redhat.com'

Signed-off-by: Jacob Thebault-Spieker <summatusmentis@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

fs/afs/pioctl.c | 31 +++++++++++++++++++++++++++++++
include/linux/afscall.h | 1 +
include/linux/venus.h | 1 +
3 files changed, 33 insertions(+), 0 deletions(-)


diff --git a/fs/afs/pioctl.c b/fs/afs/pioctl.c
index 2e4f741..3d95a0d 100644
--- a/fs/afs/pioctl.c
+++ b/fs/afs/pioctl.c
@@ -11,6 +11,7 @@
#include <linux/afscall.h>
#include <linux/pioctl.h>
#include <linux/venus.h>
+#include <linux/string.h>
#include "internal.h"

/*
@@ -39,6 +40,32 @@ static long afs_PGetFID(struct dentry *dentry, struct vice_ioctl *arg,
}

/*
+ * Get the cell that the file belongs to
+ */
+long afs_PGetFileCell(struct dentry *dentry, struct vice_ioctl *arg,
+ struct key *key)
+{
+ struct afs_vnode *vnode;
+ size_t name_len;
+
+ _enter("");
+
+ vnode = AFS_FS_I(dentry->d_inode);
+ name_len = strlen(vnode->volume->vlocation->cell->name);
+
+ if (arg->out_size < name_len + 1) {
+ _leave(" = -EINVAL [%d < %zu]", arg->out_size, name_len + 1);
+ return -EINVAL;
+ }
+
+ memcpy(arg->out, &vnode->volume->vlocation->cell->name, name_len + 1);
+ arg->out_size = name_len + 1;
+
+ _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)
@@ -64,6 +91,10 @@ long afs_pioctl(struct dentry *dentry, int cmd, struct vice_ioctl *arg)
ret = afs_PGetFID(dentry, arg, key);
break;

+ case VIOC_COMMAND(PGetFileCell):
+ ret = afs_PGetFileCell(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 cb006a2..0976469 100644
--- a/include/linux/afscall.h
+++ b/include/linux/afscall.h
@@ -15,5 +15,6 @@

/* pioctl commands */
#define PGetFID 22 /* get file ID */
+#define PGetFileCell 30 /* get the cell a file inhabits */

#endif /* _LINUX_AFSCALL_H */
diff --git a/include/linux/venus.h b/include/linux/venus.h
index ea896e4..9cc115c 100644
--- a/include/linux/venus.h
+++ b/include/linux/venus.h
@@ -18,5 +18,6 @@
* pioctl commands (not usable as ioctls)
*/
#define VIOCGETFID _VICEIOCTL(PGetFID)
+#define VIOC_FILE_CELL_NAME _VICEIOCTL(PGetFileCell)

#endif /* _LINUX_VENUS_H */


\
 
 \ /
  Last update: 2009-06-16 22:43    [W:0.184 / U:6.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site