diff options
-rw-r--r-- | sys/kern/kern_shutdown.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 18272ad..6f616ae 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -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. |