new helper: inode_wrong_type()
commit 6e3e2c4362e41a2f18e3f7a5ad81bd2f49a47b85 upstream. 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> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
ded9137fcf
commit
40ba433a85
@@ -252,7 +252,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
|
||||
if (ret == -ENOMEM)
|
||||
goto out;
|
||||
if (ret || fuse_invalid_attr(&outarg.attr) ||
|
||||
(outarg.attr.mode ^ inode->i_mode) & S_IFMT)
|
||||
inode_wrong_type(inode, outarg.attr.mode))
|
||||
goto invalid;
|
||||
|
||||
forget_all_cached_acls(inode);
|
||||
@@ -1062,7 +1062,7 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
|
||||
err = fuse_simple_request(fm, &args);
|
||||
if (!err) {
|
||||
if (fuse_invalid_attr(&outarg.attr) ||
|
||||
(inode->i_mode ^ outarg.attr.mode) & S_IFMT) {
|
||||
inode_wrong_type(inode, outarg.attr.mode)) {
|
||||
fuse_make_bad(inode);
|
||||
err = -EIO;
|
||||
} else {
|
||||
@@ -1699,7 +1699,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
|
||||
}
|
||||
|
||||
if (fuse_invalid_attr(&outarg.attr) ||
|
||||
(inode->i_mode ^ outarg.attr.mode) & S_IFMT) {
|
||||
inode_wrong_type(inode, outarg.attr.mode)) {
|
||||
fuse_make_bad(inode);
|
||||
err = -EIO;
|
||||
goto error;
|
||||
|
@@ -340,7 +340,7 @@ retry:
|
||||
inode->i_generation = generation;
|
||||
fuse_init_inode(inode, attr);
|
||||
unlock_new_inode(inode);
|
||||
} else if ((inode->i_mode ^ attr->mode) & S_IFMT) {
|
||||
} else if (inode_wrong_type(inode, attr->mode)) {
|
||||
/* Inode has changed type, any I/O on the old should fail */
|
||||
fuse_make_bad(inode);
|
||||
iput(inode);
|
||||
|
@@ -202,7 +202,7 @@ retry:
|
||||
inode = d_inode(dentry);
|
||||
if (!inode ||
|
||||
get_node_id(inode) != o->nodeid ||
|
||||
((o->attr.mode ^ inode->i_mode) & S_IFMT)) {
|
||||
inode_wrong_type(inode, o->attr.mode)) {
|
||||
d_invalidate(dentry);
|
||||
dput(dentry);
|
||||
goto retry;
|
||||
|
Reference in New Issue
Block a user