Commit 4f99ed67cc1cf5302ea18aa042d75641b61a0a1b
Committed by
Linus Torvalds
1 parent
28ec039c21
Exists in
master
and in
7 other branches
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>
Showing 3 changed files with 22 additions and 0 deletions Side-by-side Diff
fs/ext2/ext2.h
... | ... | @@ -133,6 +133,7 @@ |
133 | 133 | extern void ext2_truncate (struct inode *); |
134 | 134 | extern int ext2_setattr (struct dentry *, struct iattr *); |
135 | 135 | extern void ext2_set_inode_flags(struct inode *inode); |
136 | +extern void ext2_get_inode_flags(struct ext2_inode_info *); | |
136 | 137 | |
137 | 138 | /* ioctl.c */ |
138 | 139 | extern int ext2_ioctl (struct inode *, struct file *, unsigned int, |
fs/ext2/inode.c
... | ... | @@ -1055,6 +1055,25 @@ |
1055 | 1055 | inode->i_flags |= S_DIRSYNC; |
1056 | 1056 | } |
1057 | 1057 | |
1058 | +/* Propagate flags from i_flags to EXT2_I(inode)->i_flags */ | |
1059 | +void 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 | + | |
1058 | 1077 | void ext2_read_inode (struct inode * inode) |
1059 | 1078 | { |
1060 | 1079 | struct ext2_inode_info *ei = EXT2_I(inode); |
... | ... | @@ -1188,6 +1207,7 @@ |
1188 | 1207 | if (ei->i_state & EXT2_STATE_NEW) |
1189 | 1208 | memset(raw_inode, 0, EXT2_SB(sb)->s_inode_size); |
1190 | 1209 | |
1210 | + ext2_get_inode_flags(ei); | |
1191 | 1211 | raw_inode->i_mode = cpu_to_le16(inode->i_mode); |
1192 | 1212 | if (!(test_opt(sb, NO_UID32))) { |
1193 | 1213 | raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid)); |