Skip to content

Commit

Permalink
Check whether /sys, /media is a mount point.
Browse files Browse the repository at this point in the history
It is possible that /sys, /media is not mounted in a container,
so check it before we bind-mount it into chroot.
  • Loading branch information
arbuztw committed Sep 8, 2015
1 parent 159d6db commit 4538914
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions host-bin/enter-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,10 @@ WARNING: CRAS not running in Chromium OS. Audio forwarding will not work." 1>&2
fi

# Bind-mount /media, specifically the removable directory
# It is possible that /media is not mounted inside containers,so bind-mount it
# only if /media is a mountpoint.
destmedia="`fixabslinks '/var/host/media'`"
if ! mountpoint -q "$destmedia"; then
if mountpoint -q "/media" && ! mountpoint -q "$destmedia"; then
mount --make-shared /media
mkdir -p "$destmedia" "$CHROOT/media"
ln -sf "/var/host/media/removable" "$CHROOT/media/"
Expand Down Expand Up @@ -562,7 +564,9 @@ if [ -z "$NOLOGIN" -a -f "$shares" ]; then
fi

# Bind-mount /sys recursively, making it a slave in the chroot
if ! mountpoint -q "$CHROOT/sys"; then
# It is possible that /sys is not mounted inside containers,so bind-mount it
# only if /sys is a mountpoint.
if mountpoint -q "/sys" && ! mountpoint -q "$CHROOT/sys"; then
mkdir -p "$CHROOT/sys"
mount --make-rshared /sys
mount --rbind /sys "$CHROOT/sys"
Expand Down

0 comments on commit 4538914

Please sign in to comment.