On 10/08/2013 03:03:03 AM, Karel Zak wrote:
On Sat, Oct 05, 2013 at 06:42:44PM -0500, Rob Landley wrote:
> Oh, attached is a dumb "zapchroot" script I've been using for years
to
> unlink all mount points under a given directory, taking advantage
of the
> fact that mount points are appended to the end of the list so if
you unlink
> from the end to the front you should get the sub-mounts before the
parent
> mounts (modulo mount --move not reordering the list, but that's
uncommon).
util-linux umount supports --recursive, it uses /proc/self/mountinfo
to compose the hierarchy. The important is that the mountinfo file
contains Id and Parent_Id relations, so you don't rely on the order
only.
Ah, that's what happened.
For some reason /proc/self/mounts stopped adjusting itself for chroot a
while back, apparently because containers use switch_root instead so
chroot is generally deprecated or something? This made /proc/mounts
completely useless in a chroot because the paths it showed were not the
ones you actually had to use to umount anything.
Instead they added a new way to get this info, in a new format where
you have to parse the 5th field out of each line to get the mount point
(to make it friendly to scripts and tools).
Good to know.
Rob--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html