summaryrefslogtreecommitdiff
path: root/src/shutdown/s6-linux-init-shutdown.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shutdown/s6-linux-init-shutdown.c')
-rw-r--r--src/shutdown/s6-linux-init-shutdown.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/shutdown/s6-linux-init-shutdown.c b/src/shutdown/s6-linux-init-shutdown.c
index 85c3ae3..ce7f01f 100644
--- a/src/shutdown/s6-linux-init-shutdown.c
+++ b/src/shutdown/s6-linux-init-shutdown.c
@@ -190,7 +190,7 @@ static inline void access_control (void)
strerr_dief1x(1, "no authorized users logged in") ;
}
-static void wallit (uint64_t t, char const *msg)
+static inline void wallit (uint64_t t, char const *msg)
{
struct iovec v[11] ;
unsigned int m = 11 ;
@@ -199,45 +199,52 @@ static void wallit (uint64_t t, char const *msg)
char fmtm[UINT64_FMT] ;
char fmts[UINT64_FMT] ;
v[--m].iov_base = "\n" ; v[m].iov_len = 1 ;
- v[--m].iov_base = HPR_WALL_POST ; v[m].iov_len = sizeof(HPR_WALL_POST) - 1 ;
- if (!t)
+ if (msg)
{
- v[--m].iov_base = "NOW" ; v[m].iov_len = 3 ;
+ v[--m].iov_base = (char *)msg ; v[m].iov_len = strlen(msg) ;
}
else
{
- if (t % 60)
+ v[--m].iov_base = HPR_WALL_POST ; v[m].iov_len = sizeof(HPR_WALL_POST) - 1 ;
+ if (!t)
{
- v[--m].iov_base = " seconds" ; v[m].iov_len = 8 ;
- v[--m].iov_base = fmts ; v[m].iov_len = uint64_fmt(fmts, t % 60) ;
+ v[--m].iov_base = "NOW" ; v[m].iov_len = 3 ;
}
- t /= 60 ;
- if (t)
+ else
{
if (t % 60)
{
- v[--m].iov_base = " minutes " ; v[m].iov_len = 9 ;
- v[--m].iov_base = fmtm ; v[m].iov_len = uint64_fmt(fmtm, t % 60) ;
+ v[--m].iov_base = " seconds" ; v[m].iov_len = 8 ;
+ v[--m].iov_base = fmts ; v[m].iov_len = uint64_fmt(fmts, t % 60) ;
}
t /= 60 ;
if (t)
{
- if (t % 24)
+ if (t % 60)
{
- v[--m].iov_base = " hours " ; v[m].iov_len = 7 ;
- v[--m].iov_base = fmth ; v[m].iov_len = uint64_fmt(fmth, t % 24) ;
+ v[--m].iov_base = " minutes " ; v[m].iov_len = 9 ;
+ v[--m].iov_base = fmtm ; v[m].iov_len = uint64_fmt(fmtm, t % 60) ;
}
- t /= 24 ;
+ t /= 60 ;
if (t)
{
- v[--m].iov_base = " days " ; v[m].iov_len = 6 ;
- v[--m].iov_base = fmtd ; v[m].iov_len = uint64_fmt(fmtd, t) ;
+ if (t % 24)
+ {
+ v[--m].iov_base = " hours " ; v[m].iov_len = 7 ;
+ v[--m].iov_base = fmth ; v[m].iov_len = uint64_fmt(fmth, t % 24) ;
+ }
+ t /= 24 ;
+ if (t)
+ {
+ v[--m].iov_base = " days " ; v[m].iov_len = 6 ;
+ v[--m].iov_base = fmtd ; v[m].iov_len = uint64_fmt(fmtd, t) ;
+ }
}
}
}
+ v[--m].iov_base = HPR_WALL_PRE ; v[m].iov_len = sizeof(HPR_WALL_PRE) - 1 ;
}
- v[--m].iov_base = HPR_WALL_PRE ; v[m].iov_len = sizeof(HPR_WALL_PRE) - 1 ;
- hpr_wallv(v + m, 9 - m) ;
+ hpr_wallv(v + m, 11 - m) ;
}
/* main */
@@ -301,7 +308,7 @@ int main (int argc, char const *const *argv)
if (!argc) dieusage() ;
parse_time(&when, argv[0]) ;
tain_sub(&when, &when, &STAMP) ;
- if (argv[1]) wallit(tai_sec(tain_secp(&when)), argv[1]) ;
+ wallit(tai_sec(tain_secp(&when)), argv[1]) ;
if (what < 4)
{
if (gracetime > 300)