Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2013 22:31:42 +0100
From:      Jilles Tjoelker <jilles@stack.nl>
To:        freebsd-hackers@freebsd.org
Subject:   [patch] statfs does not detect -t nullfs -o union as a union mount
Message-ID:  <20130227213141.GA18210@stack.nl>

next in thread | raw e-mail | index | archive | help
While testing recent changes to opendir(), I noticed that fstatfs() does
not return the MNT_UNION flag for a -t nullfs -o union mount. As a
result, opendir()/readdir() return files that exist in both top and
bottom directories twice (at least . and ..). Other -o union mounts and
-t unionfs mounts work correctly in this regard.

The below patch passes through just the MNT_UNION flag of the nullfs
mount itself. Perhaps more flags should be passed through.

commit fce32a779af4eb977c9b96feb6e4f811d89f2881
Author: Jilles Tjoelker <jilles@stack.nl>
Date:   Sat Feb 23 22:22:39 2013 +0100

    nullfs: Preserve the MNT_UNION flag of the nullfs mount itself.
    
    This is needed so that opendir() can properly detect a union mount like
    mount -t nullfs -o union dir1 dir2.

diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c
index 3724e0a..ff06f57 100644
--- a/sys/fs/nullfs/null_vfsops.c
+++ b/sys/fs/nullfs/null_vfsops.c
@@ -313,7 +313,7 @@ nullfs_statfs(mp, sbp)
 
 	/* now copy across the "interesting" information and fake the rest */
 	sbp->f_type = mstat.f_type;
-	sbp->f_flags = mstat.f_flags;
+	sbp->f_flags = (sbp->f_flags & MNT_UNION) | mstat.f_flags;
 	sbp->f_bsize = mstat.f_bsize;
 	sbp->f_iosize = mstat.f_iosize;
 	sbp->f_blocks = mstat.f_blocks;

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130227213141.GA18210>