Fix /dev/pts mount options handling
The current implementation - as introduced in Iee44703297a15b14c715f4bfb7bae67f613aceee - has some shortcomings / bugs, like: * the 'grep' check is too sloppy * when /dev/pts is already mounted multiple times the current implementation fails: $ mount | grep devpts | sed 's/.*(\(.*\))/\1/' rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 * code duplication * Using the undocumented and non-robust output of 'mount'. This patch fixed the above problems. Change-Id: Ib0c7358772480c56d405659a6a32afd60c311686 Signed-off-by: Andreas Florath <andreas@florath.net>
This commit is contained in:
parent
8133166a63
commit
46a07de480
@ -23,6 +23,8 @@ fi
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
source $_LIB/common-functions
|
||||
|
||||
if [ -f ${TARGET_ROOT}/.extra_settings ] ; then
|
||||
. ${TARGET_ROOT}/.extra_settings
|
||||
fi
|
||||
@ -223,13 +225,7 @@ function _install_pkg_manager {
|
||||
sudo mkdir -p $TARGET_ROOT/proc $TARGET_ROOT/dev $TARGET_ROOT/sys
|
||||
sudo mount -t proc none $TARGET_ROOT/proc
|
||||
sudo mount --bind /dev $TARGET_ROOT/dev
|
||||
# Kernel commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eedf265aa003b4781de24cfed40a655a664457e6
|
||||
# introduced in v4.7 allows multiple instances of devpts. However,
|
||||
# some distributions are running older kernels so we need to take
|
||||
# care on what options we use to mount a new instance of devpts
|
||||
# filesystem since it's not completely independent. The best thing
|
||||
# to do is to simply use the existing mount options.
|
||||
sudo mount -t devpts -o $(mount | grep devpts | sed 's/.*(\(.*\))/\1/') devpts $TARGET_ROOT/dev/pts
|
||||
sudo mount -t devpts $(mount_dev_pts_options) devpts $TARGET_ROOT/dev/pts
|
||||
sudo mount -t sysfs none $TARGET_ROOT/sys
|
||||
|
||||
# initalize rpmdb
|
||||
|
@ -24,6 +24,8 @@ fi
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
source $_LIB/common-functions
|
||||
|
||||
function cleanup() {
|
||||
sudo umount $TARGET_ROOT/proc
|
||||
sudo umount $TARGET_ROOT/dev/pts
|
||||
@ -87,13 +89,7 @@ sudo zypper ${ZYPPER_TARGET_OPTS} refresh
|
||||
sudo mkdir -p $TARGET_ROOT/proc $TARGET_ROOT/dev $TARGET_ROOT/sys
|
||||
sudo mount -t proc none $TARGET_ROOT/proc
|
||||
sudo mount --bind /dev $TARGET_ROOT/dev
|
||||
# Kernel commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eedf265aa003b4781de24cfed40a655a664457e6
|
||||
# introduced in v4.7 allows multiple instances of devpts. However,
|
||||
# some distributions are running older kernels so we need to take
|
||||
# care on what options we use to mount a new instance of devpts
|
||||
# filesystem since it's not completely independent. The best thing
|
||||
# to do is to simply use the existing mount options.
|
||||
sudo mount -t devpts -o $(mount | grep devpts | sed 's/.*(\(.*\))/\1/') devpts $TARGET_ROOT/dev/pts
|
||||
sudo mount -t devpts $(mount_dev_pts_options) devpts $TARGET_ROOT/dev/pts
|
||||
sudo mount -t sysfs none $TARGET_ROOT/sys
|
||||
|
||||
# Install filesystem, base and useful tools
|
||||
|
@ -312,17 +312,22 @@ function create_base () {
|
||||
mount_proc_dev_sys
|
||||
}
|
||||
|
||||
# Get mount options for mounting /dev/pts
|
||||
# Kernel commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eedf265aa003b4781de24cfed40a655a664457e6
|
||||
# introduced in v4.7 allows multiple instances of devpts. However,
|
||||
# some distributions are running older kernels so we need to take
|
||||
# care on what options we use to mount a new instance of devpts
|
||||
# filesystem since it's not completely independent. The best thing
|
||||
# to do is to simply use the existing mount options.
|
||||
function mount_dev_pts_options() {
|
||||
echo "-o $(findmnt --first-only /dev/pts --noheadings --output OPTIONS)"
|
||||
}
|
||||
|
||||
function mount_proc_dev_sys () {
|
||||
# supporting kernel file systems
|
||||
sudo mount -t proc none $TMP_MOUNT_PATH/proc
|
||||
sudo mount --bind /dev $TMP_MOUNT_PATH/dev
|
||||
# Kernel commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eedf265aa003b4781de24cfed40a655a664457e6
|
||||
# introduced in v4.7 allows multiple instances of devpts. However,
|
||||
# some distributions are running older kernels so we need to take
|
||||
# care on what options we use to mount a new instance of devpts
|
||||
# filesystem since it's not completely independent. The best thing
|
||||
# to do is to simply use the existing mount options.
|
||||
sudo mount -t devpts -o $(mount | grep devpts | sed 's/.*(\(.*\))/\1/') devpts $TMP_MOUNT_PATH/dev/pts
|
||||
sudo mount -t devpts $(mount_dev_pts_options) devpts $TMP_MOUNT_PATH/dev/pts
|
||||
sudo mount -t sysfs none $TMP_MOUNT_PATH/sys
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user