Commit acfa4380 authored by Al Viro's avatar Al Viro

inode->i_op is never NULL

We used to have rather schizophrenic set of checks for NULL ->i_op even
though it had been eliminated years ago.  You'd need to go out of your
way to set it to NULL explicitly _and_ a bunch of code would die on
such inodes anyway.  After killing two remaining places that still
did that bogosity, all that crap can go away.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 9742df33
...@@ -1641,7 +1641,7 @@ static int cifs_vmtruncate(struct inode *inode, loff_t offset) ...@@ -1641,7 +1641,7 @@ static int cifs_vmtruncate(struct inode *inode, loff_t offset)
i_size_write(inode, offset); i_size_write(inode, offset);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
out_truncate: out_truncate:
if (inode->i_op && inode->i_op->truncate) if (inode->i_op->truncate)
inode->i_op->truncate(inode); inode->i_op->truncate(inode);
return 0; return 0;
out_sig: out_sig:
......
...@@ -612,8 +612,7 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz) ...@@ -612,8 +612,7 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
struct ecryptfs_crypt_stat *crypt_stat; struct ecryptfs_crypt_stat *crypt_stat;
lower_dentry = ecryptfs_dentry_to_lower(dentry); lower_dentry = ecryptfs_dentry_to_lower(dentry);
if (!lower_dentry->d_inode->i_op || if (!lower_dentry->d_inode->i_op->readlink) {
!lower_dentry->d_inode->i_op->readlink) {
rc = -EINVAL; rc = -EINVAL;
goto out; goto out;
} }
......
...@@ -257,7 +257,7 @@ int inode_permission(struct inode *inode, int mask) ...@@ -257,7 +257,7 @@ int inode_permission(struct inode *inode, int mask)
return -EACCES; return -EACCES;
} }
if (inode->i_op && inode->i_op->permission) if (inode->i_op->permission)
retval = inode->i_op->permission(inode, mask); retval = inode->i_op->permission(inode, mask);
else else
retval = generic_permission(inode, mask, NULL); retval = generic_permission(inode, mask, NULL);
...@@ -432,7 +432,7 @@ static int exec_permission_lite(struct inode *inode) ...@@ -432,7 +432,7 @@ static int exec_permission_lite(struct inode *inode)
{ {
umode_t mode = inode->i_mode; umode_t mode = inode->i_mode;
if (inode->i_op && inode->i_op->permission) if (inode->i_op->permission)
return -EAGAIN; return -EAGAIN;
if (current_fsuid() == inode->i_uid) if (current_fsuid() == inode->i_uid)
...@@ -908,9 +908,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd) ...@@ -908,9 +908,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
inode = next.dentry->d_inode; inode = next.dentry->d_inode;
if (!inode) if (!inode)
goto out_dput; goto out_dput;
err = -ENOTDIR;
if (!inode->i_op)
goto out_dput;
if (inode->i_op->follow_link) { if (inode->i_op->follow_link) {
err = do_follow_link(&next, nd); err = do_follow_link(&next, nd);
...@@ -920,9 +917,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd) ...@@ -920,9 +917,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
inode = nd->path.dentry->d_inode; inode = nd->path.dentry->d_inode;
if (!inode) if (!inode)
break; break;
err = -ENOTDIR;
if (!inode->i_op)
break;
} else } else
path_to_nameidata(&next, nd); path_to_nameidata(&next, nd);
err = -ENOTDIR; err = -ENOTDIR;
...@@ -961,7 +955,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd) ...@@ -961,7 +955,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
break; break;
inode = next.dentry->d_inode; inode = next.dentry->d_inode;
if ((lookup_flags & LOOKUP_FOLLOW) if ((lookup_flags & LOOKUP_FOLLOW)
&& inode && inode->i_op && inode->i_op->follow_link) { && inode && inode->i_op->follow_link) {
err = do_follow_link(&next, nd); err = do_follow_link(&next, nd);
if (err) if (err)
goto return_err; goto return_err;
...@@ -973,7 +967,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd) ...@@ -973,7 +967,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
break; break;
if (lookup_flags & LOOKUP_DIRECTORY) { if (lookup_flags & LOOKUP_DIRECTORY) {
err = -ENOTDIR; err = -ENOTDIR;
if (!inode->i_op || !inode->i_op->lookup) if (!inode->i_op->lookup)
break; break;
} }
goto return_base; goto return_base;
...@@ -1469,7 +1463,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -1469,7 +1463,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode,
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->create) if (!dir->i_op->create)
return -EACCES; /* shouldn't it be ENOSYS? */ return -EACCES; /* shouldn't it be ENOSYS? */
mode &= S_IALLUGO; mode &= S_IALLUGO;
mode |= S_IFREG; mode |= S_IFREG;
...@@ -1752,7 +1746,7 @@ struct file *do_filp_open(int dfd, const char *pathname, ...@@ -1752,7 +1746,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
error = -ENOENT; error = -ENOENT;
if (!path.dentry->d_inode) if (!path.dentry->d_inode)
goto exit_dput; goto exit_dput;
if (path.dentry->d_inode->i_op && path.dentry->d_inode->i_op->follow_link) if (path.dentry->d_inode->i_op->follow_link)
goto do_link; goto do_link;
path_to_nameidata(&path, &nd); path_to_nameidata(&path, &nd);
...@@ -1933,7 +1927,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) ...@@ -1933,7 +1927,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD)) if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
return -EPERM; return -EPERM;
if (!dir->i_op || !dir->i_op->mknod) if (!dir->i_op->mknod)
return -EPERM; return -EPERM;
error = devcgroup_inode_mknod(mode, dev); error = devcgroup_inode_mknod(mode, dev);
...@@ -2035,7 +2029,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -2035,7 +2029,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->mkdir) if (!dir->i_op->mkdir)
return -EPERM; return -EPERM;
mode &= (S_IRWXUGO|S_ISVTX); mode &= (S_IRWXUGO|S_ISVTX);
...@@ -2126,7 +2120,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -2126,7 +2120,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->rmdir) if (!dir->i_op->rmdir)
return -EPERM; return -EPERM;
DQUOT_INIT(dir); DQUOT_INIT(dir);
...@@ -2213,7 +2207,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -2213,7 +2207,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->unlink) if (!dir->i_op->unlink)
return -EPERM; return -EPERM;
DQUOT_INIT(dir); DQUOT_INIT(dir);
...@@ -2320,7 +2314,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname) ...@@ -2320,7 +2314,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->symlink) if (!dir->i_op->symlink)
return -EPERM; return -EPERM;
error = security_inode_symlink(dir, dentry, oldname); error = security_inode_symlink(dir, dentry, oldname);
...@@ -2401,7 +2395,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de ...@@ -2401,7 +2395,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
*/ */
if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
return -EPERM; return -EPERM;
if (!dir->i_op || !dir->i_op->link) if (!dir->i_op->link)
return -EPERM; return -EPERM;
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
return -EPERM; return -EPERM;
...@@ -2608,7 +2602,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2608,7 +2602,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (error) if (error)
return error; return error;
if (!old_dir->i_op || !old_dir->i_op->rename) if (!old_dir->i_op->rename)
return -EPERM; return -EPERM;
DQUOT_INIT(old_dir); DQUOT_INIT(old_dir);
......
...@@ -1211,7 +1211,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1211,7 +1211,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
dirp = dentry->d_inode; dirp = dentry->d_inode;
err = nfserr_notdir; err = nfserr_notdir;
if(!dirp->i_op || !dirp->i_op->lookup) if (!dirp->i_op->lookup)
goto out; goto out;
/* /*
* Check whether the response file handle has been verified yet. * Check whether the response file handle has been verified yet.
...@@ -1347,7 +1347,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1347,7 +1347,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
/* Get all the sanity checks out of the way before /* Get all the sanity checks out of the way before
* we lock the parent. */ * we lock the parent. */
err = nfserr_notdir; err = nfserr_notdir;
if(!dirp->i_op || !dirp->i_op->lookup) if (!dirp->i_op->lookup)
goto out; goto out;
fh_lock_nested(fhp, I_MUTEX_PARENT); fh_lock_nested(fhp, I_MUTEX_PARENT);
...@@ -1482,7 +1482,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp) ...@@ -1482,7 +1482,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
inode = dentry->d_inode; inode = dentry->d_inode;
err = nfserr_inval; err = nfserr_inval;
if (!inode->i_op || !inode->i_op->readlink) if (!inode->i_op->readlink)
goto out; goto out;
touch_atime(fhp->fh_export->ex_path.mnt, dentry); touch_atime(fhp->fh_export->ex_path.mnt, dentry);
...@@ -2162,7 +2162,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl) ...@@ -2162,7 +2162,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl)
size_t size; size_t size;
int error; int error;
if (!IS_POSIXACL(inode) || !inode->i_op || if (!IS_POSIXACL(inode) ||
!inode->i_op->setxattr || !inode->i_op->removexattr) !inode->i_op->setxattr || !inode->i_op->removexattr)
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch(type) { switch(type) {
......
...@@ -412,7 +412,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len) ...@@ -412,7 +412,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len)
if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0))
goto out_fput; goto out_fput;
if (inode->i_op && inode->i_op->fallocate) if (inode->i_op->fallocate)
ret = inode->i_op->fallocate(inode, mode, offset, len); ret = inode->i_op->fallocate(inode, mode, offset, len);
else else
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
......
...@@ -305,7 +305,7 @@ asmlinkage long sys_readlinkat(int dfd, const char __user *pathname, ...@@ -305,7 +305,7 @@ asmlinkage long sys_readlinkat(int dfd, const char __user *pathname,
struct inode *inode = path.dentry->d_inode; struct inode *inode = path.dentry->d_inode;
error = -EINVAL; error = -EINVAL;
if (inode->i_op && inode->i_op->readlink) { if (inode->i_op->readlink) {
error = security_inode_readlink(path.dentry); error = security_inode_readlink(path.dentry);
if (!error) { if (!error) {
touch_atime(path.mnt, path.dentry); touch_atime(path.mnt, path.dentry);
......
...@@ -175,7 +175,7 @@ vfs_listxattr(struct dentry *d, char *list, size_t size) ...@@ -175,7 +175,7 @@ vfs_listxattr(struct dentry *d, char *list, size_t size)
if (error) if (error)
return error; return error;
error = -EOPNOTSUPP; error = -EOPNOTSUPP;
if (d->d_inode->i_op && d->d_inode->i_op->listxattr) { if (d->d_inode->i_op->listxattr) {
error = d->d_inode->i_op->listxattr(d, list, size); error = d->d_inode->i_op->listxattr(d, list, size);
} else { } else {
error = security_inode_listsecurity(d->d_inode, list, size); error = security_inode_listsecurity(d->d_inode, list, size);
......
...@@ -2266,7 +2266,7 @@ int vmtruncate(struct inode * inode, loff_t offset) ...@@ -2266,7 +2266,7 @@ int vmtruncate(struct inode * inode, loff_t offset)
unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
} }
if (inode->i_op && inode->i_op->truncate) if (inode->i_op->truncate)
inode->i_op->truncate(inode); inode->i_op->truncate(inode);
return 0; return 0;
...@@ -2286,7 +2286,7 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end) ...@@ -2286,7 +2286,7 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
* a way to truncate a range of blocks (punch a hole) - * a way to truncate a range of blocks (punch a hole) -
* we should return failure right now. * we should return failure right now.
*/ */
if (!inode->i_op || !inode->i_op->truncate_range) if (!inode->i_op->truncate_range)
return -ENOSYS; return -ENOSYS;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
......
...@@ -86,7 +86,7 @@ int vmtruncate(struct inode *inode, loff_t offset) ...@@ -86,7 +86,7 @@ int vmtruncate(struct inode *inode, loff_t offset)
i_size_write(inode, offset); i_size_write(inode, offset);
out_truncate: out_truncate:
if (inode->i_op && inode->i_op->truncate) if (inode->i_op->truncate)
inode->i_op->truncate(inode); inode->i_op->truncate(inode);
return 0; return 0;
out_sig: out_sig:
......
...@@ -238,7 +238,7 @@ int cap_inode_need_killpriv(struct dentry *dentry) ...@@ -238,7 +238,7 @@ int cap_inode_need_killpriv(struct dentry *dentry)
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
int error; int error;
if (!inode->i_op || !inode->i_op->getxattr) if (!inode->i_op->getxattr)
return 0; return 0;
error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0); error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0);
...@@ -259,7 +259,7 @@ int cap_inode_killpriv(struct dentry *dentry) ...@@ -259,7 +259,7 @@ int cap_inode_killpriv(struct dentry *dentry)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
if (!inode->i_op || !inode->i_op->removexattr) if (!inode->i_op->removexattr)
return 0; return 0;
return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS); return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS);
...@@ -317,7 +317,7 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data ...@@ -317,7 +317,7 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data)); memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data));
if (!inode || !inode->i_op || !inode->i_op->getxattr) if (!inode || !inode->i_op->getxattr)
return -ENODATA; return -ENODATA;
size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps, size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment