common.sh: Use /proc/mounts instead of mtab for umount

Using /proc/mounts is safer because mtab may in rare cases get desynced.
The only significant difference in output is "X Y" instead of "X on Y".

BUG=chromium-os:30249
TEST=create a chroot; enter a chroot; exit a chroot
TEST=assortment of manual tests

Change-Id: I392290e6f52a677ee2d77d77e025ef60240b11b5
Reviewed-on: https://gerrit.chromium.org/gerrit/21499
Tested-by: Zdenek Behan <zbehan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Zdenek Behan <zbehan@chromium.org>
This commit is contained in:
Zdenek Behan 2012-05-01 01:58:48 +02:00 committed by Gerrit
parent 916b1f1e11
commit 1d5d3b56e4

View File

@ -431,9 +431,8 @@ function sub_mounts() {
# that things were mounted (since it always has and hopefully always
# will). As such, we have to unmount in reverse order to cleanly
# unmount submounts (think /dev/pts and /dev).
mount | \
awk -v path="$1" -v len="${#1}" \
'(substr($3, 1, len) == path) { print $3 }' | \
awk -v path="$1" -v len="${#1}" \
'(substr($2, 1, len) == path) { print $2 }' /proc/mounts | \
tac
}