]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-cmdebug-human-readable-expiration-time-20071109
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 12 Jan 2008 15:49:44 +0000 (15:49 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 12 Jan 2008 15:49:44 +0000 (15:49 +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.

(cherry picked from commit 578e0d957547e4ac7f39b0559e166fd9eea5f150)

src/venus/cmdebug.c

index 00c3ab167bcd0f68a4f88c8479b71463c3373e46..0b4c6f39dc6eed0b3d3d8389c92fd35516fe17ae 100644 (file)
@@ -39,6 +39,8 @@ RCSID
 
 extern struct hostent *hostutil_GetHostByName();
 
+static int print_ctime = 0;
+
 static int
 PrintCacheConfig(struct rx_connection *aconn)
 {
@@ -303,8 +305,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 */
@@ -405,8 +412,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 */
@@ -499,6 +511,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;
@@ -563,6 +579,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);