]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: implement Reboot for linux.
authorDavid Anderson <danderson@google.com>
Wed, 9 Mar 2011 13:45:08 +0000 (05:45 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 9 Mar 2011 13:45:08 +0000 (05:45 -0800)
The published interface is the simple version of the syscall,
allowing all reboot functions except for the esoteric
LINUX_REBOOT_CMD_RESTART2.

R=golang-dev, bradfitzgo, bradfitzwork
CC=golang-dev
https://golang.org/cl/4256060

src/pkg/syscall/mkerrors.sh
src/pkg/syscall/syscall_linux.go
src/pkg/syscall/zerrors_linux_386.go
src/pkg/syscall/zerrors_linux_amd64.go
src/pkg/syscall/zerrors_linux_arm.go
src/pkg/syscall/zsyscall_linux_386.go
src/pkg/syscall/zsyscall_linux_amd64.go
src/pkg/syscall/zsyscall_linux_arm.go

index d40d1f6b3df0e71345386fd8defc5c9035e2ec5b..7329a90c989670086e65ad9c620c0f2662e372ff 100755 (executable)
@@ -30,6 +30,7 @@ includes_Linux='
 #include <linux/ptrace.h>
 #include <linux/wait.h>
 #include <linux/if_tun.h>
+#include <linux/reboot.h>
 #include <net/if.h>
 #include <netpacket/packet.h>
 '
@@ -124,6 +125,8 @@ done
                $2 == "CTL_MAXNAME" ||
                $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
                $2 ~ /^(O|F|FD|NAME|S|PTRACE)_/ ||
+               $2 ~ /^LINUX_REBOOT_CMD_/ ||
+               $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
                $2 ~ /^SIOC/ ||
                $2 !~ "WMESGLEN" &&
                $2 ~ /^W[A-Z0-9]+$/ {printf("\t$%s = %s,\n", $2, $2)}
index 30ad896461d86126043a17f1f43e29d1e697f947..550a377b89d02be209a42ea3dbeb0716cad6de81 100644 (file)
@@ -667,6 +667,11 @@ func PtraceAttach(pid int) (errno int) { return ptrace(PTRACE_ATTACH, pid, 0, 0)
 
 func PtraceDetach(pid int) (errno int) { return ptrace(PTRACE_DETACH, pid, 0, 0) }
 
+//sys  reboot(magic1 uint, magic2 uint, cmd int, arg string) (errno int)
+func Reboot(cmd int) (errno int) {
+       return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, "")
+}
+
 // Sendto
 // Recvfrom
 // Socketpair
@@ -842,7 +847,6 @@ func PtraceDetach(pid int) (errno int) { return ptrace(PTRACE_DETACH, pid, 0, 0)
 // Quotactl
 // Readahead
 // Readv
-// Reboot
 // RemapFilePages
 // Removexattr
 // RequestKey
index a73a949617755ce4586fa2d96ce19eb1a54aba06..198e713692d981e7f90439a5eca48858d98d9cc0 100644 (file)
@@ -408,6 +408,16 @@ const (
        IP_TOS                           = 0x1
        IP_TTL                           = 0x2
        IP_UNBLOCK_SOURCE                = 0x25
+       LINUX_REBOOT_CMD_CAD_OFF         = 0
+       LINUX_REBOOT_CMD_CAD_ON          = 0x89abcdef
+       LINUX_REBOOT_CMD_HALT            = 0xcdef0123
+       LINUX_REBOOT_CMD_KEXEC           = 0x45584543
+       LINUX_REBOOT_CMD_POWER_OFF       = 0x4321fedc
+       LINUX_REBOOT_CMD_RESTART         = 0x1234567
+       LINUX_REBOOT_CMD_RESTART2        = 0xa1b2c3d4
+       LINUX_REBOOT_CMD_SW_SUSPEND      = 0xd000fce2
+       LINUX_REBOOT_MAGIC1              = 0xfee1dead
+       LINUX_REBOOT_MAGIC2              = 0x28121969
        MAP_32BIT                        = 0x40
        MAP_ANON                         = 0x20
        MAP_ANONYMOUS                    = 0x20
index eea55a2753b9753867bd4fed24f24848f83c2def..675bc95499f4e935cfd43e40018e769c02cc95db 100644 (file)
@@ -408,6 +408,16 @@ const (
        IP_TOS                           = 0x1
        IP_TTL                           = 0x2
        IP_UNBLOCK_SOURCE                = 0x25
+       LINUX_REBOOT_CMD_CAD_OFF         = 0
+       LINUX_REBOOT_CMD_CAD_ON          = 0x89abcdef
+       LINUX_REBOOT_CMD_HALT            = 0xcdef0123
+       LINUX_REBOOT_CMD_KEXEC           = 0x45584543
+       LINUX_REBOOT_CMD_POWER_OFF       = 0x4321fedc
+       LINUX_REBOOT_CMD_RESTART         = 0x1234567
+       LINUX_REBOOT_CMD_RESTART2        = 0xa1b2c3d4
+       LINUX_REBOOT_CMD_SW_SUSPEND      = 0xd000fce2
+       LINUX_REBOOT_MAGIC1              = 0xfee1dead
+       LINUX_REBOOT_MAGIC2              = 0x28121969
        MAP_32BIT                        = 0x40
        MAP_ANON                         = 0x20
        MAP_ANONYMOUS                    = 0x20
index 1f8b1830b387238e0311a49473ab2a7d43cdf1a9..adbbc774f775011f69b84720ea7bf81635fa7201 100644 (file)
@@ -379,6 +379,16 @@ const (
        IP_TOS                           = 0x1
        IP_TTL                           = 0x2
        IP_UNBLOCK_SOURCE                = 0x25
+       LINUX_REBOOT_CMD_CAD_OFF         = 0
+       LINUX_REBOOT_CMD_CAD_ON          = 0x89abcdef
+       LINUX_REBOOT_CMD_HALT            = 0xcdef0123
+       LINUX_REBOOT_CMD_KEXEC           = 0x45584543
+       LINUX_REBOOT_CMD_POWER_OFF       = 0x4321fedc
+       LINUX_REBOOT_CMD_RESTART         = 0x1234567
+       LINUX_REBOOT_CMD_RESTART2        = 0xa1b2c3d4
+       LINUX_REBOOT_CMD_SW_SUSPEND      = 0xd000fce2
+       LINUX_REBOOT_MAGIC1              = 0xfee1dead
+       LINUX_REBOOT_MAGIC2              = 0x28121969
        NAME_MAX                         = 0xff
        O_ACCMODE                        = 0x3
        O_APPEND                         = 0x400
index 005cc1542a20eea2ccc7a1d17dd2cef7703feac6..746fee8a6711a006adfb5969641461e59f04bd39 100644 (file)
@@ -81,6 +81,14 @@ func ptrace(request int, pid int, addr uintptr, data uintptr) (errno int) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func reboot(magic1 uint, magic2 uint, cmd int, arg string) (errno int) {
+       _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(StringBytePtr(arg))), 0, 0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Access(path string, mode uint32) (errno int) {
        _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), 0)
        errno = int(e1)
index d449a3bfed3af2650d29fe08951cf86e22ed7deb..b688ecf0226495d1291236c83575eb60d05d936d 100644 (file)
@@ -81,6 +81,14 @@ func ptrace(request int, pid int, addr uintptr, data uintptr) (errno int) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func reboot(magic1 uint, magic2 uint, cmd int, arg string) (errno int) {
+       _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(StringBytePtr(arg))), 0, 0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Access(path string, mode uint32) (errno int) {
        _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), 0)
        errno = int(e1)
index 22b736bfaa90393864020fddaa4186b55c889423..fc4ef9fd50e812d24a41432d953f463c1fe77e07 100644 (file)
@@ -81,6 +81,14 @@ func ptrace(request int, pid int, addr uintptr, data uintptr) (errno int) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func reboot(magic1 uint, magic2 uint, cmd int, arg string) (errno int) {
+       _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(StringBytePtr(arg))), 0, 0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Access(path string, mode uint32) (errno int) {
        _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), 0)
        errno = int(e1)