summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1999-12-06 22:35:51 +0000
committerphk <phk@FreeBSD.org>1999-12-06 22:35:51 +0000
commit34f4dd658bb7b6a79398d4927571a3eaba0267bd (patch)
tree562bc77a9dd4e6841b81c5962fb8b41f88172e7a /sys/kern
parenta32554879fbb77f4a0e8a79c20c3c56d41721ae5 (diff)
downloadFreeBSD-src-34f4dd658bb7b6a79398d4927571a3eaba0267bd.zip
FreeBSD-src-34f4dd658bb7b6a79398d4927571a3eaba0267bd.tar.gz
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.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_shutdown.c30
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.
OpenPOWER on IntegriCloud