aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2007-05-08 03:31:04 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:13 -0400
commit4f99ed67cc1cf5302ea18aa042d75641b61a0a1b (patch)
treeabf64c561c22b1aa1ba03f2dfb0bdef4d156ca8a /fs
parent28ec039c21839914389975b896160a815ffd8b83 (diff)
ext3: copy i_flags to inode flags on write
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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext2/ext2.h1
-rw-r--r--fs/ext2/inode.c20
-rw-r--r--fs/ext2/ioctl.c1
3 files changed, 22 insertions, 0 deletions
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index e2a0ea50af1d..9fd0ec5ba0d0 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -133,6 +133,7 @@ extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
133extern void ext2_truncate (struct inode *); 133extern void ext2_truncate (struct inode *);
134extern int ext2_setattr (struct dentry *, struct iattr *); 134extern int ext2_setattr (struct dentry *, struct iattr *);
135extern void ext2_set_inode_flags(struct inode *inode); 135extern void ext2_set_inode_flags(struct inode *inode);
136extern void ext2_get_inode_flags(struct ext2_inode_info *);
136 137
137/* ioctl.c */ 138/* ioctl.c */
138extern int ext2_ioctl (struct inode *, struct file *, unsigned int, 139extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 9fa1bd65a028..0079b2cd5314 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1055,6 +1055,25 @@ void ext2_set_inode_flags(struct inode *inode)
1055 inode->i_flags |= S_DIRSYNC; 1055 inode->i_flags |= S_DIRSYNC;
1056} 1056}
1057 1057
1058/* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
1059void ext2_get_inode_flags(struct ext2_inode_info *ei)
1060{
1061 unsigned int flags = ei->vfs_inode.i_flags;
1062
1063 ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
1064 EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
1065 if (flags & S_SYNC)
1066 ei->i_flags |= EXT2_SYNC_FL;
1067 if (flags & S_APPEND)
1068 ei->i_flags |= EXT2_APPEND_FL;
1069 if (flags & S_IMMUTABLE)
1070 ei->i_flags |= EXT2_IMMUTABLE_FL;
1071 if (flags & S_NOATIME)
1072 ei->i_flags |= EXT2_NOATIME_FL;
1073 if (flags & S_DIRSYNC)
1074 ei->i_flags |= EXT2_DIRSYNC_FL;
1075}
1076
1058void ext2_read_inode (struct inode * inode) 1077void ext2_read_inode (struct inode * inode)
1059{ 1078{
1060 struct ext2_inode_info *ei = EXT2_I(inode); 1079 struct ext2_inode_info *ei = EXT2_I(inode);
@@ -1188,6 +1207,7 @@ static int ext2_update_inode(struct inode * inode, int do_sync)
1188 if (ei->i_state & EXT2_STATE_NEW) 1207 if (ei->i_state & EXT2_STATE_NEW)
1189 memset(raw_inode, 0, EXT2_SB(sb)->s_inode_size); 1208 memset(raw_inode, 0, EXT2_SB(sb)->s_inode_size);
1190 1209
1210 ext2_get_inode_flags(ei);
1191 raw_inode->i_mode = cpu_to_le16(inode->i_mode); 1211 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
1192 if (!(test_opt(sb, NO_UID32))) { 1212 if (!(test_opt(sb, NO_UID32))) {
1193 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid)); 1213 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 4b099d310712..e85c48218239 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -27,6 +27,7 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
27 27
28 switch (cmd) { 28 switch (cmd) {
29 case EXT2_IOC_GETFLAGS: 29 case EXT2_IOC_GETFLAGS:
30 ext2_get_inode_flags(ei);
30 flags = ei->i_flags & EXT2_FL_USER_VISIBLE; 31 flags = ei->i_flags & EXT2_FL_USER_VISIBLE;
31 return put_user(flags, (int __user *) arg); 32 return put_user(flags, (int __user *) arg);
32 case EXT2_IOC_SETFLAGS: { 33 case EXT2_IOC_SETFLAGS: {