-/* $OpenBSD: itime.c,v 1.26 2023/12/21 08:01:21 otto Exp $ */
+/* $OpenBSD: itime.c,v 1.27 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: itime.c,v 1.4 1997/04/15 01:09:50 lukem Exp $ */
/*-
FILE *df;
struct dumpdates *dtwalk;
int fd, i;
- char *fname;
+ char *fname, *ct;
time_t t;
if(uflag == 0)
quit("ftruncate (%s): %s\n", dumpdates, strerror(errno));
(void) fclose(df);
t = (time_t)spcl.c_date;
- msg("level %c dump on %s", level, t == 0 ? "the epoch\n" : ctime(&t));
+ if (t == 0)
+ ct = "the epoch\n";
+ else if ((ct = ctime(&t)) == NULL)
+ ct = "?\n";
+ msg("level %c dump on %s", level, ct);
}
static void
dumprecout(FILE *file, struct dumpdates *what)
{
+ char *ct;
+
+ ct = ctime(&what->dd_ddate);
+ if (ct == NULL)
+ quit("Cannot convert date\n");
if (fprintf(file, DUMPOUTFMT,
what->dd_name,
dumpdates, recno);
#ifdef FDEBUG
- msg("getrecord: %s %c %s", ddatep->dd_name, ddatep->dd_level,
- ddatep->dd_ddate == 0 ? "the epoch\n" : ctime(&ddatep->dd_ddate));
+ {
+ char *ct;
+
+ if (ddatep->dd_ddate == 0)
+ ct = "the epoch\n";
+ else
+ ct = ctime(&ddatep->dd_ddate);
+
+ if (ct)
+ msg("getrecord: %s %c %s", ddatep->dd_name,
+ ddatep->dd_level, ct);
+ else
+ msg("getrecord: %s %c %lld seconds after the epoch\n",
+ ddatep->dd_name, ddatep->dd_level,
+ ddatep->dd_ddate);
+ }
#endif
return(0);
}
-/* $OpenBSD: main.c,v 1.65 2024/01/09 03:16:00 guenther Exp $ */
+/* $OpenBSD: main.c,v 1.66 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */
/*-
ino_t maxino;
time_t t;
int dirlist;
- char *toplevel, *str, *mount_point = NULL, *realpath;
+ char *toplevel, *str, *mount_point = NULL, *realpath, *ct;
int just_estimate = 0;
u_int64_t zero_uid = 0;
getdumptime(); /* /etc/dumpdates snarfed */
t = (time_t)spcl.c_date;
+ ct = ctime(&t);
msg("Date of this level %c dump: %s", level,
- t == 0 ? "the epoch\n" : ctime(&t));
+ t == 0 ? "the epoch\n" : ct ? ct : "?\n");
t = (time_t)spcl.c_ddate;
+ ct = ctime(&t);
msg("Date of last level %c dump: %s", lastlevel,
- t == 0 ? "the epoch\n" : ctime(&t));
+ t == 0 ? "the epoch\n" : ct ? ct : "?\n");
msg("Dumping %s ", disk);
if (mount_point != NULL)
msgtail("(%s) ", mount_point);
spcl.c_tapea, spcl.c_volume,
(spcl.c_volume == 1) ? "" : "s");
t = (time_t)spcl.c_date;
+ ct = ctime(&t);
msg("Date of this level %c dump: %s", level,
- t == 0 ? "the epoch\n" : ctime(&t));
+ t == 0 ? "the epoch\n" : ct ? ct : "?\n");
t = do_stats();
- msg("Date this dump completed: %s", ctime(&t));
+ ct = ctime(&t);
+ msg("Date this dump completed: %s", ct ? ct : "?\n");
msg("Average transfer rate: %ld KB/s\n", xferrate / tapeno);
putdumptime();
trewind();
-/* $OpenBSD: optr.c,v 1.41 2023/03/08 04:43:06 guenther Exp $ */
+/* $OpenBSD: optr.c,v 1.42 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: optr.c,v 1.11 1997/05/27 08:34:36 mrg Exp $ */
/*-
if (strncmp(lastname, dtwalk->dd_name,
sizeof(dtwalk->dd_name)) == 0)
continue;
- date = (char *)ctime(&dtwalk->dd_ddate);
- date[16] = '\0'; /* blast away seconds and year */
+ date = ctime(&dtwalk->dd_ddate);
+ if (date)
+ date[16] = '\0'; /* blast away seconds and year */
+ else
+ date = "?";
lastname = dtwalk->dd_name;
dt = fstabsearch(dtwalk->dd_name);
dumpme = (dt != NULL &&
-/* $OpenBSD: tape.c,v 1.48 2023/03/08 04:43:06 guenther Exp $ */
+/* $OpenBSD: tape.c,v 1.49 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $ */
/*-
{
time_t tnow, ttaken;
int64_t blocks;
+ char *ct;
(void)time(&tnow);
ttaken = tnow - tstart_volume;
blocks = spcl.c_tapea - tapea_volume;
- msg("Volume %d completed at: %s", tapeno, ctime(&tnow));
+ ct = ctime(&tnow);
+ msg("Volume %d completed at: %s", tapeno, ct ? ct : "?\n");
if (ttaken > 0) {
msg("Volume %d took %lld:%02lld:%02lld\n", tapeno,
(long long)ttaken / 3600, ((long long)ttaken % 3600) / 60,
pid_t childpid;
int status;
pid_t waitingpid;
- char *p;
+ char *p, *ct;
sig_t interrupt_save;
interrupt_save = signal(SIGINT, SIG_IGN);
writeheader((ino_t)slp->inode);
if (sblock->fs_magic != FS_UFS2_MAGIC)
spcl.c_flags &=~ DR_NEWHEADER;
- msg("Volume %d started at: %s", tapeno, ctime(&tstart_volume));
+ ct = ctime(&tstart_volume);
+ msg("Volume %d started at: %s", tapeno, ct ? ct : "?\n");
if (tapeno > 1)
msg("Volume %d begins with blocks from inode %llu\n",
tapeno, (unsigned long long)slp->inode);
-/* $OpenBSD: dumpfs.c,v 1.38 2024/02/03 18:51:57 beck Exp $ */
+/* $OpenBSD: dumpfs.c,v 1.39 2024/05/09 08:35:40 florian Exp $ */
/*
* Copyright (c) 2002 Networks Associates Technology, Inc.
off_t off;
int i, j;
u_int cg;
+ char *ct;
switch (afs.fs_magic) {
case FS_UFS2_MAGIC:
fssize = afs.fs_size;
fstime = afs.fs_time;
- printf("magic\t%x (FFS2)\ttime\t%s",
- afs.fs_magic, ctime(&fstime));
+ ct = ctime(&fstime);
+ if (ct)
+ printf("magic\t%x (FFS2)\ttime\t%s",
+ afs.fs_magic, ctime(&fstime));
+ else
+ printf("magic\t%x (FFS2)\ttime\t%lld\n",
+ afs.fs_magic, fstime);
printf("superblock location\t%jd\tid\t[ %x %x ]\n",
(intmax_t)afs.fs_sblockloc, afs.fs_id[0], afs.fs_id[1]);
printf("ncg\t%u\tsize\t%jd\tblocks\t%jd\n",
case FS_UFS1_MAGIC:
fssize = afs.fs_ffs1_size;
fstime = afs.fs_ffs1_time;
- printf("magic\t%x (FFS1)\ttime\t%s",
- afs.fs_magic, ctime(&fstime));
+ ct = ctime(&fstime);
+ if (ct)
+ printf("magic\t%x (FFS1)\ttime\t%s",
+ afs.fs_magic, ctime(&fstime));
+ else
+ printf("magic\t%x (FFS1)\ttime\t%lld\n",
+ afs.fs_magic, fstime);
printf("id\t[ %x %x ]\n", afs.fs_id[0], afs.fs_id[1]);
i = 0;
if (afs.fs_postblformat != FS_42POSTBLFMT) {
time_t cgtime;
off_t cur;
int i, j;
+ char *ct;
printf("\ncg %u:\n", c);
cur = (off_t)fsbtodb(&afs, cgtod(&afs, c)) * DEV_BSIZE;
switch (afs.fs_magic) {
case FS_UFS2_MAGIC:
cgtime = acg.cg_ffs2_time;
- printf("magic\t%x\ttell\t%jx\ttime\t%s",
- acg.cg_magic, (intmax_t)cur, ctime(&cgtime));
+ ct = ctime(&cgtime);
+ if (ct)
+ printf("magic\t%x\ttell\t%jx\ttime\t%s",
+ acg.cg_magic, (intmax_t)cur, ct);
+ else
+ printf("magic\t%x\ttell\t%jx\ttime\t%lld\n",
+ acg.cg_magic, (intmax_t)cur, cgtime);
printf("cgx\t%u\tndblk\t%u\tniblk\t%u\tinitiblk %u\n",
acg.cg_cgx, acg.cg_ndblk, acg.cg_ffs2_niblk,
acg.cg_initediblk);
break;
case FS_UFS1_MAGIC:
cgtime = acg.cg_time;
- printf("magic\t%x\ttell\t%jx\ttime\t%s",
- afs.fs_postblformat == FS_42POSTBLFMT ?
- ((struct ocg *)&acg)->cg_magic : acg.cg_magic,
- (intmax_t)cur, ctime(&cgtime));
+ ct = ctime(&cgtime);
+ if (ct)
+ printf("magic\t%x\ttell\t%jx\ttime\t%s",
+ afs.fs_postblformat == FS_42POSTBLFMT ?
+ ((struct ocg *)&acg)->cg_magic : acg.cg_magic,
+ (intmax_t)cur, ct);
+ else
+ printf("magic\t%x\ttell\t%jx\ttime\t%lld\n",
+ afs.fs_postblformat == FS_42POSTBLFMT ?
+ ((struct ocg *)&acg)->cg_magic : acg.cg_magic,
+ (intmax_t)cur, cgtime);
printf("cgx\t%u\tncyl\t%d\tniblk\t%d\tndblk\t%u\n",
acg.cg_cgx, acg.cg_ncyl, acg.cg_niblk, acg.cg_ndblk);
break;
-/* $OpenBSD: inode.c,v 1.30 2024/04/23 13:34:50 jsg Exp $ */
+/* $OpenBSD: inode.c,v 1.31 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: inode.c,v 1.8 2000/01/28 16:01:46 bouyer Exp $ */
/*
printf("SIZE=%llu ", (long long)inosize(dp));
t = (time_t) letoh32(dp->e2di_mtime);
p = ctime(&t);
- printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
+ if (p)
+ printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
+ else
+ printf("MTIME=%lld ", t);
}
void
-/* $OpenBSD: pass1.c,v 1.18 2019/07/01 07:13:44 kevlo Exp $ */
+/* $OpenBSD: pass1.c,v 1.19 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: pass1.c,v 1.9 2000/01/31 11:40:12 bouyer Exp $ */
/*
if (dp->e2di_dtime != 0) {
time_t t = letoh32(dp->e2di_dtime);
char *p = ctime(&t);
- pwarn("INODE I=%llu HAS DTIME=%12.12s %4.4s",
- (unsigned long long)inumber, &p[4], &p[20]);
+ if (p)
+ pwarn("INODE I=%llu HAS DTIME=%12.12s %4.4s",
+ (unsigned long long)inumber, &p[4], &p[20]);
+ else
+ pwarn("INODE I=%llu HAS DTIME=%lld",
+ (unsigned long long)inumber, t);
if (preen) {
printf(" (CORRECTED)\n");
}
-/* $OpenBSD: inode.c,v 1.51 2024/01/09 03:16:00 guenther Exp $ */
+/* $OpenBSD: inode.c,v 1.52 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */
/*
printf("SIZE=%llu ", (unsigned long long)DIP(dp, di_size));
t = DIP(dp, di_mtime);
p = ctime(&t);
- printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
+ if (p)
+ printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
+ else
+ printf("MTIME=%lld ", t);
}
void
-/* $OpenBSD: fsdbutil.c,v 1.20 2019/02/05 02:17:32 deraadt Exp $ */
+/* $OpenBSD: fsdbutil.c,v 1.21 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: fsdbutil.c,v 1.5 1996/09/28 19:30:37 christos Exp $ */
/*-
DIP(dp, di_mode), DIP(dp, di_size));
t = DIP(dp, di_mtime);
p = ctime(&t);
- printf("\n\tMTIME=%15.15s %4.4s [%d nsec]", &p[4], &p[20],
- DIP(dp, di_mtimensec));
+ if (p)
+ printf("\n\tMTIME=%15.15s %4.4s [%d nsec]", &p[4], &p[20],
+ DIP(dp, di_mtimensec));
+ else
+ printf("\n\tMTIME=%lld [%d nsec]", t, DIP(dp, di_mtimensec));
t = DIP(dp, di_ctime);
p = ctime(&t);
- printf("\n\tCTIME=%15.15s %4.4s [%d nsec]", &p[4], &p[20],
- DIP(dp, di_ctimensec));
+ if (p)
+ printf("\n\tCTIME=%15.15s %4.4s [%d nsec]", &p[4], &p[20],
+ DIP(dp, di_ctimensec));
+ else
+ printf("\n\tCTIME=%lld [%d nsec]", t, DIP(dp, di_ctimensec));
t = DIP(dp, di_atime);
p = ctime(&t);
- printf("\n\tATIME=%15.15s %4.4s [%d nsec]\n", &p[4], &p[20],
- DIP(dp, di_atimensec));
-
+ if (p)
+ printf("\n\tATIME=%15.15s %4.4s [%d nsec]\n", &p[4], &p[20],
+ DIP(dp, di_atimensec));
+ else
+ printf("\n\tATIME=%lld [%d nsec]\n", t, DIP(dp, di_atimensec));
if ((name = user_from_uid(DIP(dp, di_uid), 1)) != NULL)
printf("OWNER=%s ", name);
else
-/* $OpenBSD: fsirand.c,v 1.43 2020/06/20 07:49:04 otto Exp $ */
+/* $OpenBSD: fsirand.c,v 1.44 2024/05/09 08:35:40 florian Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <millert@openbsd.org>
if (printonly && (sblock->fs_id[0] || sblock->fs_id[1])) {
if (sblock->fs_inodefmt >= FS_44INODEFMT && sblock->fs_id[0]) {
time_t t = sblock->fs_id[0]; /* XXX 2038 */
- (void)printf("%s was randomized on %s", devpath,
- ctime(&t));
+ char *ct = ctime(&t);
+ if (ct)
+ (void)printf("%s was randomized on %s", devpath,
+ ct);
+ else
+ (void)printf("%s was randomized on %lld\n",
+ devpath, t);
}
(void)printf("fsid: %x %x\n", sblock->fs_id[0],
sblock->fs_id[1]);
-/* $OpenBSD: mount.c,v 1.77 2023/07/23 23:21:19 kn Exp $ */
+/* $OpenBSD: mount.c,v 1.78 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp $ */
/*
char buf[26];
time_t t = sf->f_ctime;
- ctime_r(&t, buf);
- buf[24] = '\0';
- printf(", ctime=%s", buf);
+ if (ctime_r(&t, buf))
+ printf(", ctime=%.24s", buf);
+ else
+ printf(", ctime=%lld", t);
}
/*
-/* $OpenBSD: pfctl_table.c,v 1.87 2024/01/15 07:23:32 sashan Exp $ */
+/* $OpenBSD: pfctl_table.c,v 1.88 2024/05/09 08:35:40 florian Exp $ */
/*
* Copyright (c) 2002 Cedric Berger
void
print_tstats(struct pfr_tstats *ts, int debug)
{
- time_t time = ts->pfrts_tzero;
- int dir, op;
+ time_t time = ts->pfrts_tzero;
+ int dir, op;
+ char *ct;
if (!debug && !(ts->pfrts_flags & PFR_TFLAG_ACTIVE))
return;
+ ct = ctime(&time);
print_table(&ts->pfrts_t, 1, debug);
printf("\tAddresses: %d\n", ts->pfrts_cnt);
- printf("\tCleared: %s", ctime(&time));
+ if (ct)
+ printf("\tCleared: %s", ct);
+ else
+ printf("\tCleared: %lld\n", time);
printf("\tReferences: [ Anchors: %-18d Rules: %-18d ]\n",
ts->pfrts_refcnt[PFR_REFCNT_ANCHOR],
ts->pfrts_refcnt[PFR_REFCNT_RULE]);
void
print_astats(struct pfr_astats *as, int dns)
{
- time_t time = as->pfras_tzero;
- int dir, op;
+ time_t time = as->pfras_tzero;
+ int dir, op;
+ char *ct;
+ ct = ctime(&time);
print_addrx(&as->pfras_a, NULL, dns);
- printf("\tCleared: %s", ctime(&time));
+ if (ct)
+ printf("\tCleared: %s", ctime(&time));
+ else
+ printf("\tCleared: %lld\n", time);
if (as->pfras_a.pfra_states)
printf("\tActive States: %d\n", as->pfras_a.pfra_states);
if (as->pfras_a.pfra_type == PFRKE_COST)
void
print_iface(struct pfi_kif *p, int opts)
{
- time_t tzero = p->pfik_tzero;
- int i, af, dir, act;
+ time_t tzero = p->pfik_tzero;
+ int i, af, dir, act;
+ char *ct;
printf("%s", p->pfik_name);
if (opts & PF_OPT_VERBOSE) {
if (!(opts & PF_OPT_VERBOSE2))
return;
- printf("\tCleared: %s", ctime(&tzero));
+
+ ct = ctime(&tzero);
+ if (ct)
+ printf("\tCleared: %s", ct);
+ else
+ printf("\tCleared: %lld\n", tzero);
printf("\tReferences: [ States: %-18d Rules: %-18d ]\n",
p->pfik_states, p->pfik_rules);
for (i = 0; i < 8; i++) {
-/* $OpenBSD: tape.c,v 1.53 2023/03/08 04:43:07 guenther Exp $ */
+/* $OpenBSD: tape.c,v 1.54 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: tape.c,v 1.26 1997/04/15 07:12:25 lukem Exp $ */
/*
}
if (tmpbuf.c_date != dumpdate || tmpbuf.c_ddate != dumptime) {
time_t t = (time_t)tmpbuf.c_date;
- fprintf(stderr, "Wrong dump date\n\tgot: %s", ctime(&t));
- fprintf(stderr, "\twanted: %s", ctime(&dumpdate));
+ char ct1buf[26], ct2buf[26];
+ char *ct1, *ct2;
+
+ ct1 = ctime_r(&t, ct1buf);
+ ct2 = ctime_r(&dumpdate, ct2buf);
+ if (ct1 && ct2) {
+ fprintf(stderr, "Wrong dump date\n\tgot: %s", ct1);
+ fprintf(stderr, "\twanted: %s", ct2);
+ } else {
+ fprintf(stderr, "Wrong dump date\n\tgot: %lld\n", t);
+ fprintf(stderr, "\twanted: %lld\n", dumpdate);
+ }
volno = 0;
goto again;
}
printdumpinfo(void)
{
time_t t;
+ char *ct;
t = (time_t)spcl.c_date;
- fprintf(stdout, "Dump date: %s", ctime(&t));
+ ct = ctime(&t);
+ if (ct)
+ fprintf(stdout, "Dump date: %s", ct);
+ else
+ fprintf(stdout, "Dump date: %lld\n", t);
t = (time_t)spcl.c_ddate;
- fprintf(stdout, "Dumped from: %s",
- (spcl.c_ddate == 0) ? "the epoch\n" : ctime(&t));
+ ct = ctime(&t);
+ if (ct)
+ fprintf(stdout, "Dumped from: %s",
+ (spcl.c_ddate == 0) ? "the epoch\n" : ct);
+ else
+ fprintf(stdout, "Dumped from: %lld\n", t);
if (spcl.c_host[0] == '\0')
return;
fprintf(stderr, "Level %d dump of %s on %s:%s\n",
-/* $OpenBSD: route.c,v 1.266 2024/04/28 16:43:42 florian Exp $ */
+/* $OpenBSD: route.c,v 1.267 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/*
int n;
char msg[2048];
time_t now;
+ char *ct;
verbose = 1;
for (;;) {
err(1, "read");
}
now = time(NULL);
- printf("got message of size %d on %s", n, ctime(&now));
+ ct = ctime(&now);
+ if (ct)
+ printf("got message of size %d on %s", n, ct);
+ else
+ printf("got message of size %d on %lld\n", n, now);
print_rtmsg((struct rt_msghdr *)msg, n);
}
}
-/* $OpenBSD: savecore.c,v 1.65 2022/12/04 23:50:47 cheloha Exp $ */
+/* $OpenBSD: savecore.c,v 1.66 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */
/*-
get_crashtime(void)
{
time_t dumptime; /* Time the dump was taken. */
+ char *ct;
(void)KREAD(kd_dump, dump_nl[X_TIME].n_value, &dumptime);
if (dumptime == 0) {
syslog(LOG_ERR, "dump time is zero");
return (0);
}
- (void)printf("savecore: system went down at %s", ctime(&dumptime));
+ ct = ctime(&dumptime);
+ if (ct)
+ printf("savecore: system went down at %s", ct);
+ else
+ printf("savecore: system went down %lld seconds after the"
+ " epoch\n", dumptime);
#define SECSPERDAY (24 * 60 * 60)
#define LEEWAY (7 * SECSPERDAY)
if (dumptime < now - LEEWAY || dumptime > now + LEEWAY) {
-/* $OpenBSD: scan_ffs.c,v 1.23 2019/06/28 13:32:46 deraadt Exp $ */
+/* $OpenBSD: scan_ffs.c,v 1.24 2024/05/09 08:35:40 florian Exp $ */
/*
* Copyright (c) 1998 Niklas Hallqvist, Tobias Weingartner
static void usage(void);
+static void
+print_info(int flags, struct fs *sb, long long at, char* lastmount)
+{
+ if (flags & FLAG_LABELS ) {
+ printf("X: %lld %lld 4.2BSD %d %d %d # %s\n",
+ ((off_t)sb->fs_ffs1_size * sb->fs_fsize / 512), at,
+ sb->fs_fsize, sb->fs_bsize, sb->fs_cpg, lastmount);
+ } else {
+ /* XXX 2038 */
+ time_t t = sb->fs_ffs1_time;
+ char *ct = ctime(&t);
+ if (ct)
+ printf("ffs at %lld size %lld mount %s time %s", at,
+ (long long)(off_t) sb->fs_ffs1_size * sb->fs_fsize,
+ lastmount, ct);
+ else
+ printf("ffs at %lld size %lld mount %s time %lld\n", at,
+ (long long)(off_t) sb->fs_ffs1_size * sb->fs_fsize,
+ lastmount, t);
+ }
+}
+
static int
ufsscan(int fd, daddr_t beg, daddr_t end, int flags)
{
sb->fs_ffs1_size);
if (((blk+(n/512)) - lastblk) == (SBSIZE/512)) {
- if (flags & FLAG_LABELS ) {
- printf("X: %lld %lld 4.2BSD %d %d %d # %s\n",
- ((off_t)sb->fs_ffs1_size *
- sb->fs_fsize / 512),
- (long long)(blk + (n/512) -
- (2*SBSIZE/512)),
- sb->fs_fsize, sb->fs_bsize,
- sb->fs_cpg, lastmount);
- } else {
- /* XXX 2038 */
- time_t t = sb->fs_ffs1_time;
-
- printf("ffs at %lld size %lld "
- "mount %s time %s",
- (long long)(blk+(n/512) -
- (2*SBSIZE/512)),
- (long long)(off_t)sb->fs_ffs1_size *
- sb->fs_fsize,
- lastmount, ctime(&t));
- }
-
+ print_info(flags, sb,
+ (long long)(blk + (n/512) -
+ (2*SBSIZE/512)), lastmount);
if (flags & FLAG_SMART) {
off_t size = (off_t)sb->fs_ffs1_size *
sb->fs_fsize;
-/* $OpenBSD: sysctl.c,v 1.260 2024/02/11 21:29:12 bluhm Exp $ */
+/* $OpenBSD: sysctl.c,v 1.261 2024/05/09 08:35:40 florian Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
struct timeval *btp = (struct timeval *)buf;
if (!nflag) {
+ char *ct;
boottime = btp->tv_sec;
- (void)printf("%s%s%s", string, equ, ctime(&boottime));
+ ct = ctime(&boottime);
+ if (ct)
+ (void)printf("%s%s%s", string, equ, ct);
+ else
+ (void)printf("%s%s%lld\n", string, equ,
+ boottime);
} else
(void)printf("%lld\n", (long long)btp->tv_sec);
return;
time_t t = s->tv.tv_sec;
char ct[26];
- ctime_r(&t, ct);
- ct[19] = '\0';
- printf(", %s.%03ld", ct, s->tv.tv_usec / 1000);
+ if (ctime_r(&t, ct)) {
+ ct[19] = '\0';
+ printf(", %s.%03ld", ct, s->tv.tv_usec / 1000);
+ } else
+ printf(", %lld.%03ld", t, s->tv.tv_usec / 1000);
}
}
/** ctime r for autotrust */
static char* autr_ctime_r(time_t* t, char* s)
{
- ctime_r(t, s);
+ if (ctime_r(t, s) == NULL) {
+ s[0] = '?';
+ s[1] = '\n';
+ s[2] = '\0';
+ }
#ifdef USE_WINSOCK
if(strlen(s) > 10 && s[7]==' ' && s[8]=='0')
s[8]=' '; /* fix error in windows ctime */