diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2014-10-24 00:14:36 +0200 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2015-04-17 15:51:00 +0800 |
commit | ae311653282de97e927ff8c961a79be3ab259cb1 (patch) | |
tree | 52c610a864f530cf7b5b4edd57ac991056e43e42 /include | |
parent | 574c7ef9787b3b3d0513830e40323c34c2f53a39 (diff) |
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>
(cherry picked from commit cbdf35bcb833bfd00f0925d7a9a33a21f41ea582)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/fs.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 82c78d6a2006..ddb9ab5d23f6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2300,6 +2300,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) { @@ -2787,6 +2788,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)) |