summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2014-02-05 14:51:19 +0000
committerDmitry V. Levin <ldv@altlinux.org>2014-02-05 14:51:19 +0000
commit9aaf88c0004f0d9856947aad7d618fb84d5dba40 (patch)
treeaabe3e8f6f46806051a14346f58472cb36ea041f
parent90aa9f4d72e26581ea0a39c02db625d7bd4e2962 (diff)
downloadstrace-9aaf88c0004f0d9856947aad7d618fb84d5dba40.tar.gz
strace-9aaf88c0004f0d9856947aad7d618fb84d5dba40.tar.bz2
strace-9aaf88c0004f0d9856947aad7d618fb84d5dba40.tar.xz
Enhance reboot decoding
* 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.
-rw-r--r--Makefile.am2
-rw-r--r--linux/reboot.h39
-rw-r--r--reboot.c45
-rw-r--r--system.c40
4 files changed, 86 insertions, 40 deletions
diff --git a/Makefile.am b/Makefile.am
index 55cd4cc..5524293 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
index 0000000..aa33674
--- /dev/null
+++ b/linux/reboot.h
@@ -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
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;
+}
diff --git a/system.c b/system.c
index b4e1896..604988b 100644
--- 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