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

Side by Side Diff: enter_chroot.sh

Issue 6519022: Make mount points before attempting to mount on them (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Typo fix Created 9 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Script to enter the chroot environment 7 # Script to enter the chroot environment
8 8
9 # --- BEGIN COMMON.SH BOILERPLATE --- 9 # --- BEGIN COMMON.SH BOILERPLATE ---
10 # Load common CrOS utilities. Inside the chroot this file is installed in 10 # Load common CrOS utilities. Inside the chroot this file is installed in
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 function ensure_mounted { 136 function ensure_mounted {
137 # If necessary, mount $source in the host FS at $target inside the 137 # If necessary, mount $source in the host FS at $target inside the
138 # chroot directory with $mount_args. 138 # chroot directory with $mount_args.
139 local source="$1" 139 local source="$1"
140 local mount_args="$2" 140 local mount_args="$2"
141 local target="$3" 141 local target="$3"
142 142
143 local mounted_path="$(readlink -f "${FLAGS_chroot}/$target")" 143 local mounted_path="$(readlink -f "${FLAGS_chroot}/$target")"
144 144
145 if [ -z "$(mount | grep -F "on ${mounted_path} ")" ]; then 145 if [ -z "$(mount | grep -F "on ${mounted_path} ")" ]; then
146 # Attempt to make the mountpoint as the user. This depends on the
147 # fact that all mountpoints that should be owned by root are
148 # already present.
149 mkdir -p "${mounted_path}"
150
146 # NB: mount_args deliberately left unquoted 151 # NB: mount_args deliberately left unquoted
147 debug mount ${mount_args} "${source}" "${mounted_path}" 152 debug mount ${mount_args} "${source}" "${mounted_path}"
148 sudo -- mount ${mount_args} "${source}" "${mounted_path}" || \ 153 sudo -- mount ${mount_args} "${source}" "${mounted_path}" || \
149 die "Could not mount ${source} on ${mounted_path}" 154 die "Could not mount ${source} on ${mounted_path}"
150 fi 155 fi
151 } 156 }
152 157
153 function setup_env { 158 function setup_env {
154 # Validate sudo timestamp before entering the critical section so that we 159 # Validate sudo timestamp before entering the critical section so that we
155 # don't stall for a password while we have the lockfile. 160 # don't stall for a password while we have the lockfile.
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 # Run command or interactive shell. Also include the non-chrooted path to 390 # Run command or interactive shell. Also include the non-chrooted path to
386 # the source trunk for scripts that may need to print it (e.g. 391 # the source trunk for scripts that may need to print it (e.g.
387 # build_image.sh). 392 # build_image.sh).
388 sudo -- chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ 393 sudo -- chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \
389 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \ 394 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \
390 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" "$@" 395 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" "$@"
391 396
392 # Remove trap and explicitly unmount 397 # Remove trap and explicitly unmount
393 trap - EXIT 398 trap - EXIT
394 teardown_env 399 teardown_env
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698