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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/scripts/enter_chroot.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Common constants for build scripts 5 # Common constants for build scripts
6 # This must evaluate properly for both /bin/bash and /bin/sh 6 # This must evaluate properly for both /bin/bash and /bin/sh
7 7
8 # All scripts should die on error unless commands are specifically excepted 8 # All scripts should die on error unless commands are specifically excepted
9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. 9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'.
10 # TODO: Re-enable this once shflags is less prone to dying. 10 # TODO: Re-enable this once shflags is less prone to dying.
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 function sudo_clobber() { 330 function sudo_clobber() {
331 sudo tee "$1" > /dev/null 331 sudo tee "$1" > /dev/null
332 } 332 }
333 333
334 # Writes stdin to the given file name as root using sudo in append mode. 334 # Writes stdin to the given file name as root using sudo in append mode.
335 # 335 #
336 # $1 - The output file name. 336 # $1 - The output file name.
337 function sudo_append() { 337 function sudo_append() {
338 sudo tee -a "$1" > /dev/null 338 sudo tee -a "$1" > /dev/null
339 } 339 }
340
341 # Unmounts a directory, if the unmount fails, warn, and then lazily unmount.
342 #
343 # $1 - The path to unmount.
344 function safe_umount {
345 path=${1:?}
346 shift
347
348 if ! sudo umount -d "${path}"; then
349 warn "Failed to unmount ${path}"
350 warn "Doing a lazy unmount"
351
352 sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}"
353 fi
354 }
OLDNEW
« 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