Date: Wed, 09 Jun 2004 15:13:20 +0200 From: Uwe Doering <gemini@geminix.org> To: freebsd-stable@freebsd.org Subject: Re: patch for unionfs mounts Message-ID: <40C70CF0.5080304@geminix.org> In-Reply-To: <200406080903.i5893AO01551@Mail.NOSPAM.DynDNS.dK> References: <200406080903.i5893AO01551@Mail.NOSPAM.DynDNS.dK>
next in thread | previous in thread | raw e-mail | index | archive | help
Barry Bouwsma wrote: > [...] > Without this patch, a getcwd() call (from csh, and others, but > apparently not bash) returns the upper unionfs-mounted layer. > This breaks things like `make world' and its ilk when one mounts, > say, /usr/source-hacks atop /usr/src (perhaps additional intermediate > directories, like /usr/local/source-hacks, are necessary to demonstrate > the problem). > > In other words, when one is in /usr/src (or /usr/local/source-hacks) > and asks for getcwd(), several shells return /usr/local/source-hacks > instead of /usr/src, without this patch, which as noted breaks > buildworlds. (Or perhaps in subdirectories -- I don't recall) > > After applying this patch, a getcwd() call returns /usr/src, no > matter what shell, which allows buildworlds to complete. I've > had this patch for years, and never had any problems with it. > I've only had problems without including it. > > The trivial one-liner patch is as follows: > > --- union_vnops.c-ORIG Tue Jan 13 22:20:02 2004 > +++ union_vnops.c Tue May 11 14:49:02 2004 > @@ -963,6 +963,8 @@ > union_newsize(ap->a_vp, VNOVAL, vap->va_size); > } > > + ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0]; > + > if ((vap != ap->a_vap) && (vap->va_type == VDIR)) > ap->a_vap->va_nlink += vap->va_nlink; > return (0); > > > > > As noted, without this, builds fail with a union-mounted > directory of hacks atop the pristine virginal /usr/src. With > this patch, no ill effects have been noted. I'm afraid there is a problem with this approach. 'va_fsid' and 'va_fileid' end up as 'st_dev' and 'st_ino' on the application level ("struct stat"). The combination of these two variables is supposed to be unique, at least by convention. Software relies on the assumption that if 'st_dev' and 'st_ino' are identical for two files it is actually the same file. Now, by forcing 'va_fsid', and therefore 'st_dev', to the same value (the unionfs mount's file system id) regardless of which device (file system) the file is actually located on this patch introduces ambiguity. There can be two different files with the same 'va_fileid' value (the inode number, for instance), living on two different file systems, that now appear to be the same file due to the "fake" value in 'va_fsid'. This is going to break existing software. So I recommend against committing this patch to the FreeBSD CVS repository. I have no idea how else to fix your initial problem, but this patch is not the way to do it, IMHO. Uwe -- Uwe Doering | EscapeBox - Managed On-Demand UNIX Servers gemini@geminix.org | http://www.escapebox.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40C70CF0.5080304>