summaryrefslogtreecommitdiff
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2021-03-02 04:37:10 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2021-03-08 18:19:35 +0300
commit6e3e2c4362e41a2f18e3f7a5ad81bd2f49a47b85 (patch)
treeef51a46d8ebbfa4300e6fa4f1c20b171b351bf13 /include/linux/fs.h
parenta38fd8748464831584a19438cbb3082b5a2dab15 (diff)
downloadlinux-6e3e2c4362e41a2f18e3f7a5ad81bd2f49a47b85.tar.xz
new helper: inode_wrong_type()
inode_wrong_type(inode, mode) returns true if setting inode->i_mode to given value would've changed the inode type. We have enough of those checks open-coded to make a helper worthwhile. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index ec8f3ddf4a6a..9e0d76a41229 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2884,6 +2884,11 @@ static inline bool execute_ok(struct inode *inode)
return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
}
+static inline bool inode_wrong_type(const struct inode *inode, umode_t mode)
+{
+ return (inode->i_mode ^ mode) & S_IFMT;
+}
+
static inline void file_start_write(struct file *file)
{
if (!S_ISREG(file_inode(file)->i_mode))