fs: fold __inode_permission() into inode_permission()
[linux-2.6-microblaze.git] / fs / namei.c
index 5424b10..29b0440 100644 (file)
@@ -390,50 +390,6 @@ static inline int do_inode_permission(struct inode *inode, int mask)
        return generic_permission(inode, mask);
 }
 
-/**
- * __inode_permission - Check for access rights to a given inode
- * @inode: Inode to check permission on
- * @mask: Right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
- *
- * Check for read/write/execute permissions on an inode.
- *
- * When checking for MAY_APPEND, MAY_WRITE must also be set in @mask.
- *
- * This does not check for a read-only file system.  You probably want
- * inode_permission().
- */
-int __inode_permission(struct inode *inode, int mask)
-{
-       int retval;
-
-       if (unlikely(mask & MAY_WRITE)) {
-               /*
-                * Nobody gets write access to an immutable file.
-                */
-               if (IS_IMMUTABLE(inode))
-                       return -EPERM;
-
-               /*
-                * Updating mtime will likely cause i_uid and i_gid to be
-                * written back improperly if their true value is unknown
-                * to the vfs.
-                */
-               if (HAS_UNMAPPED_ID(inode))
-                       return -EACCES;
-       }
-
-       retval = do_inode_permission(inode, mask);
-       if (retval)
-               return retval;
-
-       retval = devcgroup_inode_permission(inode, mask);
-       if (retval)
-               return retval;
-
-       return security_inode_permission(inode, mask);
-}
-EXPORT_SYMBOL(__inode_permission);
-
 /**
  * sb_permission - Check superblock-level permissions
  * @sb: Superblock of inode to check permission on
@@ -472,7 +428,32 @@ int inode_permission(struct inode *inode, int mask)
        retval = sb_permission(inode->i_sb, inode, mask);
        if (retval)
                return retval;
-       return __inode_permission(inode, mask);
+
+       if (unlikely(mask & MAY_WRITE)) {
+               /*
+                * Nobody gets write access to an immutable file.
+                */
+               if (IS_IMMUTABLE(inode))
+                       return -EPERM;
+
+               /*
+                * Updating mtime will likely cause i_uid and i_gid to be
+                * written back improperly if their true value is unknown
+                * to the vfs.
+                */
+               if (HAS_UNMAPPED_ID(inode))
+                       return -EACCES;
+       }
+
+       retval = do_inode_permission(inode, mask);
+       if (retval)
+               return retval;
+
+       retval = devcgroup_inode_permission(inode, mask);
+       if (retval)
+               return retval;
+
+       return security_inode_permission(inode, mask);
 }
 EXPORT_SYMBOL(inode_permission);
 
@@ -3459,7 +3440,7 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
                goto out;
        child = vfs_tmpfile(path.dentry, op->mode, op->open_flag);
        error = PTR_ERR(child);
-       if (unlikely(IS_ERR(child)))
+       if (IS_ERR(child))
                goto out2;
        dput(path.dentry);
        path.dentry = child;
@@ -4010,10 +3991,9 @@ EXPORT_SYMBOL(vfs_unlink);
  * writeout happening, and we don't want to prevent access to the directory
  * while waiting on the I/O.
  */
-static long do_unlinkat(int dfd, const char __user *pathname)
+long do_unlinkat(int dfd, struct filename *name)
 {
        int error;
-       struct filename *name;
        struct dentry *dentry;
        struct path path;
        struct qstr last;
@@ -4022,8 +4002,7 @@ static long do_unlinkat(int dfd, const char __user *pathname)
        struct inode *delegated_inode = NULL;
        unsigned int lookup_flags = 0;
 retry:
-       name = filename_parentat(dfd, getname(pathname), lookup_flags,
-                               &path, &last, &type);
+       name = filename_parentat(dfd, name, lookup_flags, &path, &last, &type);
        if (IS_ERR(name))
                return PTR_ERR(name);
 
@@ -4065,12 +4044,12 @@ exit2:
        mnt_drop_write(path.mnt);
 exit1:
        path_put(&path);
-       putname(name);
        if (retry_estale(error, lookup_flags)) {
                lookup_flags |= LOOKUP_REVAL;
                inode = NULL;
                goto retry;
        }
+       putname(name);
        return error;
 
 slashes:
@@ -4091,12 +4070,12 @@ SYSCALL_DEFINE3(unlinkat, int, dfd, const char __user *, pathname, int, flag)
        if (flag & AT_REMOVEDIR)
                return do_rmdir(dfd, pathname);
 
-       return do_unlinkat(dfd, pathname);
+       return do_unlinkat(dfd, getname(pathname));
 }
 
 SYSCALL_DEFINE1(unlink, const char __user *, pathname)
 {
-       return do_unlinkat(AT_FDCWD, pathname);
+       return do_unlinkat(AT_FDCWD, getname(pathname));
 }
 
 int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)