vserver 1.9.5.x5
[linux-2.6.git] / fs / attr.c
index 5f78d75..fb83f57 100644 (file)
--- a/fs/attr.c
+++ b/fs/attr.c
 #include <linux/fcntl.h>
 #include <linux/quotaops.h>
 #include <linux/security.h>
-#include <linux/vs_base.h>
+#include <linux/time.h>
 #include <linux/proc_fs.h>
 #include <linux/devpts_fs.h>
+#include <linux/vserver/debug.h>
 
 /* Taken over from the old code... */
 
@@ -64,22 +65,19 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)
                goto fine;
 
        if (IS_BARRIER(inode)) {
-               printk(KERN_WARNING
-                       "VSW: xid=%d messing with the barrier.\n",
+               vxwprintk(1, "xid=%d messing with the barrier.",
                        vx_current_xid());
                goto error;
        }
        switch (inode->i_sb->s_magic) {
                case PROC_SUPER_MAGIC:
-                       printk(KERN_WARNING
-                               "VSW: xid=%d messing with the procfs.\n",
+                       vxwprintk(1, "xid=%d messing with the procfs.",
                                vx_current_xid());
                        goto error;
                case DEVPTS_SUPER_MAGIC:
                        if (vx_check(inode->i_xid, VX_IDENT))
                                goto fine;
-                       printk(KERN_WARNING
-                               "VSW: xid=%d messing with the devpts.\n",
+                       vxwprintk(1, "xid=%d messing with the devpts.",
                                vx_current_xid());
                        goto error;
        }
@@ -135,11 +133,14 @@ int inode_setattr(struct inode * inode, struct iattr * attr)
        if (ia_valid & ATTR_XID)
                inode->i_xid = attr->ia_xid;
        if (ia_valid & ATTR_ATIME)
-               inode->i_atime = attr->ia_atime;
+               inode->i_atime = timespec_trunc(attr->ia_atime,
+                                               inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_MTIME)
-               inode->i_mtime = attr->ia_mtime;
+               inode->i_mtime = timespec_trunc(attr->ia_mtime,
+                                               inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_CTIME)
-               inode->i_ctime = attr->ia_ctime;
+               inode->i_ctime = timespec_trunc(attr->ia_ctime,
+                                               inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_MODE) {
                umode_t mode = attr->ia_mode;
 
@@ -185,7 +186,7 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
        struct inode *inode = dentry->d_inode;
        mode_t mode = inode->i_mode;
        int error;
-       struct timespec now = CURRENT_TIME;
+       struct timespec now = current_fs_time(inode->i_sb);
        unsigned int ia_valid = attr->ia_valid;
 
        if (!inode)
@@ -219,6 +220,9 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
        if (!attr->ia_valid)
                return 0;
 
+       if (ia_valid & ATTR_SIZE)
+               down_write(&dentry->d_inode->i_alloc_sem);
+
        if (inode->i_op && inode->i_op->setattr) {
                error = security_inode_setattr(dentry, attr);
                if (!error)
@@ -236,6 +240,10 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
                                error = inode_setattr(inode, attr);
                }
        }
+
+       if (ia_valid & ATTR_SIZE)
+               up_write(&dentry->d_inode->i_alloc_sem);
+
        if (!error) {
                unsigned long dn_mask = setattr_mask(ia_valid);
                if (dn_mask)