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:
parent
a32554879f
commit
34f4dd658b
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user