Resurrect patches to support Proper
authorSteve Muir <smuir@cs.princeton.edu>
Mon, 18 Apr 2005 17:58:17 +0000 (17:58 +0000)
committerSteve Muir <smuir@cs.princeton.edu>
Mon, 18 Apr 2005 17:58:17 +0000 (17:58 +0000)
fs/ioctl.c
include/linux/vserver/inode.h
kernel/vserver/inode.c

index 19e902d..6af7a74 100644 (file)
@@ -174,6 +174,19 @@ asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
                                error = vx_proc_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
                        break;
 #endif
+               case FIOC_SETIATTR:
+               case FIOC_GETIATTR:
+                       /*
+                        * Verify that this filp is a file object,
+                        * not (say) a socket.
+                        */
+                       error = -ENOTTY;
+                       if (S_ISREG(filp->f_dentry->d_inode->i_mode) ||
+                           S_ISDIR(filp->f_dentry->d_inode->i_mode))
+                               error = vc_iattr_ioctl(filp->f_dentry,
+                                                      cmd, arg);
+                       break;
+
                default:
                        error = -ENOTTY;
                        if (S_ISREG(filp->f_dentry->d_inode->i_mode))
index a1054e8..d9587f2 100644 (file)
@@ -57,6 +57,10 @@ extern int vc_set_iattr_v0(uint32_t, void __user *);
 extern int vc_get_iattr(uint32_t, void __user *);
 extern int vc_set_iattr(uint32_t, void __user *);
 
+extern int vc_iattr_ioctl(struct dentry *de,
+                         unsigned int cmd,
+                         unsigned long arg);
+
 #endif /* __KERNEL__ */
 
 /* inode ioctls */
@@ -64,6 +68,9 @@ extern int vc_set_iattr(uint32_t, void __user *);
 #define FIOC_GETXFLG   _IOR('x', 5, long)
 #define FIOC_SETXFLG   _IOW('x', 6, long)
 
+#define FIOC_GETIATTR   _IOR('x', 7, long)
+#define FIOC_SETIATTR   _IOR('x', 8, long)
+
 #else  /* _VX_INODE_H */
 #warning duplicate inclusion
 #endif /* _VX_INODE_H */
index 8fdd30c..ca16e0c 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/vs_context.h>
+#include <linux/fs.h>
 #include <linux/proc_fs.h>
 #include <linux/devpts_fs.h>
 #include <linux/namei.h>
@@ -188,6 +189,37 @@ int vc_set_iattr(uint32_t id, void __user *data)
        return ret;
 }
 
+int vc_iattr_ioctl(struct dentry *de, unsigned int cmd, unsigned long arg)
+{
+       void __user *data = (void __user *)arg;
+       struct vcmd_ctx_iattr_v1 vc_data;
+       int ret;
+
+       /*
+        * I don't think we need any dget/dput pairs in here as long as
+        * this function is always called from sys_ioctl i.e., de is
+         * a field of a struct file that is guaranteed not to be freed.
+        */
+       if (cmd == FIOC_SETIATTR) {
+               if (!capable(CAP_SYS_ADMIN) || !capable(CAP_LINUX_IMMUTABLE))
+                       return -EPERM;
+               if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+                       return -EFAULT;
+               ret = __vc_set_iattr(de,
+                       &vc_data.xid, &vc_data.flags, &vc_data.mask);
+       }
+       else {
+               if (!vx_check(0, VX_ADMIN))
+                       return -ENOSYS;
+               ret = __vc_get_iattr(de->d_inode,
+                       &vc_data.xid, &vc_data.flags, &vc_data.mask);
+       }
+
+       if (!ret && copy_to_user (data, &vc_data, sizeof(vc_data)))
+               ret = -EFAULT;
+       return ret;
+}
+
 
 #ifdef CONFIG_VSERVER_LEGACY