SVN: rc-scripts/trunk/rc.d/rc.sysinit

glen glen at pld-linux.org
Thu May 30 20:09:23 CEST 2013


Author: glen
Date: Thu May 30 20:09:23 2013
New Revision: 12667

Modified:
   rc-scripts/trunk/rc.d/rc.sysinit
Log:
rc.sysinit: move /proc/cmdline parsing to single function


Modified: rc-scripts/trunk/rc.d/rc.sysinit
==============================================================================
--- rc-scripts/trunk/rc.d/rc.sysinit	(original)
+++ rc-scripts/trunk/rc.d/rc.sysinit	Thu May 30 20:09:23 2013
@@ -48,6 +48,47 @@
 	modprobe_c_cache=$(modprobe -c)
 }
 
+# parse kernel cmdline
+# needs /proc mounted
+parse_cmdline() {
+	read cmdline < /proc/cmdline
+	local arg
+
+	for arg in $cmdline; do
+		case "$arg" in
+		pld.no-upstart)
+			# default is set in /etc/sysconfig/system or detected in init.d/functions
+			USE_UPSTART=no
+		;;
+		noudev)
+			# default is set in /etc/sysconfig/system
+			START_UDEV=no
+		;;
+		nousb)
+			nousb=1
+		;;
+		nohdparm)
+			nohdparm=1
+		;;
+		fastboot)
+			fastboot=1
+		;;
+		nopnp)
+			nopnp=1
+		;;
+		nomodules)
+			nomodules=1
+		;;
+		nofirewire)
+			nofirewire=1
+		;;
+		nofsck)
+			nofsck=1
+		;;
+		esac
+	done
+}
+
 disable_selinux() {
 	local _d selinuxfs _t _r
 
@@ -180,6 +221,8 @@
 	# we need /proc mounted before everything
 	is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc
 
+	parse_cmdline
+
 	if [ -d /run ]; then
 		is_fsmounted tmpfs /run || mount -n -t tmpfs run /run
 	fi
@@ -187,12 +230,6 @@
 	# Early sysctls
 	sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
 
-	# Only read this once.
-	cmdline=$(cat /proc/cmdline)
-	if strstr "$cmdline" "pld.no-upstart" ; then
-		USE_UPSTART="no"
-	fi
-
 	# sysfs is also needed before any other things (under kernel > 2.5)
 	if grep -q sysfs /proc/filesystems 2>/dev/null; then
 		is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
@@ -329,7 +366,7 @@
 
 	# Initialize USB controllers
 	usb=0
-	if ! strstr "$cmdline" "nousb" && ! is_fsmounted usbfs /proc/bus/usb; then
+	if [ -z "$nousb" ] && ! is_fsmounted usbfs /proc/bus/usb; then
 		aliases=$(modprobe_c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
 		if [ -n "$aliases" -a "$aliases" != "off" ] ; then
 			modprobe -s usbcore
@@ -365,14 +402,12 @@
 	fi
 
 	# Setup hdparm thing (if exists and is needed)
-	if ! strstr "$cmdline" nohdparm; then
+	if [ -z "$nohdparm" ]; then
 		[ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
 	fi
 
-	if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
-		fastboot=yes
-	else
-		fastboot=
+	if [ -z "$fastboot" ] && [ -f /fastboot ]; then
+		fastboot=1
 	fi
 
 	if [ -f /fsckoptions ]; then
@@ -398,15 +433,8 @@
 		check_root_fs
 	fi
 
-	# Check for arguments
-	if strstr "$cmdline" nopnp; then
-		PNP=
-	else
-		PNP=yes
-	fi
-
 	# set up pnp and kernel pnp
-	if [ -n "$PNP" ]; then
+	if [ -z "$nopnp" ]; then
 		if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
 			run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
 		fi
@@ -507,7 +535,7 @@
 
 	if [ ! -f /proc/modules ]; then
 		USEMODULES=
-	elif ! strstr "$cmdline" nomodules; then
+	elif [ -z "$nomodules" ]; then
 		USEMODULES=y
 	else
 		USEMODULES=
@@ -553,7 +581,7 @@
 	fi
 
 	# Load firewire devices
-	if ! strstr "$cmdline" nofirewire; then
+	if [ -z "$nofirewire" ]; then
 		aliases=$(modprobe_c | awk '/^alias ieee1394-controller/ { print $3 }')
 		if [ -n "$aliases" -a "$aliases" != "off" ] ; then
 			for alias in $aliases ; do
@@ -769,7 +797,7 @@
 
 	_RUN_QUOTACHECK=0
 	# Check filesystems
-	if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then
+	if [ -z "$fastboot" ] && [ -z "$nofsck" ]; then
 		rc_splash "fsck start"
 		show "Checking filesystems"; started
 		initlog -c "fsck -C -T -R -A -a -P $fsckoptions"


More information about the pld-cvs-commit mailing list