aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2014-10-23 18:14:36 -0400
committerMiklos Szeredi <mszeredi@suse.cz>2014-10-23 18:14:36 -0400
commitcbdf35bcb833bfd00f0925d7a9a33a21f41ea582 (patch)
treefe76fb2eeaaf2b56d4961840caf97719567c6a88 /fs/namei.c
parentc771d683a62e5d36bc46036f5c07f4f5bb7dda61 (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>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/fs/namei.c b/fs/namei.c
index d944f6db9b07..77fd536106cb 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2384,22 +2384,17 @@ kern_path_mountpoint(int dfd, const char *name, struct path *path,
2384} 2384}
2385EXPORT_SYMBOL(kern_path_mountpoint); 2385EXPORT_SYMBOL(kern_path_mountpoint);
2386 2386
2387/* 2387int __check_sticky(struct inode *dir, struct inode *inode)
2388 * It's inline, so penalty for filesystems that don't use sticky bit is
2389 * minimal.
2390 */
2391static inline int check_sticky(struct inode *dir, struct inode *inode)
2392{ 2388{
2393 kuid_t fsuid = current_fsuid(); 2389 kuid_t fsuid = current_fsuid();
2394 2390
2395 if (!(dir->i_mode & S_ISVTX))
2396 return 0;
2397 if (uid_eq(inode->i_uid, fsuid)) 2391 if (uid_eq(inode->i_uid, fsuid))
2398 return 0; 2392 return 0;
2399 if (uid_eq(dir->i_uid, fsuid)) 2393 if (uid_eq(dir->i_uid, fsuid))
2400 return 0; 2394 return 0;
2401 return !capable_wrt_inode_uidgid(inode, CAP_FOWNER); 2395 return !capable_wrt_inode_uidgid(inode, CAP_FOWNER);
2402} 2396}
2397EXPORT_SYMBOL(__check_sticky);
2403 2398
2404/* 2399/*
2405 * Check whether we can remove a link victim from directory dir, check 2400 * Check whether we can remove a link victim from directory dir, check