summaryrefslogtreecommitdiff
path: root/src/shutdown/s6-linux-init-shutdownd.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-11-30 18:27:41 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-11-30 18:27:41 +0000
commit2fa0acdd248c006270010196ad02e530d8ab09ea (patch)
tree0c5f946f06a1c98d2a35c8eb350dc62d3e97a8ff /src/shutdown/s6-linux-init-shutdownd.c
parentc1171b979c236ec2c486bc12e4866112a12b9a84 (diff)
downloads6-linux-init-2fa0acdd248c006270010196ad02e530d8ab09ea.tar.xz
Adapt to skalibs-2.10.0.0 and s6-2.10.0.0
Diffstat (limited to 'src/shutdown/s6-linux-init-shutdownd.c')
-rw-r--r--src/shutdown/s6-linux-init-shutdownd.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/shutdown/s6-linux-init-shutdownd.c b/src/shutdown/s6-linux-init-shutdownd.c
index 5e681e1..b646b5c 100644
--- a/src/shutdown/s6-linux-init-shutdownd.c
+++ b/src/shutdown/s6-linux-init-shutdownd.c
@@ -43,6 +43,7 @@
#define DOTPREFIXLEN (sizeof(DOTPREFIX) - 1)
#define DOTSUFFIX ":XXXXXX"
#define DOTSUFFIXLEN (sizeof(DOTSUFFIX) - 1)
+#define CONTAINERDIR S6_LINUX_INIT_TMPFS "/" CONTAINER_RESULTS
#define USAGE "s6-linux-init-shutdownd [ -c basedir ] [ -g gracetime ] [ -C ] [ -B ]"
#define dieusage() strerr_dieusage(100, USAGE)
@@ -160,6 +161,14 @@ static inline void prepare_stage4 (char const *basedir, char what)
int fd ;
char buf[512] ;
size_t sabase = satmp.len ;
+ if (inns)
+ {
+ char s[2] = { what, '\n' } ;
+ if (mkdir(CONTAINERDIR, 0755) < 0 && errno != EEXIST)
+ strerr_diefu1sys(111, "mkdir " CONTAINERDIR) ;
+ if (!openwritenclose_unsafe(CONTAINERDIR "/haltcode", s, 2))
+ strerr_diefu1sys(111, "write to " CONTAINERDIR "/haltcode") ;
+ }
unlink_void(STAGE4_FILE ".new") ;
fd = open_excl(STAGE4_FILE ".new") ;
if (fd == -1) strerr_diefu3sys(111, "open ", STAGE4_FILE ".new", " for writing") ;
@@ -174,9 +183,8 @@ static inline void prepare_stage4 (char const *basedir, char what)
|| (!nologger && buffer_puts(&b,
EXECLINE_EXTBINPREFIX "foreground { "
S6_EXTBINPREFIX "s6-svc -Xh -- " SCANPREFIX LOGGER_SERVICEDIR " }\n ") < 0)
- || buffer_puts(&b, S6_EXTBINPREFIX "s6-svscanctl -") < 0
- || buffer_put(&b, what == 'h' ? "s" : &what, 1) < 0
- || buffer_putsflush(&b, "b -- " SCANDIRFULL "\n}\n") < 0)
+ || buffer_puts(&b,
+ S6_EXTBINPREFIX "s6-svscanctl -b -- " SCANDIRFULL "\n}\n") < 0)
strerr_diefu2sys(111, "write to ", STAGE4_FILE ".new") ;
}
else