diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2011-12-28 00:28:35 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2011-12-28 00:28:35 +0100 |
commit | e3372f9819e603914db63aa8aed1293488c5299d (patch) | |
tree | a4389a40e40c488243670388952361c641d2ecfc /ext2fs | |
parent | d88bebe601742481f5b244e08c0fa442ddbefbf2 (diff) |
Do not inherit all ext2fs flags
* ext2fs/ext2_fs.h (EXT2_FL_INHERITED, EXT2_REG_FLMASK, EXT2_OTHER_FLMASK):
New macros.
(ext2_mask_flags): New inline function.
* ext2fs/ialloc.c (diskfs_alloc_node): Use EXT2_FL_INHERITED and call
ext2_mask_flags.
Diffstat (limited to 'ext2fs')
-rw-r--r-- | ext2fs/ext2_fs.h | 23 | ||||
-rw-r--r-- | ext2fs/ialloc.c | 5 |
2 files changed, 25 insertions, 3 deletions
diff --git a/ext2fs/ext2_fs.h b/ext2fs/ext2_fs.h index a8f922e1..b1caeefa 100644 --- a/ext2fs/ext2_fs.h +++ b/ext2fs/ext2_fs.h @@ -203,6 +203,29 @@ struct ext2_group_desc #define EXT2_FL_USER_VISIBLE 0x00001FFF /* User visible flags */ #define EXT2_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */ +/* Flags that should be inherited by new inodes from their parent. */ +#define EXT2_FL_INHERITED (EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_COMPR_FL |\ + EXT2_SYNC_FL | EXT2_NODUMP_FL |\ + EXT2_NOATIME_FL | EXT2_COMPRBLK_FL |\ + EXT2_NOCOMP_FL) + +/* Flags that are appropriate for regular files (all but dir-specific ones). */ +#define EXT2_REG_FLMASK (~(0)) + +/* Flags that are appropriate for non-directories/regular files. */ +#define EXT2_OTHER_FLMASK (EXT2_NODUMP_FL | EXT2_NOATIME_FL) + +/* Mask out flags that are inappropriate for the given type of inode. */ +static __inline__ __u32 ext2_mask_flags(mode_t mode, __u32 flags) +{ + if (S_ISDIR(mode)) + return flags; + else if (S_ISREG(mode)) + return flags & EXT2_REG_FLMASK; + else + return flags & EXT2_OTHER_FLMASK; +} + /* * ioctl commands */ diff --git a/ext2fs/ialloc.c b/ext2fs/ialloc.c index 22d911b5..15c17a4e 100644 --- a/ext2fs/ialloc.c +++ b/ext2fs/ialloc.c @@ -315,9 +315,8 @@ diskfs_alloc_node (struct node *dir, mode_t mode, struct node **node) } /* Propagate initial inode flags from the directory, as Linux does. */ - np->dn->info.i_flags = dir->dn->info.i_flags; - if (S_ISLNK (mode)) - np->dn->info.i_flags &= ~(EXT2_IMMUTABLE_FL | EXT2_APPEND_FL); + np->dn->info.i_flags = + ext2_mask_flags(mode, dir->dn->info.i_flags & EXT2_FL_INHERITED); st->st_flags = 0; |