Bind-mount /run if it exists

Ubuntu 11.10, for whatever reason, moved /dev/shm to /run/shm.  Since
/run is not mounted in the chroot, /dev/shm is a dangling symlink and
various things that require shared memory start failing.

If /run and /run/shm exist, bind-mount them in the chroot.

Because /run doesn't yet exist in the SDK tarballs, try to create it
(and /run/shm if necessary) as root if it and can't be created as a
normal user.

BUG=chromium-os:19871
TEST=Run cros_sdk, verify that /dev/shm has the expected contents

Change-Id: I61583c1c0d409c1234fa8d8930a9b64544c9a8e7
Reviewed-on: https://gerrit.chromium.org/gerrit/10222
Tested-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: David James <davidjames@chromium.org>
This commit is contained in:
Aaron Plattner 2011-10-18 08:54:57 -07:00 committed by Gerrit
parent e7c2d1c82b
commit 130d363aaa

View File

@ -104,8 +104,12 @@ function ensure_mounted {
*) *)
# Attempt to make the mountpoint as the user. This depends on the # Attempt to make the mountpoint as the user. This depends on the
# fact that all mountpoints that should be owned by root are # fact that all mountpoints that should be owned by root are
# already present. # already present. However, when distributions add new paths (such as
mkdir -p "${mounted_path}" # Ubuntu 11.10's /run), it might not yet exist in the chroot. If that
# happens, just create it as root.
if ! mkdir -p "${mounted_path}" 2>/dev/null; then
sudo mkdir -p "${mounted_path}"
fi
# NB: mount_args deliberately left unquoted # NB: mount_args deliberately left unquoted
debug mount ${mount_args} "${source}" "${mounted_path}" debug mount ${mount_args} "${source}" "${mounted_path}"
@ -238,6 +242,12 @@ function setup_env {
ensure_mounted none "-t sysfs" /sys ensure_mounted none "-t sysfs" /sys
ensure_mounted /dev "--bind" /dev ensure_mounted /dev "--bind" /dev
ensure_mounted none "-t devpts" /dev/pts ensure_mounted none "-t devpts" /dev/pts
if [ -d /run ]; then
ensure_mounted /run "--bind" /run
if [ -d /run/shm ]; then
ensure_mounted /run/shm "--bind" /run/shm
fi
fi
ensure_mounted "${FLAGS_trunk}" "--bind" "${CHROOT_TRUNK_DIR}" ensure_mounted "${FLAGS_trunk}" "--bind" "${CHROOT_TRUNK_DIR}"
if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then