Browse Source

Define new boot type, rc

If you type 'rc' at boot, it drops you into rc.

You can then type, e.g., startdisk, then exit, and you'll have a system running on
a local disk.

This lets you debug getting local disk going.

I now have local disk with fossil/venti on my samsung chromebook.

Change-Id: Ib06cae7f68f8b2dc82f989722a5936ad69296bbb
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 8 years ago
parent
commit
cd63e1d784

+ 1 - 0
.gitignore

@@ -70,3 +70,4 @@ util/auth/bin/
 util/third_party/authsrv9/authsrv9
 util/third_party/authsrv9/passtokey
 util/convert
+usr/harvey/tmp

+ 2 - 0
sys/src/9/boot/boot.h

@@ -77,5 +77,7 @@ extern int	connectembed(void);
 
 extern void	configip(int, char**, int);
 
+extern void	configrc(Method*);
+extern int	connectrc(void);
 /* hack for passing authentication address */
 extern char	*authaddr;

+ 1 - 0
sys/src/9/boot/boot.json

@@ -30,6 +30,7 @@
 			"bootcache.c",
 			"bootip.c",
 			"bootk8cpu.c",
+			"bootrc.c",
 			"embed.c",
 			"local.c",
 			"paq.c",

+ 49 - 0
sys/src/9/boot/bootrc.c

@@ -0,0 +1,49 @@
+/*
+ * This file is part of the UCB release of Plan 9. It is subject to the license
+ * terms in the LICENSE file found in the top-level directory of this
+ * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
+ * part of the UCB release of Plan 9, including this file, may be copied,
+ * modified, propagated, or distributed except according to the terms contained
+ * in the LICENSE file.
+ */
+
+#include <u.h>
+#include <libc.h>
+#include <ip.h>
+
+#include "boot.h"
+
+void
+configrc(Method* m)
+{
+	void configloopback(void);
+	configloopback();
+	bind("#S", "/dev", MAFTER);
+	char *argv[] = {"rc", "-m", "/boot/rcmain", "-i", 0,};
+	switch(fork()){
+	case -1:
+		print("configrc: fork failed: %r\n");
+	case 0:
+		exec("/boot/rc", argv);
+		fatal("can't exec rc");
+	default:
+		break;
+	}
+	while(waitpid() != -1)
+		;
+	print("rc is done, continuing...\n");
+}
+
+int
+connectrc(void)
+{
+	int fd;
+	char buf[64];
+
+	// Later, make this anything.
+	snprint(buf, sizeof buf, "/srv/fossil");
+	fd = open("#s/fossil", 2);
+	if (fd < 0)
+		werrstr("dial %s: %r", buf);
+	return fd;
+}

+ 6 - 1
sys/src/9/k10/k8cpu.json

@@ -91,7 +91,12 @@
 				"rc": "/amd64/bin/rc",
 				"rcmain": "/rc/lib/rcmain",
 				"screenconsole": "/amd64/bin/aux/screenconsole",
-				"srv": "/amd64/bin/srv"
+				"srv": "/amd64/bin/srv",
+				"fdisk": "/amd64/bin/disk/fdisk",
+				"prep": "/amd64/bin/disk/prep",
+				"venti": "/amd64/bin/venti/venti",
+				"fossil": "/amd64/bin/fossil/fossil",
+				"startdisk" : "startdisk"
 			}
 		},
 		"Program": "9k8cpu",

+ 8 - 0
sys/src/9/k10/startdisk

@@ -0,0 +1,8 @@
+#!/boot/rc -m /boot/rcmain
+/boot/fdisk -p '#S/sdE0/data' > '#S/sdE0/ctl'
+/boot/prep -p '#S/sdE0/plan9' > '#S/sdE0/ctl'
+/boot/venti -c '#S/sdE0/arenas'
+venti=tcp!127.0.0.1!17034
+/boot/fossil -f '#S/sdE0/fossil'
+
+

+ 6 - 0
sys/src/sysconf.json

@@ -870,6 +870,12 @@
 			"Config": "configtcp",
 			"Connect": "connecttcp",
 			"Arg": ""
+		},
+		{
+			"Name": "rc",
+			"Config": "configrc",
+			"Connect": "connectrc",
+			"Arg": ""
 		}
 	]
 }