Skip to contentSkip to conversation

Pass init argument(s) to real init

PATCH In review Andrey Borzenkov 2 participants 3 messages Jan 30, 2010 – Mar 4, 2010 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Pass init argument(s) to real init

I was rather surprised why all my attempts to enter single user were not successful :) Simple patch to collect and pass to real init what _looks_ like init arguments.

-andrey

Common wisdom to enter single user on Linux is to edit command line and add "single". This was not possible because switch_root was always called with empty init arguments. Collect them from command line and pass to real init when switching root.

---

 modules.d/99base/init |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
modules.d/99base/init +11 -1
index ab033a7..e5158f8 100755
@@ -259,10 +259,10 @@ done
 
 initargs=""
 
+read CLINE </proc/cmdline
 if getarg init= >/dev/null ; then
     ignoreargs="console BOOT_IMAGE"
     # only pass arguments after init= to the init
-    read CLINE </proc/cmdline
     CLINE=${CLINE#*init=}
     set $CLINE
     shift
@@ -273,6 +273,16 @@ if getarg init= >/dev/null ; then
         initargs="$initargs $x"
     done
     unset CLINE
+else
+    set $CLINE
+    shift
+    for x in "$@"; do
+        case "$x" in
+            [0-9]|s|S|single|emergency|auto )
+                initargs="$initargs $x"
+            ;;
+        esac
+    done
 fi
 
 # Debug: Copy state

A message that is not in the archive (sent off-list or not yet received): 201001301757.49473.arvidjaar-JGs/[email protected]

#2 lore raw
Quoted 4 lines · On Saturday 30 of January 2010 17:57:45 Andrey Borzenkov wrote:

I was rather surprised why all my attempts to enter single user were not successful :) Simple patch to collect and pass to real init what _looks_ like init arguments.

Ping.

Was it bad, is it unnecessary?

A message that is not in the archive (sent off-list or not yet received): 201003012112.58174.arvidjaar-JGs/[email protected]

#4 lore raw
Quoted 9 lines · Andrey Borzenkov
Quoted 4 lines · On Saturday 30 of January 2010 17:57:45 Andrey Borzenkov wrote:

I was rather surprised why all my attempts to enter single user were not successful :) Simple patch to collect and pass to real init what _looks_ like init arguments.

Ping.

Was it bad, is it unnecessary?

no, pushed