GIT: unionfs2-2.6.27.y: Unionfs: ensure consistent lower inodes types

Erez Zadok ezk at fsl.cs.sunysb.edu
Thu Aug 12 23:17:46 EDT 2010


commit 442c1297715b26a1cce1544df230d54237123285
Author: Erez Zadok <ezk at cs.sunysb.edu>
Date:   Fri Feb 15 17:18:48 2008 -0500

    Unionfs: ensure consistent lower inodes types
    
    When looking up a lower object in multiple branches, especially for
    directories, ignore any existing entries whose type is different than the
    type of the first found object (otherwise we'll be trying to, say, call
    readdir on a non-dir inode).
    
    Signed-off-by: Himanshu Kanda <hkanda at fsl.cs.sunysb.edu>
    Signed-off-by: Erez Zadok <ezk at cs.sunysb.edu>

diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index b9ee072..755158e 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -256,6 +256,19 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 			continue;
 		}
 
+		/*
+		 * If we already found at least one positive dentry
+		 * (dentry_count is non-zero), then we skip all remaining
+		 * positive dentries if their type is a non-dir.  This is
+		 * because only directories are allowed to stack on multiple
+		 * branches, but we have to skip non-dirs (to avoid, say,
+		 * calling readdir on a regular file).
+		 */
+		if (!S_ISDIR(lower_dentry->d_inode->i_mode) && dentry_count) {
+			dput(lower_dentry);
+			continue;
+		}
+
 		/* number of positive dentries */
 		dentry_count++;
 


More information about the unionfs-cvs mailing list