diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-12-04 10:06:33 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-01-05 11:54:28 -0500 |
commit | acfa4380efe77e290d3a96b11cd4c9f24f4fbb18 (patch) | |
tree | d656232c7ef39c83681c2de4c8e28ba439242f66 | |
parent | 9742df331deb3fce95b321f38d4ea0c4e75edb63 (diff) |
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: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/cifs/inode.c | 2 | ||||
-rw-r--r-- | fs/ecryptfs/inode.c | 3 | ||||
-rw-r--r-- | fs/namei.c | 32 | ||||
-rw-r--r-- | fs/nfsd/vfs.c | 8 | ||||
-rw-r--r-- | fs/open.c | 2 | ||||
-rw-r--r-- | fs/stat.c | 2 | ||||
-rw-r--r-- | fs/xattr.c | 2 | ||||
-rw-r--r-- | mm/memory.c | 4 | ||||
-rw-r--r-- | mm/nommu.c | 2 | ||||
-rw-r--r-- | security/commoncap.c | 6 |
10 files changed, 28 insertions, 35 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index f247da9f4edc..5ab9896fdcb2 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -1641,7 +1641,7 @@ do_expand: | |||
1641 | i_size_write(inode, offset); | 1641 | i_size_write(inode, offset); |
1642 | spin_unlock(&inode->i_lock); | 1642 | spin_unlock(&inode->i_lock); |
1643 | out_truncate: | 1643 | out_truncate: |
1644 | if (inode->i_op && inode->i_op->truncate) | 1644 | if (inode->i_op->truncate) |
1645 | inode->i_op->truncate(inode); | 1645 | inode->i_op->truncate(inode); |
1646 | return 0; | 1646 | return 0; |
1647 | out_sig: | 1647 | out_sig: |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 5e78fc179886..0111906a8877 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -612,8 +612,7 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz) | |||
612 | struct ecryptfs_crypt_stat *crypt_stat; | 612 | struct ecryptfs_crypt_stat *crypt_stat; |
613 | 613 | ||
614 | lower_dentry = ecryptfs_dentry_to_lower(dentry); | 614 | lower_dentry = ecryptfs_dentry_to_lower(dentry); |
615 | if (!lower_dentry->d_inode->i_op || | 615 | if (!lower_dentry->d_inode->i_op->readlink) { |
616 | !lower_dentry->d_inode->i_op->readlink) { | ||
617 | rc = -EINVAL; | 616 | rc = -EINVAL; |
618 | goto out; | 617 | goto out; |
619 | } | 618 | } |
diff --git a/fs/namei.c b/fs/namei.c index dd5c9f0bf829..1f6656c3d1b9 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -257,7 +257,7 @@ int inode_permission(struct inode *inode, int mask) | |||
257 | return -EACCES; | 257 | return -EACCES; |
258 | } | 258 | } |
259 | 259 | ||
260 | if (inode->i_op && inode->i_op->permission) | 260 | if (inode->i_op->permission) |
261 | retval = inode->i_op->permission(inode, mask); | 261 | retval = inode->i_op->permission(inode, mask); |
262 | else | 262 | else |
263 | retval = generic_permission(inode, mask, NULL); | 263 | retval = generic_permission(inode, mask, NULL); |
@@ -432,7 +432,7 @@ static int exec_permission_lite(struct inode *inode) | |||
432 | { | 432 | { |
433 | umode_t mode = inode->i_mode; | 433 | umode_t mode = inode->i_mode; |
434 | 434 | ||
435 | if (inode->i_op && inode->i_op->permission) | 435 | if (inode->i_op->permission) |
436 | return -EAGAIN; | 436 | return -EAGAIN; |
437 | 437 | ||
438 | if (current_fsuid() == inode->i_uid) | 438 | if (current_fsuid() == inode->i_uid) |
@@ -908,9 +908,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd) | |||
908 | inode = next.dentry->d_inode; | 908 | inode = next.dentry->d_inode; |
909 | if (!inode) | 909 | if (!inode) |
910 | goto out_dput; | 910 | goto out_dput; |
911 | err = -ENOTDIR; | ||
912 | if (!inode->i_op) | ||
913 | goto out_dput; | ||
914 | 911 | ||
915 | if (inode->i_op->follow_link) { | 912 | if (inode->i_op->follow_link) { |
916 | err = do_follow_link(&next, nd); | 913 | err = do_follow_link(&next, nd); |
@@ -920,9 +917,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd) | |||
920 | inode = nd->path.dentry->d_inode; | 917 | inode = nd->path.dentry->d_inode; |
921 | if (!inode) | 918 | if (!inode) |
922 | break; | 919 | break; |
923 | err = -ENOTDIR; | ||
924 | if (!inode->i_op) | ||
925 | break; | ||
926 | } else | 920 | } else |
927 | path_to_nameidata(&next, nd); | 921 | path_to_nameidata(&next, nd); |
928 | err = -ENOTDIR; | 922 | err = -ENOTDIR; |
@@ -961,7 +955,7 @@ last_component: | |||
961 | break; | 955 | break; |
962 | inode = next.dentry->d_inode; | 956 | inode = next.dentry->d_inode; |
963 | if ((lookup_flags & LOOKUP_FOLLOW) | 957 | if ((lookup_flags & LOOKUP_FOLLOW) |
964 | && inode && inode->i_op && inode->i_op->follow_link) { | 958 | && inode && inode->i_op->follow_link) { |
965 | err = do_follow_link(&next, nd); | 959 | err = do_follow_link(&next, nd); |
966 | if (err) | 960 | if (err) |
967 | goto return_err; | 961 | goto return_err; |
@@ -973,7 +967,7 @@ last_component: | |||
973 | break; | 967 | break; |
974 | if (lookup_flags & LOOKUP_DIRECTORY) { | 968 | if (lookup_flags & LOOKUP_DIRECTORY) { |
975 | err = -ENOTDIR; | 969 | err = -ENOTDIR; |
976 | if (!inode->i_op || !inode->i_op->lookup) | 970 | if (!inode->i_op->lookup) |
977 | break; | 971 | break; |
978 | } | 972 | } |
979 | goto return_base; | 973 | goto return_base; |
@@ -1469,7 +1463,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1469 | if (error) | 1463 | if (error) |
1470 | return error; | 1464 | return error; |
1471 | 1465 | ||
1472 | if (!dir->i_op || !dir->i_op->create) | 1466 | if (!dir->i_op->create) |
1473 | return -EACCES; /* shouldn't it be ENOSYS? */ | 1467 | return -EACCES; /* shouldn't it be ENOSYS? */ |
1474 | mode &= S_IALLUGO; | 1468 | mode &= S_IALLUGO; |
1475 | mode |= S_IFREG; | 1469 | mode |= S_IFREG; |
@@ -1752,7 +1746,7 @@ do_last: | |||
1752 | error = -ENOENT; | 1746 | error = -ENOENT; |
1753 | if (!path.dentry->d_inode) | 1747 | if (!path.dentry->d_inode) |
1754 | goto exit_dput; | 1748 | goto exit_dput; |
1755 | if (path.dentry->d_inode->i_op && path.dentry->d_inode->i_op->follow_link) | 1749 | if (path.dentry->d_inode->i_op->follow_link) |
1756 | goto do_link; | 1750 | goto do_link; |
1757 | 1751 | ||
1758 | path_to_nameidata(&path, &nd); | 1752 | path_to_nameidata(&path, &nd); |
@@ -1933,7 +1927,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
1933 | if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD)) | 1927 | if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD)) |
1934 | return -EPERM; | 1928 | return -EPERM; |
1935 | 1929 | ||
1936 | if (!dir->i_op || !dir->i_op->mknod) | 1930 | if (!dir->i_op->mknod) |
1937 | return -EPERM; | 1931 | return -EPERM; |
1938 | 1932 | ||
1939 | error = devcgroup_inode_mknod(mode, dev); | 1933 | error = devcgroup_inode_mknod(mode, dev); |
@@ -2035,7 +2029,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
2035 | if (error) | 2029 | if (error) |
2036 | return error; | 2030 | return error; |
2037 | 2031 | ||
2038 | if (!dir->i_op || !dir->i_op->mkdir) | 2032 | if (!dir->i_op->mkdir) |
2039 | return -EPERM; | 2033 | return -EPERM; |
2040 | 2034 | ||
2041 | mode &= (S_IRWXUGO|S_ISVTX); | 2035 | mode &= (S_IRWXUGO|S_ISVTX); |
@@ -2126,7 +2120,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
2126 | if (error) | 2120 | if (error) |
2127 | return error; | 2121 | return error; |
2128 | 2122 | ||
2129 | if (!dir->i_op || !dir->i_op->rmdir) | 2123 | if (!dir->i_op->rmdir) |
2130 | return -EPERM; | 2124 | return -EPERM; |
2131 | 2125 | ||
2132 | DQUOT_INIT(dir); | 2126 | DQUOT_INIT(dir); |
@@ -2213,7 +2207,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry) | |||
2213 | if (error) | 2207 | if (error) |
2214 | return error; | 2208 | return error; |
2215 | 2209 | ||
2216 | if (!dir->i_op || !dir->i_op->unlink) | 2210 | if (!dir->i_op->unlink) |
2217 | return -EPERM; | 2211 | return -EPERM; |
2218 | 2212 | ||
2219 | DQUOT_INIT(dir); | 2213 | DQUOT_INIT(dir); |
@@ -2320,7 +2314,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname) | |||
2320 | if (error) | 2314 | if (error) |
2321 | return error; | 2315 | return error; |
2322 | 2316 | ||
2323 | if (!dir->i_op || !dir->i_op->symlink) | 2317 | if (!dir->i_op->symlink) |
2324 | return -EPERM; | 2318 | return -EPERM; |
2325 | 2319 | ||
2326 | error = security_inode_symlink(dir, dentry, oldname); | 2320 | 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 | */ | 2395 | */ |
2402 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) | 2396 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) |
2403 | return -EPERM; | 2397 | return -EPERM; |
2404 | if (!dir->i_op || !dir->i_op->link) | 2398 | if (!dir->i_op->link) |
2405 | return -EPERM; | 2399 | return -EPERM; |
2406 | if (S_ISDIR(inode->i_mode)) | 2400 | if (S_ISDIR(inode->i_mode)) |
2407 | return -EPERM; | 2401 | return -EPERM; |
@@ -2608,7 +2602,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2608 | if (error) | 2602 | if (error) |
2609 | return error; | 2603 | return error; |
2610 | 2604 | ||
2611 | if (!old_dir->i_op || !old_dir->i_op->rename) | 2605 | if (!old_dir->i_op->rename) |
2612 | return -EPERM; | 2606 | return -EPERM; |
2613 | 2607 | ||
2614 | DQUOT_INIT(old_dir); | 2608 | DQUOT_INIT(old_dir); |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index d1c5f787b365..5245a3965004 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -1211,7 +1211,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1211 | dirp = dentry->d_inode; | 1211 | dirp = dentry->d_inode; |
1212 | 1212 | ||
1213 | err = nfserr_notdir; | 1213 | err = nfserr_notdir; |
1214 | if(!dirp->i_op || !dirp->i_op->lookup) | 1214 | if (!dirp->i_op->lookup) |
1215 | goto out; | 1215 | goto out; |
1216 | /* | 1216 | /* |
1217 | * Check whether the response file handle has been verified yet. | 1217 | * 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 | /* Get all the sanity checks out of the way before | 1347 | /* Get all the sanity checks out of the way before |
1348 | * we lock the parent. */ | 1348 | * we lock the parent. */ |
1349 | err = nfserr_notdir; | 1349 | err = nfserr_notdir; |
1350 | if(!dirp->i_op || !dirp->i_op->lookup) | 1350 | if (!dirp->i_op->lookup) |
1351 | goto out; | 1351 | goto out; |
1352 | fh_lock_nested(fhp, I_MUTEX_PARENT); | 1352 | fh_lock_nested(fhp, I_MUTEX_PARENT); |
1353 | 1353 | ||
@@ -1482,7 +1482,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp) | |||
1482 | inode = dentry->d_inode; | 1482 | inode = dentry->d_inode; |
1483 | 1483 | ||
1484 | err = nfserr_inval; | 1484 | err = nfserr_inval; |
1485 | if (!inode->i_op || !inode->i_op->readlink) | 1485 | if (!inode->i_op->readlink) |
1486 | goto out; | 1486 | goto out; |
1487 | 1487 | ||
1488 | touch_atime(fhp->fh_export->ex_path.mnt, dentry); | 1488 | 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 | size_t size; | 2162 | size_t size; |
2163 | int error; | 2163 | int error; |
2164 | 2164 | ||
2165 | if (!IS_POSIXACL(inode) || !inode->i_op || | 2165 | if (!IS_POSIXACL(inode) || |
2166 | !inode->i_op->setxattr || !inode->i_op->removexattr) | 2166 | !inode->i_op->setxattr || !inode->i_op->removexattr) |
2167 | return -EOPNOTSUPP; | 2167 | return -EOPNOTSUPP; |
2168 | switch(type) { | 2168 | switch(type) { |
@@ -412,7 +412,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len) | |||
412 | if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) | 412 | if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) |
413 | goto out_fput; | 413 | goto out_fput; |
414 | 414 | ||
415 | if (inode->i_op && inode->i_op->fallocate) | 415 | if (inode->i_op->fallocate) |
416 | ret = inode->i_op->fallocate(inode, mode, offset, len); | 416 | ret = inode->i_op->fallocate(inode, mode, offset, len); |
417 | else | 417 | else |
418 | ret = -EOPNOTSUPP; | 418 | ret = -EOPNOTSUPP; |
@@ -305,7 +305,7 @@ asmlinkage long sys_readlinkat(int dfd, const char __user *pathname, | |||
305 | struct inode *inode = path.dentry->d_inode; | 305 | struct inode *inode = path.dentry->d_inode; |
306 | 306 | ||
307 | error = -EINVAL; | 307 | error = -EINVAL; |
308 | if (inode->i_op && inode->i_op->readlink) { | 308 | if (inode->i_op->readlink) { |
309 | error = security_inode_readlink(path.dentry); | 309 | error = security_inode_readlink(path.dentry); |
310 | if (!error) { | 310 | if (!error) { |
311 | touch_atime(path.mnt, path.dentry); | 311 | touch_atime(path.mnt, path.dentry); |
diff --git a/fs/xattr.c b/fs/xattr.c index 468377e66531..237804cd6b56 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -175,7 +175,7 @@ vfs_listxattr(struct dentry *d, char *list, size_t size) | |||
175 | if (error) | 175 | if (error) |
176 | return error; | 176 | return error; |
177 | error = -EOPNOTSUPP; | 177 | error = -EOPNOTSUPP; |
178 | if (d->d_inode->i_op && d->d_inode->i_op->listxattr) { | 178 | if (d->d_inode->i_op->listxattr) { |
179 | error = d->d_inode->i_op->listxattr(d, list, size); | 179 | error = d->d_inode->i_op->listxattr(d, list, size); |
180 | } else { | 180 | } else { |
181 | error = security_inode_listsecurity(d->d_inode, list, size); | 181 | error = security_inode_listsecurity(d->d_inode, list, size); |
diff --git a/mm/memory.c b/mm/memory.c index 0a2010a9518c..7b9db658aca2 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -2266,7 +2266,7 @@ int vmtruncate(struct inode * inode, loff_t offset) | |||
2266 | unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); | 2266 | unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); |
2267 | } | 2267 | } |
2268 | 2268 | ||
2269 | if (inode->i_op && inode->i_op->truncate) | 2269 | if (inode->i_op->truncate) |
2270 | inode->i_op->truncate(inode); | 2270 | inode->i_op->truncate(inode); |
2271 | return 0; | 2271 | return 0; |
2272 | 2272 | ||
@@ -2286,7 +2286,7 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end) | |||
2286 | * a way to truncate a range of blocks (punch a hole) - | 2286 | * a way to truncate a range of blocks (punch a hole) - |
2287 | * we should return failure right now. | 2287 | * we should return failure right now. |
2288 | */ | 2288 | */ |
2289 | if (!inode->i_op || !inode->i_op->truncate_range) | 2289 | if (!inode->i_op->truncate_range) |
2290 | return -ENOSYS; | 2290 | return -ENOSYS; |
2291 | 2291 | ||
2292 | mutex_lock(&inode->i_mutex); | 2292 | mutex_lock(&inode->i_mutex); |
diff --git a/mm/nommu.c b/mm/nommu.c index 7695dc850785..1c28ea3a4e9c 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -86,7 +86,7 @@ do_expand: | |||
86 | i_size_write(inode, offset); | 86 | i_size_write(inode, offset); |
87 | 87 | ||
88 | out_truncate: | 88 | out_truncate: |
89 | if (inode->i_op && inode->i_op->truncate) | 89 | if (inode->i_op->truncate) |
90 | inode->i_op->truncate(inode); | 90 | inode->i_op->truncate(inode); |
91 | return 0; | 91 | return 0; |
92 | out_sig: | 92 | out_sig: |
diff --git a/security/commoncap.c b/security/commoncap.c index 79713545cd63..69fc9952650f 100644 --- a/security/commoncap.c +++ b/security/commoncap.c | |||
@@ -238,7 +238,7 @@ int cap_inode_need_killpriv(struct dentry *dentry) | |||
238 | struct inode *inode = dentry->d_inode; | 238 | struct inode *inode = dentry->d_inode; |
239 | int error; | 239 | int error; |
240 | 240 | ||
241 | if (!inode->i_op || !inode->i_op->getxattr) | 241 | if (!inode->i_op->getxattr) |
242 | return 0; | 242 | return 0; |
243 | 243 | ||
244 | error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0); | 244 | error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0); |
@@ -259,7 +259,7 @@ int cap_inode_killpriv(struct dentry *dentry) | |||
259 | { | 259 | { |
260 | struct inode *inode = dentry->d_inode; | 260 | struct inode *inode = dentry->d_inode; |
261 | 261 | ||
262 | if (!inode->i_op || !inode->i_op->removexattr) | 262 | if (!inode->i_op->removexattr) |
263 | return 0; | 263 | return 0; |
264 | 264 | ||
265 | return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS); | 265 | 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 | 317 | ||
318 | memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data)); | 318 | memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data)); |
319 | 319 | ||
320 | if (!inode || !inode->i_op || !inode->i_op->getxattr) | 320 | if (!inode || !inode->i_op->getxattr) |
321 | return -ENODATA; | 321 | return -ENODATA; |
322 | 322 | ||
323 | size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps, | 323 | size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps, |