code: plan9front

Download patch

ref: efc7a9a729b075aab06bc24ae778304ad98c3ab6
parent: 302e5bc94465df9b36e326faea94dcd018b1b491
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Aug 12 06:36:55 EDT 2022

fshalt: allow passing a kernel to 'fshalt -r'

reboot(1) doesn't shut down the file system gracefully,
and fshalt -r didn't support passing a kernel; this
change allows rebooting into a new kernel with fshalt.

--- a/rc/bin/fshalt
+++ b/rc/bin/fshalt
@@ -1,15 +1,17 @@
 #!/bin/rc
-# fshalt [-r] - sync (flush) and, if possible, halt all file servers
+# fshalt [-r [kernel]] - sync (flush) and, if possible, halt all file servers
 #	and optionally reboot
 rfork en
+flagfmt='r:reboot'
 reboot=no
 scram=no
-switch ($#*) {
-case 0
-case 1
+bootf=()
+if(~ $1 -r){
 	reboot=yes
-case *
-	echo usage: $0 '[-r]' >[1=2]
+	shift
+}
+if not if(! ~ $#* 0 && ! ~ $#* 1){
+	echo usage: $0 '[-r bootkern]' >[1=2]
 	exit usage
 }
 
@@ -46,6 +48,11 @@
 cp /bin/sleep /tmp
 cp /bin/scram /tmp
 cp /bin/test /tmp
+if(~ $reboot yes && ~ $#* 1){
+	if(! cp $1 /tmp/bootf)
+		exit 'failed to copy kernel'
+	bootf=/bin/bootf
+}
 bind /tmp /rc
 bind /tmp /bin
 
@@ -66,7 +73,7 @@
 
 	if (~ $reboot yes) {
 		echo rebooting...
-		echo reboot >'#c/reboot'
+		echo reboot $bootf >'#c/reboot'
 	}
 	if (~ $scram yes){
 		scram