- merge revision 1.3
authorMark Huang <mlhuang@cs.princeton.edu>
Tue, 30 Nov 2004 16:46:45 +0000 (16:46 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Tue, 30 Nov 2004 16:46:45 +0000 (16:46 +0000)
date: 2004/11/23 15:00:18;  author: smuir;  state: Exp;  lines: +2 -2
Fix comment
----------------------------
- merge revision 1.2
date: 2004/11/18 20:06:31;  author: smuir;  state: Exp;  lines: +33 -1
Need a way to manipulate vserver file attrs using a file descriptor

kernel/vserver/inode.c

index dda8818..3e8120b 100644 (file)
@@ -170,6 +170,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           
 #include <linux/proc_fs.h>