code: plan9front

Download patch

ref: e2509e7653a9845c7901e297e5c0da679322eee5
parent: 0b7f6f27b215c5cfa680d2b70d13806706386f3f
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Dec 12 15:45:34 EST 2022

bootrc: let /boot/boot run in a more natural namespace

Mount /fd, /proc, /srv and /shr in initcode
and open /dev/cons instead of #c/cons.

This way, /boot/boot could theoretically be a rc-script
and there is less reliance on magic device characters.

--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -8,9 +8,6 @@
 bind /root /mnt/broot
 unmount /root
 
-bind -q '#σ' /shr
-bind -q '#d' /fd
-bind -q '#p' /proc
 for(i in ¶ P S f æ t b m)
 	bind -qa '#'^$i /dev
 
--- a/sys/src/9/port/initcode.c
+++ b/sys/src/9/port/initcode.c
@@ -7,15 +7,21 @@
 #include <u.h>
 #include <libc.h>
 
-char cons[] = "#c/cons";
+char cons[] = "/dev/cons";
 char boot[] = "/boot/boot";
 char dev[] = "/dev";
 char c[] = "#c";
+char d[] = "#d";
 char e[] = "#e";
 char ec[] = "#ec";
+char p[] = "#p";
 char s[] = "#s";
-char srv[] = "/srv";
+char σ[] = "#σ";
 char env[] = "/env";
+char fd[] = "/fd";
+char proc[] = "/proc";
+char srv[] = "/srv";
+char shr[] = "/shr";
 
 void
 startboot(char*, char **argv)
@@ -22,14 +28,17 @@
 {
 	char buf[200];	/* keep this fairly large to capture error details */
 
-	/* in case boot is a shell script */
-	open(cons, OREAD);
-	open(cons, OWRITE);
-	open(cons, OWRITE);
 	bind(c, dev, MAFTER);
+	bind(d, fd, MREPL);
 	bind(ec, env, MAFTER);
 	bind(e, env, MCREATE|MAFTER);
+	bind(p, proc, MREPL);
 	bind(s, srv, MREPL|MCREATE);
+	bind(σ, shr, MREPL);
+
+	open(cons, OREAD);
+	open(cons, OWRITE);
+	open(cons, OWRITE);
 
 	exec(boot, argv);