mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-18 07:35:12 +08:00
nilfs2: tighten restrictions on inode flags
Nilfs has few rectrictions on which flags may be set on which inodes like ext2/3/4 filesystems used to be. Specifically DIRSYNC may only be set on directories and IMMUTABLE and APPEND may not be set on links. Tighten that to disallow TOPDIR being set on non-directories and only NODUMP and NOATIME to be set on non-regular file, non-directories. This introduces a flags masking function like those of extN and uses it during inode creation. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
This commit is contained in:
parent
32f4aeb315
commit
b253a3e4f2
@ -315,11 +315,8 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
|
|||||||
/* No lock is needed; iget() ensures it. */
|
/* No lock is needed; iget() ensures it. */
|
||||||
}
|
}
|
||||||
|
|
||||||
ii->i_flags = NILFS_I(dir)->i_flags;
|
ii->i_flags = nilfs_mask_flags(
|
||||||
if (S_ISLNK(mode))
|
mode, NILFS_I(dir)->i_flags & NILFS_FL_INHERITED);
|
||||||
ii->i_flags &= ~(FS_IMMUTABLE_FL | FS_APPEND_FL);
|
|
||||||
if (!S_ISDIR(mode))
|
|
||||||
ii->i_flags &= ~FS_DIRSYNC_FL;
|
|
||||||
|
|
||||||
/* ii->i_file_acl = 0; */
|
/* ii->i_file_acl = 0; */
|
||||||
/* ii->i_dir_acl = 0; */
|
/* ii->i_dir_acl = 0; */
|
||||||
|
@ -212,6 +212,23 @@ static inline int nilfs_init_acl(struct inode *inode, struct inode *dir)
|
|||||||
|
|
||||||
#define NILFS_ATIME_DISABLE
|
#define NILFS_ATIME_DISABLE
|
||||||
|
|
||||||
|
/* Flags that should be inherited by new inodes from their parent. */
|
||||||
|
#define NILFS_FL_INHERITED \
|
||||||
|
(FS_SECRM_FL | FS_UNRM_FL | FS_COMPR_FL | FS_SYNC_FL | \
|
||||||
|
FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL |\
|
||||||
|
FS_COMPRBLK_FL | FS_NOCOMP_FL | FS_NOTAIL_FL | FS_DIRSYNC_FL)
|
||||||
|
|
||||||
|
/* Mask out flags that are inappropriate for the given type of inode. */
|
||||||
|
static inline __u32 nilfs_mask_flags(umode_t mode, __u32 flags)
|
||||||
|
{
|
||||||
|
if (S_ISDIR(mode))
|
||||||
|
return flags;
|
||||||
|
else if (S_ISREG(mode))
|
||||||
|
return flags & ~(FS_DIRSYNC_FL | FS_TOPDIR_FL);
|
||||||
|
else
|
||||||
|
return flags & (FS_NODUMP_FL | FS_NOATIME_FL);
|
||||||
|
}
|
||||||
|
|
||||||
/* dir.c */
|
/* dir.c */
|
||||||
extern int nilfs_add_link(struct dentry *, struct inode *);
|
extern int nilfs_add_link(struct dentry *, struct inode *);
|
||||||
extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *);
|
extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *);
|
||||||
|
Loading…
Reference in New Issue
Block a user