int num = LogThreadNum();
struct in_addr hostAddr;
time_t currenttime;
- char *timeStamp;
char tbuffer[26];
+ struct tm tm;
/* Don't print the timestamp or thread id if we recursed */
if (rec == 0) {
currenttime = time(0);
- timeStamp = afs_ctime(¤ttime, tbuffer,
- sizeof(tbuffer));
- timeStamp[24] = ' '; /* ts[24] is the newline, 25 is the null */
- audit_ops->append_msg(timeStamp);
+ if (strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y ",
+ localtime_r(¤ttime, &tm)) !=0)
+ audit_ops->append_msg(tbuffer);
if (num > -1)
audit_ops->append_msg("[%d] ", num);
char *str)
{
time_t now;
- char tbuffer[32], *timestr;
+ char tbuffer[32];
+ struct tm tm;
now = time(0);
- timestr = afs_ctime(&now, tbuffer, sizeof(tbuffer));
- timestr[24] = '\0';
+ if (strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&now, &tm)) != 0)
+ fprintf(logIO, "%s: ", tbuffer);
- fprintf(logIO, "%s: ", timestr);
if (task)
fprintf(logIO, "Task %u: ", task);
PrintLogStr(logIO, error1, error2, str);
if (lastPass && lastLogIO) {
- fprintf(lastLogIO, "%s: ", timestr);
+ fprintf(lastLogIO, "%s: ", tbuffer);
if (task)
fprintf(lastLogIO, "Task %u: ", task);
PrintLogStr(lastLogIO, error1, error2, str);
char *errStr)
{
time_t now;
- char tbuffer[32], *timestr;
+ char tbuffer[32];
+ struct tm tm;
now = time(0);
- timestr = afs_ctime(&now, tbuffer, sizeof(tbuffer));
- timestr[24] = '\0';
- fprintf(ErrorlogIO, "%s: ", timestr);
+ if (strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&now, &tm)) != 0)
+ fprintf(ErrorlogIO, "%s: ", tbuffer);
/* Print the time and task number */
if (task)
{
char tbuffer[32]; /* need at least 26 bytes */
time_t passtime; /* modern systems have 64 bit time */
+ struct tm tm;
- if (!time)
- strcpy(tstr, "no date"); /* special case this */
- else if (time == NEVERDATE)
+ passtime = time;
+
+ if (time == NEVERDATE)
strcpy(tstr, "never");
else {
- passtime = time;
- strncpy(tstr, afs_ctime(&passtime, tbuffer, sizeof(tbuffer)), tlen);
- tstr[strlen(tstr) - 1] = '\0'; /* punt the newline character */
+ if (!time || strftime(tbuffer, sizeof(tbuffer), "%c",
+ localtime_r(&passtime, &tm)) == 0)
+ strcpy(tstr, "no date");
+ else {
+ strncpy(tstr, tbuffer, tlen);
+ }
}
}
$(LIBDIR)\afsrx.lib \
$(LIBDIR)\afslwp.lib \
$(LIBDIR)\afs\afsutil.lib \
- $(LIBDIR)\afs\afsreg.lib
+ $(LIBDIR)\afs\afsreg.lib \
+ $(LIBDIR)\afsroken.lib
$(OUT)\rxdebug.res: rxdebug.rc $(VERSFILE).h
$(RC) /Fo$*.RES $(*F).rc
$(DESTDIR)\lib\afslwp.lib \
$(DESTDIR)\lib\afs\afscom_err.lib \
$(DESTDIR)\lib\afs\afscmd.lib \
- $(DESTDIR)\lib\afs\afsutil.lib
+ $(DESTDIR)\lib\afs\afsutil.lib \
+ $(DESTDIR)\lib\afsroken.lib
$(RS_UDBG_EXEFILE): $(UDBG_EXEOBJS) $(UDBG_EXELIBS)
extern int ReOpenLog(const char *fileName);
extern void SetupLogSignals(void);
-/* special version of ctime that clobbers a *different static variable, so
- * that ViceLog can call ctime and not cause buffer confusion.
- */
-extern char *vctime(const time_t * atime);
-
-/* Need a thead safe ctime for pthread builds. Use std ctime for LWP */
-#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
-#if defined(AFS_SUN5_ENV) && !defined(_POSIX_PTHREAD_SEMANTICS) && (_POSIX_C_SOURCE - 0 < 199506L)
-#define afs_ctime(C, B, L) ctime_r(C, B, L)
-#else
-/* Cast is for platforms which do not prototype ctime_r */
-#define afs_ctime(C, B, L) (char*)ctime_r(C, B)
-#endif /* AFS_SUN5_ENV */
-#else /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */
-static_inline char *
-afs_ctime(const time_t *C, char *B, size_t S) {
-#if !defined(AFS_NT40_ENV) || (_MSC_VER < 1400)
- strncpy(B, ctime(C), (S-1));
- B[S-1] = '\0';
-#else
- ctime_s(B, S, C);
-#endif
- return B;
-}
-#endif /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */
-
-
/* abort the current process. */
#ifdef AFS_NT40_ENV
#define afs_abort() afs_NTAbort()
#endif
#define TIMESTAMP_BUFFER_SIZE 26 /* including the null */
-#define TIMESTAMP_NEWLINE_POS 24 /* offset to the newline placed by ctime */
void
AssertionFailed(char *file, int line)
{
char tdate[TIMESTAMP_BUFFER_SIZE];
time_t when;
+ struct tm tm;
- time(&when);
- (void)afs_ctime(&when, tdate, sizeof(tdate));
- tdate[TIMESTAMP_NEWLINE_POS] = ' ';
+ when = time(NULL);
+ strftime(tdate, sizeof(tdate), "%a %b %d %T %Y",
+ localtime_r(&when, &tm));
fprintf(stderr, "%sAssertion failed! file %s, line %d.\n", tdate, file,
line);
fflush(stderr);
vFSLog(const char *format, va_list args)
{
time_t currenttime;
- char *timeStamp;
char tbuffer[1024];
char *info;
size_t len;
+ struct tm tm;
int num;
- currenttime = time(0);
- timeStamp = afs_ctime(¤ttime, tbuffer, sizeof(tbuffer));
- timeStamp[24] = ' '; /* ts[24] is the newline, 25 is the null */
- info = &timeStamp[25];
+ currenttime = time(NULL);
+ len = strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y ",
+ localtime_r(¤ttime, &tm));
+ info = &tbuffer[len+1];
if (mrafsStyleLogs || threadIdLogs) {
num = (*threadNumProgram) ();
char tbuffer[32];
char hoststr[16];
time_t LastCall, expTime;
+ struct tm tm;
H_LOCK;
LastCall = host->LastCall;
H_UNLOCK;
return flags;
}
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&LastCall, &tm));
snprintf(tmpStr, sizeof tmpStr, "Host %s:%d down = %d, LastCall %s",
afs_inet_ntoa_r(host->host, hoststr),
ntohs(host->port), (host->hostFlags & VENUSDOWN),
- afs_ctime(&LastCall, tbuffer, sizeof(tbuffer)));
+ tbuffer);
(void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
for (client = host->FirstClient; client; client = client->next) {
if (!client->deleted) {
expTime = client->expTime;
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&expTime, &tm));
snprintf(tmpStr, sizeof tmpStr,
" user id=%d, name=%s, sl=%s till %s",
client->ViceId, h_UserName(client),
client->authClass ? "Authenticated"
: "Not authenticated",
- client->authClass ? afs_ctime(&expTime, tbuffer,
- sizeof(tbuffer))
- : "No Limit\n");
+ client->authClass ? tbuffer : "No Limit\n");
(void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
snprintf(tmpStr, sizeof tmpStr, " CPS-%d is [",
client->CPS.prlist_len);
time_t now;
char tmpStr[256];
char tbuffer[32];
+ struct tm tm;
StreamHandle_t *file = STREAM_OPEN(AFSDIR_SERVER_CLNTDUMP_FILEPATH, "w");
return;
}
now = FT_ApproxTime();
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&now, &tm));
snprintf(tmpStr, sizeof tmpStr, "List of active users at %s\n",
- afs_ctime(&now, tbuffer, sizeof(tbuffer)));
+ tbuffer);
(void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
h_Enumerate(h_PrintClient, (char *)file);
STREAM_REALLYCLOSE(file);
StreamHandle_t *file = STREAM_OPEN(AFSDIR_SERVER_HOSTDUMP_FILEPATH, "w");
char tmpStr[256];
char tbuffer[32];
+ struct tm tm;
if (file == NULL) {
ViceLog(0,
return;
}
now = FT_ApproxTime();
- snprintf(tmpStr, sizeof tmpStr, "List of active hosts at %s\n",
- afs_ctime(&now, tbuffer, sizeof(tbuffer)));
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&now, &tm));
+ snprintf(tmpStr, sizeof tmpStr, "List of active hosts at %s\n", tbuffer);
(void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
h_Enumerate(h_DumpHost, (char *)file);
STREAM_REALLYCLOSE(file);
#endif
if (printBanner && (++msg & 1)) { /* Every 10 minutes */
time_t now = FT_ApproxTime();
+ struct tm tm;
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&now, &tm));
ViceLog(2,
- ("File server is running at %s\n",
- afs_ctime(&now, tbuffer, sizeof(tbuffer))));
+ ("File server is running at %s\n", tbuffer));
}
#ifdef AFS_DEMAND_ATTACH_FS
FS_STATE_WRLOCK;
int workstations, activeworkstations, delworkstations;
int processSize = 0;
char tbuffer[32];
+ struct tm tm;
#ifdef AFS_DEMAND_ATTACH_FS
int stats_flags = 0;
#endif
FT_GetTimeOfDay(&tpl, 0);
Statistics = 1;
- ViceLog(0,
- ("Vice was last started at %s\n",
- afs_ctime(&StartTime, tbuffer, sizeof(tbuffer))));
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&StartTime, &tm));
+ ViceLog(0, ("Vice was last started at %s\n", tbuffer));
#ifdef AFS_DEMAND_ATTACH_FS
if (LogLevel >= 125) {
void
ShutDownAndCore(int dopanic)
{
- time_t now = time(0);
+ time_t now = time(NULL);
+ struct tm tm;
char tbuffer[32];
if (dopanic) {
FS_STATE_UNLOCK;
#endif
- ViceLog(0,
- ("Shutting down file server at %s",
- afs_ctime(&now, tbuffer, sizeof(tbuffer))));
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&now, &tm));
+ ViceLog(0, ("Shutting down file server at %s", tbuffer));
if (dopanic)
ViceLog(0, ("ABNORMAL SHUTDOWN, see core file.\n"));
DFlush();
fflush(debugFile);
}
now = time(0);
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&now, &tm));
if (dopanic) {
- ViceLog(0,
- ("File server has terminated abnormally at %s\n",
- afs_ctime(&now, tbuffer, sizeof(tbuffer))));
+ ViceLog(0, ("File server has terminated abnormally at %s\n", tbuffer));
} else {
- ViceLog(0,
- ("File server has terminated normally at %s\n",
- afs_ctime(&now, tbuffer, sizeof(tbuffer))));
+ ViceLog(0, ("File server has terminated normally at %s\n", tbuffer));
}
if (dopanic) /* XXX pass in file and line? */
#endif
int curLimit;
time_t t;
+ struct tm tm;
afs_uint32 rx_bindhost;
VolumePackageOptions opts;
}
t = tp.tv_sec;
- ViceLog(0,
- ("File Server started %s",
- afs_ctime(&t, tbuffer, sizeof(tbuffer))));
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ localtime_r(&t, &tm));
+ ViceLog(0, ("File Server started %s", tbuffer));
#if FS_STATS_DETAILED
afs_FullPerfStats.det.epoch.tv_sec = StartTime = tp.tv_sec;
#endif
int i;
char strg[30];
time_t start_time = stats->start_time;
+ struct tm tm;
- afs_ctime(&start_time, strg, sizeof(strg));
- strg[strlen(strg) - 1] = 0;
+ strftime(strg, sizeof(strg), "%a %b %d %T %Y",
+ localtime_r(&start_time, &tm));
printf("Dynamic statistics stats (starting time: %s):\n", strg);
printf("OpcodeName\t# Requests\t# Aborts\n");
for (i = 0; i < VL_NUMBER_OPCODESX; i++)