On Sun, 2011-08-21 at 18:22 -0400, Joey Hess wrote:
> Ben Hutchings wrote:
> > It not only inhibits umount from updating /etc/mtab, but also means that
> > it never uses /etc/mtab to canonicalize the given path.
>
> That seems very doubtful. Especially since I tried applying your patch and
> pbuilder --create still fails:
>
> I: mounting /proc filesystem
> mount: /proc already mounted or /var/cache/pbuilder/build//3625/proc busy
> mount: according to mtab, /proc is mounted on /proc
It worked for me with a sid host bootstrapping both squeeze and sid.
> As well, when I try -n by hand, it doesn't help:
>
> joey@gnu:~/tmp>mkdir proc
> joey@gnu:~/tmp>sudo mount -n -t proc proc proc
> joey@gnu:~/tmp>sudo umount -n `pwd`/proc
> umount: /proc: device is busy.
> (In some cases useful info about processes that use
> the device is found by lsof(8) or fuser(1))
>
> It seems to only get confused when the cwd is the parent of the mount point.
>
> joey@gnu:~/tmp>cd ..
> joey@gnu:~>sudo umount `pwd`/proc
> joey@gnu:~>
Right. umount will first look for a mount entry with matching path,
then with matching device. The getmntdevbackward() function does:
/* non-canonical names in mtab (this is BAD THING!) */
for (mc = mcprev->prev; mc && mc != mc0; mc = mc->prev) {
char *cn = canonicalize(mc->m.mnt_fsname);
int res = cn ? streq(cn, name) : 0;
free(cn);
if (res)
return mc;
}
and now `pwd`/proc matches the 'proc' filesystem actually mounted at
/proc!
In the current version of util-linux (2.19.1-5) this appears to be done
regardless of whether the -n option is used, as you found.
> > > Also, portability is a concern. busybox umount does not support -n,
> > > for example.
> > >
> > > When I run debootstrap, it ends successfully with $chroot/proc not being
> > > mounted. Is there something about it being run by pbuilder that triggers
> > > this bug?
> >
> > Don't know.
>
> pbuilder runs "debootstrap ." --- so the bug could actually be worked
> around by doing a cd / before umount.
Looks like it. But I think it would be better to be consistent about
running mount and unmount inside or outside the chroot.
Ben.
Attachment:
signature.asc
Description: This is a digitally signed message part