From 63a41178dc2435ba18ebede40c0fa977c36787c5 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Fri, 15 Feb 2008 17:18:48 -0500 Subject: [PATCH] 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 Signed-off-by: Erez Zadok --- fs/unionfs/lookup.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c index b9ee072c52d..755158e9ce2 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++; -- 2.43.0