mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* ATTR_ATTR_FLAG
@ 2004-05-03 17:24 Herbert Poetzl
  0 siblings, 0 replies; only message in thread
From: Herbert Poetzl @ 2004-05-03 17:24 UTC (permalink / raw)
  To: linux-kernel


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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-05-03 17:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-03 17:24 ATTR_ATTR_FLAG Herbert Poetzl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®