From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vultr.musolino.id.au ([45.76.123.158]) by ewsd; Tue Jun 2 00:38:05 EDT 2020 Received: from 58.96.111.26 ([58.96.111.26]) by vultr; Tue Jun 2 14:37:45 EST 2020 Message-ID: <08D04ADCF6BC5A7E9B1225642948AAB8@musolino.id.au> To: 9front@9front.org Subject: -d option for fshalt From: Alex Musolino Date: Tue, 2 Jun 2020 14:07:44 +0930 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: converged shader XMPP over ACPI grid element solution 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)