mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-22 22:21:10 +02:00
enter_chroot: avoid multiple readlink calls on mount point
We call `readlink -f` on the chroot mount point to resolve any symlinks in the path (since that is what `mount` records). But the only paths that can have symlinks are in the base chroot mount. Everything below that we know are not going to be symlinks (since we've set up the paths ourselves). So process the chroot mount point with readlink once and reuse that value everywhere else. BUG=None TEST=`cros_sdk --enter true` still mounts & unmounts properly Change-Id: Id1e734d20c0cb766f5490583b793930af77b3b14 Reviewed-on: http://gerrit.chromium.org/gerrit/8645 Reviewed-by: David James <davidjames@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
4ad673ecfc
commit
0a0e6ecee3
@ -86,6 +86,7 @@ LOCKFILE="$FLAGS_chroot/var/lock/enter_chroot"
|
|||||||
SYNCERPIDFILE="${FLAGS_chroot}/var/tmp/enter_chroot_sync.pid"
|
SYNCERPIDFILE="${FLAGS_chroot}/var/tmp/enter_chroot_sync.pid"
|
||||||
|
|
||||||
|
|
||||||
|
MOUNTED_PATH=$(readlink -f "$FLAGS_chroot")
|
||||||
function ensure_mounted {
|
function ensure_mounted {
|
||||||
# If necessary, mount $source in the host FS at $target inside the
|
# If necessary, mount $source in the host FS at $target inside the
|
||||||
# chroot directory with $mount_args.
|
# chroot directory with $mount_args.
|
||||||
@ -94,7 +95,7 @@ function ensure_mounted {
|
|||||||
local target="$3"
|
local target="$3"
|
||||||
local warn="$4"
|
local warn="$4"
|
||||||
|
|
||||||
local mounted_path="$(readlink -f "${FLAGS_chroot}/$target")"
|
local mounted_path="${MOUNTED_PATH}$target"
|
||||||
|
|
||||||
case ${MOUNT_CACHE} in
|
case ${MOUNT_CACHE} in
|
||||||
*" on ${mounted_path} "*)
|
*" on ${mounted_path} "*)
|
||||||
@ -420,7 +421,6 @@ function teardown_env {
|
|||||||
sudo rm -f "${SYNCERPIDFILE}" || \
|
sudo rm -f "${SYNCERPIDFILE}" || \
|
||||||
debug "Unable to clean up syncer process.";
|
debug "Unable to clean up syncer process.";
|
||||||
|
|
||||||
MOUNTED_PATH=$(readlink -f "$FLAGS_chroot")
|
|
||||||
debug "Unmounting chroot environment."
|
debug "Unmounting chroot environment."
|
||||||
safe_umount_tree "${MOUNTED_PATH}/"
|
safe_umount_tree "${MOUNTED_PATH}/"
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user