Unionfs: Fix an OOPs in whiteout lookup
authorRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 25 Nov 2007 21:28:45 +0000 (16:28 -0500)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Thu, 1 May 2008 23:03:20 +0000 (19:03 -0400)
Pass the dbstart of the parent and get the correct lower dentry of the
parent.  We need the parent's lower dentry so that we can lookup the
child(whiteout) and find the child's lower dentry too.

Signed-off-by: Rachita Kothiyal(rachita@fsl.cs.sunysb.edu)
fs/unionfs/lookup.c

index 2b156d6c94aa145e9c8d335ba547793da3504fea..d939b5d92a33bed2c0904fa0d0921e21bd9ce6da 100644 (file)
@@ -114,7 +114,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
                if (UNIONFS_D(dentry)->odf.dentry) {
                        /* return negative dentry if a whiteout */
                        if (UNIONFS_D(dentry)->odf.whiteout) {
-                               bindex = 0;
+                               bindex = bstart;
                                goto out_negative;
                        }
                        /* if opaque dir lookup only until opaque branch */
@@ -240,6 +240,15 @@ out_negative:
        }
        /* This should only happen if we found a whiteout. */
        if (first_dentry_offset == -1) {
+               /*
+                * If we are a whiteout, we haven't filled up lower_dir_dentry
+                * at all, so this is NULL at this point.  Fill this up now.
+                * Note, this was why we needed to pass the right bindex from
+                * above.
+                */
+               if (!lower_dir_dentry)
+                       lower_dir_dentry =
+                               unionfs_lower_dentry_idx(parent_dentry, bindex);
                first_lower_dentry = lookup_one_len(name, lower_dir_dentry,
                                                    namelen);
                first_dentry_offset = bindex;