]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/namei.c
[PATCH] namei fixes (2/19)
[linux-2.6-omap-h63xx.git] / fs / namei.c
index 0f76fd75591bd0d5c3fbf44a2540519a972a44a2..12d75ed214f6fb8c8ec48f36bd56350114d94c51 100644 (file)
@@ -493,6 +493,11 @@ fail:
        return PTR_ERR(link);
 }
 
+struct path {
+       struct vfsmount *mnt;
+       struct dentry *dentry;
+};
+
 static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
        int error;
@@ -518,27 +523,32 @@ static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd)
  * Without that kind of total limit, nasty chains of consecutive
  * symlinks can cause almost arbitrarily long lookups. 
  */
-static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
+static inline int do_follow_link(struct path *path, struct nameidata *nd)
 {
        int err = -ELOOP;
+       mntget(path->mnt);
        if (current->link_count >= MAX_NESTED_LINKS)
                goto loop;
        if (current->total_link_count >= 40)
                goto loop;
        BUG_ON(nd->depth >= MAX_NESTED_LINKS);
        cond_resched();
-       err = security_inode_follow_link(dentry, nd);
+       err = security_inode_follow_link(path->dentry, nd);
        if (err)
                goto loop;
        current->link_count++;
        current->total_link_count++;
        nd->depth++;
-       err = __do_follow_link(dentry, nd);
+       err = __do_follow_link(path->dentry, nd);
        current->link_count--;
        nd->depth--;
+       dput(path->dentry);
+       mntput(path->mnt);
        return err;
 loop:
        path_release(nd);
+       dput(path->dentry);
+       mntput(path->mnt);
        return err;
 }
 
@@ -641,11 +651,6 @@ static inline void follow_dotdot(struct vfsmount **mnt, struct dentry **dentry)
        follow_mount(mnt, dentry);
 }
 
-struct path {
-       struct vfsmount *mnt;
-       struct dentry *dentry;
-};
-
 /*
  *  It's more convoluted than I'd like it to be, but... it's still fairly
  *  small and for now I'd prefer to have fast path as straight as possible.
@@ -783,10 +788,7 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
                        goto out_dput;
 
                if (inode->i_op->follow_link) {
-                       mntget(next.mnt);
-                       err = do_follow_link(next.dentry, nd);
-                       dput(next.dentry);
-                       mntput(next.mnt);
+                       err = do_follow_link(&next, nd);
                        if (err)
                                goto return_err;
                        err = -ENOENT;
@@ -837,10 +839,7 @@ last_component:
                inode = next.dentry->d_inode;
                if ((lookup_flags & LOOKUP_FOLLOW)
                    && inode && inode->i_op && inode->i_op->follow_link) {
-                       mntget(next.mnt);
-                       err = do_follow_link(next.dentry, nd);
-                       dput(next.dentry);
-                       mntput(next.mnt);
+                       err = do_follow_link(&next, nd);
                        if (err)
                                goto return_err;
                        inode = nd->dentry->d_inode;
@@ -1580,6 +1579,7 @@ enoent:
 fail:
        return dentry;
 }
+EXPORT_SYMBOL_GPL(lookup_create);
 
 int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
 {
@@ -2071,8 +2071,8 @@ exit:
  *        ->i_sem on parents, which works but leads to some truely excessive
  *        locking].
  */
-int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
-              struct inode *new_dir, struct dentry *new_dentry)
+static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
+                         struct inode *new_dir, struct dentry *new_dentry)
 {
        int error = 0;
        struct inode *target;
@@ -2116,8 +2116,8 @@ int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
        return error;
 }
 
-int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
-              struct inode *new_dir, struct dentry *new_dentry)
+static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
+                           struct inode *new_dir, struct dentry *new_dentry)
 {
        struct inode *target;
        int error;