shithub: riscv

Download patch

ref: ecebba779f8cb55dadac70ef1c109e9e69c63423
parent: 24150b117110e982496b10c2f1dfef329160a36a
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Feb 13 20:42:32 EST 2016

provide /n and /mnt early in bootrc to allow consistent use in /lib/namespace

theres a bootstrap problem:

when /bin/init is run, it processes /lib/namespace where we might want to
mount or bind resources to /n or /mnt. but mntgen was run later in
cpurc/termrc so these mounts would be ignored.

we already have mntgen in bootfs, so we can provide these mountpoints early.

i keep the termrc/cpurc mntgens where they are, but ignore the error
prints. this way old kernels will continue to work.

--- a/lib/namespace
+++ b/lib/namespace
@@ -31,8 +31,8 @@
 mount -a /srv/dns /net
 mount -a /srv/net /net
 
-mount -qC /srv/boot /n/other other
-bind -qc /n/other/usr/$user/tmp /usr/$user/tmp
+mount -C /srv/boot /n/other other
+bind -c /n/other/usr/$user/tmp /usr/$user/tmp
 
 bind -c /usr/$user/tmp /tmp
 cd /usr/$user
--- a/rc/bin/cpurc
+++ b/rc/bin/cpurc
@@ -8,10 +8,11 @@
 
 mount -qb /srv/cons /dev
 
-# mount points
-mntgen -s slashn && chmod 666 /srv/slashn
+# mount points (if not done by bootrc already)
+>[2]/dev/null {
+mntgen -s slashn /n && chmod 666 /srv/slashn
 mntgen -s slashmnt /mnt && chmod 666 /srv/slashmnt
-mntgen -s mntexport /mnt/exportfs && chmod 666 /srv/mntexport
+mntgen -s mntexport /mnt/exportfs && chmod 666 /srv/mntexport}
 
 # move factotum from /mnt to /mnt/factotum
 mount /srv/factotum /mnt/temp
--- a/rc/bin/termrc
+++ b/rc/bin/termrc
@@ -9,10 +9,11 @@
 
 mount -qb /srv/cons /dev
 
-# mount points 
-mntgen -s slashn && chmod 666 /srv/slashn
+# mount points (if not done by bootrc already)
+>[2]/dev/null {
+mntgen -s slashn /n && chmod 666 /srv/slashn
 mntgen -s slashmnt /mnt && chmod 666 /srv/slashmnt
-mntgen -s mntexport /mnt/exportfs && chmod 666 /srv/mntexport
+mntgen -s mntexport /mnt/exportfs && chmod 666 /srv/mntexport}
 
 # move factotum from /mnt to /mnt/factotum
 mount /srv/factotum /mnt/temp
--- a/sys/src/9/boot/bootfs.proto
+++ b/sys/src/9/boot/bootfs.proto
@@ -10,6 +10,7 @@
 		bind
 		cat
 		cfs
+		chmod
 		cryptsetup
 		dd
 		disk
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -1,6 +1,10 @@
 #!/bin/rc
 
-mntgen -s slash /mnt
+# mount points
+mntgen -s slashn /n && chmod 666 /srv/slashn
+mntgen -s slashmnt /mnt && chmod 666 /srv/slashmnt
+mntgen -s mntexport /mnt/exportfs && chmod 666 /srv/mntexport
+
 bind /root /mnt/broot
 unmount /root
 
@@ -229,5 +233,5 @@
 
 	# cleanup so it can be restarted
 	nobootprompt=()
-	rm -f /srv/^(cfs boot slashn cs dns)
+	rm -f /srv/^(cfs boot cs dns)
 } </dev/cons
--- a/sys/src/9/port/devroot.c
+++ b/sys/src/9/port/devroot.c
@@ -101,6 +101,7 @@
 	addrootdir("env");
 	addrootdir("fd");
 	addrootdir("mnt");
+	addrootdir("n");
 	addrootdir("net");
 	addrootdir("net.alt");
 	addrootdir("proc");