Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Mar 2013 06:13:04 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: [patch] statfs does not detect -t nullfs -o union as a union mount
Message-ID:  <20130302041304.GI2930@kib.kiev.ua>
In-Reply-To: <20130302000032.GB49921@stack.nl>
References:  <20130227213141.GA18210@stack.nl> <20130227222144.GG2454@kib.kiev.ua> <20130302000032.GB49921@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <jilles@stack.nl>
> > > 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--



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