#include <linux/ext3_fs.h>
#include <linux/ext3_jbd.h>
#include <linux/time.h>
+#include <linux/vserver/xid.h>
#include <asm/uaccess.h>
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;
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))
*
* 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;
}
}
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;
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);
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;