1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-31 16:57:10 +00:00

I always forget to check before I reboot a system, and while it

boots I try in vain to remember which month or even year this system
was last booted in.

Print out the uptime before rebooting, and give people like me
less (or more as it may be) to think about while the systems boots.
This commit is contained in:
Poul-Henning Kamp 1999-12-06 22:35:51 +00:00
parent 6c36ecd55c
commit 72dfe7a3d7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=54233

View File

@ -111,6 +111,7 @@ static void boot __P((int)) __dead2;
static void dumpsys __P((void));
static int setdumpdev __P((dev_t dev));
static void poweroff_wait __P((void *, int));
static void print_uptime __P((void));
static void shutdown_halt __P((void *junk, int howto));
static void shutdown_panic __P((void *junk, int howto));
static void shutdown_reset __P((void *junk, int howto));
@ -164,6 +165,33 @@ shutdown_nice()
static int waittime = -1;
static struct pcb dumppcb;
static void
print_uptime()
{
int f;
struct timespec ts;
getnanouptime(&ts);
printf("Uptime: ");
f = 0;
if (ts.tv_sec >= 86400) {
printf("%ldd", ts.tv_sec / 86400);
ts.tv_sec %= 86400;
f = 1;
}
if (f || ts.tv_sec >= 3600) {
printf("%ldh", ts.tv_sec / 3600);
ts.tv_sec %= 3600;
f = 1;
}
if (f || ts.tv_sec >= 60) {
printf("%ldm", ts.tv_sec / 60);
ts.tv_sec %= 60;
f = 1;
}
printf("%lds\n", ts.tv_sec);
}
/*
* Go through the rigmarole of shutting down..
* this used to be in machdep.c but I'll be dammned if I could see
@ -261,6 +289,8 @@ boot(howto)
DELAY(100000); /* wait for console output to finish */
}
print_uptime();
/*
* Ok, now do things that assume all filesystem activity has
* been completed.