]> granicus.if.org Git - strace/commitdiff
sock: decode SIOCSIFNAME on entering syscall
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 31 Oct 2014 19:36:01 +0000 (19:36 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 31 Oct 2014 22:59:19 +0000 (22:59 +0000)
* sock.c (sock_ioctl): Handle SIOCSIFNAME on entering syscall.

sock.c

diff --git a/sock.c b/sock.c
index 7f653dcd0b7a9d1f95de35bc0f4b2b0ebe9e4faf..546c651cf46c74788d348063e9d4e543b1b6dfa9 100644 (file)
--- a/sock.c
+++ b/sock.c
@@ -60,12 +60,22 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
        unsigned char *bytes;
 
        if (entering(tcp)) {
-               if (code == SIOCGIFCONF) {
+               switch (code) {
+               case SIOCGIFCONF:
                        if (umove(tcp, tcp->u_arg[2], &ifc) >= 0
                            && ifc.ifc_buf == NULL)
                                tprintf(", {%d -> ", ifc.ifc_len);
                        else
                                tprints(", {");
+                       break;
+               case SIOCSIFNAME:
+                       if (umove(tcp, tcp->u_arg[2], &ifr) < 0)
+                               tprintf(", %#lx", tcp->u_arg[2]);
+                       else
+                               tprintf(", {ifr_name=\"%.*s\", ifr_newname=\"%.*s\"}",
+                                       IFNAMSIZ, ifr.ifr_name,
+                                       IFNAMSIZ, ifr.ifr_newname);
+                       break;
                }
                return 0;
        }
@@ -99,9 +109,9 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
        case SIOCATMARK:
 #endif
                printnum(tcp, arg, ", %#d");
+       case SIOCSIFNAME:
                return 1;
        case SIOCGIFNAME:
-       case SIOCSIFNAME:
        case SIOCGIFINDEX:
        case SIOCGIFADDR:
        case SIOCSIFADDR:
@@ -132,14 +142,8 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                                tprintf(", {ifr_index=%d, ifr_name=???}",
                                        ifr.ifr_ifindex);
                        } else {
-                               tprintf(", {ifr_name=\"%.*s\", ",
+                               tprintf(", {ifr_name=\"%.*s\", ???}",
                                        IFNAMSIZ, ifr.ifr_name);
-
-                               if (code == SIOCSIFNAME)
-                                       tprintf("ifr_newname=\"%.*s\"}",
-                                               IFNAMSIZ, ifr.ifr_newname);
-                               else
-                                       tprintf("???}");
                        }
                } else if (code == SIOCGIFNAME) {
                        tprintf(", {ifr_index=%d, ifr_name=\"%.*s\"}",
@@ -199,10 +203,6 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                        case SIOCSIFMTU:
                                tprintf("ifr_mtu=%d", ifr.ifr_mtu);
                                break;
-                       case SIOCSIFNAME:
-                               tprintf("ifr_newname=\"%.*s\"",
-                                       IFNAMSIZ, ifr.ifr_newname);
-                               break;
                        case SIOCGIFSLAVE:
                        case SIOCSIFSLAVE:
                                tprintf("ifr_slave=\"%s\"", ifr.ifr_slave);