]> granicus.if.org Git - strace/commitdiff
Mpersify SIOC* ioctls
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 26 Dec 2016 14:07:24 +0000 (17:07 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 29 Dec 2016 02:54:49 +0000 (02:54 +0000)
struct ifreq and struct ifconf are ABI-dependent and should have been
mpersified.

* defs.h (sock_ioctl): Remove prototype.
* sock.c (struct_ifconf, struct_ifreq): New typedefs.
(DEF_MPERS_TYPE(struct_ifconf), DEF_MPERS_TYPE(struct_ifreq),
MPERS_DEFS): New includes.
(print_ifreq, print_ifc_len, print_ifconf_ifreq): Replace struct ifreq
with struct_ifreq.
(decode_ifconf): Replace struct ifconf with struct_ifconf, struct ifreq
with struct_fireq.
(sock_ioctl): Wrap into MPERS_PRINTER_DECL.

defs.h
sock.c

diff --git a/defs.h b/defs.h
index 3ecab0bfd150c408494cbea95bd219701c09e967..7582a9e59f8ce27c2f27d17ca3aa4869a62a3043 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -672,7 +672,6 @@ DECL_IOCTL(file);
 DECL_IOCTL(fs_x);
 DECL_IOCTL(ptp);
 DECL_IOCTL(scsi);
-DECL_IOCTL(sock);
 DECL_IOCTL(term);
 DECL_IOCTL(ubi);
 DECL_IOCTL(uffdio);
diff --git a/sock.c b/sock.c
index b1611f6d747ea8cee5e6e6e21951d8250d0e5222..9dd247cce9976d8a78a897162c89f12298b5b7d4 100644 (file)
--- a/sock.c
+++ b/sock.c
@@ -26,6 +26,7 @@
  */
 
 #include "defs.h"
+
 #include <sys/socket.h>
 #if defined ALPHA || defined SH || defined SH64
 # include <linux/ioctl.h>
 #include <arpa/inet.h>
 #include <net/if.h>
 
+#include DEF_MPERS_TYPE(struct_ifconf)
+#include DEF_MPERS_TYPE(struct_ifreq)
+
+typedef struct ifconf struct_ifconf;
+typedef struct ifreq struct_ifreq;
+
+#include MPERS_DEFS
+
 #include "xlat/iffflags.h"
 
 #define PRINT_IFREQ_ADDR(tcp, ifr, sockaddr)                                   \
@@ -51,7 +60,7 @@ print_ifname(const char *ifname)
 
 static void
 print_ifreq(struct tcb *const tcp, const unsigned int code,
-           const kernel_ulong_t arg, const struct ifreq *const ifr)
+           const kernel_ulong_t arg, const struct_ifreq *const ifr)
 {
        switch (code) {
        case SIOCSIFADDR:
@@ -105,11 +114,11 @@ print_ifreq(struct tcb *const tcp, const unsigned int code,
                break;
        case SIOCSIFMAP:
        case SIOCGIFMAP:
-               tprintf("ifr_map={mem_start=%#lx, "
-                       "mem_end=%#lx, base_addr=%#x, "
+               tprintf("ifr_map={mem_start=%#" PRI_klx ", "
+                       "mem_end=%#" PRI_klx ", base_addr=%#x, "
                        "irq=%u, dma=%u, port=%u}",
-                       ifr->ifr_map.mem_start,
-                       ifr->ifr_map.mem_end,
+                       (kernel_ulong_t) ifr->ifr_map.mem_start,
+                       (kernel_ulong_t) ifr->ifr_map.mem_end,
                        (unsigned) ifr->ifr_map.base_addr,
                        (unsigned) ifr->ifr_map.irq,
                        (unsigned) ifr->ifr_map.dma,
@@ -121,9 +130,9 @@ print_ifreq(struct tcb *const tcp, const unsigned int code,
 static unsigned int
 print_ifc_len(int len)
 {
-       const unsigned int n = (unsigned int) len / sizeof(struct ifreq);
+       const unsigned int n = (unsigned int) len / sizeof(struct_ifreq);
 
-       if (len < 0 || n * sizeof(struct ifreq) != (unsigned int) len)
+       if (len < 0 || n * sizeof(struct_ifreq) != (unsigned int) len)
                tprintf("%d", len);
        else
                tprintf("%u * sizeof(struct ifreq)", n);
@@ -135,7 +144,7 @@ static bool
 print_ifconf_ifreq(struct tcb *tcp, void *elem_buf, size_t elem_size,
                   void *dummy)
 {
-       struct ifreq *ifr = elem_buf;
+       struct_ifreq *ifr = elem_buf;
 
        tprints("{ifr_name=");
        print_ifname(ifr->ifr_name);
@@ -162,8 +171,8 @@ print_ifconf_ifreq(struct tcb *tcp, void *elem_buf, size_t elem_size,
 static int
 decode_ifconf(struct tcb *const tcp, const kernel_ulong_t addr)
 {
-       struct ifconf *entering_ifc = NULL;
-       struct ifconf *ifc =
+       struct_ifconf *entering_ifc = NULL;
+       struct_ifconf *ifc =
                entering(tcp) ? malloc(sizeof(*ifc)) : alloca(sizeof(*ifc));
 
        if (exiting(tcp)) {
@@ -224,10 +233,10 @@ decode_ifconf(struct tcb *const tcp, const kernel_ulong_t addr)
                        printaddr(ptr_to_kulong(ifc->ifc_buf));
                }
        } else {
-               struct ifreq ifr;
+               struct_ifreq ifr;
 
                print_array(tcp, ptr_to_kulong(ifc->ifc_buf),
-                           ifc->ifc_len / sizeof(struct ifreq),
+                           ifc->ifc_len / sizeof(struct_ifreq),
                            &ifr, sizeof(ifr),
                            umoven_or_printaddr, print_ifconf_ifreq, NULL);
        }
@@ -237,10 +246,11 @@ decode_ifconf(struct tcb *const tcp, const kernel_ulong_t addr)
        return RVAL_DECODED | 1;
 }
 
-int
-sock_ioctl(struct tcb *const tcp, const unsigned int code, const kernel_ulong_t arg)
+MPERS_PRINTER_DECL(int, sock_ioctl,
+                  struct tcb *tcp, const unsigned int code,
+                  const kernel_ulong_t arg)
 {
-       struct ifreq ifr;
+       struct_ifreq ifr;
 
        switch (code) {
        case SIOCGIFCONF: