]> granicus.if.org Git - strace/commitdiff
loop: mpersify struct loop_info and loop_ioctl function
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 19 Dec 2016 00:15:27 +0000 (03:15 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 29 Dec 2016 00:11:30 +0000 (00:11 +0000)
struct loop_info contains fields of type long, so it definitely should
have been mpersified.

* defs.h (loop_ioctl): Remove prototype.
* loop.c (struct_loop_info): New typedef.
Include DEF_MPERS_TYPE(struct_loop_info) and MPERS_DEFS.
(decode_loop_info): Replace struct loop_info with struct_loop_info.
Cast lo_inode, lo_init[0], and lo_init[1] to kernel_ulong_t and print
them using appropriate format specifiers.
(loop_ioctl): Wrap into MPERS_PRINTER_DECL.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
defs.h
loop.c

diff --git a/defs.h b/defs.h
index 1e056068ce3be39a2e1794fcea615184dcec9ff2..3ecab0bfd150c408494cbea95bd219701c09e967 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -670,7 +670,6 @@ name ## _ioctl(struct tcb *, unsigned int request, kernel_ulong_t arg)
 DECL_IOCTL(dm);
 DECL_IOCTL(file);
 DECL_IOCTL(fs_x);
-DECL_IOCTL(loop);
 DECL_IOCTL(ptp);
 DECL_IOCTL(scsi);
 DECL_IOCTL(sock);
diff --git a/loop.c b/loop.c
index 292339196257347a68487c3341a91dd4ced29fcc..ebb518bcabdd8e1a7a1bafc7e7ba3c05450e3b26 100644 (file)
--- a/loop.c
+++ b/loop.c
 #include <linux/ioctl.h>
 #include <linux/loop.h>
 
+typedef struct loop_info struct_loop_info;
+
+#include DEF_MPERS_TYPE(struct_loop_info)
+
+#include MPERS_DEFS
+
 #include "xlat/loop_flags_options.h"
 #include "xlat/loop_crypt_type_options.h"
 
 static void
 decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr)
 {
-       struct loop_info info;
+       struct_loop_info info;
 
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &info))
@@ -46,7 +52,7 @@ decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr)
        if (!abbrev(tcp)) {
                tprints(", lo_device=");
                print_dev_t(info.lo_device);
-               tprintf(", lo_inode=%lu", info.lo_inode);
+               tprintf(", lo_inode=%" PRI_klu, (kernel_ulong_t) info.lo_inode);
                tprints(", lo_rdevice=");
                print_dev_t(info.lo_rdevice);
        }
@@ -74,9 +80,10 @@ decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr)
        }
 
        if (!abbrev(tcp))
-               tprintf(", lo_init=[%#lx, %#lx]"
+               tprintf(", lo_init=[%#" PRI_klx ", %#" PRI_klx "]"
                        ", reserved=[%#x, %#x, %#x, %#x]}",
-                       info.lo_init[0], info.lo_init[1],
+                       (kernel_ulong_t) info.lo_init[0],
+                       (kernel_ulong_t) info.lo_init[1],
                        info.reserved[0], info.reserved[1],
                        info.reserved[2], info.reserved[3]);
        else
@@ -141,9 +148,9 @@ decode_loop_info64(struct tcb *const tcp, const kernel_ulong_t addr)
                tprints(", ...}");
 }
 
-int
-loop_ioctl(struct tcb *const tcp, const unsigned int code,
-          const kernel_ulong_t arg)
+MPERS_PRINTER_DECL(int, loop_ioctl,
+                  struct tcb *tcp, const unsigned int code,
+                  const kernel_ulong_t arg)
 {
        if (!verbose(tcp))
                return RVAL_DECODED;