sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file
[safe/jmp/linux-2.6] / fs / ocfs2 / ioctl.c
index 5177fba..31fbb06 100644 (file)
@@ -21,6 +21,7 @@
 #include "ocfs2_fs.h"
 #include "ioctl.h"
 #include "resize.h"
+#include "refcounttree.h"
 
 #include <linux/ext2_fs.h>
 
@@ -59,10 +60,6 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
                goto bail;
        }
 
-       status = -EROFS;
-       if (IS_RDONLY(inode))
-               goto bail_unlock;
-
        status = -EACCES;
        if (!is_owner_or_cap(inode))
                goto bail_unlock;
@@ -105,21 +102,23 @@ bail_unlock:
 bail:
        mutex_unlock(&inode->i_mutex);
 
-       if (bh)
-               brelse(bh);
+       brelse(bh);
 
        mlog_exit(status);
        return status;
 }
 
-int ocfs2_ioctl(struct inode * inode, struct file * filp,
-       unsigned int cmd, unsigned long arg)
+long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
+       struct inode *inode = filp->f_path.dentry->d_inode;
        unsigned int flags;
        int new_clusters;
        int status;
        struct ocfs2_space_resv sr;
        struct ocfs2_new_group_input input;
+       struct reflink_arguments args;
+       const char *old_path, *new_path;
+       bool preserve;
 
        switch (cmd) {
        case OCFS2_IOC_GETFLAGS:
@@ -133,8 +132,13 @@ int ocfs2_ioctl(struct inode * inode, struct file * filp,
                if (get_user(flags, (int __user *) arg))
                        return -EFAULT;
 
-               return ocfs2_set_inode_attr(inode, flags,
+               status = mnt_want_write(filp->f_path.mnt);
+               if (status)
+                       return status;
+               status = ocfs2_set_inode_attr(inode, flags,
                        OCFS2_FL_MODIFIABLE);
+               mnt_drop_write(filp->f_path.mnt);
+               return status;
        case OCFS2_IOC_RESVSP:
        case OCFS2_IOC_RESVSP64:
        case OCFS2_IOC_UNRESVSP:
@@ -160,6 +164,15 @@ int ocfs2_ioctl(struct inode * inode, struct file * filp,
                        return -EFAULT;
 
                return ocfs2_group_add(inode, &input);
+       case OCFS2_IOC_REFLINK:
+               if (copy_from_user(&args, (struct reflink_arguments *)arg,
+                                  sizeof(args)))
+                       return -EFAULT;
+               old_path = (const char *)(unsigned long)args.old_path;
+               new_path = (const char *)(unsigned long)args.new_path;
+               preserve = (args.preserve != 0);
+
+               return ocfs2_reflink_ioctl(inode, old_path, new_path, preserve);
        default:
                return -ENOTTY;
        }
@@ -168,9 +181,6 @@ int ocfs2_ioctl(struct inode * inode, struct file * filp,
 #ifdef CONFIG_COMPAT
 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 {
-       struct inode *inode = file->f_path.dentry->d_inode;
-       int ret;
-
        switch (cmd) {
        case OCFS2_IOC32_GETFLAGS:
                cmd = OCFS2_IOC_GETFLAGS;
@@ -185,14 +195,12 @@ long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
        case OCFS2_IOC_GROUP_EXTEND:
        case OCFS2_IOC_GROUP_ADD:
        case OCFS2_IOC_GROUP_ADD64:
+       case OCFS2_IOC_REFLINK:
                break;
        default:
                return -ENOIOCTLCMD;
        }
 
-       lock_kernel();
-       ret = ocfs2_ioctl(inode, file, cmd, arg);
-       unlock_kernel();
-       return ret;
+       return ocfs2_ioctl(file, cmd, arg);
 }
 #endif