linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH] Copy i_flags to ext2 inode flags on write
Date: Mon, 23 Apr 2007 20:35:54 +0200	[thread overview]
Message-ID: <20070423183554.GB6029@duck.suse.cz> (raw)

[-- Attachment #1: Type: text/plain, Size: 175 bytes --]

  Hi,

  attached is a patch that stores i_flags to ext2 specific inode flags on
write / IOC_GETFLAGS ioctl for ext2.

									Honza
-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

[-- Attachment #2: ext2-2.6.21-rc6-propagate_flags.diff --]
[-- Type: text/x-patch, Size: 2940 bytes --]

Propagate flags such as S_APPEND, S_IMMUTABLE, etc. from i_flags into
ext2-specific i_flags. Hence, when someone sets these flags via a different
interface than ioctl, they are stored correctly.

Signed-off-by: Jan Kara <jack@suse.cz>

diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6-2-ext4_flags_update/fs/ext2/ext2.h linux-2.6.21-rc6-3-ext2_flags_update/fs/ext2/ext2.h
--- linux-2.6.21-rc6-2-ext4_flags_update/fs/ext2/ext2.h	2007-04-23 18:30:41.000000000 +0200
+++ linux-2.6.21-rc6-3-ext2_flags_update/fs/ext2/ext2.h	2007-04-23 18:30:00.000000000 +0200
@@ -133,6 +133,7 @@ extern int ext2_get_block(struct inode *
 extern void ext2_truncate (struct inode *);
 extern int ext2_setattr (struct dentry *, struct iattr *);
 extern void ext2_set_inode_flags(struct inode *inode);
+extern void ext2_get_inode_flags(struct ext2_inode_info *);
 
 /* ioctl.c */
 extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6-2-ext4_flags_update/fs/ext2/inode.c linux-2.6.21-rc6-3-ext2_flags_update/fs/ext2/inode.c
--- linux-2.6.21-rc6-2-ext4_flags_update/fs/ext2/inode.c	2006-11-29 22:57:37.000000000 +0100
+++ linux-2.6.21-rc6-3-ext2_flags_update/fs/ext2/inode.c	2007-04-23 19:09:06.000000000 +0200
@@ -1055,6 +1055,25 @@ void ext2_set_inode_flags(struct inode *
 		inode->i_flags |= S_DIRSYNC;
 }
 
+/* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
+void ext2_get_inode_flags(struct ext2_inode_info *ei)
+{
+	unsigned int flags = ei->vfs_inode.i_flags;
+
+	ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
+			EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
+	if (flags & S_SYNC)
+		ei->i_flags |= EXT2_SYNC_FL;
+	if (flags & S_APPEND)
+		ei->i_flags |= EXT2_APPEND_FL;
+	if (flags & S_IMMUTABLE)
+		ei->i_flags |= EXT2_IMMUTABLE_FL;
+	if (flags & S_NOATIME)
+		ei->i_flags |= EXT2_NOATIME_FL;
+	if (flags & S_DIRSYNC)
+		ei->i_flags |= EXT2_DIRSYNC_FL;
+}
+
 void ext2_read_inode (struct inode * inode)
 {
 	struct ext2_inode_info *ei = EXT2_I(inode);
@@ -1188,6 +1207,7 @@ static int ext2_update_inode(struct inod
 	if (ei->i_state & EXT2_STATE_NEW)
 		memset(raw_inode, 0, EXT2_SB(sb)->s_inode_size);
 
+	ext2_get_inode_flags(ei);
 	raw_inode->i_mode = cpu_to_le16(inode->i_mode);
 	if (!(test_opt(sb, NO_UID32))) {
 		raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6-2-ext4_flags_update/fs/ext2/ioctl.c linux-2.6.21-rc6-3-ext2_flags_update/fs/ext2/ioctl.c
--- linux-2.6.21-rc6-2-ext4_flags_update/fs/ext2/ioctl.c	2007-02-07 12:03:23.000000000 +0100
+++ linux-2.6.21-rc6-3-ext2_flags_update/fs/ext2/ioctl.c	2007-04-23 18:27:08.000000000 +0200
@@ -27,6 +27,7 @@ int ext2_ioctl (struct inode * inode, st
 
 	switch (cmd) {
 	case EXT2_IOC_GETFLAGS:
+		ext2_get_inode_flags(ei);
 		flags = ei->i_flags & EXT2_FL_USER_VISIBLE;
 		return put_user(flags, (int __user *) arg);
 	case EXT2_IOC_SETFLAGS: {

                 reply	other threads:[~2007-04-23 18:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070423183554.GB6029@duck.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).