umountBelow - unmounts all mount points below belowPath
/proc/mounts must be present and readable. Because of the way
linux handles changeroots, we can't trust everything we see in
/proc/mounts. However, we make the following assumptions:
- there is a one-to-one correspondence between the entries in
/proc/mounts and the actual mounts, and
(2) every mount point we might encounter is a suffix of one of
the mount points listed in /proc/mounts (because being in a
a chroot doesn't affect /proc/mounts.)
So we can search /proc/mounts for an entry has the mount point
we are looking for as a substring, then add the extra text on
the right to our path and try to unmount that. Then we start
again since nested mounts might have been revealed.
For example, suppose we are chrooted into
/home/david/environments/sid and we call umountBelow /proc. We
might see the mount point /home/david/environments/sid/proc/bus/usb
in /proc/mounts, which means we need to run umount /proc/bus/usb.
See also: umountSucceeded
|