vos-ctime-help-20050705
authorDerrick Brashear <shadow@dementia.org>
Thu, 7 Jul 2005 02:31:05 +0000 (02:31 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 7 Jul 2005 02:31:05 +0000 (02:31 +0000)
FIXES 6031

kept looking at this backwards, fix is obvious

acconfig.h
acinclude.m4
src/volser/vos.c

index 8a1f21e..2aa1dae 100644 (file)
@@ -49,6 +49,7 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
 #undef STRUCT_TASK_STRUCT_HAS_SIGHAND
 #undef STRUCT_TASK_STRUCT_HAS_SIGMASK_LOCK
 #undef ssize_t
+#undef SIZEOF_TIME_T
 #undef HAVE_STRUCT_BUF
 #undef HAVE_ARPA_NAMESER_COMPAT_H
 /* glue for RedHat kernel bug */
index a72095f..6d96aab 100644 (file)
@@ -1030,6 +1030,21 @@ fi
 AC_CHECK_TYPE(ssize_t, int)
 AC_SIZEOF_TYPE(long)
 
+AC_MSG_CHECKING(size of time_t)
+AC_CACHE_VAL(ac_cv_sizeof_time_t,
+[AC_TRY_RUN([#include <stdio.h>
+#include <time.h>
+main()
+{
+  FILE *f=fopen("conftestval", "w");
+  if (!f) exit(1);
+  fprintf(f, "%d\n", sizeof(time_t));
+  exit(0);
+}], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
+])
+AC_MSG_RESULT($ac_cv_sizeof_time_t)
+AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
+
 AC_CHECK_FUNCS(timegm)
 AC_CHECK_FUNCS(daemon)
 
index dc83288..abbb27b 100644 (file)
@@ -444,6 +444,17 @@ DumpFunction(struct rx_call *call, char *filename)
     return (error);
 }
 
+#if SIZEOF_TIME_T!=4
+static char *
+vos_ctime(afs_int32 *timep)
+{
+    time_t *foo = timep;
+    return ctime(foo);
+}
+#else
+#define vos_ctime ctime
+#endif
+
 static void
 DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
              longlist, disp)
@@ -486,24 +497,24 @@ DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
                    (unsigned long)pntr->backupID);
            fprintf(STDOUT, "    MaxQuota %10d K \n", pntr->maxquota);
            fprintf(STDOUT, "    Creation    %s",
-                   ctime((time_t *) & pntr->creationDate));
+                   vos_ctime(& pntr->creationDate));
 #ifdef FULL_LISTVOL_SWITCH
            fprintf(STDOUT, "    Copy        %s",
-                   ctime((time_t *) & pntr->copyDate));
+                   vos_ctime( & pntr->copyDate));
            if (!pntr->backupDate)
                fprintf(STDOUT, "    Backup      Never\n");
            else
                fprintf(STDOUT, "    Backup      %s",
-                       ctime((time_t *) & pntr->backupDate));
+                       vos_ctime( & pntr->backupDate));
            if (pntr->accessDate)
                fprintf(STDOUT, "    Last Access %s",
-                       ctime((time_t *) & pntr->accessDate));
+                       vos_ctime( & pntr->accessDate));
 #endif
            if (!pntr->updateDate)
                fprintf(STDOUT, "    Last Update Never\n");
            else {
                fprintf(STDOUT, "    Last Update %s",
-                       ctime((time_t *) & pntr->updateDate));
+                       vos_ctime( & pntr->updateDate));
                fprintf(STDOUT,
                        "    %d accesses in the past day (i.e., vnode references)\n",
                        pntr->dayUse);
@@ -643,24 +654,24 @@ XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
                    (unsigned long)a_xInfoP->backupID);
            fprintf(STDOUT, "    MaxQuota %10d K \n", a_xInfoP->maxquota);
            fprintf(STDOUT, "    Creation    %s",
-                   ctime((time_t *) & a_xInfoP->creationDate));
+                   vos_ctime( & a_xInfoP->creationDate));
 #ifdef FULL_LISTVOL_SWITCH
            fprintf(STDOUT, "    Copy        %s",
-                   ctime((time_t *) & a_xInfoP->copyDate));
+                   vos_ctime( & a_xInfoP->copyDate));
            if (!a_xInfoP->backupDate)
                fprintf(STDOUT, "    Backup      Never\n");
            else
                fprintf(STDOUT, "    Backup      %s",
-                       ctime((time_t *) & a_xInfoP->backupDate));
+                       vos_ctime( & a_xInfoP->backupDate));
            if (a_xInfoP->accessDate)
                fprintf(STDOUT, "    Last Access %s",
-                       ctime((time_t *) & a_xInfoP->accessDate));
+                       vos_ctime( & a_xInfoP->accessDate));
 #endif
            if (!a_xInfoP->updateDate)
                fprintf(STDOUT, "    Last Update Never\n");
            else {
                fprintf(STDOUT, "    Last Update %s",
-                       ctime((time_t *) & a_xInfoP->updateDate));
+                       vos_ctime( & a_xInfoP->updateDate));
                fprintf(STDOUT,
                        "    %d accesses in the past day (i.e., vnode references)\n",
                        a_xInfoP->dayUse);
@@ -906,15 +917,15 @@ XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
                        break;
                }
                fprintf(STDOUT, "creationDate\t%-9lu\t%s", a_xInfoP->creationDate,
-                       ctime(&a_xInfoP->creationDate));
+                       vos_ctime(&a_xInfoP->creationDate));
                fprintf(STDOUT, "accessDate\t%-9lu\t%s", a_xInfoP->accessDate,
-                       ctime(&a_xInfoP->accessDate));
+                       vos_ctime(&a_xInfoP->accessDate));
                fprintf(STDOUT, "updateDate\t%-9lu\t%s", a_xInfoP->updateDate,
-                       ctime(&a_xInfoP->updateDate));
+                       vos_ctime(&a_xInfoP->updateDate));
                fprintf(STDOUT, "backupDate\t%-9lu\t%s", a_xInfoP->backupDate,
-                       ctime(&a_xInfoP->backupDate));
+                       vos_ctime(&a_xInfoP->backupDate));
                fprintf(STDOUT, "copyDate\t%-9lu\t%s", a_xInfoP->copyDate,
-                       ctime(&a_xInfoP->copyDate));
+                       vos_ctime(&a_xInfoP->copyDate));
                
                fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
                fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
@@ -1058,15 +1069,15 @@ DisplayFormat2(server, partition, pntr)
        break;
     }
     fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate,
-           ctime(&pntr->creationDate));
+           vos_ctime(&pntr->creationDate));
     fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate,
-           ctime(&pntr->accessDate));
+           vos_ctime(&pntr->accessDate));
     fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate,
-           ctime(&pntr->updateDate));
+           vos_ctime(&pntr->updateDate));
     fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate,
-           ctime(&pntr->backupDate));
+           vos_ctime(&pntr->backupDate));
     fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate,
-           ctime(&pntr->copyDate));
+           vos_ctime(&pntr->copyDate));
     fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
     fprintf(STDOUT, "diskused\t%u\n", pntr->size);
     fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
@@ -3937,7 +3948,7 @@ VolserStatus(as)
        /*print out the relevant info */
        fprintf(STDOUT, "--------------------------------------\n");
        fprintf(STDOUT, "transaction: %lu  created: %s",
-               (unsigned long)pntr->tid, ctime((time_t *) & pntr->time));
+               (unsigned long)pntr->tid, vos_ctime( & pntr->time));
        if (pntr->returnCode) {
            fprintf(STDOUT, "returnCode: %lu\n",
                    (unsigned long)pntr->returnCode);