lnstools

Linux namespace tools
git clone https://ccx.te2000.cz/git/lnstools
Log | Files | Refs | README

commit 7fbfb934cdaa187a063a4df41498c06c46d4a6a9
parent 0253d2bcae9a5fe32fe14ae79a8b0f18ce5fe066
Author: Jan Pobrislo <ccx@te2000.cz>
Date:   Wed, 26 Nov 2025 04:28:41 +0000

Remove old versions of scripts, try for busybox mount compatability

Diffstat:
Mconfigure | 5-----
Dsrc/lns-mount-chroot | 66------------------------------------------------------------------
Dsrc/lns-mount-chroot.gen | 16----------------
Msrc/lns-mount-chroot.in | 6+++---
Dsrc/lns-mounts-to-env | 44--------------------------------------------
Dsrc/lns-mounts-to-env.gen | 7-------
6 files changed, 3 insertions(+), 141 deletions(-)

diff --git a/configure b/configure @@ -115,7 +115,6 @@ got_prog() { (mount) prog_mount=$2 ;; (multisubstitute) prog_multisubstitute=$2 ;; (runblock) prog_runblock=$2 ;; - (s6-mount) prog_s6_mount=$2 ;; (sh) prog_sh=$2 ;; (shift) prog_shift=$2 ;; (*) return 1 ;; @@ -216,7 +215,6 @@ case $enable_abspath in : ${prog_mount=mount} : ${prog_multisubstitute=multisubstitute} : ${prog_runblock=runblock} - : ${prog_s6_mount=s6-mount} : ${prog_sh=sh} : ${prog_shift=shift} ;; @@ -233,7 +231,6 @@ case $enable_abspath in : ${prog_mount=$(which mount 2>/dev/null )} : ${prog_multisubstitute=$(which multisubstitute 2>/dev/null )} : ${prog_runblock=$(which runblock 2>/dev/null )} - : ${prog_s6_mount=$(which s6-mount 2>/dev/null )} : ${prog_sh=$(which sh 2>/dev/null )} : ${prog_shift=$(which shift 2>/dev/null )} ;; @@ -260,7 +257,6 @@ test -n "$prog_mknod" || die_notfound mknod test -n "$prog_mount" || die_notfound mount test -n "$prog_multisubstitute" || die_notfound multisubstitute test -n "$prog_runblock" || die_notfound runblock -test -n "$prog_s6_mount" || die_notfound s6-mount test -n "$prog_sh" || die_notfound sh test -n "$prog_shift" || die_notfound shift @@ -309,7 +305,6 @@ mk_script_gen() { mount="$prog_mount" \ multisubstitute="$prog_multisubstitute" \ runblock="$prog_runblock" \ - s6-mount="$prog_s6_mount" \ sh="$prog_sh" \ shift="$prog_shift" } diff --git a/src/lns-mount-chroot b/src/lns-mount-chroot @@ -1,66 +0,0 @@ -#!/command/execlineb -S1 - -multisubstitute { - importas -i 1 1 # require first argument - importas -D /mnt/chroot LNS_ROOT LNS_ROOT -} -shift -n 1 # remove first argument so we don't have to deal with it with runblock - -lns-mounts-to-env - -if { mount -o rbind $1 $NS_ROOT } - -# /proc -if { mount -t proc proc ${LNS_ROOT}/proc } - -# /dev -if { s6-mount -nwt tmpfs -o nosuid,dev,mode=0755 dev ${LNS_ROOT}/dev } -if { mknod -m 666 ${LNS_ROOT}/dev/null c 1 3 } -if { mknod -m 666 ${LNS_ROOT}/dev/full c 1 7 } -if { mknod -m 666 ${LNS_ROOT}/dev/ptmx c 5 2 } -if { mknod -m 644 ${LNS_ROOT}/dev/random c 1 8 } -if { mknod -m 644 ${LNS_ROOT}/dev/urandom c 1 9 } -if { mknod -m 666 ${LNS_ROOT}/dev/zero c 1 5 } -if { mknod -m 666 ${LNS_ROOT}/dev/tty c 5 0 } -if { s6-ln -sf /proc/self/fd ${LNS_ROOT}/dev/fd } -if { s6-ln -sf /proc/self/fd/0 ${LNS_ROOT}/dev/stdin } -if { s6-ln -sf /proc/self/fd/1 ${LNS_ROOT}/dev/stout } -if { s6-ln -sf /proc/self/fd/2 ${LNS_ROOT}/dev/stderr } -if { s6-ln -sf ../run/shm ${LNS_ROOT}/dev/shm } - -# dev/shm is intentionally ommited to allow custom mount or symlink -# pts and mqueue are provided below - -# Create top-level /dev directories. Many may be bind-mounted from host if neededx. -if { - mkdir - - ${LNS_ROOT}/dev/pts - ${LNS_ROOT}/dev/mqueue - - ${LNS_ROOT}/dev/block - ${LNS_ROOT}/dev/bus - ${LNS_ROOT}/dev/bus/usb - ${LNS_ROOT}/dev/char - ${LNS_ROOT}/dev/dri - ${LNS_ROOT}/dev/input - ${LNS_ROOT}/dev/loop - ${LNS_ROOT}/dev/net - ${LNS_ROOT}/dev/snd - ${LNS_ROOT}/dev/usb - -} -if { mount -t devpts devpts ${LNS_ROOT}/dev/pts } -if { s6-mount -nwt mqueue -o nosuid,nodev,noexec mqueue ${LNS_ROOT}/dev/mqueue } - -# run -if { - cd $NS_ROOT - runblock 1 -} - -# now we can make /dev immutable -if { mount -o remount,ro ${LNS_ROOT}/dev } - -# chainload into the rest of the argv -runblock -r 1 diff --git a/src/lns-mount-chroot.gen b/src/lns-mount-chroot.gen @@ -1,16 +0,0 @@ -#!/bin/sh -e -exec awk -f "$(dirname "$0")/../scripts/abspaths2.awk" "${0%.gen}.in" \ -"execlineb=$(which 'execlineb' 2>/dev/null)" \ -"multisubstitute=$(which 'multisubstitute' 2>/dev/null)" \ -"importas=$(which 'importas' 2>/dev/null)" \ -"shift=$(which 'shift' 2>/dev/null)" \ -"if=$(which 'if' 2>/dev/null)" \ -"mount=$(which 'mount' 2>/dev/null)" \ -"mknod=$(which 'mknod' 2>/dev/null)" \ -"ln=$(which 'ln' 2>/dev/null)" \ -"mkdir=$(which 'mkdir' 2>/dev/null)" \ -"cd=$(which 'cd' 2>/dev/null)" \ -"runblock=$(which 'runblock' 2>/dev/null)" \ -"s6-mount=$(which 's6-mount' 2>/dev/null)" \ -"lns-mounts-to-env=$(which 'lns-mounts-to-env' 2>/dev/null)" \ -"$@" diff --git a/src/lns-mount-chroot.in b/src/lns-mount-chroot.in @@ -14,7 +14,7 @@ elquote:if { elquote:mount -t proc proc ${LNS_ROOT}/proc } # /dev -elquote:if { elquote:mount -nwt tmpfs -o nosuid,dev,mode=0755 dev ${LNS_ROOT}/dev } +elquote:if { elquote:mount -wt tmpfs -o nosuid,dev,mode=0755 dev ${LNS_ROOT}/dev } # Create top-level /dev directories. Many may be bind-mounted from host if needed. elquote:if { elquote:mkdir @@ -35,8 +35,8 @@ ${LNS_ROOT}/dev/usb } -elquote:if { elquote:mount -nwt devpts devpts ${LNS_ROOT}/dev/pts } -elquote:if { elquote:mount -nwt mqueue -o nosuid,nodev,noexec mqueue ${LNS_ROOT}/dev/mqueue } +elquote:if { elquote:mount -wt devpts devpts ${LNS_ROOT}/dev/pts } +elquote:if { elquote:mount -wt mqueue -o nosuid,nodev,noexec mqueue ${LNS_ROOT}/dev/mqueue } elquote:if { elquote:mknod -m 666 ${LNS_ROOT}/dev/null c 1 3 } elquote:if { elquote:mknod -m 666 ${LNS_ROOT}/dev/full c 1 7 } diff --git a/src/lns-mounts-to-env b/src/lns-mounts-to-env @@ -1,44 +0,0 @@ -#!/bin/sh -prog=$(awk ' -function el_quote(s) { - gsub(/\\/, "\\\\", s); # first double all backslashes - gsub(/"/, "\\\"", s); # then escape quote marks - return "\"" s "\"" # then surround with quote marks -} - -BEGIN { - # mount IDs seem to be unsigned, so lets use -1 to signify not found - max_id = -1 - root_id = -1 - count = 0 -} - -# read in /proc/self/mountinfo -$5 == "/" { root_id = $1 } -{ - max_id = max_id < $1 ? $1 : max_id - parents[$1] = $2 - mountpoints[$1] = $5 -} - -function print_umount(mtp){ - print "NS_MTP_" (++count) "=" el_quote(mtp) -} - -function recursively_umount(mount_id, id) { - for(id=max_id; id>=0; id--){ - if(parents[id] == mount_id){ - recursively_umount(id) - } - } - print_umount(mountpoints[mount_id]) -} - -END{ - if(root_id == -1) { exit 111 } - print "env" - recursively_umount(root_id) - print "NS_MTP_COUNT=" count -} -' /proc/self/mountinfo) || exit $? -exec execlineb -s0 -c "$prog \$@" "$@" diff --git a/src/lns-mounts-to-env.gen b/src/lns-mounts-to-env.gen @@ -1,7 +0,0 @@ -#!/bin/sh -e - -export prog_sh=${prog_sh:-"$(which sh)"} -export prog_awk=${prog_awk:-"$(which awk)"} -export prog_execlineb=${prog_execlineb:-"$(which execlineb)"} - -awk -f "$(dirname "$0")/../scripts/abspaths.awk" "${0%.gen}.in"