commit adc784c8cbd41b2aeb69fee3cc6cf7d11c225a26
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Fri May 11 20:42:14 2007 -0400

    export: get_parent: build the route to the parent using the parent from odf

diff --git a/fs/unionfs/export.c b/fs/unionfs/export.c
index 7c3107d..c3abd36 100644
--- a/fs/unionfs/export.c
+++ b/fs/unionfs/export.c
@@ -1,10 +1,44 @@
 #include "union.h"
 
+static struct dentry *__get_parent(struct super_block *sb, struct dentry 
*odf_dentry)
+{
+       struct dentry *odf_root = UNIONFS_SB(sb)->odf->odi_ns->dentry;
+       struct dentry *d, *parent, *child = NULL;
+       struct dentry_stack stack;
+       int count = 0;
+
+       if (odf_root == odf_dentry)
+               return sb->s_root;
+
+       __ds_init(&stack, 8);
+       if (!stack.item)
+               return ERR_PTR(-ENOMEM);
+
+       d = odf_dentry;
+       do {
+               BUG_ON(!d);
+               __ds_push(&stack, d);
+               d = d->d_parent;
+       } while (d != odf_root);
+
+       parent = sb->s_root;
+       while (stack.n) {
+               d = __ds_pop(&stack);
+               child = lookup_one_len(d->d_name.name, parent, d->d_name.len);
+               if (IS_ERR(child))
+                       break;
+               parent = child;
+       }
+
+       kfree(stack.item);
+       return child;
+}
+
 static struct dentry *unionfs_get_parent(struct dentry *child)
 {
        struct odf_sb_info *odf;
        struct super_block *odf_sb;
-       struct inode *odf_i, *i;
+       struct inode *odf_i;
        struct dentry *odf_child, *odf_parent, *res ;
 
        res = ERR_PTR(-EACCES);
@@ -32,16 +66,8 @@ static struct dentry *unionfs_get_parent(struct dentry 
*child)
                goto out;
        }
 
-       i = iget(child->d_sb, odf_parent->d_inode->i_ino);
-       if (!i)
-               goto out;
-       res = d_alloc_anon(i);
-       if (!res) {
-               iput(i);
-               res = ERR_PTR(-ENOMEM);
-               goto out;
-       }
-       res->d_op = &unionfs_dops;
+       res = __get_parent(child->d_sb, odf_parent);
+
 out:
        return res;
 }
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to