afsmonitor: Skip additional bits for large timeval
authorMarc Dionne <marc.dionne@your-file-system.com>
Mon, 16 Dec 2013 21:52:17 +0000 (16:52 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 23 Aug 2015 20:04:41 +0000 (16:04 -0400)
When the timeval structure uses 64-bit values for sec and usec,
64 extra bits need to be skipped in the input for every time value
that is parsed.  There's a remaining assumption in this part of the
code that the time values received from the server are 32-bits, but
after decoding they will always have the local size which may well
be 64-bits.

Change-Id: Iaf52df8f9da1146807dddc1c44a9e52e83654d9c
Reviewed-on: http://gerrit.openafs.org/10592
Reviewed-by: Daria Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/afsmonitor/afsmonitor.c

index f900e0f..e7b3030 100644 (file)
@@ -1870,6 +1870,7 @@ fs_FullPerfs_ltoa(struct fs_Display_Data *a_fsData,
     int i, j;
     afs_int32 *tmpbuf;
     int code;
+    int large_time;
 
     /* there are two parts to the xstat FS statistics
      * - fullPerfP->overall which give the overall performance statistics, and
@@ -1906,6 +1907,15 @@ fs_FullPerfs_ltoa(struct fs_Display_Data *a_fsData,
 
     srcbuf = (afs_int32 *) (fullPerfP->det.rpcOpTimes);
 
+    /*
+     * For every time value below, we'll have to skip an additional
+     * 64 bits of input if struct timeval uses 64-bit values
+     */
+    if (sizeof(struct timeval) == 16)
+       large_time = 1;
+    else
+       large_time = 0;
+
     for (i = 0; i < FS_STATS_NUM_RPC_OPS; i++) {
        sprintf(a_fsData->data[idx], "%d", *srcbuf);    /* numOps */
        idx++;
@@ -1917,18 +1927,26 @@ fs_FullPerfs_ltoa(struct fs_Display_Data *a_fsData,
        sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf);
        idx++;
        srcbuf++;
+       if (large_time)
+           srcbuf += 2;
        tmpbuf = srcbuf++;      /* sqr time */
        sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf);
        idx++;
        srcbuf++;
+       if (large_time)
+           srcbuf += 2;
        tmpbuf = srcbuf++;      /* min time */
        sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf);
        idx++;
        srcbuf++;
+       if (large_time)
+           srcbuf += 2;
        tmpbuf = srcbuf++;      /* max time */
        sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf);
        idx++;
        srcbuf++;
+       if (large_time)
+           srcbuf += 2;
     }
 
     /* copy fs transfer timings */
@@ -1945,18 +1963,26 @@ fs_FullPerfs_ltoa(struct fs_Display_Data *a_fsData,
        sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf);
        idx++;
        srcbuf++;
+       if (large_time)
+           srcbuf += 2;
        tmpbuf = srcbuf++;      /* sqr time */
        sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf);
        idx++;
        srcbuf++;
+       if (large_time)
+           srcbuf += 2;
        tmpbuf = srcbuf++;      /* min time */
        sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf);
        idx++;
        srcbuf++;
+       if (large_time)
+           srcbuf += 2;
        tmpbuf = srcbuf++;      /* max time */
        sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf);
        idx++;
        srcbuf++;
+       if (large_time)
+           srcbuf += 2;
        sprintf(a_fsData->data[idx], "%d", *srcbuf);    /* sum bytes */
        idx++;
        srcbuf++;