summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/s6-rc-compile.html13
-rw-r--r--src/s6-rc/s6-rc-compile.c13
2 files changed, 19 insertions, 7 deletions
diff --git a/doc/s6-rc-compile.html b/doc/s6-rc-compile.html
index b429e8e..048f6cb 100644
--- a/doc/s6-rc-compile.html
+++ b/doc/s6-rc-compile.html
@@ -104,6 +104,12 @@ definition directory <em>service</em> is expected to contain the following files
<tt>oneshot</tt>, <tt>longrun</tt> or <tt>bundle</tt>, and a terminating
newline. This file declares the type of service defined by the
directory. </li>
+ <li> An optional regular file named <tt>flag-essential</tt>. The contents of this
+file are irrelevant, only its presence is tested. If this file exists, the service
+will be marked as essential, which means that a <tt>s6-rc -d change <em>foo</em></tt>
+command will not stop the service. Only a <tt>s6-rc -D change <em>foo</em></tt>
+command will. If the service is a bundle, the flag will be propagated to all its
+contents, i.e. all the services it represents will be marked as essential. </li>
</ul>
<h3> For bundles </h3>
@@ -113,7 +119,7 @@ directory. </li>
of service names, one per line. Whitespace at the beginning of a line
is ignored, but trailing whitespace is not. Lines starting with a <tt>#</tt>
character are ignored. The file defines the services that will be
-represented by the bundle named <em>service</em>.
+represented by the bundle named <em>service</em>. </li>
</ul>
<p>
@@ -143,11 +149,6 @@ is ignored, but trailing whitespace is not. Lines starting with a <tt>#</tt>
character are ignored. The file defines the <em>direct dependencies</em> of
<em>service</em>, i.e. the services that must be up in order for
<em>service</em> to work properly. </li>
- <li> An optional regular file named <tt>flag-essential</tt>. The contents of this
-file are irrelevant, only its presence is tested. If this file exists, the service
-will be marked as essential, which means that a <tt>s6-rc -d change <em>foo</em></tt>
-command will not stop the service. Only a <tt>s6-rc -D change <em>foo</em></tt>
-command will. </li>
</ul>
<p>
diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c
index f2b6a84..4414ded 100644
--- a/src/s6-rc/s6-rc-compile.c
+++ b/src/s6-rc/s6-rc-compile.c
@@ -116,6 +116,7 @@ struct bundle_s
unsigned int name ; /* pos in data */
unsigned int n ;
unsigned int listindex ; /* pos in indices */
+ uint32_t annotation_flags ;
} ;
typedef struct before_s before_t, *before_t_ref ;
@@ -351,7 +352,7 @@ static uint32_t read_timeout (int dfd, char const *srcdir, char const *name, cha
return timeout ;
}
-static inline uint32_t read_flags (int dfd, char const *srcdir, char const *name)
+static uint32_t read_flags (int dfd, char const *srcdir, char const *name)
{
static char const *files[32] =
{
@@ -490,6 +491,7 @@ static inline void add_bundle (before_t *be, int dfd, char const *srcdir, char c
add_name(be, srcdir, name, SVTYPE_BUNDLE, &bundle.name, &dummy) ;
if (!add_namelist(be, dfd, srcdir, name, "contents", &bundle.listindex, &bundle.n))
strerr_diefu5sys(111, "open ", srcdir, "/", name, "/contents") ;
+ bundle.annotation_flags = read_flags(dfd, srcdir, name) ;
if (!genalloc_append(bundle_t, &be->bundles, &bundle)) dienomem() ;
}
@@ -689,6 +691,7 @@ static inline unsigned int resolve_bundles (bundle_t const *oldb, bundle_t *newb
for (; i < nbundles ; i++)
{
newb[i].name = oldb[i].name ;
+ newb[i].annotation_flags = oldb[i].annotation_flags ;
recinfo.source = i ;
resolve_bundle_rec(&recinfo, i) ;
}
@@ -899,6 +902,13 @@ static inline void flatlist_services (s6rc_db_t *db, unsigned char const *sarray
}
}
+static inline void propagate_bundle_flags (s6rc_db_t *db, bundle_t const *bundles, unsigned int nbundles, uint32_t const *bdeps)
+{
+ for (unsigned int i = 0 ; i < nbundles ; i++)
+ for (unsigned int j = 0 ; j < bundles[i].n ; j++)
+ db->services[bdeps[bundles[i].listindex + j]].flags |= bundles[i].annotation_flags ;
+}
+
/* Write the compiled database */
@@ -1517,6 +1527,7 @@ int main (int argc, char const *const *argv)
uint32_t deps[db.ndeps << 1] ;
db.deps = deps ;
flatlist_services(&db, sarray) ;
+ propagate_bundle_flags(&db, bundles, nbundles, bdeps) ;
write_compiled(compiled, &db, srcdirs, bundles, nbundles, bdeps, fdhuser, blocking) ;
}
}