special case for 9vx -i without root - vx32 - Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log
Files
Refs
---
commit 9720d679df046dfb219a6c20c006574baea63e40
parent ba0642e03d3ca6ccebf97cbafa392b7f1690f511
Author: Jesus Galan Lopez (yiyus) 
Date:   Sat, 18 Sep 2010 20:47:16 +0200

special case for 9vx -i without root

Diffstat:
  M doc/9vx.1                           |       6 ++++--
  M src/9vx/cpurc                       |       4 ++--
  M src/9vx/main.c                      |      23 +++++++++++++++++++----

3 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/doc/9vx.1 b/doc/9vx.1
@@ -101,9 +101,11 @@ Do not fork at init
 Do not start the gui
 .TP
 .BI -i
-Run rc(1) instead of init (sets
+If there is no root, boot from
+.I rootfs.bz2
+and run rc(1), else set
 .I init=/386/init -tm
-)
+(see init(8))
 .TP
 .BI -t
 Use tty for input/output
diff --git a/src/9vx/cpurc b/src/9vx/cpurc
@@ -1,6 +1,6 @@
 #!/bin/rc
 
-ip/ipconfig
+#ip/ipconfig
 auth/factotum
-echo 'key proto=p9sk1 dom=9vx user=glenda !password=p4ss' >/mnt/factotum/ctl
+echo 'key proto=p9sk1 dom=9vx user=glenda !password=password' >/mnt/factotum/ctl
 aux/listen1 -t tcp!*!17010 /bin/cpu -R
diff --git a/src/9vx/main.c b/src/9vx/main.c
@@ -51,6 +51,10 @@ int        nocpuload;
 char*        argv0;
 char*        conffile = "9vx";
 char*        defaultroot = "local!/boot/rootfs.bz2";
+char*        defaultinit = "\
+/386/bin/bind -a /386/bin /bin; \
+/386/bin/bind -a /rc/bin /bin; \
+/386/bin/rc -i";
 Conf        conf;
 
 static Mach mach0;
@@ -527,10 +531,21 @@ init0(void)
         ksetenv("user", username, 0);
         ksetenv("sysname", "vx32", 0);
         inifields(&inienv);
-        if(initrc != 0)
-                inienv("init", "/386/init -tm");
-        else if(initcmd)
-                inienv("init", smprint("/386/init -t '. /rc/bin/termrc; home=/usr/$user; cd; %s; reboot'", initcmd));
+
+        if(initrc != 0){
+                if(localroot == nil && bootargc == 0){
+                        inienv("nobootprompt", defaultroot);
+                        inienv("initcmd", defaultinit);
+                        inienv("init", "/386/bin/rc -c 'eval $initcmd'");
+                }
+                else
+                        inienv("init", "/386/init -tm");
+        }
+        else if(initcmd){
+                ksetenv("initcmd", initcmd, 0);
+                inienv("init", "/386/init -t '. /rc/bin/termrc; home=/usr/$user;\
+                        test -d $home && cd; rc -c $initcmd; reboot'");
+        }
         if(localroot)
                 inienv("nobootprompt", nobootprompt(localroot));
         inienv("cputype", "386");