]> granicus.if.org Git - strace/blobdiff - reboot.c
nlattr: add unsigned int decoders that print in hex form
[strace] / reboot.c
index f8c3de7aa917496795d363944466939fcbc03ad3..12de30bc4090a64f323e9c61678fb6d2867ae86c 100644 (file)
--- a/reboot.c
+++ b/reboot.c
@@ -1,45 +1,28 @@
 #include "defs.h"
-#include <linux/reboot.h>
 
-static const struct xlat bootflags1[] = {
-       XLAT(LINUX_REBOOT_MAGIC1),
-       XLAT_END
-};
+#include "xlat/bootflags1.h"
+#include "xlat/bootflags2.h"
+#include "xlat/bootflags3.h"
 
-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)
+SYS_FUNC(reboot)
 {
-       if (exiting(tcp))
-               return 0;
+       const unsigned int magic1 = tcp->u_arg[0];
+       const unsigned int magic2 = tcp->u_arg[1];
+       const unsigned int cmd = tcp->u_arg[2];
 
-       printflags(bootflags1, tcp->u_arg[0], "LINUX_REBOOT_MAGIC_???");
+       printxval(bootflags1, magic1, "LINUX_REBOOT_MAGIC_???");
        tprints(", ");
-       printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???");
+       printxval(bootflags2, magic2, "LINUX_REBOOT_MAGIC_???");
        tprints(", ");
-       printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???");
-       if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) {
+       printxval(bootflags3, cmd, "LINUX_REBOOT_CMD_???");
+       if (cmd == LINUX_REBOOT_CMD_RESTART2) {
                tprints(", ");
-               printstr(tcp, tcp->u_arg[3], -1);
+               /*
+                * The size of kernel buffer is 256 bytes and
+                * the last byte is always zero, at most 255 bytes
+                * are copied from the user space.
+                */
+               printstr_ex(tcp, tcp->u_arg[3], 255, QUOTE_0_TERMINATED);
        }
-       return 0;
+       return RVAL_DECODED;
 }