]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: beginnings of layout ioctls
authorSage Weil <sage@newdream.net>
Fri, 15 Aug 2008 02:24:04 +0000 (19:24 -0700)
committerSage Weil <sage@newdream.net>
Fri, 15 Aug 2008 02:24:04 +0000 (19:24 -0700)
src/kernel/file.c
src/kernel/ioctl.h [new file with mode: 0644]

index 6903aa3501e3af82db6aba77fce6bb5e27512c7b..0880e70cc8a5b310e59a85f7fac320c0c131897f 100644 (file)
@@ -8,6 +8,7 @@ int ceph_debug_file = -1;
 #include "super.h"
 
 #include "mds_client.h"
+#include "ioctl.h"
 
 #include <linux/namei.h>
 
@@ -382,9 +383,45 @@ static int ceph_fsync(struct file *file, struct dentry *dentry, int datasync)
        return 0;
 }
 
+
+/*
+ * ioctls
+ */
+
+static long ceph_ioctl_get_layout(struct file *file, void __user *arg)
+{
+       struct ceph_inode_info *ci = ceph_inode(file->f_dentry->d_inode);
+
+       if (copy_to_user(arg, &ci->i_layout, sizeof(ci->i_layout)))
+               return -EFAULT;
+
+       return 0;
+}
+
+static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct ceph_file_layout l;
+
+       if (copy_from_user(&l, arg, sizeof(l)))
+               return -EFAULT;
+
+       /* validate */
+       /* ... */
+
+       return 0;
+}
+
 static long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       return -EINVAL;
+       switch (cmd) {
+       case CEPH_IOC_GET_LAYOUT:
+               return ceph_ioctl_get_layout(file, (void __user *)arg);
+
+       case CEPH_IOC_SET_LAYOUT:
+               return ceph_ioctl_set_layout(file, (void __user *)arg);
+       }
+       return -ENOTTY;
 }
 
 const struct file_operations ceph_file_fops = {
diff --git a/src/kernel/ioctl.h b/src/kernel/ioctl.h
new file mode 100644 (file)
index 0000000..3420a8c
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef FS_CEPH_IOCTL_H
+#define FS_CEPH_IOCTL_H
+
+#include <linux/ioctl.h>
+#include "ceph_fs.h"
+
+#define CEPH_IOCTL_MAGIC 0x97
+
+#define CEPH_IOC_GET_LAYOUT _IOR(CEPH_IOCTL_MAGIC, 1, struct ceph_file_layout)
+#define CEPH_IOC_SET_LAYOUT _IOW(CEPH_IOCTL_MAGIC, 2, struct ceph_file_layout)
+
+#endif