ATTR_ATTR_FLAG

From: Herbert Poetzl
Date: Mon May 03 2004 - 12:26:50 EST



Hi Folks!

stumbled about ATTR_ATTR_FLAG, and asked myself,
shouldn't this be handled in *_setattr() too?

maybe something like this:
(of course it would need some modifications for
filesystems handling *_setattr special)

best,
Herbert

--- linux/fs/attr.c 2002-02-25 20:38:07.000000000 +0100
+++ linux.new/fs/attr.c 2004-04-30 23:55:01.000000000 +0200
@@ -58,6 +58,?? @@ error:
return retval;
}

+
+int inode_setattr_flags(struct inode *inode, unsigned int flags)
+{
+ unsigned int oldflags, newflags;
+
+ oldflags = inode->i_flags;
+ newflags = oldflags & ~(S_SYNC | S_NOATIME | S_APPEND | S_IMMUTABLE);
+ if (flags & ATTR_FLAG_SYNCRONOUS)
+ newflags |= S_SYNC;
+ if (flags & ATTR_FLAG_NOATIME || flags & ATTR_FLAG_NODIRATIME)
+ newflags |= S_NOATIME;
+ if (flags & ATTR_FLAG_APPEND)
+ newflags |= S_APPEND;
+ if (flags & ATTR_FLAG_IMMUTABLE)
+ newflags |= S_IMMUTABLE;
+
+ if (oldflags ^ newflags) {
+ inode->i_flags = newflags;
+ }
+ return 0;
+}
+
+
int inode_setattr(struct inode * inode, struct iattr * attr)
{
unsigned int ia_valid = attr->ia_valid;
@@ -84,6 +112,8 @@ int inode_setattr(struct inode * inode,
if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
inode->i_mode &= ~S_ISGID;
}
+ if (ia_valid & ATTR_ATTR_FLAG)
+ inode_setattr_flags(inode, attr->ia_attr_flags);
mark_inode_dirty(inode);
out:
return error;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/