Stephen writes:
> The 2.2 notify_change is far more correct than the 2.4 one.  For
> example, 2.4 blocks the notify_change if you aren't the file owner,
> but write access alone should be quite enough if you're doing a
> ftruncate...  you're best starting off with the 2.2 code than the 2.4
> code if you want to do this.

Andreas wrote:
> > What happened to the attribute flag setting code that is in
> > ext2_notify_change?  It isn't in the generic inode_setattr code.  Is the
> > only method of updating these attributes via ioctl?
> 
> At present, yes.

I had a look at the 2.2 and 2.4 ext2_notify_change() code, and the only
differences were:

- the ATTR_ATTR handling was broken in 2.4 (which my previous patch fixed).
- the 2.2 code does LARGE_FILE handling in notify_change, whereas 2.4 waits
  until ext2_update_inode().

Both 2.2 and 2.4 are checking for ATTR_ATTR, when in fact there is no other
code in the kernel which sets or uses this flag, so until that time, it is
only a waste of cycles.  Here is a new patch (for 2.4.2, but basically the
"#if 0" changes should go in 2.2 as well).  I still correct the ATTR_ATTR
and the incorrect file ownership checking (even though it is #ifdef'd out,
in case we need it again later).

Both 2.2 and 2.4 also call mark_inode_dirty() when inode_setattr() calls
mark_inode_dirty() itself so I moved the inode_setattr() call to the end.

Cheers, Andreas
============================================================================
diff -ru linux-2.4.2/fs/ext2/inode.c linux-2.4.2-aed/fs/ext2/inode.c
--- linux-2.4.2/fs/ext2/inode.c Fri Dec 29 15:36:44 2000
+++ linux-2.4.2-aed/fs/ext2/inode.c     Sun Feb 25 23:24:20 2001
@@ -1243,26 +1233,26 @@
 {
        struct inode *inode = dentry->d_inode;
        int             retval;
-       unsigned int    flags;
-       
+#if 0  /* Can currently only set attribute flags via ext2_ioctl */
        retval = -EPERM;
-       if (iattr->ia_valid & ATTR_ATTR_FLAG &&
-           ((!(iattr->ia_attr_flags & ATTR_FLAG_APPEND) !=
-             !(inode->u.ext2_i.i_flags & EXT2_APPEND_FL)) ||
-            (!(iattr->ia_attr_flags & ATTR_FLAG_IMMUTABLE) !=
-             !(inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL)))) {
-               if (!capable(CAP_LINUX_IMMUTABLE))
+       if (iattr->ia_valid & ATTR_ATTR_FLAG) {
+               if (((!(iattr->ia_attr_flags & ATTR_FLAG_APPEND) !=
+                     !(inode->u.ext2_i.i_flags & EXT2_APPEND_FL)) ||
+                    (!(iattr->ia_attr_flags & ATTR_FLAG_IMMUTABLE) !=
+                     !(inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL))) &&
+                   !capable(CAP_LINUX_IMMUTABLE))
                        goto out;
-       } else if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
-               goto out;
-
+               if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
+                       goto out;
+       }
+#endif
        retval = inode_change_ok(inode, iattr);
        if (retval != 0)
                goto out;
 
-       inode_setattr(inode, iattr);
-       
-       flags = iattr->ia_attr_flags;
+#if 0  /* Can currently only set attribute flags via ext2_ioctl */
+       if (iattr->ia_valid & ATTR_ATTR_FLAG) {
+               unsigned int flags = iattr->ia_attr_flags;
        if (flags & ATTR_FLAG_SYNCRONOUS) {
                inode->i_flags |= S_SYNC;
                inode->u.ext2_i.i_flags |= EXT2_SYNC_FL;
@@ -1291,7 +1281,9 @@
                inode->i_flags &= ~S_IMMUTABLE;
                inode->u.ext2_i.i_flags &= ~EXT2_IMMUTABLE_FL;
        }
-       mark_inode_dirty(inode);
+       }
+#endif
+       inode_setattr(inode, iattr);
 out:
        return retval;
 }
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]

Reply via email to