]> granicus.if.org Git - strace/commitdiff
2008-10-22 Dmitry V. Levin <ldv@altlinux.org>
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 10 Nov 2008 17:21:23 +0000 (17:21 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 10 Nov 2008 17:21:23 +0000 (17:21 +0000)
Handle socket type flags introduced in linux 2.6.27.
* net.c (socktypes): Add SOCK_DCCP.
(sock_type_flags): New xlat structure.
(tprint_sock_type): New function.
(sys_socket, sys_socketpair): Use it to parse socket type and
socket type flags.

ChangeLog
net.c

index 688476c70ec433edb2a245672fab3b0e1ca319e9..490f8306efbee3253b26b6abfed32a17e26800b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-10-22  Dmitry V. Levin <ldv@altlinux.org>
+
+       Handle socket type flags introduced in linux 2.6.27.
+       * net.c (socktypes): Add SOCK_DCCP.
+       (sock_type_flags): New xlat structure.
+       (tprint_sock_type): New function.
+       (sys_socket, sys_socketpair): Use it to parse socket type and
+       socket type flags.
+
 2008-09-29  Dmitry V. Levin <ldv@altlinux.org>
 
        * strace.c (startup_child): Save child pid for future use.
diff --git a/net.c b/net.c
index a0ae6b94f99de696c27852b04fbfb7ae8b42372a..98278c1b4b476d6f7192588f016ddbeadf988e4e 100644 (file)
--- a/net.c
+++ b/net.c
@@ -320,17 +320,32 @@ static const struct xlat socktypes[] = {
 #ifdef SOCK_RAW
        { SOCK_RAW,     "SOCK_RAW"      },
 #endif
+#ifdef SOCK_RDM
+       { SOCK_RDM,     "SOCK_RDM"      },
+#endif
 #ifdef SOCK_SEQPACKET
        { SOCK_SEQPACKET,"SOCK_SEQPACKET"},
 #endif
-#ifdef SOCK_RDM
-       { SOCK_RDM,     "SOCK_RDM"      },
+#ifdef SOCK_DCCP
+       { SOCK_DCCP,    "SOCK_DCCP"     },
 #endif
 #ifdef SOCK_PACKET
        { SOCK_PACKET,  "SOCK_PACKET"   },
 #endif
        { 0,            NULL            },
 };
+const struct xlat sock_type_flags[] = {
+#ifdef SOCK_CLOEXEC
+       { SOCK_CLOEXEC, "SOCK_CLOEXEC"  },
+#endif
+#ifdef SOCK_NONBLOCK
+       { SOCK_NONBLOCK,"SOCK_NONBLOCK" },
+#endif
+       { 0,            NULL            },
+};
+#ifndef SOCK_TYPE_MASK
+# define SOCK_TYPE_MASK 0xf
+#endif
 static const struct xlat socketlayers[] = {
 #if defined(SOL_IP)
        { SOL_IP,       "SOL_IP"        },
@@ -1182,14 +1197,33 @@ long addr;
 
 #endif /* HAVE_SENDMSG */
 
+/*
+ * low bits of the socket type define real socket type,
+ * other bits are socket type flags.
+ */
+static void
+tprint_sock_type(struct tcb *tcp, int flags)
+{
+       const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
+
+       if (str)
+       {
+               tprintf("%s", str);
+               flags &= ~SOCK_TYPE_MASK;
+               if (!flags)
+                       return;
+               tprintf("|");
+       }
+       printflags(sock_type_flags, flags, "SOCK_???");
+}
+
 int
-sys_socket(tcp)
-struct tcb *tcp;
+sys_socket(struct tcb *tcp)
 {
        if (entering(tcp)) {
                printxval(domains, tcp->u_arg[0], "PF_???");
                tprintf(", ");
-               printxval(socktypes, tcp->u_arg[1], "SOCK_???");
+               tprint_sock_type(tcp, tcp->u_arg[1]);
                tprintf(", ");
                switch (tcp->u_arg[0]) {
                case PF_INET:
@@ -1489,8 +1523,7 @@ struct tcb *tcp;
 }
 
 int
-sys_socketpair(tcp)
-struct tcb *tcp;
+sys_socketpair(struct tcb *tcp)
 {
 #ifdef LINUX
        int fds[2];
@@ -1499,7 +1532,7 @@ struct tcb *tcp;
        if (entering(tcp)) {
                printxval(domains, tcp->u_arg[0], "PF_???");
                tprintf(", ");
-               printxval(socktypes, tcp->u_arg[1], "SOCK_???");
+               tprint_sock_type(tcp, tcp->u_arg[1]);
                tprintf(", ");
                switch (tcp->u_arg[0]) {
                case PF_INET: