summaryrefslogtreecommitdiff
path: root/ext2fs/ext2_fs.h
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-12-28 00:28:35 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-12-28 00:28:35 +0100
commite3372f9819e603914db63aa8aed1293488c5299d (patch)
treea4389a40e40c488243670388952361c641d2ecfc /ext2fs/ext2_fs.h
parentd88bebe601742481f5b244e08c0fa442ddbefbf2 (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/ext2_fs.h')
-rw-r--r--ext2fs/ext2_fs.h23
1 files changed, 23 insertions, 0 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
*/