From cb013df1407dc75d033de2ce79aafc4edd510483 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Thu, 23 Aug 2018 10:07:18 +0000 Subject: Move code blocks for initializing the early userspace together --- initramfs-init.in | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'initramfs-init.in') diff --git a/initramfs-init.in b/initramfs-init.in index 5f0a5ff..538f286 100755 --- a/initramfs-init.in +++ b/initramfs-init.in @@ -7,20 +7,6 @@ sysroot=/sysroot splashfile=/.splash.ctrl repofile=/tmp/repositories -/bin/busybox mkdir -p /usr/bin /usr/sbin /proc /sys /dev $sysroot \ - /media/cdrom /media/usb /tmp /run -/bin/busybox --install -s - -# basic environment -export PATH=/usr/bin:/bin:/usr/sbin:/sbin - -# needed devs -[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3 - -# basic mounts -mount -t proc -o noexec,nosuid,nodev proc /proc -mount -t sysfs -o noexec,nosuid,nodev sysfs /sys - # some helpers ebegin() { last_emsg="$*" @@ -293,6 +279,34 @@ is_url() { esac } +/bin/busybox mkdir -p /usr/bin /usr/sbin /proc /sys /dev $sysroot \ + /media/cdrom /media/usb /tmp /run + +# Spread out busybox symlinks and make them available without full path +/bin/busybox --install -s +export PATH=/usr/bin:/bin:/usr/sbin:/sbin + +# Make sure /dev/null is a device node. If /dev/null does not exist yet, the command +# mounting the devtmpfs will create it implicitly as an file with the "2>" redirection. +# The -c check is required to deal with initramfs with pre-seeded device nodes without +# error message. +[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3 + +mount -t proc -o noexec,nosuid,nodev proc /proc +mount -t sysfs -o noexec,nosuid,nodev sysfs /sys +mount -t devtmpfs -o exec,nosuid,mode=0755,size=2M devtmpfs /dev 2>/dev/null \ + || mount -t tmpfs -o exec,nosuid,mode=0755,size=2M tmpfs /dev + +# pty device nodes (later system will need it) +[ -c /dev/ptmx ] || mknod -m 666 /dev/ptmx c 5 2 +[ -d /dev/pts ] || mkdir -m 755 /dev/pts +mount -t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts + +# shared memory area (later system will need it) +[ -d /dev/shm ] || mkdir /dev/shm +mount -t tmpfs -o nodev,nosuid,noexec shm /dev/shm + + # read the kernel options. we need surve things like: # acpi_osi="!Windows 2006" xen-pciback.hide=(01:00.0) set -- $(cat /proc/cmdline) @@ -356,18 +370,6 @@ for i in ${KOPT_blacklist//,/ }; do echo "blacklist $i" >> /etc/modprobe.d/boot-opt-blacklist.conf done -# setup /dev -mount -t devtmpfs -o exec,nosuid,mode=0755,size=2M devtmpfs /dev 2>/dev/null \ - || mount -t tmpfs -o exec,nosuid,mode=0755,size=2M tmpfs /dev -[ -d /dev/pts ] || mkdir -m 755 /dev/pts -[ -c /dev/ptmx ] || mknod -m 666 /dev/ptmx c 5 2 -# make sure /dev/null is setup correctly -[ -f /dev/null ] && rm -f /dev/null -[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3 -mount -t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts -[ -d /dev/shm ] || mkdir /dev/shm -mount -t tmpfs -o nodev,nosuid,noexec shm /dev/shm - # determine if we are going to need networking if [ -n "$KOPT_ip" ] || [ -n "$KOPT_nbd" ] || \ is_url "$KOPT_apkovl" || is_url "$ALPINE_REPO"; then -- cgit v1.2.3