summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/s6-linux-init-maker.html7
-rw-r--r--src/init/s6-linux-init-maker.c39
2 files changed, 30 insertions, 16 deletions
diff --git a/doc/s6-linux-init-maker.html b/doc/s6-linux-init-maker.html
index 9b148de..1c42767 100644
--- a/doc/s6-linux-init-maker.html
+++ b/doc/s6-linux-init-maker.html
@@ -64,6 +64,7 @@ machine</em>. If it is not the case, the system will fail to boot.
[ -U <em>utmp_user</em> ] \
[ -C ] \
[ -B ] \
+ [ -S ] \
<em>dir</em>
</pre>
@@ -386,6 +387,12 @@ discouraged. On a containerized system (when paired with the <tt>-C</tt>
option), it simply means that these outputs go to the default stdout and
stderr given to the container's <tt>init</tt> - this should generally
not be the default, but might be useful in some cases. </li>
+
+ <li> <tt>-S</tt>&nbsp;: when used with the <tt>-C</tt> option, set up
+the container so the disks are <tt>sync</tt>ed on container halt. By
+default, no sync is performed. This option has no effect when the <tt>-C</tt>
+option is not present: on real machines, a <tt>sync</tt> is <em>always</em>
+performed just before a system halt. </li>
</ul>
<h2> Organization of the created directory </h2>
diff --git a/src/init/s6-linux-init-maker.c b/src/init/s6-linux-init-maker.c
index d7b4a42..d830d0d 100644
--- a/src/init/s6-linux-init-maker.c
+++ b/src/init/s6-linux-init-maker.c
@@ -29,11 +29,11 @@
#ifdef S6_LINUX_INIT_UTMPD_PATH
# include <utmps/config.h>
# define USAGE "s6-linux-init-maker [ -c basedir ] [ -u log_user ] [ -G early_getty_cmd ] [ -1 ] [ -L ] [ -p initial_path ] [ -m initial_umask ] [ -t timestamp_style ] [ -d slashdev ] [ -s env_store ] [ -e initial_envvar ... ] [ -q default_grace_time ] [ -D initdefault ] [ -n | -N ] [ -f skeldir ] [ -U utmp_user ] [ -C ] [ -B ] dir"
-# define OPTION_STRING "c:u:G:1Lp:m:t:d:s:e:E:q:D:nNf:U:CB"
+# define OPTION_STRING "c:u:G:1Lp:m:t:d:s:e:E:q:D:nNf:U:CBS"
# define UTMPS_DIR "utmps"
#else
# define USAGE "s6-linux-init-maker [ -c basedir ] [ -u log_user ] [ -G early_getty_cmd ] [ -1 ] [ -L ] [ -p initial_path ] [ -m initial_umask ] [ -t timestamp_style ] [ -d slashdev ] [ -s env_store ] [ -e initial_envvar ... ] [ -q default_grace_time ] [ -D initdefault ] [ -n | -N ] [ -f skeldir ] [ -C ] [ -B ] dir"
-# define OPTION_STRING "c:u:G:1Lp:m:t:d:s:e:E:q:D:nNf:CB"
+# define OPTION_STRING "c:u:G:1Lp:m:t:d:s:e:E:q:D:nNf:CBS"
#endif
#define dieusage() strerr_dieusage(100, USAGE)
@@ -56,6 +56,7 @@ static int mounttype = 1 ;
static int console = 0 ;
static int logouthookd = 0 ;
static int inns = 0 ;
+static int innssync = 0 ;
static int nologger = 0 ;
static uid_t myuid = -1 ;
static gid_t mygid = -1 ;
@@ -131,20 +132,25 @@ static int container_crash_script (buffer *b, char const *data)
static int container_exit_script (buffer *b, char const *data)
{
(void)data ;
- return put_shebang(b)
- && buffer_puts(b,
- S6_EXTBINPREFIX "s6-envdir -- " S6_LINUX_INIT_TMPFS "/" CONTAINER_RESULTS "\n"
- EXECLINE_EXTBINPREFIX "multisubstitute\n{\n"
- " importas -uD0 -- EXITCODE exitcode\n "
- " importas -uDh -- HALTCODE haltcode\n}\n"
- EXECLINE_EXTBINPREFIX "fdclose 1\n"
- EXECLINE_EXTBINPREFIX "fdclose 2\n"
- EXECLINE_EXTBINPREFIX "wait { }\n"
- EXECLINE_EXTBINPREFIX "ifelse -X { test $HALTCODE = r } { "
- S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fnr }\n"
- EXECLINE_EXTBINPREFIX "ifelse -X { test $HALTCODE = p } { "
- S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fnp }\n"
- EXECLINE_EXTBINPREFIX "exit $EXITCODE\n") >= 0 ;
+ if (!put_shebang(b)
+ || buffer_puts(b,
+ S6_EXTBINPREFIX "s6-envdir -- " S6_LINUX_INIT_TMPFS "/" CONTAINER_RESULTS "\n"
+ EXECLINE_EXTBINPREFIX "multisubstitute\n{\n"
+ " importas -uD0 -- EXITCODE exitcode\n "
+ " importas -uDh -- HALTCODE haltcode\n}\n"
+ EXECLINE_EXTBINPREFIX "fdclose 1\n"
+ EXECLINE_EXTBINPREFIX "fdclose 2\n"
+ EXECLINE_EXTBINPREFIX "wait { }\n"
+ EXECLINE_EXTBINPREFIX "ifelse -X { test $HALTCODE = r } { "
+ S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fr") < 0
+ || (!innssync && buffer_puts(b, "n") < 0)
+ || buffer_puts(b, " }\n"
+ EXECLINE_EXTBINPREFIX "ifelse -X { test $HALTCODE = p } { "
+ S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fp") < 0
+ || (!innssync && buffer_puts(b, "n") < 0)
+ || buffer_puts(b, " }\n"
+ EXECLINE_EXTBINPREFIX "exit $EXITCODE\n") < 0) return 0 ;
+ return 1 ;
}
static int s6_svscan_log_script (buffer *b, char const *data)
@@ -667,6 +673,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
#endif
case 'C' : inns = 1 ; break ;
case 'B' : nologger = 1 ; break ;
+ case 'S' : innssync = 1 ; break ;
default : dieusage() ;
}
}