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

Unified Diff: src/scripts/common.sh

Issue 1593021: Add a safe_unmount function and use it in enter_chroot. (Closed)
Patch Set: Don't rely on $? Created 10 years, 8 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 | « no previous file | src/scripts/enter_chroot.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scripts/common.sh
diff --git a/src/scripts/common.sh b/src/scripts/common.sh
index c5ae10413238823a0ce78a38a855839bc14455e9..f0e139504e5069d1e9ef3dc837ab63d7ac779773 100644
--- a/src/scripts/common.sh
+++ b/src/scripts/common.sh
@@ -337,3 +337,18 @@ function sudo_clobber() {
function sudo_append() {
sudo tee -a "$1" > /dev/null
}
+
+# Unmounts a directory, if the unmount fails, warn, and then lazily unmount.
+#
+# $1 - The path to unmount.
+function safe_umount {
+ path=${1:?}
+ shift
+
+ if ! sudo umount -d "${path}"; then
+ warn "Failed to unmount ${path}"
+ warn "Doing a lazy unmount"
+
+ sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}"
+ fi
+}
« no previous file with comments | « no previous file | src/scripts/enter_chroot.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698