9front - general discussion about 9front
 help / color / mirror / Atom feed
* -d option for fshalt
@ 2020-06-02  4:37 Alex Musolino
  2020-06-02  4:58 ` [9front] " Alex Musolino
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Alex Musolino @ 2020-06-02  4:37 UTC (permalink / raw)
  To: 9front

Hi all,

I've added support for a -d option in fshalt(8) that triggers a dump
of the local filesystem before halting.  I've found it useful in my
current situation where my 9front machine spends most of its time
powered off.

Any objections to the following?

diff -r 8006152d13d2 rc/bin/fshalt
--- a/rc/bin/fshalt	Tue Apr 28 20:51:19 2020 -0700
+++ b/rc/bin/fshalt	Tue Jun 02 14:03:03 2020 +0930
@@ -1,16 +1,20 @@
 #!/bin/rc
-# fshalt [-r] - sync (flush) and, if possible, halt all file servers
-#	and optionally reboot
 rfork en
+dump=no
 reboot=no
 scram=no
-switch ($#*) {
-case 0
-case 1
-	reboot=yes
-case *
-	echo usage: $0 '[-r]' >[1=2]
-	exit usage
+
+while (~ $1 -*) {
+	switch ($1) {
+	case -d
+		dump=yes
+	case -r
+		reboot=yes
+	case *
+		echo usage: $0 '[-r]' >[1=2]
+		exit usage
+	}
+	shift
 }
 
 path=(/bin)
@@ -53,6 +57,13 @@
 # when it's no longer accessible
 fn x {
 	echo
+	echo -n dumping...
+	if (~ $dump yes) {
+		for (i in $c $h)
+			echo dump >>$i
+	}
+
+	echo
 	echo -n halting...
 	for (i in $c $h)
 		echo halt >>$i
diff -r 8006152d13d2 sys/man/8/fshalt
--- a/sys/man/8/fshalt	Tue Apr 28 20:51:19 2020 -0700
+++ b/sys/man/8/fshalt	Tue Jun 02 14:03:03 2020 +0930
@@ -4,6 +4,8 @@
 .SH SYNOPSIS
 .B fshalt
 [
+.B -d
+] [
 .B -r
 ]
 .br
@@ -20,13 +22,15 @@
 and
 .IR hjfs (4)
 servers.
-If given
-.BR -r ,
-.I fshalt
-will then reboot the machine.
-Else it will invoke
+The
+.BR -d
+option causes a dump command to be issued to the local filesystem
+before the sync and halt commands.  Once any filesystems have been
+halted,
 .I scram
-to shut down the machine.
+will be invoked to shut down the machine, unless the
+.BR -r
+option is specified, in which case the machine is instead rebooted.
 The halting and rebooting is done by copying all necessary
 commands into a
 .IR ramfs (4)


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-06-04 15:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  4:37 -d option for fshalt Alex Musolino
2020-06-02  4:58 ` [9front] " Alex Musolino
2020-06-02  6:54 ` Alex Musolino
2020-06-02  6:59 ` rgl
2020-06-04  6:57   ` Alex Musolino
2020-06-04 12:27     ` kvik
2020-06-04 13:57       ` Alex Musolino
2020-06-04 15:50         ` kvik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).