PCI Hotplug: cpqphp_ctrl.c: kmalloc + memset conversion to kzalloc
[safe/jmp/linux-2.6] / fs / attr.c
index c3c76fe..f8dfc22 100644 (file)
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -9,12 +9,11 @@
 #include <linux/time.h>
 #include <linux/mm.h>
 #include <linux/string.h>
-#include <linux/smp_lock.h>
-#include <linux/dnotify.h>
+#include <linux/capability.h>
+#include <linux/fsnotify.h>
 #include <linux/fcntl.h>
 #include <linux/quotaops.h>
 #include <linux/security.h>
-#include <linux/time.h>
 
 /* Taken over from the old code... */
 
@@ -43,7 +42,7 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)
 
        /* Make sure a caller can chmod. */
        if (ia_valid & ATTR_MODE) {
-               if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
+               if (!is_owner_or_cap(inode))
                        goto error;
                /* Also check the setgid bit! */
                if (!in_group_p((ia_valid & ATTR_GID) ? attr->ia_gid :
@@ -53,7 +52,7 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)
 
        /* Check for setting the inode time. */
        if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
-               if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
+               if (!is_owner_or_cap(inode))
                        goto error;
        }
 fine:
@@ -67,20 +66,12 @@ EXPORT_SYMBOL(inode_change_ok);
 int inode_setattr(struct inode * inode, struct iattr * attr)
 {
        unsigned int ia_valid = attr->ia_valid;
-       int error = 0;
-
-       if (ia_valid & ATTR_SIZE) {
-               if (attr->ia_size != i_size_read(inode)) {
-                       error = vmtruncate(inode, attr->ia_size);
-                       if (error || (ia_valid == ATTR_SIZE))
-                               goto out;
-               } else {
-                       /*
-                        * We skipped the truncate but must still update
-                        * timestamps
-                        */
-                       ia_valid |= ATTR_MTIME|ATTR_CTIME;
-               }
+
+       if (ia_valid & ATTR_SIZE &&
+           attr->ia_size != i_size_read(inode)) {
+               int error = vmtruncate(inode, attr->ia_size);
+               if (error)
+                       return error;
        }
 
        if (ia_valid & ATTR_UID)
@@ -104,33 +95,10 @@ int inode_setattr(struct inode * inode, struct iattr * attr)
                inode->i_mode = mode;
        }
        mark_inode_dirty(inode);
-out:
-       return error;
-}
-
-EXPORT_SYMBOL(inode_setattr);
-
-int setattr_mask(unsigned int ia_valid)
-{
-       unsigned long dn_mask = 0;
 
-       if (ia_valid & ATTR_UID)
-               dn_mask |= DN_ATTRIB;
-       if (ia_valid & ATTR_GID)
-               dn_mask |= DN_ATTRIB;
-       if (ia_valid & ATTR_SIZE)
-               dn_mask |= DN_MODIFY;
-       /* both times implies a utime(s) call */
-       if ((ia_valid & (ATTR_ATIME|ATTR_MTIME)) == (ATTR_ATIME|ATTR_MTIME))
-               dn_mask |= DN_ATTRIB;
-       else if (ia_valid & ATTR_ATIME)
-               dn_mask |= DN_ACCESS;
-       else if (ia_valid & ATTR_MTIME)
-               dn_mask |= DN_MODIFY;
-       if (ia_valid & ATTR_MODE)
-               dn_mask |= DN_ATTRIB;
-       return dn_mask;
+       return 0;
 }
+EXPORT_SYMBOL(inode_setattr);
 
 int notify_change(struct dentry * dentry, struct iattr * attr)
 {
@@ -140,9 +108,6 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
        struct timespec now;
        unsigned int ia_valid = attr->ia_valid;
 
-       if (!inode)
-               BUG();
-
        mode = inode->i_mode;
        now = current_fs_time(inode->i_sb);
 
@@ -197,11 +162,9 @@ int notify_change(struct dentry * dentry, struct iattr * 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)
-                       dnotify_parent(dentry, dn_mask);
-       }
+       if (!error)
+               fsnotify_change(dentry, ia_valid);
+
        return error;
 }