From a64b09d741a61771bd08a944ac60419f0fb9d058 Mon Sep 17 00:00:00 2001 From: Cem Keylan Date: Wed, 20 May 2020 13:01:16 +0300 Subject: init: primitive parsing of the command line --- rc.lib | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'rc.lib') diff --git a/rc.lib b/rc.lib index e0ee61f..7d5068d 100644 --- a/rc.lib +++ b/rc.lib @@ -39,3 +39,25 @@ random() { esac } +parse_cmdline() { + # This is a primitive way of parsing kernel command line + # options. Before now, carbs-init ignored these options + # set by the user. More will be added as needed. Init scripts + # don't need to handle most of the command line options + # as the kernel deals with most of them, but not things + # such as mount options. + [ -r /proc/cmdline ] || { + err "Kernel command line options cannot be parsed" + shell + } + + # We want to read words instead of lines here. + # shellcheck disable=2013 + for arg in $(cat /proc/cmdline); do + case "$arg" in + ro) RO=1 ;; + forcefsck) FORCEFSCK="-f" ;; + fastboot) FASTBOOT=1 ;; + esac + done +} -- cgit v1.2.3