vserver 1.9.3
[linux-2.6.git] / fs / ext3 / ioctl.c
index 3681474..82b4dcb 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/ext3_fs.h>
 #include <linux/ext3_jbd.h>
 #include <linux/time.h>
+#include <linux/vserver/xid.h>
 #include <asm/uaccess.h>
 
 
@@ -26,7 +27,7 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
        switch (cmd) {
        case EXT3_IOC_GETFLAGS:
                flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
-               return put_user(flags, (int *) arg);
+               return put_user(flags, (int __user *) arg);
        case EXT3_IOC_SETFLAGS: {
                handle_t *handle = NULL;
                int err;
@@ -40,7 +41,7 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
                        return -EACCES;
 
-               if (get_user(flags, (int *) arg))
+               if (get_user(flags, (int __user *) arg))
                        return -EFAULT;
 
                if (!S_ISDIR(inode->i_mode))
@@ -57,7 +58,9 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                 *
                 * This test looks nicer. Thanks to Pauline Middelink
                 */
-               if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
+               if ((oldflags & EXT3_IMMUTABLE_FL) ||
+                       ((flags ^ oldflags) & (EXT3_APPEND_FL |
+                       EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL))) {
                        if (!capable(CAP_LINUX_IMMUTABLE))
                                return -EPERM;
                }
@@ -100,7 +103,7 @@ flags_err:
        }
        case EXT3_IOC_GETVERSION:
        case EXT3_IOC_GETVERSION_OLD:
-               return put_user(inode->i_generation, (int *) arg);
+               return put_user(inode->i_generation, (int __user *) arg);
        case EXT3_IOC_SETVERSION:
        case EXT3_IOC_SETVERSION_OLD: {
                handle_t *handle;
@@ -112,7 +115,7 @@ flags_err:
                        return -EPERM;
                if (IS_RDONLY(inode))
                        return -EROFS;
-               if (get_user(generation, (int *) arg))
+               if (get_user(generation, (int __user *) arg))
                        return -EFAULT;
 
                handle = ext3_journal_start(inode, 1);
@@ -150,6 +153,38 @@ flags_err:
                        remove_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
                        return ret;
                }
+#endif
+#if defined(CONFIG_VSERVER_LEGACY) && !defined(CONFIG_INOXID_NONE)
+       case EXT3_IOC_SETXID: {
+               handle_t *handle;
+               struct ext3_iloc iloc;
+               int xid;
+               int err;
+
+               /* fixme: if stealth, return -ENOTTY */
+               if (!capable(CAP_CONTEXT))
+                       return -EPERM;
+               if (IS_RDONLY(inode))
+                       return -EROFS;
+               if (!(inode->i_sb->s_flags & MS_TAGXID))
+                       return -ENOSYS;
+               if (get_user(xid, (int *) arg))
+                       return -EFAULT;
+
+               handle = ext3_journal_start(inode, 1);
+               if (IS_ERR(handle))
+                       return PTR_ERR(handle);
+               err = ext3_reserve_inode_write(handle, inode, &iloc);
+               if (err)
+                       return err;
+
+               inode->i_xid = (xid & 0xFFFF);
+               inode->i_ctime = CURRENT_TIME;
+
+               err = ext3_mark_iloc_dirty(handle, inode, &iloc);
+               ext3_journal_stop(handle);
+               return err;
+       }
 #endif
        default:
                return -ENOTTY;