git: 9front

Download patch

ref: 1c96968413e9fb9fbaf054a96b555d790ec8a035
parent: e8682d0129850f44cc89e5c5e3b512f7f4c8a83d
parent: 19616ad6506b6ea4d23e2d4b5b02b9b77b92bb2d
author: cinap_lenrek <cinap_lenrek@localhost>
date: Mon May 16 12:30:34 EDT 2011

merge2

--- a/rc/bin/fshalt
+++ b/rc/bin/fshalt
@@ -48,6 +48,7 @@
 cp /bin/rc /tmp
 cp /bin/sed /tmp
 cp /bin/sleep /tmp
+cp /bin/scram /tmp
 bind /tmp /rc
 bind /tmp /bin
 
@@ -77,6 +78,7 @@
 		echo rebooting...
 		echo reboot >'#c/reboot'
 	}
+	if not scram
 }
 
 x
--- a/sys/man/8/fshalt
+++ b/sys/man/8/fshalt
@@ -1,6 +1,6 @@
 .TH FSHALT 8
 .SH NAME
-fshalt, reboot \- halt any local file systems and optionally reboot the system
+fshalt, scram, reboot \- halt any local file systems and optionally shut down or reboot the system
 .SH SYNOPSIS
 .B fshalt
 [
@@ -8,6 +8,8 @@
 ]
 .br
 .B reboot
+.br
+.B scram
 .SH DESCRIPTION
 .I Fshalt
 syncs all local
@@ -25,6 +27,9 @@
 .BR -r ,
 .I fshalt
 will then reboot the machine.
+Else it will invoke
+.I scram
+to shut down the machine.
 The halting and rebooting is done by copying all necessary
 commands into a
 .IR ramfs (4)
@@ -35,6 +40,9 @@
 .PP
 .I Reboot
 restarts the machine it is invoked on.
+.PP
+.I Scram
+shuts down the machine it is invoked on.
 .SH SOURCE
 .B /rc/bin/fshalt
 .br
@@ -43,6 +51,9 @@
 .IR cons (3),
 .IR reboot (8)
 .SH BUGS
-On standalone machines, it will be impossible to do anything
+On standalone machines, it will be impossible to do anything if scram fails
 after invoking bare
-.LR fshalt .
+.IR fshalt .
+
+.I Scram
+is limited to the PC and requires APM.
--- /dev/null
+++ b/sys/src/cmd/scram.c
@@ -1,0 +1,20 @@
+#include <u.h>
+#include </386/include/ureg.h>
+typedef struct Ureg Ureg;
+#include <libc.h>
+
+void
+main()
+{
+	Ureg ureg;
+	int fd;
+	
+	fd = open("/dev/apm", OWRITE);
+	if(fd < 0) sysfatal("%r");
+	memset(&ureg, 0, sizeof ureg);
+	ureg.ax = 0x5307;
+	ureg.bx = 0x0001;
+	ureg.cx = 0x0003;
+	ureg.trap = 0x15;
+	write(fd, &ureg, sizeof ureg);
+}
--