Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: src/scripts/enter_chroot.sh

Issue 1211001: Update enter_chroot.sh to exit with error messages when mount/unmount fails. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scripts/common.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scripts/enter_chroot.sh
diff --git a/src/scripts/enter_chroot.sh b/src/scripts/enter_chroot.sh
index 3c196a93136cd46c1c2257dd383092646308cd2c..33aad4bea3ef67e493c0805b4fcfd1f9177fadca 100755
--- a/src/scripts/enter_chroot.sh
+++ b/src/scripts/enter_chroot.sh
@@ -78,25 +78,28 @@ function setup_env {
# Mount only if not already mounted
MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/proc")"
- if [ -z "$(mount | grep -F "on $MOUNTED_PATH")" ]
+ if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
- sudo mount none -t proc "$MOUNTED_PATH"
+ sudo mount none -t proc "$MOUNTED_PATH" || \
+ die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/dev/pts")"
- if [ -z "$(mount | grep -F "on $MOUNTED_PATH")" ]
+ if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
- sudo mount none -t devpts "$MOUNTED_PATH"
+ sudo mount none -t devpts "$MOUNTED_PATH" || \
+ die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")"
- if [ -z "$(mount | grep -F "on $MOUNTED_PATH")" ]
+ if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
- sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH"
+ sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH" || \
+ die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_CHROME_ROOT}")"
- if [ -z "$(mount | grep -F "on $MOUNTED_PATH")" ]
+ if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
! CHROME_ROOT="$(readlink -f "$FLAGS_chrome_root")"
if [ -z "$CHROME_ROOT" ]; then
@@ -111,12 +114,13 @@ function setup_env {
echo "$CHROME_ROOT" | \
sudo dd of="${FLAGS_chroot}${CHROME_ROOT_CONFIG}"
mkdir -p "$MOUNTED_PATH"
- sudo mount --bind "$CHROME_ROOT" "$MOUNTED_PATH"
+ sudo mount --bind "$CHROME_ROOT" "$MOUNTED_PATH" || \
+ die "Could not mount $MOUNTED_PATH"
fi
fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_DEPOT_TOOLS_ROOT}")"
- if [ -z "$(mount | grep -F "on $MOUNTED_PATH")" ]
+ if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
if [ $(which gclient 2>/dev/null) ]; then
echo "Mounting depot_tools"
@@ -128,16 +132,11 @@ function setup_env {
fi
fi
fi
- ) 200>>"$LOCKFILE"
+ ) 200>>"$LOCKFILE" || die "setup_env failed"
}
function teardown_env {
# Only teardown if we're the last enter_chroot to die
-
- # We should not return with an error if cleanup has an error. Cleanup is
- # best effort only.
- set +e
-
(
flock 200
@@ -165,11 +164,13 @@ function teardown_env {
echo "At least one other pid is running in the chroot, so not"
echo "tearing down env."
else
+ MOUNTED_PATH=$(readlink -f "$FLAGS_chroot")
echo "Unmounting chroot environment."
- mount | grep "on $(readlink -f "$FLAGS_chroot")" | awk '{print $3}' \
- | xargs -r -L1 sudo umount
+ for i in $(mount | grep -F "on $MOUNTED_PATH/" | awk '{print $3}'); do
+ sudo umount "$i" || die "Failed to umount $i"
+ done
fi
- ) 200>>"$LOCKFILE"
+ ) 200>>"$LOCKFILE" || die "teardown_env failed"
}
if [ $FLAGS_mount -eq $FLAGS_TRUE ]
« no previous file with comments | « src/scripts/common.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698