From owner-freebsd-hackers@FreeBSD.ORG Sat Mar 2 00:00:48 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AB4281A5 for ; Sat, 2 Mar 2013 00:00:48 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (unknown [IPv6:2001:610:1108:5012::107]) by mx1.freebsd.org (Postfix) with ESMTP id 77DD11D97 for ; Sat, 2 Mar 2013 00:00:48 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 630211203CA; Sat, 2 Mar 2013 01:00:33 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 3B4EE2848C; Sat, 2 Mar 2013 01:00:33 +0100 (CET) Date: Sat, 2 Mar 2013 01:00:33 +0100 From: Jilles Tjoelker To: Konstantin Belousov Subject: Re: [patch] statfs does not detect -t nullfs -o union as a union mount Message-ID: <20130302000032.GB49921@stack.nl> References: <20130227213141.GA18210@stack.nl> <20130227222144.GG2454@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130227222144.GG2454@kib.kiev.ua> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Mar 2013 00:00:48 -0000 On Thu, Feb 28, 2013 at 12:21:44AM +0200, Konstantin Belousov wrote: > On Wed, Feb 27, 2013 at 10:31:42PM +0100, Jilles Tjoelker wrote: > > 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 > > 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; > Would it make sense to preserve more flags from the upper mount ? > I see a use for MNT_NOEXEC as well, at least. Yes, preserving MNT_NOEXEC will make -t nullfs -o noexec work better, in particular rtld's check for libraries loaded via environment variables. In the same way MNT_RDONLY, MNT_NOSUID and MNT_NOSYMFOLLOW could be preserved. On the other hand, MNT_ROOTFS should probably not be passed through from the underlying filesystem. This would give sbp->f_flags = (sbp->f_flags & (MNT_RDONLY | MNT_NOEXEC | MNT_NOSUID | MNT_UNION | MNT_NOSYMFOLLOW) | (mstat.f_flags & ~MNT_ROOTFS); -- Jilles Tjoelker