]> granicus.if.org Git - strace/blobdiff - stream.c
Fix decoding of file descriptors
[strace] / stream.c
index dfdfdb2f57d7f4f8929e8d2056845352e3d8c956..eb4e3964b924bd9ae7da2658207f381d9b5588d3 100644 (file)
--- a/stream.c
+++ b/stream.c
@@ -55,9 +55,9 @@
 #ifndef HAVE_STROPTS_H
 #define RS_HIPRI 1
 struct strbuf {
-        int     maxlen;                 /* no. of bytes in buffer */
-        int     len;                    /* no. of bytes returned */
-        char    *buf;                   /* pointer to data */
+       int     maxlen;                 /* no. of bytes in buffer */
+       int     len;                    /* no. of bytes returned */
+       const char *buf;                /* pointer to data */
 };
 #define MORECTL 1
 #define MOREDATA 2
@@ -338,7 +338,9 @@ decode_poll(struct tcb *tcp, long pts)
                                tprintf("{fd=%d}", fds.fd);
                                continue;
                        }
-                       tprintf("{fd=%d, events=", fds.fd);
+                       tprintf("{fd=");
+                       printfd(tcp, fds.fd);
+                       tprintf(", events=");
                        printflags(pollflags, fds.events, "POLL???");
                        tprintf("}");
                }
@@ -350,7 +352,7 @@ decode_poll(struct tcb *tcp, long pts)
        } else {
                static char outstr[1024];
                char str[64];
-                const char *flagstr;
+               const char *flagstr;
                unsigned int cumlen;
 
                if (syserror(tcp))
@@ -417,15 +419,10 @@ decode_poll(struct tcb *tcp, long pts)
                        strcat(outstr, "]");
 
                if (pts) {
-                       struct timespec ts;
                        char str[128];
 
                        sprintf(str, "%sleft ", cumlen ? ", " : "");
-                       if (umove(tcp, pts, &ts) == 0)
-                               sprintf(str + strlen(str), "{%lu, %lu}",
-                                       ts.tv_sec, ts.tv_nsec);
-                       else
-                               strcat(str, "{...}");
+                       sprint_timespec(str + strlen(str), tcp, pts);
                        if ((cumlen += strlen(str)) < sizeof(outstr))
                                strcat(outstr, str);
                }
@@ -459,11 +456,8 @@ sys_ppoll(struct tcb *tcp)
 {
        int rc = decode_poll(tcp, tcp->u_arg[2]);
        if (entering(tcp)) {
-               struct timespec ts;
-               if (umove(tcp, tcp->u_arg[2], &ts) == 0)
-                       tprintf("{%lu, %lu}, ", ts.tv_sec, ts.tv_nsec);
-               else
-                       tprintf("{...}, ");
+               print_timespec(tcp, tcp->u_arg[2]);
+               tprintf(", ");
                print_sigset(tcp, tcp->u_arg[3], 0);
                tprintf(", %lu", tcp->u_arg[4]);
        }
@@ -476,7 +470,7 @@ int
 sys_poll(tcp)
 struct tcb *tcp;
 {
-       return 0;
+       return 0;
 }
 #endif
 
@@ -1041,10 +1035,7 @@ int len;
 #endif /* TI_BIND */
 
 
-static int
-internal_stream_ioctl(tcp, arg)
-struct tcb *tcp;
-int arg;
+static int internal_stream_ioctl(struct tcb *tcp, int arg)
 {
        struct strioctl si;
        struct ioctlent *iop;
@@ -1159,9 +1150,6 @@ int arg;
        case SI_GETUDATA:
                if (entering(tcp))
                        break;
-#if 0
-               tprintf("struct si_udata ");
-#endif
                if (umove(tcp, (int) si.ic_dp, &udata) < 0)
                        tprintf("{...}");
                else {
@@ -1172,9 +1160,6 @@ int arg;
                        tprintf("servtype=%d, so_state=%d, ",
                                udata.servtype, udata.so_state);
                        tprintf("so_options=%d", udata.so_options);
-#if 0
-                       tprintf(", tsdusize=%d", udata.tsdusize);
-#endif
                        tprintf("}");
                }
                break;
@@ -1185,7 +1170,7 @@ int arg;
        }
        if (exiting(tcp)) {
                tprintf("}");
-               if (timod && tcp->u_rval) {
+               if (timod && tcp->u_rval && !syserror(tcp)) {
                        tcp->auxstr = xlookup (tli_errors, tcp->u_rval);
                        return RVAL_STR + 1;
                }