]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
cmdebug-human-readable-expiration-time-20071109
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 10 Nov 2007 00:18:11 +0000 (00:18 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 10 Nov 2007 00:18:11 +0000 (00:18 +0000)
add -ctime parameter which produces human readable expiration times.
Doesn't work with OpenAFS for Windows prior to 1.5.28 because time()
was not used in those versions for tracking expiration times.

src/venus/cmdebug.c

index 90fe9c15d8eabf916f555e73728dbd8a04fa21d3..81b1c617986e973797914c3d4c718050e70b6afb 100644 (file)
@@ -40,6 +40,8 @@ RCSID
 
 extern struct hostent *hostutil_GetHostByName();
 
+static int print_ctime = 0;
+
 static int
 PrintCacheConfig(struct rx_connection *aconn)
 {
@@ -304,8 +306,13 @@ PrintCacheEntries32(struct rx_connection *aconn, int aint32)
        }
        printf("    %12d bytes  DV %12d  refcnt %5d\n", centry.Length,
               centry.DataVersion, centry.refCount);
-       printf("    callback %08x\texpires %u\n", centry.callback,
-              centry.cbExpires);
+        if (print_ctime) {
+            time_t t = centry.cbExpires;
+            printf("    callback %08x\texpires %s\n", centry.callback,
+                    ctime(&t));
+        } else
+            printf("    callback %08x\texpires %u\n", centry.callback,
+                   centry.cbExpires);
        printf("    %d opens\t%d writers\n", centry.opens, centry.writers);
 
        /* now display states */
@@ -406,8 +413,13 @@ PrintCacheEntries64(struct rx_connection *aconn, int aint32)
        printf("    %12d bytes  DV %12d  refcnt %5d\n", centry.Length,
               centry.DataVersion, centry.refCount);
 #endif
-       printf("    callback %08x\texpires %u\n", centry.callback,
-              centry.cbExpires);
+        if (print_ctime) {
+            time_t t = centry.cbExpires;
+            printf("    callback %08x\texpires %s\n", centry.callback,
+                    ctime(&t));
+        } else
+            printf("    callback %08x\texpires %u\n", centry.callback,
+                   centry.cbExpires);
        printf("    %d opens\t%d writers\n", centry.opens, centry.writers);
 
        /* now display states */
@@ -500,6 +512,10 @@ CommandProc(struct cmd_syndesc *as, void *arock)
        PrintCacheConfig(conn);
        return 0;
     }
+
+    if (as->parms[7].items)
+        print_ctime = 1;
+
     if (as->parms[2].items)
         /* -long */
        int32p = 1;
@@ -564,6 +580,8 @@ main(int argc, char **argv)
                "print only host interfaces");
     cmd_AddParm(ts, "-cache", CMD_FLAG, CMD_OPTIONAL,
                "print only cache configuration");
+    cmd_AddParm(ts, "-ctime", CMD_FLAG, CMD_OPTIONAL, 
+                "print human readable expiration time");
 
     cmd_Dispatch(argc, argv);
     exit(0);