From owner-freebsd-hackers@FreeBSD.ORG Sat Mar 2 04:13:08 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 630BBE3 for ; Sat, 2 Mar 2013 04:13:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id B467A86E for ; Sat, 2 Mar 2013 04:13:07 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.6/8.14.6) with ESMTP id r224D4KH040200; Sat, 2 Mar 2013 06:13:04 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.0 kib.kiev.ua r224D4KH040200 Received: (from kostik@localhost) by tom.home (8.14.6/8.14.6/Submit) id r224D4iA040199; Sat, 2 Mar 2013 06:13:04 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 2 Mar 2013 06:13:04 +0200 From: Konstantin Belousov To: Jilles Tjoelker Subject: Re: [patch] statfs does not detect -t nullfs -o union as a union mount Message-ID: <20130302041304.GI2930@kib.kiev.ua> References: <20130227213141.GA18210@stack.nl> <20130227222144.GG2454@kib.kiev.ua> <20130302000032.GB49921@stack.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4LwthZj+AV2mq5CX" Content-Disposition: inline In-Reply-To: <20130302000032.GB49921@stack.nl> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home 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 04:13:08 -0000 --4LwthZj+AV2mq5CX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Mar 02, 2013 at 01:00:33AM +0100, Jilles Tjoelker wrote: > 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() d= oes > > > 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 a= nd > > > -t unionfs mounts work correctly in this regard. >=20 > > > The below patch passes through just the MNT_UNION flag of the nullfs > > > mount itself. Perhaps more flags should be passed through. >=20 > > > commit fce32a779af4eb977c9b96feb6e4f811d89f2881 > > > Author: Jilles Tjoelker > > > Date: Sat Feb 23 22:22:39 2013 +0100 > > >=20 > > > nullfs: Preserve the MNT_UNION flag of the nullfs mount itself. > > > =20 > > > This is needed so that opendir() can properly detect a union moun= t like > > > mount -t nullfs -o union dir1 dir2. > > >=20 > > > 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) > > > =20 > > > /* now copy across the "interesting" information and fake the rest = */ > > > sbp->f_type =3D mstat.f_type; > > > - sbp->f_flags =3D mstat.f_flags; > > > + sbp->f_flags =3D (sbp->f_flags & MNT_UNION) | mstat.f_flags; > > > sbp->f_bsize =3D mstat.f_bsize; > > > sbp->f_iosize =3D mstat.f_iosize; > > > sbp->f_blocks =3D mstat.f_blocks; >=20 > > Would it make sense to preserve more flags from the upper mount ? > > I see a use for MNT_NOEXEC as well, at least. >=20 > Yes, preserving MNT_NOEXEC will make -t nullfs -o noexec work better, in > particular rtld's check for libraries loaded via environment variables. >=20 > In the same way MNT_RDONLY, MNT_NOSUID and MNT_NOSYMFOLLOW could be > preserved. >=20 > On the other hand, MNT_ROOTFS should probably not be passed through from > the underlying filesystem. >=20 > This would give > sbp->f_flags =3D (sbp->f_flags & (MNT_RDONLY | MNT_NOEXEC | MNT_NOSUID | > MNT_UNION | MNT_NOSYMFOLLOW) | (mstat.f_flags & ~MNT_ROOTFS); I think this is fine. --4LwthZj+AV2mq5CX Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJRMXxPAAoJEJDCuSvBvK1BBfsP+QERYVXfGU9X12Fv7nNZtQRC rtBkXuhqDGQ4iVjJ0JVNK6gU40X5mnIlqi3G2o+O+SeBDJYLX6phCWk4UIEg0nbj VXw5cObZsyp9iJX7B7ptGHLBV1U9hZOX8t8lAzfMWbjyjAXHRUPtr2yFTxGslOQM ecLJfcnKhy90u/QQzTGEzPLs4MnUhHZHTn70d95SViBC8Dp8YRXlgCII9mstmOBE GroumBgGVdgSvA6Wxm0uUBUHf1YaklY8GTbQg+ptp5v+MfxGOTOtGxbKT0BKyRhg f64iUlBf3FXn9PtuJOS7j3h1IeBMKOwj0Wi6QsTcFY7E5hQbidUA4qk7rVDpQEjN 2pFteBXPkCQw1FTtla8o8T465hixHWUmEKVx7QE3ajk2KzMQyyU3An8KmRWTlNw4 ZzZOKjJnO1ZZF3O9u6UYY1Kxm7HkIyBeYNdiXlTWzIa3dzY61uP/f1muaIAFMt+1 fUcFENkwQjroj8VKepGmSigWhCJ62NVWkcIjNvi7zzDrGnuqD8GB2Ck2GeMU0XP4 KGd+BJy6b3F24aifI2CEC4AZH343g3kbXI6wmbeFZ0ZYXkJuv6Aix/7PtvhMHsgA F3l8qVHQ30sBeGMXSxdzFFc+Z8+VtzbvtGF1M8BwwkjwhzC1NykZCpzLi+FIkeDh Ukb83c9OCgKu0wNceXto =riYL -----END PGP SIGNATURE----- --4LwthZj+AV2mq5CX--