vfs: export check_sticky()
It's already duplicated in btrfs and about to be used in overlayfs too. Move the sticky bit check to an inline helper and call the out-of-line helper only in the unlikly case of the sticky bit being set. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
This commit is contained in:
@@ -2259,6 +2259,7 @@ extern int notify_change(struct dentry *, struct iattr *, struct inode **);
|
||||
extern int inode_permission(struct inode *, int);
|
||||
extern int __inode_permission(struct inode *, int);
|
||||
extern int generic_permission(struct inode *, int);
|
||||
extern int __check_sticky(struct inode *dir, struct inode *inode);
|
||||
|
||||
static inline bool execute_ok(struct inode *inode)
|
||||
{
|
||||
@@ -2745,6 +2746,14 @@ static inline int is_sxid(umode_t mode)
|
||||
return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP));
|
||||
}
|
||||
|
||||
static inline int check_sticky(struct inode *dir, struct inode *inode)
|
||||
{
|
||||
if (!(dir->i_mode & S_ISVTX))
|
||||
return 0;
|
||||
|
||||
return __check_sticky(dir, inode);
|
||||
}
|
||||
|
||||
static inline void inode_has_no_xattr(struct inode *inode)
|
||||
{
|
||||
if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & MS_NOSEC))
|
||||
|
Reference in New Issue
Block a user