From 4cb4089d43bc9e18a3a95af56af6115e9788a270 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 14 Aug 2008 19:24:04 -0700 Subject: [PATCH] kclient: beginnings of layout ioctls --- src/kernel/file.c | 39 ++++++++++++++++++++++++++++++++++++++- src/kernel/ioctl.h | 12 ++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/kernel/ioctl.h diff --git a/src/kernel/file.c b/src/kernel/file.c index 6903aa3501e3a..0880e70cc8a5b 100644 --- a/src/kernel/file.c +++ b/src/kernel/file.c @@ -8,6 +8,7 @@ int ceph_debug_file = -1; #include "super.h" #include "mds_client.h" +#include "ioctl.h" #include @@ -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 index 0000000000000..3420a8cdeb8ae --- /dev/null +++ b/src/kernel/ioctl.h @@ -0,0 +1,12 @@ +#ifndef FS_CEPH_IOCTL_H +#define FS_CEPH_IOCTL_H + +#include +#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 -- 2.39.5