Enhance reboot decoding
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 5 Feb 2014 14:51:19 +0000 (14:51 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 5 Feb 2014 14:51:19 +0000 (14:51 +0000)
* linux/reboot.h: New file.
* system.c (bootflags1, bootflags2, bootflags3, sys_reboot): Move...
* reboot.c: ... here.
(bootflags2, bootflags3): Update constants.
* Makefile.am (strace_SOURCES): Add reboot.c.
(EXTRA_DIST): Add linux/reboot.h.

Makefile.am
linux/reboot.h [new file with mode: 0644]
reboot.c [new file with mode: 0644]
system.c

index 55cd4ccdab711fda7bcb0909d853cfc0d876c9be..5524293fb15aadf8d41940a2c2e0d5710233af12 100644 (file)
@@ -34,6 +34,7 @@ strace_SOURCES =      \
        process.c       \
        ptp.c           \
        quota.c         \
+       reboot.c        \
        resource.c      \
        scsi.c          \
        signal.c        \
@@ -137,6 +138,7 @@ EXTRA_DIST =                                \
        linux/powerpc/syscallent.h      \
        linux/powerpc/syscallent1.h     \
        linux/ptp_clock.h               \
+       linux/reboot.h                  \
        linux/s390/ioctlent.h.in        \
        linux/s390/syscallent.h         \
        linux/s390x/ioctlent.h.in       \
diff --git a/linux/reboot.h b/linux/reboot.h
new file mode 100644 (file)
index 0000000..aa33674
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef _LINUX_REBOOT_H
+#define _LINUX_REBOOT_H
+
+/*
+ * Magic values required to use _reboot() system call.
+ */
+
+#define        LINUX_REBOOT_MAGIC1     0xfee1dead
+#define        LINUX_REBOOT_MAGIC2     672274793
+#define        LINUX_REBOOT_MAGIC2A    85072278
+#define        LINUX_REBOOT_MAGIC2B    369367448
+#define        LINUX_REBOOT_MAGIC2C    537993216
+
+
+/*
+ * Commands accepted by the _reboot() system call.
+ *
+ * RESTART     Restart system using default command and mode.
+ * HALT        Stop OS and give system control to ROM monitor, if any.
+ * CAD_ON      Ctrl-Alt-Del sequence causes RESTART command.
+ * CAD_OFF     Ctrl-Alt-Del sequence sends SIGINT to init task.
+ * POWER_OFF   Stop OS and remove all power from system, if possible.
+ * RESTART2    Restart system using given command string.
+ * SW_SUSPEND  Suspend system using software suspend if compiled in.
+ * KEXEC       Restart system using a previously loaded Linux kernel
+ */
+
+#define        LINUX_REBOOT_CMD_RESTART        0x01234567
+#define        LINUX_REBOOT_CMD_HALT           0xCDEF0123
+#define        LINUX_REBOOT_CMD_CAD_ON         0x89ABCDEF
+#define        LINUX_REBOOT_CMD_CAD_OFF        0x00000000
+#define        LINUX_REBOOT_CMD_POWER_OFF      0x4321FEDC
+#define        LINUX_REBOOT_CMD_RESTART2       0xA1B2C3D4
+#define        LINUX_REBOOT_CMD_SW_SUSPEND     0xD000FCE2
+#define        LINUX_REBOOT_CMD_KEXEC          0x45584543
+
+
+
+#endif /* _LINUX_REBOOT_H */
diff --git a/reboot.c b/reboot.c
new file mode 100644 (file)
index 0000000..f8c3de7
--- /dev/null
+++ b/reboot.c
@@ -0,0 +1,45 @@
+#include "defs.h"
+#include <linux/reboot.h>
+
+static const struct xlat bootflags1[] = {
+       XLAT(LINUX_REBOOT_MAGIC1),
+       XLAT_END
+};
+
+static const struct xlat bootflags2[] = {
+       XLAT(LINUX_REBOOT_MAGIC2),
+       XLAT(LINUX_REBOOT_MAGIC2A),
+       XLAT(LINUX_REBOOT_MAGIC2B),
+       XLAT(LINUX_REBOOT_MAGIC2C),
+       XLAT_END
+};
+
+static const struct xlat bootflags3[] = {
+       XLAT(LINUX_REBOOT_CMD_RESTART),
+       XLAT(LINUX_REBOOT_CMD_HALT),
+       XLAT(LINUX_REBOOT_CMD_CAD_ON),
+       XLAT(LINUX_REBOOT_CMD_CAD_OFF),
+       XLAT(LINUX_REBOOT_CMD_POWER_OFF),
+       XLAT(LINUX_REBOOT_CMD_RESTART2),
+       XLAT(LINUX_REBOOT_CMD_SW_SUSPEND),
+       XLAT(LINUX_REBOOT_CMD_KEXEC),
+       XLAT_END
+};
+
+int
+sys_reboot(struct tcb *tcp)
+{
+       if (exiting(tcp))
+               return 0;
+
+       printflags(bootflags1, tcp->u_arg[0], "LINUX_REBOOT_MAGIC_???");
+       tprints(", ");
+       printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???");
+       tprints(", ");
+       printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???");
+       if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) {
+               tprints(", ");
+               printstr(tcp, tcp->u_arg[3], -1);
+       }
+       return 0;
+}
index b4e1896a7c8759f1aacb86c6cd3a93c65900e176..604988b5c2d1f71a2515f18ceadce1a471b73471 100644 (file)
--- a/system.c
+++ b/system.c
@@ -275,46 +275,6 @@ sys_syslog(struct tcb *tcp)
        return 0;
 }
 
-#include <linux/reboot.h>
-static const struct xlat bootflags1[] = {
-       XLAT(LINUX_REBOOT_MAGIC1),
-       XLAT_END
-};
-
-static const struct xlat bootflags2[] = {
-       XLAT(LINUX_REBOOT_MAGIC2),
-       XLAT(LINUX_REBOOT_MAGIC2A),
-       XLAT(LINUX_REBOOT_MAGIC2B),
-       XLAT_END
-};
-
-static const struct xlat bootflags3[] = {
-       XLAT(LINUX_REBOOT_CMD_CAD_OFF),
-       XLAT(LINUX_REBOOT_CMD_RESTART),
-       XLAT(LINUX_REBOOT_CMD_HALT),
-       XLAT(LINUX_REBOOT_CMD_CAD_ON),
-       XLAT(LINUX_REBOOT_CMD_POWER_OFF),
-       XLAT(LINUX_REBOOT_CMD_RESTART2),
-       XLAT_END
-};
-
-int
-sys_reboot(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               printflags(bootflags1, tcp->u_arg[0], "LINUX_REBOOT_MAGIC_???");
-               tprints(", ");
-               printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???");
-               tprints(", ");
-               printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???");
-               if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) {
-                       tprints(", ");
-                       printstr(tcp, tcp->u_arg[3], -1);
-               }
-       }
-       return 0;
-}
-
 #ifdef M68K
 static const struct xlat cacheflush_scope[] = {
 #ifdef FLUSH_SCOPE_LINE