commit 691c69e626e4ceb85567a5288348bd04378fd410 parent 1719a60278cf36558b568349c0c9f9b5eb91c999 Author: Laurent Bercot <ska-skaware@skarnet.org> Date: Mon, 30 Aug 2021 19:11:44 +0000 s6-svlink, s6-svunlink, .h changes Renamed from s6-svdir-(un)link. Doc added. Full functionality added. Still need to be tested. Unrelated: .h names simplified. Signed-off-by: Laurent Bercot <ska@appnovation.com> Diffstat:
86 files changed, 1255 insertions(+), 914 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -28,8 +28,8 @@ /s6-svdt /s6-svdt-clear /s6-permafailon -/s6-svdir-link -/s6-svdir-unlink +/s6-svlink +/s6-svunlink /s6-envdir /s6-envuidgid /s6-fghack diff --git a/NEWS b/NEWS @@ -8,6 +8,8 @@ In 2.11.0.0 - s6-svwait now supports -r and -R options to wait for restarts. - New service directory file: lock-fd, to take a lock before starting a service, protecting against concurrent instances. + - s6/lock.h, s6/supervise.h, s6/fdholder.h: simpler header names + - New binaries: s6-svlink, s6-svunlink In 2.10.0.3 diff --git a/doc/index.html b/doc/index.html @@ -174,6 +174,8 @@ a user interface to control those processes and monitor service states. <li><a href="s6-svok.html">The <tt>s6-svok</tt> program</a></li> <li><a href="s6-svstat.html">The <tt>s6-svstat</tt> program</a></li> <li><a href="s6-svperms.html">The <tt>s6-svperms</tt> program</a></li> +<li><a href="s6-svlink.html">The <tt>s6-svlink</tt> program</a></li> +<li><a href="s6-svunlink.html">The <tt>s6-svunlink</tt> program</a></li> <li><a href="s6-svwait.html">The <tt>s6-svwait</tt> program</a></li> <li><a href="s6-svlisten1.html">The <tt>s6-svlisten1</tt> program</a></li> <li><a href="s6-svlisten.html">The <tt>s6-svlisten</tt> program</a></li> diff --git a/doc/libs6/fdholder.html b/doc/libs6/fdholder.html @@ -0,0 +1,229 @@ +<html> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta http-equiv="Content-Language" content="en" /> + <title>s6: the s6-fdholder library interface</title> + <meta name="Description" content="s6: the s6-fdholder library interface" /> + <meta name="Keywords" content="s6 fdholder file descriptor fd holding fd-passing library interface" /> + <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> + </head> +<body> + +<p> +<a href="index.html">libs6</a><br /> +<a href="../">s6</a><br /> +<a href="//skarnet.org/software/">Software</a><br /> +<a href="//skarnet.org/">skarnet.org</a> +</p> + +<h1> The <tt>fdholder</tt> library interface </h1> + +<p> + The <tt>fdholder</tt> library provides an API for clients +wanting to communicate with a +<a href="../s6-fdholderd.html">s6-fdholderd</a> daemon. +</p> + +<h2> Programming </h2> + +<p> + Check the <tt>s6/fdholder.h</tt> header for the +exact function prototypes. +</p> + +<h3> A programming example </h3> + +<p> + The <tt>src/fdholder/s6-fdholder-*.c</tt> files in the s6 package, +for instance, illustrate how to use the s6-fdholder library. +</p> + +<h3> Synchronous functions with a specified maximum execution time </h3> + +<p> + The explanation given +<a href="ftrigr.html#synctimed">there</a> applies here too: the +functions documented in this page are synchronous, but can return +early if the deadline is reached, in which case the connection to the +server should be closed immediately because no protocol consistency is +guaranteed. +</p> + +<p> + The <a href="../s6-fdholderd.html">s6-fdholderd</a> server should be +very quick to answer queries, so this mechanism is provided as a simple +security against programming errors - for instance, connecting to the +wrong daemon. +</p> + +<h3> Starting and ending a session </h3> + +<pre> +s6_fdholder_t a = S6_FDHOLDER_ZERO ; +int fd = 6 ; + +tain_now_g() ; + +s6_fdholder_init(&a, fd) ; +(...) +s6_fdholder_free(&a) ; +</pre> + +<p> +<tt>s6_fdholder_init</tt> assumes that <em>fd</em> is a socket already +connected to an s6-fdholderd daemon. The <em>a</em> structure must be +initialized to <tt>S6_FDHOLDER_ZERO</tt> before use. +</p> + +<p> +<a href="//skarnet.org/software/skalibs/libstddjb/tai.html">tain_now_g()</a> +initializes a global variable that keeps track of the current time, for +use with later functions. +</p> + +<p> +<tt>s6_fdholder_free</tt> frees the resources occupied by <em>a</em>. +It does not, however, close <em>fd</em>. You should manually close it +to end the connection to the server. Note that if your program has been +started by <a href="../s6-ipcclient.html">s6-ipcclient</a>, both fds 6 +and 7 are open (and refer to the same socket), so you should close both. +</p> + +<p> + Alternatively, if your connection to s6-fdholderd has not been created yet, +you can use the following functions: +</p> + +<h4> <code> int s6_fdholder_start (s6_fdholder_t *a, char const *path, tain_t const *deadline, tain_t *stamp) </code> </h4> + +<p> + Starts a session with a <a href="../s6-fdholderd.html">s6-fdholderd</a> +instance listening on <em>path</em>. <em>a</em> must be initialized to +S6_FDHOLDER_ZERO before calling this function. On success, returns nonzero +and <em>a</em> can be used as a handle for the next <tt>s6_fdholder_*</tt> +function calls. On failure, returns 0, and sets errno. +</p> + +<h4> <code> void s6_fdholder_end (s6_fdholder_t *a) </code> </h4> + +<p> + Ends the current session and frees all allocated resources. If needed, +<em>a</em> is immediately reusable for another <tt>s6_fdholder_start</tt> call. +</p> + +<h3> Storing a fd </h3> + +<pre> +int r ; +int fd ; +tain_t limit = TAIN_INFINITE ; +char const *id = "my_identifier" ; +r = s6_fdholder_store_g(&a, fd, id, &limit, &deadline) ; +</pre> + +<p> +<tt>s6_fdholder_store</tt> (and its variant <tt>s6_fdholder_store_g</tt> +that uses the global timestamp variable) attempts to store a copy of +descriptor <em>fd</em> into s6-fdholderd, using identifier <em>id</em>, +with an expiration date of <em>limit</em>. In this example, <em>limit</em> +is TAIN_INFINITE, which means no expiration date. The operation should +return before <em>deadline</em>, else it will automatically return +0 ETIMEDOUT. The result is 1 on success and 0 on failure, with an +<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. +</p> + +<h3> Deleting a fd </h3> + +<pre> +fd = s6_fdholder_delete_g(&a, id, &deadline) ; +</pre> + +<p> +<tt>s6_fdholder_delete</tt> attempts to delete the file descriptor +identified by <em>id</em>. It returns 1 on success and 0 on failure, +with an +<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. +</p> + +<h3> Retrieving a fd </h3> + +<pre> +fd = s6_fdholder_retrieve_g(&a, id, &deadline) ; +</pre> + +<p> +<tt>s6_fdholder_retrieve</tt> attempts to retrieve the file descriptor +identified by <em>id</em>. It returns a valid fd number on success, and +-1 on failure, with an +<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. +</p> + +<p> + <tt>s6_fdholder_retrieve_delete()</tt> performs a retrieval and a +deletion at the same time, if the client is authorized to do so. +</p> + +<h3> Listing the identifiers held by the server </h3> + +<pre> +stralloc list = STRALLOC_ZERO ; +int n ; +n = s6_fdholder_list_g(&a, &list, &deadline) ; +</pre> + +<p> +<tt>s6_fdholder_list</tt> gets the list of all identifiers currently +held by the server. It stores it into the +<a href="//skarnet.org/software/skalibs/libstddjb/stralloc.html">stralloc</a> +<em>list</em>, as a series of null-terminated strings, one after the other. +There are <em>n</em> such strings. The function returns <em>n</em> on +success, or -1 on failure, with an +<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. +</p> + + +<h3> Reading a dump </h3> + +<pre> +genalloc dump = GENALLOC_ZERO ; +r = s6_fdholder_getdump_g(&a, &dump, &deadline) ; +</pre> + +<p> +<tt>s6_fdholder_getdump</tt> attempts to retrieve the whole set of +descriptors from the server. +It returns 1 on success, and 0 on failure, with an +<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. +The set is stored into the +<a href="//skarnet.org/software/skalibs/libstddjb/genalloc.html">genalloc</a> +<em>dump</em>, which is to be interpreted as a stralloc containing an array +of <tt>s6_fdholder_fd_t</tt>. +</p> + +<p> +<tt>genalloc_s(s6_fdholder_fd_t, &dump)</tt> is a pointer to this array, and +<tt>genalloc_len(s6_fdholder_fd_t, &dump)</tt> is the number of elements +in the array. A <tt>s6_fdholder_fd_t</tt> contains at least a descriptor +number, an identifier, and an expiration date, see the +<tt>s6/s6-fdholder.h</tt> header file. +</p> + +<h3> Writing a dump </h3> + +<pre> +unsigned int dumplen ; +s6_fdholder_fd_t const *dumparray ; +r = s6_fdholder_setdump_g(&a, &dumparray, dumplen, &deadline) ; +</pre> + +<p> +<tt>s6_fdholder_setdump</tt> attempts to send a set of descriptors to the +server. The descriptors are contained in the array <em>dumparray</em> of +length <em>dumplen</em>. The function +returns 1 on success, and 0 on failure, with an +<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. +</p> + +</body> +</html> diff --git a/doc/libs6/index.html b/doc/libs6/index.html @@ -65,9 +65,9 @@ provides functions to check credentials against configuration files. </li> functions to subscribe to fifodirs and be notified of events. </li> <li> The <a href="ftrigw.html">s6/ftrigw.h</a> header provides functions to manage fifodirs and send notifications to them. </li> - <li> The <a href="s6lock.html">s6/s6lock.h</a> header provides + <li> The <a href="lock.html">s6/lock.h</a> header provides functions to acquire locks with a timeout. </li> - <li> The <a href="s6-fdholder.html">s6/s6-fdholder.h</a> header provides + <li> The <a href="fdholder.html">s6/fdholder.h</a> header provides functions to communicate with a <a href="../s6-fdholderd.html">s6-fdholderd</a> server and exchange file descriptors with it. </li> diff --git a/doc/libs6/lock.html b/doc/libs6/lock.html @@ -0,0 +1,239 @@ +<html> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta http-equiv="Content-Language" content="en" /> + <title>s6: the s6lock library interface</title> + <meta name="Description" content="s6: the s6lock library interface" /> + <meta name="Keywords" content="s6 timed lock s6lock libs6 library interface" /> + <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> + </head> +<body> + +<p> +<a href="index.html">libs6</a><br /> +<a href="../">s6</a><br /> +<a href="//skarnet.org/software/">Software</a><br /> +<a href="//skarnet.org/">skarnet.org</a> +</p> + +<h1> The <tt>s6lock</tt> library interface </h1> + +<h2> General information </h2> + +<p> + <tt>s6lock</tt> is a C interface to timed locks. Unix natively provides +locks, but the locking primitives are synchronous, so either they are +unbounded in execution time or they require polling. s6lock provides +poll-free locks that can timeout during attempted acquisition. +</p> + +<h2> Programming </h2> + +<ul> + <li> Check the <tt>s6/lock.h</tt> header +for the prototypes. The functions documented here are +often simplified macros, for instance relying on the STAMP global variable +to hold the current time. Fully reentrant functions with more control +options are usually available. </li> + <li> Given the nature of the s6lock library, it makes sense to use a +<a href="../localservice.html">s6lockd service</a> concurrently +accessed by several applications using such locks to gate shared +resources. </li> + <li> If you're not using an s6lockd service, +make sure your application is not disturbed by children it doesn't +know it has. Using nonblocking waits, ignoring pids you don't know, and +using a +<a href="//skarnet.org/software/skalibs/libstddjb/selfpipe.html">self-pipe</a> +if your application is built around an event loop, are good programming +practices. </li> +</ul> + +<h3> Starting and ending a session </h3> + +<pre> +s6lock_t a = S6LOCK_ZERO ; +tain_t deadline ; + +tain_now_g() ; +tain_addsec_g(&deadline, 2) + +char const *path = S6LOCK_IPCPATH ; +s6lock_start_g(&a, path, &deadline) ; +// char const *lockdir = "/tmp/lock" ; +// s6lock_startf_g(&a, lockdir, &deadline) ; +</pre> + +<p> +<tt>s6lock_start_g</tt> starts a session by connecting to an s6lockd service +listening on <em>path</em>. The working directory is set by the administrator +of the service. <br /> +<tt>s6lock_startf_g</tt> starts a session with an s6lockd process as a child, +using <em>lockdir</em> as its working directory. +<br /> +<tt>a</tt> is an s6lock_t structure that must be declared in the stack and +initialized to S6LOCK_ZERO. +If the session initialization fails, the function returns 0 and errno is set; +else the function returns 1. +</p> +<p> +If the absolute time <tt>deadline</tt> is reached and the function +has not returned yet, it immediately returns 0 with errno set to ETIMEDOUT. + +Only local interprocess communications are involved; unless your system is +heavily overloaded, the function should return near-instantly. One or two +seconds of delay between the current time and <tt>deadline</tt> should be +enough: if the function takes more than that to return, then there is a +problem with the underlying processes. +</p> + +<p> + You can have more than one session open in parallel, by declaring +several distinct <tt>s6lock_t</tt> structures and calling +<tt>s6lock_startf_g</tt> (or <tt>s6lock_start_g</tt>) more than once. +However, one single session can handle +virtually as many concurrent locks as your application needs, so +opening several sessions is only useful if you need to acquire locks +in various distinct lock directories. +</p> + +<pre> +s6lock_end(&a) ; +</pre> + +<p> +<tt>s6lock_end</tt> frees all the resources used by the session. The +<tt>a</tt> structure is then reusable for another session. +</p> + +<h3> Acquiring and releasing locks </h3> + +<pre> +uint16_t id ; +char const *file = "lockfile" ; +tain_t limit ; +tain_t deadline ; + +int r = s6lock_acquire_sh_g (&a, &id, file, &limit, &deadline) ; +/* int r = s6lock_acquire_ex_g (&a, &id, file, &limit, &deadline) ; */ +r = s6lock_release_g(&a, id, &deadline) ; +</pre> + +<p> +<tt>s6lock_acquire_sh_g</tt> instructs the +<a href="s6lockd.html">s6lockd daemon</a>, related to the open +session represented by the <tt>a</tt> handle, to try and acquire a +shared lock on the +<em>file</em> file located under that daemon's working directory +(typically <tt>/var/lock</tt>). <em>file</em> will be interpreted as +relative to the daemon's working directory even if it starts with a +slash; however, slashes in the middle of <em>file</em> are likely to +result in an error. +</p> + +<p> +<em>limit</em> and <em>deadline</em> are two absolute dates. +<em>deadline</em> is a deadline for the execution of the +function: if by <em>deadline</em> the function has not returned, +then it instantly returns 0 and sets errno to ETIMEDOUT. The +function is normally near-instantaneous, so <em>deadline</em> can +be very close in the future and serves only as a protection against +malicious servers. <em>limit</em> is the acquisition deadline: if +by <em>limit</em> the daemon still has not been able to acquire a lock +on <em>file</em>, then it will report a timeout to the client. +</p> + +<p> +The function returns 1 in case of success, or 0 if an error occurs, +with errno set to a suitable value. If it succeeds, then a 16-bit +number is stored into *<em>id</em>; this number serves as an identifier +for this lock. +</p> + +<p> +<tt>s6lock_acquire_ex_g</tt> works just like <tt>s6lock_acquire_sh_g</tt>, +except that the daemon tries to acquire an exclusive lock. +</p> + +<p> +<tt>s6lock_release_g</tt> releases the lock identified by <em>id</em>. +It normally returns 1. It can return 0 with errno set to a suitable +value if it fails. <em>id</em> is not valid after the corresponding +lock has been released. The function normally returns instantly, with +<em>deadline</em> as a safeguard. +</p> + +<h3> Asynchronously waiting for locks </h3> + +<p> +<em> (from now on, the functions are listed with their prototypes instead +of usage examples.) </em> +</p> + +<pre> +int s6lock_fd (s6lock_t const *a) +</pre> + +<p> + Returns a file descriptor to select on for reading. Do not +<tt>read()</tt> it though. +</p> + +<pre> +int s6lock_update (s6lock_t *a) +</pre> + +<p> + Call this function whenever the fd checks readability: it will +update <em>a</em>'s internal structures with information from the +<a href="s6lockd.html">s6lockd</a> daemon. It returns -1 if an error +occurs; in case of success, it returns the number of identifiers for +which something happened. +</p> + +<p> + When <tt>s6lock_update</tt> returns, +<tt>genalloc_s(uint16_t, &a->list)</tt> points to an array of +<tt>genalloc_len(uint16_t, &a->list)</tt> 16-bit unsigned +integers. Those integers are ids waiting to be passed to +<tt>s6lock_check</tt>. +</p> + +<pre> +int s6lock_check (s6lock_t *a, uint16_t id, char *what) +</pre> + +<p> + Checks whether the lock identified by <em>id</em> has +been acquired. Use after a call to <tt>s6lock_update()</tt>. +</p> + +<ul> + <li> If an error occurred, returns -1 and sets errno. The error +number may have been transmitted from +<a href="s6lockd.html">s6lockd</a>. </li> + <li> If the lock has not been acquired yet, returns 0. </li> + <li> If the lock has been acquired, returns 1. </li> +</ul> + +<h3> Synchronously waiting for locks </h3> + +<p> +<code> int s6lock_wait_or_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline) </code> <br /> +Synchronously waits for <em>one</em> of the locks represented by the array pointed to +by <em>idlist</em> of length <em>n</em> to be acquired. Returns -1 if it fails, +or a nonnegative number on success, which is the index in <em>idlist</em> of the +acquired lock's id. If no result has been obtained by <em>deadline</em>, the +function returns -1 ETIMEDOUT. +</p> + +<p> +<code> int s6lock_wait_and_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline) </code> <br /> +Synchronously waits for <em>all</em> of the locks represented by the array pointed to +by <em>idlist</em> of length <em>n</em> to be acquired. Returns -1 if it fails and +0 if it succeeds. If no result has been obtained by <em>deadline</em>, the +function returns -1 ETIMEDOUT. +</p> + +</body> +</html> diff --git a/doc/libs6/s6-fdholder.html b/doc/libs6/s6-fdholder.html @@ -1,229 +0,0 @@ -<html> - <head> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta http-equiv="Content-Language" content="en" /> - <title>s6: the s6-fdholder library interface</title> - <meta name="Description" content="s6: the s6-fdholder library interface" /> - <meta name="Keywords" content="s6 fdholder file descriptor fd holding fd-passing library interface" /> - <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> - </head> -<body> - -<p> -<a href="index.html">libs6</a><br /> -<a href="../">s6</a><br /> -<a href="//skarnet.org/software/">Software</a><br /> -<a href="//skarnet.org/">skarnet.org</a> -</p> - -<h1> The <tt>s6-fdholder</tt> library interface </h1> - -<p> - The <tt>s6-fdholder</tt> library provides an API for clients -wanting to communicate with a -<a href="../s6-fdholderd.html">s6-fdholderd</a> daemon. -</p> - -<h2> Programming </h2> - -<p> - Check the <tt>s6/s6-fdholder.h</tt> header for the -exact function prototypes. -</p> - -<h3> A programming example </h3> - -<p> - The <tt>src/fdholder/s6-fdholder-*.c</tt> files in the s6 package, -for instance, illustrate how to use the s6-fdholder library. -</p> - -<h3> Synchronous functions with a specified maximum execution time </h3> - -<p> - The explanation given -<a href="ftrigr.html#synctimed">there</a> applies here too: the -functions documented in this page are synchronous, but can return -early if the deadline is reached, in which case the connection to the -server should be closed immediately because no protocol consistency is -guaranteed. -</p> - -<p> - The <a href="../s6-fdholderd.html">s6-fdholderd</a> server should be -very quick to answer queries, so this mechanism is provided as a simple -security against programming errors - for instance, connecting to the -wrong daemon. -</p> - -<h3> Starting and ending a session </h3> - -<pre> -s6_fdholder_t a = S6_FDHOLDER_ZERO ; -int fd = 6 ; - -tain_now_g() ; - -s6_fdholder_init(&a, fd) ; -(...) -s6_fdholder_free(&a) ; -</pre> - -<p> -<tt>s6_fdholder_init</tt> assumes that <em>fd</em> is a socket already -connected to an s6-fdholderd daemon. The <em>a</em> structure must be -initialized to <tt>S6_FDHOLDER_ZERO</tt> before use. -</p> - -<p> -<a href="//skarnet.org/software/skalibs/libstddjb/tai.html">tain_now_g()</a> -initializes a global variable that keeps track of the current time, for -use with later functions. -</p> - -<p> -<tt>s6_fdholder_free</tt> frees the resources occupied by <em>a</em>. -It does not, however, close <em>fd</em>. You should manually close it -to end the connection to the server. Note that if your program has been -started by <a href="../s6-ipcclient.html">s6-ipcclient</a>, both fds 6 -and 7 are open (and refer to the same socket), so you should close both. -</p> - -<p> - Alternatively, if your connection to s6-fdholderd has not been created yet, -you can use the following functions: -</p> - -<h4> <code> int s6_fdholder_start (s6_fdholder_t *a, char const *path, tain_t const *deadline, tain_t *stamp) </code> </h4> - -<p> - Starts a session with a <a href="../s6-fdholderd.html">s6-fdholderd</a> -instance listening on <em>path</em>. <em>a</em> must be initialized to -S6_FDHOLDER_ZERO before calling this function. On success, returns nonzero -and <em>a</em> can be used as a handle for the next <tt>s6_fdholder_*</tt> -function calls. On failure, returns 0, and sets errno. -</p> - -<h4> <code> void s6_fdholder_end (s6_fdholder_t *a) </code> </h4> - -<p> - Ends the current session and frees all allocated resources. If needed, -<em>a</em> is immediately reusable for another <tt>s6_fdholder_start</tt> call. -</p> - -<h3> Storing a fd </h3> - -<pre> -int r ; -int fd ; -tain_t limit = TAIN_INFINITE ; -char const *id = "my_identifier" ; -r = s6_fdholder_store_g(&a, fd, id, &limit, &deadline) ; -</pre> - -<p> -<tt>s6_fdholder_store</tt> (and its variant <tt>s6_fdholder_store_g</tt> -that uses the global timestamp variable) attempts to store a copy of -descriptor <em>fd</em> into s6-fdholderd, using identifier <em>id</em>, -with an expiration date of <em>limit</em>. In this example, <em>limit</em> -is TAIN_INFINITE, which means no expiration date. The operation should -return before <em>deadline</em>, else it will automatically return -0 ETIMEDOUT. The result is 1 on success and 0 on failure, with an -<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. -</p> - -<h3> Deleting a fd </h3> - -<pre> -fd = s6_fdholder_delete_g(&a, id, &deadline) ; -</pre> - -<p> -<tt>s6_fdholder_delete</tt> attempts to delete the file descriptor -identified by <em>id</em>. It returns 1 on success and 0 on failure, -with an -<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. -</p> - -<h3> Retrieving a fd </h3> - -<pre> -fd = s6_fdholder_retrieve_g(&a, id, &deadline) ; -</pre> - -<p> -<tt>s6_fdholder_retrieve</tt> attempts to retrieve the file descriptor -identified by <em>id</em>. It returns a valid fd number on success, and --1 on failure, with an -<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. -</p> - -<p> - <tt>s6_fdholder_retrieve_delete()</tt> performs a retrieval and a -deletion at the same time, if the client is authorized to do so. -</p> - -<h3> Listing the identifiers held by the server </h3> - -<pre> -stralloc list = STRALLOC_ZERO ; -int n ; -n = s6_fdholder_list_g(&a, &list, &deadline) ; -</pre> - -<p> -<tt>s6_fdholder_list</tt> gets the list of all identifiers currently -held by the server. It stores it into the -<a href="//skarnet.org/software/skalibs/libstddjb/stralloc.html">stralloc</a> -<em>list</em>, as a series of null-terminated strings, one after the other. -There are <em>n</em> such strings. The function returns <em>n</em> on -success, or -1 on failure, with an -<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. -</p> - - -<h3> Reading a dump </h3> - -<pre> -genalloc dump = GENALLOC_ZERO ; -r = s6_fdholder_getdump_g(&a, &dump, &deadline) ; -</pre> - -<p> -<tt>s6_fdholder_getdump</tt> attempts to retrieve the whole set of -descriptors from the server. -It returns 1 on success, and 0 on failure, with an -<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. -The set is stored into the -<a href="//skarnet.org/software/skalibs/libstddjb/genalloc.html">genalloc</a> -<em>dump</em>, which is to be interpreted as a stralloc containing an array -of <tt>s6_fdholder_fd_t</tt>. -</p> - -<p> -<tt>genalloc_s(s6_fdholder_fd_t, &dump)</tt> is a pointer to this array, and -<tt>genalloc_len(s6_fdholder_fd_t, &dump)</tt> is the number of elements -in the array. A <tt>s6_fdholder_fd_t</tt> contains at least a descriptor -number, an identifier, and an expiration date, see the -<tt>s6/s6-fdholder.h</tt> header file. -</p> - -<h3> Writing a dump </h3> - -<pre> -unsigned int dumplen ; -s6_fdholder_fd_t const *dumparray ; -r = s6_fdholder_setdump_g(&a, &dumparray, dumplen, &deadline) ; -</pre> - -<p> -<tt>s6_fdholder_setdump</tt> attempts to send a set of descriptors to the -server. The descriptors are contained in the array <em>dumparray</em> of -length <em>dumplen</em>. The function -returns 1 on success, and 0 on failure, with an -<a href="../s6-fdholder-errorcodes.html">appropriate</a> errno code. -</p> - -</body> -</html> diff --git a/doc/libs6/s6lock.html b/doc/libs6/s6lock.html @@ -1,239 +0,0 @@ -<html> - <head> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta http-equiv="Content-Language" content="en" /> - <title>s6: the s6lock library interface</title> - <meta name="Description" content="s6: the s6lock library interface" /> - <meta name="Keywords" content="s6 timed lock s6lock libs6 library interface" /> - <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> - </head> -<body> - -<p> -<a href="index.html">libs6</a><br /> -<a href="../">s6</a><br /> -<a href="//skarnet.org/software/">Software</a><br /> -<a href="//skarnet.org/">skarnet.org</a> -</p> - -<h1> The <tt>s6lock</tt> library interface </h1> - -<h2> General information </h2> - -<p> - <tt>s6lock</tt> is a C interface to timed locks. Unix natively provides -locks, but the locking primitives are synchronous, so either they are -unbounded in execution time or they require polling. s6lock provides -poll-free locks that can timeout during attempted acquisition. -</p> - -<h2> Programming </h2> - -<ul> - <li> Check the <tt>s6/s6lock.h</tt> header -for the prototypes. The functions documented here are -often simplified macros, for instance relying on the STAMP global variable -to hold the current time. Fully reentrant functions with more control -options are usually available. </li> - <li> Given the nature of the s6lock library, it makes sense to use a -<a href="../localservice.html">s6lockd service</a> concurrently -accessed by several applications using such locks to gate shared -resources. </li> - <li> If you're not using an s6lockd service, -make sure your application is not disturbed by children it doesn't -know it has. Using nonblocking waits, ignoring pids you don't know, and -using a -<a href="//skarnet.org/software/skalibs/libstddjb/selfpipe.html">self-pipe</a> -if your application is built around an event loop, are good programming -practices. </li> -</ul> - -<h3> Starting and ending a session </h3> - -<pre> -s6lock_t a = S6LOCK_ZERO ; -tain_t deadline ; - -tain_now_g() ; -tain_addsec_g(&deadline, 2) - -char const *path = S6LOCK_IPCPATH ; -s6lock_start_g(&a, path, &deadline) ; -// char const *lockdir = "/tmp/lock" ; -// s6lock_startf_g(&a, lockdir, &deadline) ; -</pre> - -<p> -<tt>s6lock_start_g</tt> starts a session by connecting to an s6lockd service -listening on <em>path</em>. The working directory is set by the administrator -of the service. <br /> -<tt>s6lock_startf_g</tt> starts a session with an s6lockd process as a child, -using <em>lockdir</em> as its working directory. -<br /> -<tt>a</tt> is an s6lock_t structure that must be declared in the stack and -initialized to S6LOCK_ZERO. -If the session initialization fails, the function returns 0 and errno is set; -else the function returns 1. -</p> -<p> -If the absolute time <tt>deadline</tt> is reached and the function -has not returned yet, it immediately returns 0 with errno set to ETIMEDOUT. - -Only local interprocess communications are involved; unless your system is -heavily overloaded, the function should return near-instantly. One or two -seconds of delay between the current time and <tt>deadline</tt> should be -enough: if the function takes more than that to return, then there is a -problem with the underlying processes. -</p> - -<p> - You can have more than one session open in parallel, by declaring -several distinct <tt>s6lock_t</tt> structures and calling -<tt>s6lock_startf_g</tt> (or <tt>s6lock_start_g</tt>) more than once. -However, one single session can handle -virtually as many concurrent locks as your application needs, so -opening several sessions is only useful if you need to acquire locks -in various distinct lock directories. -</p> - -<pre> -s6lock_end(&a) ; -</pre> - -<p> -<tt>s6lock_end</tt> frees all the resources used by the session. The -<tt>a</tt> structure is then reusable for another session. -</p> - -<h3> Acquiring and releasing locks </h3> - -<pre> -uint16_t id ; -char const *file = "lockfile" ; -tain_t limit ; -tain_t deadline ; - -int r = s6lock_acquire_sh_g (&a, &id, file, &limit, &deadline) ; -/* int r = s6lock_acquire_ex_g (&a, &id, file, &limit, &deadline) ; */ -r = s6lock_release_g(&a, id, &deadline) ; -</pre> - -<p> -<tt>s6lock_acquire_sh_g</tt> instructs the -<a href="s6lockd.html">s6lockd daemon</a>, related to the open -session represented by the <tt>a</tt> handle, to try and acquire a -shared lock on the -<em>file</em> file located under that daemon's working directory -(typically <tt>/var/lock</tt>). <em>file</em> will be interpreted as -relative to the daemon's working directory even if it starts with a -slash; however, slashes in the middle of <em>file</em> are likely to -result in an error. -</p> - -<p> -<em>limit</em> and <em>deadline</em> are two absolute dates. -<em>deadline</em> is a deadline for the execution of the -function: if by <em>deadline</em> the function has not returned, -then it instantly returns 0 and sets errno to ETIMEDOUT. The -function is normally near-instantaneous, so <em>deadline</em> can -be very close in the future and serves only as a protection against -malicious servers. <em>limit</em> is the acquisition deadline: if -by <em>limit</em> the daemon still has not been able to acquire a lock -on <em>file</em>, then it will report a timeout to the client. -</p> - -<p> -The function returns 1 in case of success, or 0 if an error occurs, -with errno set to a suitable value. If it succeeds, then a 16-bit -number is stored into *<em>id</em>; this number serves as an identifier -for this lock. -</p> - -<p> -<tt>s6lock_acquire_ex_g</tt> works just like <tt>s6lock_acquire_sh_g</tt>, -except that the daemon tries to acquire an exclusive lock. -</p> - -<p> -<tt>s6lock_release_g</tt> releases the lock identified by <em>id</em>. -It normally returns 1. It can return 0 with errno set to a suitable -value if it fails. <em>id</em> is not valid after the corresponding -lock has been released. The function normally returns instantly, with -<em>deadline</em> as a safeguard. -</p> - -<h3> Asynchronously waiting for locks </h3> - -<p> -<em> (from now on, the functions are listed with their prototypes instead -of usage examples.) </em> -</p> - -<pre> -int s6lock_fd (s6lock_t const *a) -</pre> - -<p> - Returns a file descriptor to select on for reading. Do not -<tt>read()</tt> it though. -</p> - -<pre> -int s6lock_update (s6lock_t *a) -</pre> - -<p> - Call this function whenever the fd checks readability: it will -update <em>a</em>'s internal structures with information from the -<a href="s6lockd.html">s6lockd</a> daemon. It returns -1 if an error -occurs; in case of success, it returns the number of identifiers for -which something happened. -</p> - -<p> - When <tt>s6lock_update</tt> returns, -<tt>genalloc_s(uint16_t, &a->list)</tt> points to an array of -<tt>genalloc_len(uint16_t, &a->list)</tt> 16-bit unsigned -integers. Those integers are ids waiting to be passed to -<tt>s6lock_check</tt>. -</p> - -<pre> -int s6lock_check (s6lock_t *a, uint16_t id, char *what) -</pre> - -<p> - Checks whether the lock identified by <em>id</em> has -been acquired. Use after a call to <tt>s6lock_update()</tt>. -</p> - -<ul> - <li> If an error occurred, returns -1 and sets errno. The error -number may have been transmitted from -<a href="s6lockd.html">s6lockd</a>. </li> - <li> If the lock has not been acquired yet, returns 0. </li> - <li> If the lock has been acquired, returns 1. </li> -</ul> - -<h3> Synchronously waiting for locks </h3> - -<p> -<code> int s6lock_wait_or_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline) </code> <br /> -Synchronously waits for <em>one</em> of the locks represented by the array pointed to -by <em>idlist</em> of length <em>n</em> to be acquired. Returns -1 if it fails, -or a nonnegative number on success, which is the index in <em>idlist</em> of the -acquired lock's id. If no result has been obtained by <em>deadline</em>, the -function returns -1 ETIMEDOUT. -</p> - -<p> -<code> int s6lock_wait_and_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline) </code> <br /> -Synchronously waits for <em>all</em> of the locks represented by the array pointed to -by <em>idlist</em> of length <em>n</em> to be acquired. Returns -1 if it fails and -0 if it succeeds. If no result has been obtained by <em>deadline</em>, the -function returns -1 ETIMEDOUT. -</p> - -</body> -</html> diff --git a/doc/s6-svlink.html b/doc/s6-svlink.html @@ -0,0 +1,111 @@ +<html> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta http-equiv="Content-Language" content="en" /> + <title>s6: the s6-svlink program</title> + <meta name="Description" content="s6: the s6-svlink program" /> + <meta name="Keywords" content="s6 command s6-svlink supervision service start scandir servicedir" /> + <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> + </head> +<body> + +<p> +<a href="index.html">s6</a><br /> +<a href="//skarnet.org/software/">Software</a><br /> +<a href="//skarnet.org/">skarnet.org</a> +</p> + +<h1> The s6-svlink program </h1> + +<p> + <tt>s6-svlink</tt> creates, in a <a href="scandir.html">scan +directory</a>, a symlink to a <a href="servicedir.html">service +directory</a>, and notifies <a href="s6-svscan.html">s6-svscan</a> +that a new service has been registered. It waits until a +<a href="s6-supervise.html">s6-supervise</a> supervisor process has +been spawned to manage the new service, then exits. +</p> + +<p> + The point of <tt>s6-svlink</tt> is to help integrate existing +service directories into an existing service manager sequence and +eliminating race conditions. +</p> + +<h2> Interface </h2> + +<pre> + s6-svlink [ -d | -D ] [ -P ] [ -f ] [ -t <em>timeout</em> ] <em>scandir</em> <em>servicedir</em> [ <em>name</em> ] +</pre> + +<ul> + <li> <tt>s6-svlink</tt> expects a running <a href="s6-svscan.html">s6-svscan</a> +process on <em>scandir</em> and a fully functional, but unsupervised, +<a href="servicedir.html">service directory</a> in <em>servicedir</em>. </li> + <li> It symlinks <em>servicedir</em> into <em>scandir</em>. The symbolic link +is named <em>name</em>; if no <em>name</em> argument has been given, the name given +to the symbolic link is the basename of <em>servicedir</em>. </li> + <li> It sends a command to <a href="s6-svscan.html">s6-svscan</a> to signal it +that a new service is available. </li> + <li> It waits for a <a href="s6-supervise.html">s6-supervise</a> process to be +spawned on <em>servicedir</em>. </li> + <li> It exits 0. </li> +</ul> + +<h2> Exit codes </h2> + +<ul> + <li> 0: success </li> + <li> 99: timeout while waiting for the supervisor to start </li> + <li> 100: wrong usage </li> + <li> 111: system call failed </li> +</ul> + +<h2> Options </h2> + +<ul> + <li> <tt>-d</tt> : down. The supervisor will be started, but the service +itself will remain down. Any <em>servicedir</em><tt>/down</tt> file will be +deleted. By default, if neither the <tt>-d</tt> nor <tt>-D</tt> options have +been given, the supervisor auto-starts the service as soon as it runs. </li> + <li> <tt>-D</tt> : down, and stay down. The supervisor will be started, +but the service itself will remain down. A <em>servicedir</em><tt>/down</tt> file +will be created. By default, if neither the <tt>-d</tt> nor <tt>-D</tt> options have +been given, the supervisor auto-starts the service as soon as it runs. </li> + <li> <tt>-P</tt> : public. If <em>servicedir</em><tt>/event</tt> does not +exist, it will be created as public, i.e. anyone will be able to subscribe to +this <a href="fifodir.html">fifodir</a>. By default, it will be created as private, +i.e. only processes running with the same gid as the <a href="s6-svscan.html">s6-svscan</a> +process will be able to susbscribe to it. </li> + <li> <tt>-f</tt> : force permissions. The presence or absence of the <tt>-P</tt> +option (i.e. the public or private state of <em>servicedir</em><tt>/event</tt>) will be +enforced even if <em>servicedir</em><tt>/event</tt> already exists. By default, +<tt>s6-svlink</tt> exits with an error message if <em>servicedir</em><tt>/event</tt> +exists and its public/private state mismatches what is requested. </li> + <li> <tt>-t <em>timeout</em></tt> : if the supervisor has not started +after <em>timeout</em> milliseconds, <tt>s6-svlink</tt> will print a message +to stderr and exit 99. By default, <em>timeout</em> is 0, which means no time +limit. </li> +</ul> + +<h2> Notes </h2> + +<ul> + <li> Using <tt>s6-svlink</tt> to start services is a suboptimal pattern: it +requires precise manipulations involving use of <a href="s6-ftrigrd.html">s6-ftrigrd</a> +in order to avoid race conditions, so it is relatively expensive. The simpler, +more efficient pattern is to have all the supervisors already started at boot +time, so the existence of the supervisor can be relied on, and starting the +service becomes a trival and instant operation - this is, for instance, how +the <a href="//skarnet.org/software/s6-rc/">s6-rc</a> service manager behaves. +However, it can be difficult to implement this pattern with other services +managers such as OpenRC; in those cases, <tt>s6-svlink</tt>, which starts the +supervisors one at a time, can be used instead. </li> + <li> If <em>servicedir</em> is logged, i.e. <em>servicedir</em><tt>/log</tt> +is also a valid service directory, then <tt>s6-svlink</tt> will wait until +supervisors have been spawned for both the service and its logger. </li> +</ul> + +</body> +</html> diff --git a/doc/s6-svunlink.html b/doc/s6-svunlink.html @@ -0,0 +1,90 @@ +<html> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta http-equiv="Content-Language" content="en" /> + <title>s6: the s6-svunlink program</title> + <meta name="Description" content="s6: the s6-svunlink program" /> + <meta name="Keywords" content="s6 command s6-svunlink supervision service stop unlink scandir servicedir" /> + <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> + </head> +<body> + +<p> +<a href="index.html">s6</a><br /> +<a href="//skarnet.org/software/">Software</a><br /> +<a href="//skarnet.org/">skarnet.org</a> +</p> + +<h1> The s6-svunlink program </h1> + +<p> + <tt>s6-svunlink</tt> unlinks a <a href="servicedir.html">service +directory from a <a href="scandir.html">scan directory</a>, then +notify the <a href="s6-svscan.html">s6-svscan</a> that a service has +been unregistered. It waits until the <a href="s6-supervise.html">s6-supervise</a> +supervisor process has disappeared, then exits. +</p> + +<p> + The point of <tt>s6-svunlink</tt> is to help integrate existing +service directories into an existing service manager sequence and +eliminating race conditions. +</p> + +<h2> Interface </h2> + +<pre> + s6-svunlink [ -X ] [ -t <em>timeout</em> ] <em>scandir</em> <em>name</em> +</pre> + +<ul> + <li> <tt>s6-svunlink</tt> expects a running <a href="s6-svscan.html">s6-svscan</a> +process on <em>scandir</em> and a fully functional supervised service on +<a href="servicedir.html">service directory</a> in <em>scandir</em><tt>/</tt><em>name</em>, +which must be a symbolic link to a real directory located somewhere else. </li> + <li> It deletes the <em>scandir</em><tt>/</tt><em>name</em> symlink. </li> + <li> It sends a command to <a href="s6-svscan.html">s6-svscan</a> to signal it +that a service has disappeared. </li> + <li> It waits for the <a href="s6-supervise.html">s6-supervise</a> process +managing the service directory to exit. </li> + <li> It exits 0. </li> +</ul> + +<h2> Exit codes </h2> + +<ul> + <li> 0: success </li> + <li> 100: wrong usage </li> + <li> 111: system call failed </li> +</ul> + +<h2> Options </h2> + +<ul> + <li> <tt>-X</tt> : don't wait. <tt>s6-svunlink</tt> will exit right +away, without waiting for the supervisor to exit first. </li> + <li> <tt>-t <em>timeout</em></tt> : if the supervisor has not exited +after <em>timeout</em> milliseconds, <tt>s6-svlink</tt> will still exit. +The default is 0, meaning no time limit.. </li> +</ul> + +<h2> Notes </h2> + +<ul> + <li> Using <tt>s6-svlink</tt> to stop services is a suboptimal pattern: +starting and stopping supervisors is a heavier operation than just stopping +services. The simpler, more efficient pattern is to simply perform +<a href="s6-svc.html">s6-svc -dwD <em>scandir</em><tt>/</tt><em>name</em>, +which only commands, and waits for, the death of the service, without +impacting the supervisor. Nevertheless, for symmetry with +<a href="s6-svlink">s6-svlink</a>, this program is provided. </li> + <li> <tt>s6-svunlink</tt> is a destructor; as is, it returns 0 even in +situations that are nominally a failure. For instance, it returns 0 even +if its timeout expires; the rationale is that there is no sensible action +for the user to do if this error is reported. <tt>s6-svunlink</tt> only +reports errors when they uncover a deeper problem in the system. </li> +</ul> + +</body> +</html> diff --git a/doc/upgrade.html b/doc/upgrade.html @@ -29,6 +29,10 @@ optional dependency bumped to 0.1.0.2. </li> optional dependency bumped to 2.8.1.0. </li> <li> <a href="s6-svwait.html">s6-svwait</a> now supports the <tt>-r</tt> and <tt>-R</tt> options, to wait for service restarts. </li> + <li> The <tt>s6/lock.h</tt>, <tt>s6/supervise.h</tt> and <tt>s6/fdholder.h</tt> +headers replace their previous versions that had an extra <tt>s6</tt> prefix. </li> + <li> New binaries: <a href="s6-svlink.html">s6-svlink</a> and +<a href="s6-svunlink.html">s6-svunlink</a>. </li> </ul> <h2> in 2.10.0.3 </h2> diff --git a/package/deps.mak b/package/deps.mak @@ -4,8 +4,8 @@ src/include/s6/compat.h: src/include/s6/config.h src/include/s6/ftrigr.h: src/include/s6/config.h -src/include/s6/s6.h: src/include/s6/accessrules.h src/include/s6/compat.h src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/s6-supervise.h src/include/s6/s6lock.h -src/include/s6/s6lock.h: src/include/s6/config.h +src/include/s6/lock.h: src/include/s6/config.h +src/include/s6/s6.h: src/include/s6/accessrules.h src/include/s6/compat.h src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/lock.h src/include/s6/supervise.h src/supervision/s6-svlisten.h: src/include/s6/ftrigr.h src/conn-tools/s6-accessrules-cdb-from-fs.o src/conn-tools/s6-accessrules-cdb-from-fs.lo: src/conn-tools/s6-accessrules-cdb-from-fs.c src/conn-tools/s6-accessrules-fs-from-cdb.o src/conn-tools/s6-accessrules-fs-from-cdb.lo: src/conn-tools/s6-accessrules-fs-from-cdb.c @@ -34,14 +34,14 @@ src/daemontools-extras/s6-tai64n.o src/daemontools-extras/s6-tai64n.lo: src/daem src/daemontools-extras/s6-tai64nlocal.o src/daemontools-extras/s6-tai64nlocal.lo: src/daemontools-extras/s6-tai64nlocal.c src/daemontools-extras/ucspilogd.o src/daemontools-extras/ucspilogd.lo: src/daemontools-extras/ucspilogd.c src/daemontools-extras/lolsyslog.h src/fdholder/s6-fdholder-daemon.o src/fdholder/s6-fdholder-daemon.lo: src/fdholder/s6-fdholder-daemon.c src/include/s6/config.h -src/fdholder/s6-fdholder-delete.o src/fdholder/s6-fdholder-delete.lo: src/fdholder/s6-fdholder-delete.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-getdump.o src/fdholder/s6-fdholder-getdump.lo: src/fdholder/s6-fdholder-getdump.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-list.o src/fdholder/s6-fdholder-list.lo: src/fdholder/s6-fdholder-list.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-retrieve.o src/fdholder/s6-fdholder-retrieve.lo: src/fdholder/s6-fdholder-retrieve.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-setdump.o src/fdholder/s6-fdholder-setdump.lo: src/fdholder/s6-fdholder-setdump.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-store.o src/fdholder/s6-fdholder-store.lo: src/fdholder/s6-fdholder-store.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-transferdump.o src/fdholder/s6-fdholder-transferdump.lo: src/fdholder/s6-fdholder-transferdump.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholderd.o src/fdholder/s6-fdholderd.lo: src/fdholder/s6-fdholderd.c src/include/s6/accessrules.h src/include/s6/s6-fdholder.h +src/fdholder/s6-fdholder-delete.o src/fdholder/s6-fdholder-delete.lo: src/fdholder/s6-fdholder-delete.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-getdump.o src/fdholder/s6-fdholder-getdump.lo: src/fdholder/s6-fdholder-getdump.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-list.o src/fdholder/s6-fdholder-list.lo: src/fdholder/s6-fdholder-list.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-retrieve.o src/fdholder/s6-fdholder-retrieve.lo: src/fdholder/s6-fdholder-retrieve.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-setdump.o src/fdholder/s6-fdholder-setdump.lo: src/fdholder/s6-fdholder-setdump.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-store.o src/fdholder/s6-fdholder-store.lo: src/fdholder/s6-fdholder-store.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-transferdump.o src/fdholder/s6-fdholder-transferdump.lo: src/fdholder/s6-fdholder-transferdump.c src/include/s6/fdholder.h +src/fdholder/s6-fdholderd.o src/fdholder/s6-fdholderd.lo: src/fdholder/s6-fdholderd.c src/include/s6/accessrules.h src/include/s6/fdholder.h src/libs6/ftrig1_free.o src/libs6/ftrig1_free.lo: src/libs6/ftrig1_free.c src/libs6/ftrig1.h src/libs6/ftrig1_make.o src/libs6/ftrig1_make.lo: src/libs6/ftrig1_make.c src/libs6/ftrig1.h src/libs6/ftrigr1_zero.o src/libs6/ftrigr1_zero.lo: src/libs6/ftrigr1_zero.c src/include/s6/ftrigr.h @@ -74,46 +74,47 @@ src/libs6/s6_accessrules_params_free.o src/libs6/s6_accessrules_params_free.lo: src/libs6/s6_accessrules_uidgid_cdb.o src/libs6/s6_accessrules_uidgid_cdb.lo: src/libs6/s6_accessrules_uidgid_cdb.c src/include/s6/accessrules.h src/libs6/s6_accessrules_uidgid_fs.o src/libs6/s6_accessrules_uidgid_fs.lo: src/libs6/s6_accessrules_uidgid_fs.c src/include/s6/accessrules.h src/libs6/s6_compat_el_semicolon.o src/libs6/s6_compat_el_semicolon.lo: src/libs6/s6_compat_el_semicolon.c src/include/s6/config.h -src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_pack.lo: src/libs6/s6_dtally_pack.c src/include/s6/s6-supervise.h -src/libs6/s6_dtally_read.o src/libs6/s6_dtally_read.lo: src/libs6/s6_dtally_read.c src/include/s6/s6-supervise.h -src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_unpack.lo: src/libs6/s6_dtally_unpack.c src/include/s6/s6-supervise.h -src/libs6/s6_dtally_write.o src/libs6/s6_dtally_write.lo: src/libs6/s6_dtally_write.c src/include/s6/s6-supervise.h -src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete.lo: src/libs6/s6_fdholder_delete.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_delete_async.lo: src/libs6/s6_fdholder_delete_async.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_end.lo: src/libs6/s6_fdholder_end.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_getdump.lo: src/libs6/s6_fdholder_getdump.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list.lo: src/libs6/s6_fdholder_list.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_async.lo: src/libs6/s6_fdholder_list_async.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_list_cb.lo: src/libs6/s6_fdholder_list_cb.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve.lo: src/libs6/s6_fdholder_retrieve.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_async.lo: src/libs6/s6_fdholder_retrieve_async.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_retrieve_cb.lo: src/libs6/s6_fdholder_retrieve_cb.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_setdump.lo: src/libs6/s6_fdholder_setdump.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_start.lo: src/libs6/s6_fdholder_start.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store.lo: src/libs6/s6_fdholder_store.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_store_async.o src/libs6/s6_fdholder_store_async.lo: src/libs6/s6_fdholder_store_async.c src/include/s6/s6-fdholder.h -src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link.lo: src/libs6/s6_supervise_link.c src/include/s6/s6-supervise.h -src/libs6/s6_supervise_link_names.o src/libs6/s6_supervise_link_names.lo: src/libs6/s6_supervise_link_names.c src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/s6-supervise.h -src/libs6/s6_supervise_unlink.o src/libs6/s6_supervise_unlink.lo: src/libs6/s6_supervise_unlink.c src/include/s6/s6-supervise.h -src/libs6/s6_svc_ok.o src/libs6/s6_svc_ok.lo: src/libs6/s6_svc_ok.c src/include/s6/s6-supervise.h -src/libs6/s6_svc_write.o src/libs6/s6_svc_write.lo: src/libs6/s6_svc_write.c src/include/s6/s6-supervise.h -src/libs6/s6_svc_writectl.o src/libs6/s6_svc_writectl.lo: src/libs6/s6_svc_writectl.c src/include/s6/s6-supervise.h -src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_pack.lo: src/libs6/s6_svstatus_pack.c src/include/s6/s6-supervise.h -src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_read.lo: src/libs6/s6_svstatus_read.c src/include/s6/s6-supervise.h -src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_unpack.lo: src/libs6/s6_svstatus_unpack.c src/include/s6/s6-supervise.h -src/libs6/s6_svstatus_write.o src/libs6/s6_svstatus_write.lo: src/libs6/s6_svstatus_write.c src/include/s6/s6-supervise.h -src/libs6/s6lock_acquire.o src/libs6/s6lock_acquire.lo: src/libs6/s6lock_acquire.c src/include/s6/s6lock.h -src/libs6/s6lock_check.o src/libs6/s6lock_check.lo: src/libs6/s6lock_check.c src/include/s6/s6lock.h -src/libs6/s6lock_end.o src/libs6/s6lock_end.lo: src/libs6/s6lock_end.c src/include/s6/s6lock.h -src/libs6/s6lock_release.o src/libs6/s6lock_release.lo: src/libs6/s6lock_release.c src/include/s6/s6lock.h -src/libs6/s6lock_start.o src/libs6/s6lock_start.lo: src/libs6/s6lock_start.c src/include/s6/s6lock.h -src/libs6/s6lock_startf.o src/libs6/s6lock_startf.lo: src/libs6/s6lock_startf.c src/include/s6/s6lock.h -src/libs6/s6lock_update.o src/libs6/s6lock_update.lo: src/libs6/s6lock_update.c src/include/s6/s6lock.h -src/libs6/s6lock_wait_and.o src/libs6/s6lock_wait_and.lo: src/libs6/s6lock_wait_and.c src/include/s6/s6lock.h -src/libs6/s6lock_wait_or.o src/libs6/s6lock_wait_or.lo: src/libs6/s6lock_wait_or.c src/include/s6/s6lock.h -src/libs6/s6lock_zero.o src/libs6/s6lock_zero.lo: src/libs6/s6lock_zero.c src/include/s6/s6lock.h +src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_pack.lo: src/libs6/s6_dtally_pack.c src/include/s6/supervise.h +src/libs6/s6_dtally_read.o src/libs6/s6_dtally_read.lo: src/libs6/s6_dtally_read.c src/include/s6/supervise.h +src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_unpack.lo: src/libs6/s6_dtally_unpack.c src/include/s6/supervise.h +src/libs6/s6_dtally_write.o src/libs6/s6_dtally_write.lo: src/libs6/s6_dtally_write.c src/include/s6/supervise.h +src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete.lo: src/libs6/s6_fdholder_delete.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_delete_async.lo: src/libs6/s6_fdholder_delete_async.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_end.lo: src/libs6/s6_fdholder_end.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_getdump.lo: src/libs6/s6_fdholder_getdump.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list.lo: src/libs6/s6_fdholder_list.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_async.lo: src/libs6/s6_fdholder_list_async.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_list_cb.lo: src/libs6/s6_fdholder_list_cb.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve.lo: src/libs6/s6_fdholder_retrieve.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_async.lo: src/libs6/s6_fdholder_retrieve_async.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_retrieve_cb.lo: src/libs6/s6_fdholder_retrieve_cb.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_setdump.lo: src/libs6/s6_fdholder_setdump.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_start.lo: src/libs6/s6_fdholder_start.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store.lo: src/libs6/s6_fdholder_store.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_store_async.o src/libs6/s6_fdholder_store_async.lo: src/libs6/s6_fdholder_store_async.c src/include/s6/fdholder.h +src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link.lo: src/libs6/s6_supervise_link.c src/include/s6/supervise.h +src/libs6/s6_supervise_link_names.o src/libs6/s6_supervise_link_names.lo: src/libs6/s6_supervise_link_names.c src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/supervise.h +src/libs6/s6_supervise_unlink.o src/libs6/s6_supervise_unlink.lo: src/libs6/s6_supervise_unlink.c src/include/s6/supervise.h +src/libs6/s6_supervise_unlink_names.o src/libs6/s6_supervise_unlink_names.lo: src/libs6/s6_supervise_unlink_names.c src/include/s6/ftrigr.h src/include/s6/supervise.h +src/libs6/s6_svc_ok.o src/libs6/s6_svc_ok.lo: src/libs6/s6_svc_ok.c src/include/s6/supervise.h +src/libs6/s6_svc_write.o src/libs6/s6_svc_write.lo: src/libs6/s6_svc_write.c src/include/s6/supervise.h +src/libs6/s6_svc_writectl.o src/libs6/s6_svc_writectl.lo: src/libs6/s6_svc_writectl.c src/include/s6/supervise.h +src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_pack.lo: src/libs6/s6_svstatus_pack.c src/include/s6/supervise.h +src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_read.lo: src/libs6/s6_svstatus_read.c src/include/s6/supervise.h +src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_unpack.lo: src/libs6/s6_svstatus_unpack.c src/include/s6/supervise.h +src/libs6/s6_svstatus_write.o src/libs6/s6_svstatus_write.lo: src/libs6/s6_svstatus_write.c src/include/s6/supervise.h +src/libs6/s6lock_acquire.o src/libs6/s6lock_acquire.lo: src/libs6/s6lock_acquire.c src/include/s6/lock.h +src/libs6/s6lock_check.o src/libs6/s6lock_check.lo: src/libs6/s6lock_check.c src/include/s6/lock.h +src/libs6/s6lock_end.o src/libs6/s6lock_end.lo: src/libs6/s6lock_end.c src/include/s6/lock.h +src/libs6/s6lock_release.o src/libs6/s6lock_release.lo: src/libs6/s6lock_release.c src/include/s6/lock.h +src/libs6/s6lock_start.o src/libs6/s6lock_start.lo: src/libs6/s6lock_start.c src/include/s6/lock.h +src/libs6/s6lock_startf.o src/libs6/s6lock_startf.lo: src/libs6/s6lock_startf.c src/include/s6/lock.h +src/libs6/s6lock_update.o src/libs6/s6lock_update.lo: src/libs6/s6lock_update.c src/include/s6/lock.h +src/libs6/s6lock_wait_and.o src/libs6/s6lock_wait_and.lo: src/libs6/s6lock_wait_and.c src/include/s6/lock.h +src/libs6/s6lock_wait_or.o src/libs6/s6lock_wait_or.lo: src/libs6/s6lock_wait_or.c src/include/s6/lock.h +src/libs6/s6lock_zero.o src/libs6/s6lock_zero.lo: src/libs6/s6lock_zero.c src/include/s6/lock.h src/libs6/s6lockd-helper.o src/libs6/s6lockd-helper.lo: src/libs6/s6lockd-helper.c src/include-local/s6lockd.h -src/libs6/s6lockd.o src/libs6/s6lockd.lo: src/libs6/s6lockd.c src/include/s6/s6lock.h +src/libs6/s6lockd.o src/libs6/s6lockd.lo: src/libs6/s6lockd.c src/include/s6/lock.h src/libs6/s6lockd_openandlock.o src/libs6/s6lockd_openandlock.lo: src/libs6/s6lockd_openandlock.c src/include-local/s6lockd.h src/pipe-tools/s6-cleanfifodir.o src/pipe-tools/s6-cleanfifodir.lo: src/pipe-tools/s6-cleanfifodir.c src/include/s6/ftrigw.h src/pipe-tools/s6-ftrig-listen.o src/pipe-tools/s6-ftrig-listen.lo: src/pipe-tools/s6-ftrig-listen.c src/include/s6/compat.h src/include/s6/ftrigr.h @@ -122,22 +123,22 @@ src/pipe-tools/s6-ftrig-notify.o src/pipe-tools/s6-ftrig-notify.lo: src/pipe-too src/pipe-tools/s6-ftrig-wait.o src/pipe-tools/s6-ftrig-wait.lo: src/pipe-tools/s6-ftrig-wait.c src/include/s6/ftrigr.h src/pipe-tools/s6-mkfifodir.o src/pipe-tools/s6-mkfifodir.lo: src/pipe-tools/s6-mkfifodir.c src/include/s6/ftrigw.h src/supervision/s6-notifyoncheck.o src/supervision/s6-notifyoncheck.lo: src/supervision/s6-notifyoncheck.c src/include/s6/s6.h -src/supervision/s6-permafailon.o src/supervision/s6-permafailon.lo: src/supervision/s6-permafailon.c src/include/s6/s6-supervise.h -src/supervision/s6-supervise.o src/supervision/s6-supervise.lo: src/supervision/s6-supervise.c src/include/s6/ftrigw.h src/include/s6/s6-supervise.h -src/supervision/s6-svc.o src/supervision/s6-svc.lo: src/supervision/s6-svc.c src/include/s6/config.h src/include/s6/s6-supervise.h -src/supervision/s6-svdir-link.o src/supervision/s6-svdir-link.lo: src/supervision/s6-svdir-link.c src/include/s6/s6-supervise.h -src/supervision/s6-svdir-unlink.o src/supervision/s6-svdir-unlink.lo: src/supervision/s6-svdir-unlink.c src/include/s6/s6-supervise.h -src/supervision/s6-svdt-clear.o src/supervision/s6-svdt-clear.lo: src/supervision/s6-svdt-clear.c src/include/s6/s6-supervise.h -src/supervision/s6-svdt.o src/supervision/s6-svdt.lo: src/supervision/s6-svdt.c src/include/s6/s6-supervise.h +src/supervision/s6-permafailon.o src/supervision/s6-permafailon.lo: src/supervision/s6-permafailon.c src/include/s6/supervise.h +src/supervision/s6-supervise.o src/supervision/s6-supervise.lo: src/supervision/s6-supervise.c src/include/s6/ftrigw.h src/include/s6/supervise.h +src/supervision/s6-svc.o src/supervision/s6-svc.lo: src/supervision/s6-svc.c src/include/s6/config.h src/include/s6/supervise.h +src/supervision/s6-svdt-clear.o src/supervision/s6-svdt-clear.lo: src/supervision/s6-svdt-clear.c src/include/s6/supervise.h +src/supervision/s6-svdt.o src/supervision/s6-svdt.lo: src/supervision/s6-svdt.c src/include/s6/supervise.h +src/supervision/s6-svlink.o src/supervision/s6-svlink.lo: src/supervision/s6-svlink.c src/include/s6/supervise.h src/supervision/s6-svlisten.o src/supervision/s6-svlisten.lo: src/supervision/s6-svlisten.c src/supervision/s6-svlisten.h src/include/s6/compat.h src/supervision/s6-svlisten1.o src/supervision/s6-svlisten1.lo: src/supervision/s6-svlisten1.c src/supervision/s6-svlisten.h -src/supervision/s6-svok.o src/supervision/s6-svok.lo: src/supervision/s6-svok.c src/include/s6/s6-supervise.h -src/supervision/s6-svperms.o src/supervision/s6-svperms.lo: src/supervision/s6-svperms.c src/include/s6/s6-supervise.h -src/supervision/s6-svscan.o src/supervision/s6-svscan.lo: src/supervision/s6-svscan.c src/include/s6/config.h src/include/s6/s6-supervise.h -src/supervision/s6-svscanctl.o src/supervision/s6-svscanctl.lo: src/supervision/s6-svscanctl.c src/include/s6/s6-supervise.h -src/supervision/s6-svstat.o src/supervision/s6-svstat.lo: src/supervision/s6-svstat.c src/include/s6/s6-supervise.h +src/supervision/s6-svok.o src/supervision/s6-svok.lo: src/supervision/s6-svok.c src/include/s6/supervise.h +src/supervision/s6-svperms.o src/supervision/s6-svperms.lo: src/supervision/s6-svperms.c src/include/s6/supervise.h +src/supervision/s6-svscan.o src/supervision/s6-svscan.lo: src/supervision/s6-svscan.c src/include/s6/config.h src/include/s6/supervise.h +src/supervision/s6-svscanctl.o src/supervision/s6-svscanctl.lo: src/supervision/s6-svscanctl.c src/include/s6/supervise.h +src/supervision/s6-svstat.o src/supervision/s6-svstat.lo: src/supervision/s6-svstat.c src/include/s6/supervise.h +src/supervision/s6-svunlink.o src/supervision/s6-svunlink.lo: src/supervision/s6-svunlink.c src/include/s6/supervise.h src/supervision/s6-svwait.o src/supervision/s6-svwait.lo: src/supervision/s6-svwait.c src/supervision/s6-svlisten.h -src/supervision/s6_svlisten_loop.o src/supervision/s6_svlisten_loop.lo: src/supervision/s6_svlisten_loop.c src/supervision/s6-svlisten.h src/include/s6/ftrigr.h src/include/s6/s6-supervise.h +src/supervision/s6_svlisten_loop.o src/supervision/s6_svlisten_loop.lo: src/supervision/s6_svlisten_loop.c src/supervision/s6-svlisten.h src/include/s6/ftrigr.h src/include/s6/supervise.h src/supervision/s6_svlisten_signal_handler.o src/supervision/s6_svlisten_signal_handler.lo: src/supervision/s6_svlisten_signal_handler.c src/supervision/s6-svlisten.h src/usertree/s6-usertree-maker.o src/usertree/s6-usertree-maker.lo: src/usertree/s6-usertree-maker.c src/include/s6/config.h @@ -210,12 +211,12 @@ s6-fdholder-transferdump: src/fdholder/s6-fdholder-transferdump.o ${LIBS6} s6-fdholderd: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} s6-fdholderd: src/fdholder/s6-fdholderd.o ${LIBS6} ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) -libs6.a.xyzzy: src/libs6/ftrigr1_zero.o src/libs6/ftrigr_check.o src/libs6/ftrigr_checksa.o src/libs6/ftrigr_ack.o src/libs6/ftrigr_end.o src/libs6/ftrigr_start.o src/libs6/ftrigr_startf.o src/libs6/ftrigr_subscribe.o src/libs6/ftrigr_unsubscribe.o src/libs6/ftrigr_update.o src/libs6/ftrigr_updateb.o src/libs6/ftrigr_wait_and.o src/libs6/ftrigr_wait_or.o src/libs6/ftrigr_zero.o src/libs6/ftrigw_clean.o src/libs6/ftrigw_fifodir_make.o src/libs6/ftrigw_notify.o src/libs6/ftrigw_notifyb.o src/libs6/ftrigw_notifyb_nosig.o src/libs6/s6_accessrules_backend_cdb.o src/libs6/s6_accessrules_backend_fs.o src/libs6/s6_accessrules_keycheck_ip4.o src/libs6/s6_accessrules_keycheck_ip6.o src/libs6/s6_accessrules_keycheck_reversedns.o src/libs6/s6_accessrules_keycheck_uidgid.o src/libs6/s6_accessrules_params_free.o src/libs6/s6_accessrules_uidgid_cdb.o src/libs6/s6_accessrules_uidgid_fs.o src/libs6/s6_compat_el_semicolon.o src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_read.o src/libs6/s6_dtally_write.o src/libs6/s6_svc_ok.o src/libs6/s6_svc_write.o src/libs6/s6_svc_writectl.o src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_write.o src/libs6/s6lock_acquire.o src/libs6/s6lock_check.o src/libs6/s6lock_end.o src/libs6/s6lock_release.o src/libs6/s6lock_start.o src/libs6/s6lock_startf.o src/libs6/s6lock_update.o src/libs6/s6lock_wait_and.o src/libs6/s6lock_wait_or.o src/libs6/s6lock_zero.o src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store_async.o src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link_names.o src/libs6/s6_supervise_unlink.o +libs6.a.xyzzy: src/libs6/ftrigr1_zero.o src/libs6/ftrigr_check.o src/libs6/ftrigr_checksa.o src/libs6/ftrigr_ack.o src/libs6/ftrigr_end.o src/libs6/ftrigr_start.o src/libs6/ftrigr_startf.o src/libs6/ftrigr_subscribe.o src/libs6/ftrigr_unsubscribe.o src/libs6/ftrigr_update.o src/libs6/ftrigr_updateb.o src/libs6/ftrigr_wait_and.o src/libs6/ftrigr_wait_or.o src/libs6/ftrigr_zero.o src/libs6/ftrigw_clean.o src/libs6/ftrigw_fifodir_make.o src/libs6/ftrigw_notify.o src/libs6/ftrigw_notifyb.o src/libs6/ftrigw_notifyb_nosig.o src/libs6/s6_accessrules_backend_cdb.o src/libs6/s6_accessrules_backend_fs.o src/libs6/s6_accessrules_keycheck_ip4.o src/libs6/s6_accessrules_keycheck_ip6.o src/libs6/s6_accessrules_keycheck_reversedns.o src/libs6/s6_accessrules_keycheck_uidgid.o src/libs6/s6_accessrules_params_free.o src/libs6/s6_accessrules_uidgid_cdb.o src/libs6/s6_accessrules_uidgid_fs.o src/libs6/s6_compat_el_semicolon.o src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_read.o src/libs6/s6_dtally_write.o src/libs6/s6_svc_ok.o src/libs6/s6_svc_write.o src/libs6/s6_svc_writectl.o src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_write.o src/libs6/s6lock_acquire.o src/libs6/s6lock_check.o src/libs6/s6lock_end.o src/libs6/s6lock_release.o src/libs6/s6lock_start.o src/libs6/s6lock_startf.o src/libs6/s6lock_update.o src/libs6/s6lock_wait_and.o src/libs6/s6lock_wait_or.o src/libs6/s6lock_zero.o src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store_async.o src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link_names.o src/libs6/s6_supervise_unlink.o src/libs6/s6_supervise_unlink_names.o else -libs6.a.xyzzy: src/libs6/ftrigr1_zero.lo src/libs6/ftrigr_check.lo src/libs6/ftrigr_checksa.lo src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_updateb.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigr_zero.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6lock_acquire.lo src/libs6/s6lock_check.lo src/libs6/s6lock_end.lo src/libs6/s6lock_release.lo src/libs6/s6lock_start.lo src/libs6/s6lock_startf.lo src/libs6/s6lock_update.lo src/libs6/s6lock_wait_and.lo src/libs6/s6lock_wait_or.lo src/libs6/s6lock_zero.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo +libs6.a.xyzzy: src/libs6/ftrigr1_zero.lo src/libs6/ftrigr_check.lo src/libs6/ftrigr_checksa.lo src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_updateb.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigr_zero.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6lock_acquire.lo src/libs6/s6lock_check.lo src/libs6/s6lock_end.lo src/libs6/s6lock_release.lo src/libs6/s6lock_start.lo src/libs6/s6lock_startf.lo src/libs6/s6lock_update.lo src/libs6/s6lock_wait_and.lo src/libs6/s6lock_wait_or.lo src/libs6/s6lock_zero.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo endif libs6.so.xyzzy: EXTRA_LIBS := -lskarnet -libs6.so.xyzzy: src/libs6/ftrigr1_zero.lo src/libs6/ftrigr_check.lo src/libs6/ftrigr_checksa.lo src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_updateb.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigr_zero.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6lock_acquire.lo src/libs6/s6lock_check.lo src/libs6/s6lock_end.lo src/libs6/s6lock_release.lo src/libs6/s6lock_start.lo src/libs6/s6lock_startf.lo src/libs6/s6lock_update.lo src/libs6/s6lock_wait_and.lo src/libs6/s6lock_wait_or.lo src/libs6/s6lock_zero.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo +libs6.so.xyzzy: src/libs6/ftrigr1_zero.lo src/libs6/ftrigr_check.lo src/libs6/ftrigr_checksa.lo src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_updateb.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigr_zero.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6lock_acquire.lo src/libs6/s6lock_check.lo src/libs6/s6lock_end.lo src/libs6/s6lock_release.lo src/libs6/s6lock_start.lo src/libs6/s6lock_startf.lo src/libs6/s6lock_update.lo src/libs6/s6lock_wait_and.lo src/libs6/s6lock_wait_or.lo src/libs6/s6lock_zero.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) libs6lockd.a.xyzzy: src/libs6/s6lockd_openandlock.o else @@ -247,14 +248,12 @@ s6-supervise: EXTRA_LIBS := -lskarnet ${SYSCLOCK_LIB} s6-supervise: src/supervision/s6-supervise.o libs6.a.xyzzy s6-svc: EXTRA_LIBS := -lskarnet s6-svc: src/supervision/s6-svc.o ${LIBS6} -s6-svdir-link: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} -s6-svdir-link: src/supervision/s6-svdir-link.o ${LIBS6} -s6-svdir-unlink: EXTRA_LIBS := -lskarnet -s6-svdir-unlink: src/supervision/s6-svdir-unlink.o ${LIBS6} s6-svdt: EXTRA_LIBS := -lskarnet s6-svdt: src/supervision/s6-svdt.o ${LIBS6} s6-svdt-clear: EXTRA_LIBS := -lskarnet s6-svdt-clear: src/supervision/s6-svdt-clear.o ${LIBS6} +s6-svlink: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} +s6-svlink: src/supervision/s6-svlink.o ${LIBS6} s6-svlisten: EXTRA_LIBS := ${EXECLINE_LIB} -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} s6-svlisten: src/supervision/s6-svlisten.o src/supervision/s6_svlisten_signal_handler.o src/supervision/s6_svlisten_loop.o ${LIBS6} s6-svlisten1: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} @@ -269,6 +268,8 @@ s6-svscanctl: EXTRA_LIBS := -lskarnet s6-svscanctl: src/supervision/s6-svscanctl.o ${LIBS6} s6-svstat: EXTRA_LIBS := -lskarnet ${SYSCLOCK_LIB} s6-svstat: src/supervision/s6-svstat.o ${LIBS6} +s6-svunlink: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} +s6-svunlink: src/supervision/s6-svunlink.o ${LIBS6} s6-svwait: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} s6-svwait: src/supervision/s6-svwait.o src/supervision/s6_svlisten_loop.o ${LIBS6} s6-usertree-maker: EXTRA_LIBS := -lskarnet diff --git a/package/targets.mak b/package/targets.mak @@ -11,8 +11,6 @@ s6-mkfifodir \ s6-svscan \ s6-supervise \ s6-svc \ -s6-svdir-link \ -s6-svdir-unlink \ s6-svscanctl \ s6-svok \ s6-svstat \ @@ -23,6 +21,8 @@ s6-svwait \ s6-svlisten1 \ s6-svlisten \ s6-svperms \ +s6-svlink \ +s6-svunlink \ s6-notifyoncheck \ s6-envdir \ s6-envuidgid \ diff --git a/src/fdholder/s6-fdholder-delete.c b/src/fdholder/s6-fdholder-delete.c @@ -4,7 +4,7 @@ #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/tai.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #define USAGE "s6-fdholder-delete [ -t timeout ] socket id" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/fdholder/s6-fdholder-getdump.c b/src/fdholder/s6-fdholder-getdump.c @@ -11,7 +11,7 @@ #include <skalibs/genalloc.h> #include <skalibs/exec.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #define USAGE "s6-fdholder-getdump [ -t timeout ] socket prog..." #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/fdholder/s6-fdholder-list.c b/src/fdholder/s6-fdholder-list.c @@ -8,7 +8,7 @@ #include <skalibs/tai.h> #include <skalibs/stralloc.h> #include <skalibs/skamisc.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #define USAGE "s6-fdholder-list [ -t timeout ] socket" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/fdholder/s6-fdholder-retrieve.c b/src/fdholder/s6-fdholder-retrieve.c @@ -7,7 +7,7 @@ #include <skalibs/djbunix.h> #include <skalibs/exec.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #define USAGE "s6-fdholder-retrieve [ -D ] [ -t timeout ] socket id prog..." #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/fdholder/s6-fdholder-setdump.c b/src/fdholder/s6-fdholder-setdump.c @@ -6,7 +6,7 @@ #include <skalibs/strerr2.h> #include <skalibs/sgetopt.h> #include <skalibs/tai.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #define USAGE "s6-fdholder-setdump [ -t timeout ] socket" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/fdholder/s6-fdholder-store.c b/src/fdholder/s6-fdholder-store.c @@ -4,7 +4,7 @@ #include <skalibs/strerr2.h> #include <skalibs/sgetopt.h> #include <skalibs/tai.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #define USAGE "s6-fdholder-store [ -d fd ] [ -t timeout ] [ -T fdtimeout ] socket id" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/fdholder/s6-fdholder-transferdump.c b/src/fdholder/s6-fdholder-transferdump.c @@ -5,7 +5,7 @@ #include <skalibs/sgetopt.h> #include <skalibs/tai.h> #include <skalibs/genalloc.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #define USAGE "s6-fdholder-transferdump [ -t timeoutfrom:timeoutto ] socketfrom socketto" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/fdholder/s6-fdholderd.c b/src/fdholder/s6-fdholderd.c @@ -32,7 +32,7 @@ #include <skalibs/unixconnection.h> #include <s6/accessrules.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #include <skalibs/posixishard.h> diff --git a/src/include/s6/s6-fdholder.h b/src/include/s6/fdholder.h diff --git a/src/include/s6/lock.h b/src/include/s6/lock.h @@ -0,0 +1,75 @@ +/* ISC license. */ + +#ifndef S6_LOCK_H +#define S6_LOCK_H + +#include <stdint.h> + +#include <skalibs/tai.h> +#include <skalibs/genalloc.h> +#include <skalibs/gensetdyn.h> +#include <skalibs/textclient.h> + +#include <s6/config.h> + + + /* Constants */ + +#define S6LOCKD_PROG S6_EXTBINPREFIX "s6lockd" +#define S6LOCKD_HELPER_PROG S6_LIBEXECPREFIX "s6lockd-helper" + +#define S6LOCK_BANNER1 "s6lock v1.0 (b)\n" +#define S6LOCK_BANNER1_LEN (sizeof S6LOCK_BANNER1 - 1) +#define S6LOCK_BANNER2 "s6lock v1.0 (a)\n" +#define S6LOCK_BANNER2_LEN (sizeof S6LOCK_BANNER2 - 1) + + + /* The client handle */ + +typedef struct s6lock_s s6lock_t, *s6lock_t_ref ; +struct s6lock_s +{ + textclient connection ; + genalloc list ; /* array of uint16_t */ + gensetdyn data ; /* set of char */ +} ; +#define S6LOCK_ZERO { .connection = TEXTCLIENT_ZERO, .list = GENALLOC_ZERO, .data = GENSETDYN_INIT(int, 2, 0, 1) } +extern s6lock_t const s6lock_zero ; + + + /* Starting and ending a session */ + +extern int s6lock_start (s6lock_t *, char const *, tain const *, tain *) ; +#define s6lock_start_g(a, ipcpath, deadline) s6lock_start(a, ipcpath, (deadline), &STAMP) +extern int s6lock_startf (s6lock_t *, char const *, tain const *, tain *) ; +#define s6lock_startf_g(a, lockdir, deadline) s6lock_startf(a, lockdir, (deadline), &STAMP) +extern void s6lock_end (s6lock_t *) ; + + + /* Asynchronous primitives */ + +#define s6lock_fd(a) textclient_fd(&(a)->connection) +extern int s6lock_update (s6lock_t *) ; +extern int s6lock_check (s6lock_t *, uint16_t) ; + + + /* Synchronous functions */ + +#define S6LOCK_OPTIONS_SH 0x0000U +#define S6LOCK_OPTIONS_EX 0x0001U + +extern int s6lock_acquire (s6lock_t *, uint16_t *, char const *, uint32_t, tain const *, tain const *, tain *) ; +#define s6lock_acquire_g(a, id, path, options, limit, deadline) s6lock_acquire(a, id, path, options, limit, (deadline), &STAMP) +#define s6lock_acquire_sh(a, id, path, limit, deadline, stamp) s6lock_aquire(a, id, path, S6LOCK_OPTIONS_SH, limit, deadline, stamp) +#define s6lock_acquire_ex(a, id, path, limit, deadline, stamp) s6lock_aquire(a, id, path, S6LOCK_OPTIONS_EX, limit, deadline, stamp) +#define s6lock_acquire_sh_g(a, id, path, limit, deadline) s6lock_acquire_sh(a, id, path, limit, (deadline), &STAMP) +#define s6lock_acquire_ex_g(a, id, path, limit, deadline) s6lock_acquire_ex(a, id, path, limit, (deadline), &STAMP) +extern int s6lock_release (s6lock_t *, uint16_t, tain const *, tain *) ; +#define s6lock_release_g(a, id, deadline) s6lock_release(a, id, (deadline), &STAMP) + +extern int s6lock_wait_and (s6lock_t *, uint16_t const *, unsigned int, tain const *, tain *) ; +#define s6lock_wait_and_g(a, list, len, deadline) s6lock_wait_and(a, list, len, (deadline), &STAMP) +extern int s6lock_wait_or (s6lock_t *, uint16_t const *, unsigned int, tain const *, tain *) ; +#define s6lock_wait_or_g(a, list, len, deadline) s6lock_wait_or(a, list, len, (deadline), &STAMP) + +#endif diff --git a/src/include/s6/s6-supervise.h b/src/include/s6/s6-supervise.h @@ -1,80 +0,0 @@ -/* ISC license. */ - -#ifndef S6_SUPERVISE_H -#define S6_SUPERVISE_H - -#include <stdint.h> -#include <sys/types.h> - -#include <skalibs/tai.h> - -#define S6_SUPERVISE_CTLDIR "supervise" -#define S6_SUPERVISE_EVENTDIR "event" -#define S6_SVSCAN_CTLDIR ".s6-svscan" -#define S6_SVSTATUS_FILENAME S6_SUPERVISE_CTLDIR "/status" -#define S6_SVSTATUS_SIZE 35 -#define S6_DTALLY_FILENAME S6_SUPERVISE_CTLDIR "/death_tally" -#define S6_MAX_DEATH_TALLY 4096 - -extern int s6_svc_ok (char const *) ; -extern int s6_svc_write (char const *, char const *, size_t) ; -extern int s6_svc_writectl (char const *, char const *, char const *, size_t) ; -extern int s6_svc_main (int, char const *const *, char const *, char const *, char const *) ; - -typedef struct s6_svstatus_s s6_svstatus_t, *s6_svstatus_t_ref ; -struct s6_svstatus_s -{ - tain stamp ; - tain readystamp ; - pid_t pid ; - int wstat ; - unsigned int flagpaused : 1 ; - unsigned int flagfinishing : 1 ; - unsigned int flagwant : 1 ; /* unused */ - unsigned int flagwantup : 1 ; - unsigned int flagready : 1 ; - unsigned int flagthrottled : 1 ; -} ; - -#define S6_SVSTATUS_ZERO \ -{ \ - .stamp = TAIN_ZERO, \ - .readystamp = TAIN_ZERO, \ - .pid = 0, \ - .wstat = 0, \ - .flagpaused = 0, \ - .flagfinishing = 0, \ - .flagwant = 1, \ - .flagwantup = 1, \ - .flagready = 1, \ - .flagthrottled = 0 \ -} - -extern void s6_svstatus_pack (char *, s6_svstatus_t const *) ; -extern void s6_svstatus_unpack (char const *, s6_svstatus_t *) ; -extern int s6_svstatus_read (char const *, s6_svstatus_t *) ; -extern int s6_svstatus_write (char const *, s6_svstatus_t const *) ; - -extern int s6_supervise_link (char const *, char const *const *, size_t, char const *, uint32_t, tain const *, tain *) ; -#define s6_supervise_link_g(scdir, servicedirs, n, prefix, options, deadline) s6_supervise_link(scdir, servicedirs, n, prefix, options, (deadline), &STAMP) -extern int s6_supervise_link_names (char const *, char const *const *, char const *const *, size_t, uint32_t, tain const *, tain *) ; -#define s6_supervise_link_names_g(scdir, servicedirs, names, n, options, deadline) s6_supervise_link_names(scdir, servicedirs, names, n, options, (deadline), &STAMP) -extern void s6_supervise_unlink (char const *, char const *, uint32_t) ; - -typedef struct s6_dtally_s s6_dtally_t, *s6_dtally_ref ; -struct s6_dtally_s -{ - tain stamp ; - unsigned char exitcode ; - unsigned char sig ; -} ; -#define S6_DTALLY_ZERO { .stamp = TAIN_ZERO, .exitcode = 0, .sig = 0 } - -#define S6_DTALLY_PACK (TAIN_PACK + 2) - -extern void s6_dtally_pack (char *, s6_dtally_t const *) ; -extern void s6_dtally_unpack (char const *, s6_dtally_t *) ; -extern ssize_t s6_dtally_read (char const *, s6_dtally_t *, size_t) ; -extern int s6_dtally_write (char const *, s6_dtally_t const *, size_t) ; - -#endif diff --git a/src/include/s6/s6.h b/src/include/s6/s6.h @@ -4,10 +4,10 @@ #define S6_H #include <s6/compat.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #include <s6/ftrigr.h> #include <s6/ftrigw.h> #include <s6/accessrules.h> -#include <s6/s6lock.h> +#include <s6/lock.h> #endif diff --git a/src/include/s6/s6lock.h b/src/include/s6/s6lock.h @@ -1,73 +0,0 @@ -/* ISC license. */ - -#ifndef S6LOCK_H -#define S6LOCK_H - -#include <stdint.h> -#include <skalibs/tai.h> -#include <skalibs/genalloc.h> -#include <skalibs/gensetdyn.h> -#include <skalibs/textclient.h> -#include <s6/config.h> - - - /* Constants */ - -#define S6LOCKD_PROG S6_EXTBINPREFIX "s6lockd" -#define S6LOCKD_HELPER_PROG S6_LIBEXECPREFIX "s6lockd-helper" - -#define S6LOCK_BANNER1 "s6lock v1.0 (b)\n" -#define S6LOCK_BANNER1_LEN (sizeof S6LOCK_BANNER1 - 1) -#define S6LOCK_BANNER2 "s6lock v1.0 (a)\n" -#define S6LOCK_BANNER2_LEN (sizeof S6LOCK_BANNER2 - 1) - - - /* The client handle */ - -typedef struct s6lock_s s6lock_t, *s6lock_t_ref ; -struct s6lock_s -{ - textclient connection ; - genalloc list ; /* array of uint16_t */ - gensetdyn data ; /* set of char */ -} ; -#define S6LOCK_ZERO { .connection = TEXTCLIENT_ZERO, .list = GENALLOC_ZERO, .data = GENSETDYN_INIT(int, 2, 0, 1) } -extern s6lock_t const s6lock_zero ; - - - /* Starting and ending a session */ - -extern int s6lock_start (s6lock_t *, char const *, tain const *, tain *) ; -#define s6lock_start_g(a, ipcpath, deadline) s6lock_start(a, ipcpath, (deadline), &STAMP) -extern int s6lock_startf (s6lock_t *, char const *, tain const *, tain *) ; -#define s6lock_startf_g(a, lockdir, deadline) s6lock_startf(a, lockdir, (deadline), &STAMP) -extern void s6lock_end (s6lock_t *) ; - - - /* Asynchronous primitives */ - -#define s6lock_fd(a) textclient_fd(&(a)->connection) -extern int s6lock_update (s6lock_t *) ; -extern int s6lock_check (s6lock_t *, uint16_t) ; - - - /* Synchronous functions */ - -#define S6LOCK_OPTIONS_SH 0x0000U -#define S6LOCK_OPTIONS_EX 0x0001U - -extern int s6lock_acquire (s6lock_t *, uint16_t *, char const *, uint32_t, tain const *, tain const *, tain *) ; -#define s6lock_acquire_g(a, id, path, options, limit, deadline) s6lock_acquire(a, id, path, options, limit, (deadline), &STAMP) -#define s6lock_acquire_sh(a, id, path, limit, deadline, stamp) s6lock_aquire(a, id, path, S6LOCK_OPTIONS_SH, limit, deadline, stamp) -#define s6lock_acquire_ex(a, id, path, limit, deadline, stamp) s6lock_aquire(a, id, path, S6LOCK_OPTIONS_EX, limit, deadline, stamp) -#define s6lock_acquire_sh_g(a, id, path, limit, deadline) s6lock_acquire_sh(a, id, path, limit, (deadline), &STAMP) -#define s6lock_acquire_ex_g(a, id, path, limit, deadline) s6lock_acquire_ex(a, id, path, limit, (deadline), &STAMP) -extern int s6lock_release (s6lock_t *, uint16_t, tain const *, tain *) ; -#define s6lock_release_g(a, id, deadline) s6lock_release(a, id, (deadline), &STAMP) - -extern int s6lock_wait_and (s6lock_t *, uint16_t const *, unsigned int, tain const *, tain *) ; -#define s6lock_wait_and_g(a, list, len, deadline) s6lock_wait_and(a, list, len, (deadline), &STAMP) -extern int s6lock_wait_or (s6lock_t *, uint16_t const *, unsigned int, tain const *, tain *) ; -#define s6lock_wait_or_g(a, list, len, deadline) s6lock_wait_or(a, list, len, (deadline), &STAMP) - -#endif diff --git a/src/include/s6/supervise.h b/src/include/s6/supervise.h @@ -0,0 +1,78 @@ +/* ISC license. */ + +#ifndef S6_SUPERVISE_H +#define S6_SUPERVISE_H + +#include <stdint.h> +#include <sys/types.h> + +#include <skalibs/tai.h> + +#define S6_SUPERVISE_CTLDIR "supervise" +#define S6_SUPERVISE_EVENTDIR "event" +#define S6_SVSCAN_CTLDIR ".s6-svscan" +#define S6_SVSTATUS_FILENAME S6_SUPERVISE_CTLDIR "/status" +#define S6_SVSTATUS_SIZE 35 +#define S6_DTALLY_FILENAME S6_SUPERVISE_CTLDIR "/death_tally" +#define S6_MAX_DEATH_TALLY 4096 + +extern int s6_svc_ok (char const *) ; +extern int s6_svc_write (char const *, char const *, size_t) ; +extern int s6_svc_writectl (char const *, char const *, char const *, size_t) ; +extern int s6_svc_main (int, char const *const *, char const *, char const *, char const *) ; + +typedef struct s6_svstatus_s s6_svstatus_t, *s6_svstatus_t_ref ; +struct s6_svstatus_s +{ + tain stamp ; + tain readystamp ; + pid_t pid ; + int wstat ; + unsigned int flagpaused : 1 ; + unsigned int flagfinishing : 1 ; + unsigned int flagwantup : 1 ; + unsigned int flagready : 1 ; +} ; + +#define S6_SVSTATUS_ZERO \ +{ \ + .stamp = TAIN_ZERO, \ + .readystamp = TAIN_ZERO, \ + .pid = 0, \ + .wstat = 0, \ + .flagpaused = 0, \ + .flagfinishing = 0, \ + .flagwantup = 1, \ + .flagready = 1, \ +} + +extern void s6_svstatus_pack (char *, s6_svstatus_t const *) ; +extern void s6_svstatus_unpack (char const *, s6_svstatus_t *) ; +extern int s6_svstatus_read (char const *, s6_svstatus_t *) ; +extern int s6_svstatus_write (char const *, s6_svstatus_t const *) ; + +extern int s6_supervise_link (char const *, char const *const *, size_t, char const *, uint32_t, tain const *, tain *) ; +#define s6_supervise_link_g(scdir, servicedirs, n, prefix, options, deadline) s6_supervise_link(scdir, servicedirs, n, prefix, options, (deadline), &STAMP) +extern int s6_supervise_link_names (char const *, char const *const *, char const *const *, size_t, uint32_t, tain const *, tain *) ; +#define s6_supervise_link_names_g(scdir, servicedirs, names, n, options, deadline) s6_supervise_link_names(scdir, servicedirs, names, n, options, (deadline), &STAMP) +extern void s6_supervise_unlink (char const *, char const *, uint32_t) ; +extern int s6_supervise_unlink_names (char const *, char const *const *, size_t, uint32_t, tain const *, tain *) ; +#define s6_supervise_unlink_names_g(scdir, names, n, options, deadline) s6_supervise_unlink_names(scdir, names, n, options, (deadline), &STAMP) + +typedef struct s6_dtally_s s6_dtally_t, *s6_dtally_ref ; +struct s6_dtally_s +{ + tain stamp ; + unsigned char exitcode ; + unsigned char sig ; +} ; +#define S6_DTALLY_ZERO { .stamp = TAIN_ZERO, .exitcode = 0, .sig = 0 } + +#define S6_DTALLY_PACK (TAIN_PACK + 2) + +extern void s6_dtally_pack (char *, s6_dtally_t const *) ; +extern void s6_dtally_unpack (char const *, s6_dtally_t *) ; +extern ssize_t s6_dtally_read (char const *, s6_dtally_t *, size_t) ; +extern int s6_dtally_write (char const *, s6_dtally_t const *, size_t) ; + +#endif diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6 @@ -65,4 +65,5 @@ s6_fdholder_store_async.o s6_supervise_link.o s6_supervise_link_names.o s6_supervise_unlink.o +s6_supervise_unlink_names.o -lskarnet diff --git a/src/libs6/s6_dtally_pack.c b/src/libs6/s6_dtally_pack.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/tai.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> void s6_dtally_pack (char *pack, s6_dtally_t const *d) { diff --git a/src/libs6/s6_dtally_read.c b/src/libs6/s6_dtally_read.c @@ -7,7 +7,7 @@ #include <skalibs/allreadwrite.h> #include <skalibs/tai.h> #include <skalibs/djbunix.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> static int truncit (char const *s) { diff --git a/src/libs6/s6_dtally_unpack.c b/src/libs6/s6_dtally_unpack.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/tai.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> void s6_dtally_unpack (char const *pack, s6_dtally_t *d) { diff --git a/src/libs6/s6_dtally_write.c b/src/libs6/s6_dtally_write.c @@ -2,7 +2,7 @@ #include <string.h> #include <skalibs/djbunix.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> int s6_dtally_write (char const *sv, s6_dtally_t const *tab, size_t n) { diff --git a/src/libs6/s6_fdholder_delete.c b/src/libs6/s6_fdholder_delete.c @@ -6,7 +6,7 @@ #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #include <skalibs/posixishard.h> diff --git a/src/libs6/s6_fdholder_delete_async.c b/src/libs6/s6_fdholder_delete_async.c @@ -4,7 +4,7 @@ #include <string.h> #include <errno.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> int s6_fdholder_delete_async (s6_fdholder_t *a, char const *id) { diff --git a/src/libs6/s6_fdholder_end.c b/src/libs6/s6_fdholder_end.c @@ -2,7 +2,7 @@ #include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> void s6_fdholder_end (s6_fdholder_t *a) { diff --git a/src/libs6/s6_fdholder_getdump.c b/src/libs6/s6_fdholder_getdump.c @@ -11,7 +11,7 @@ #include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #include <skalibs/posixishard.h> diff --git a/src/libs6/s6_fdholder_list.c b/src/libs6/s6_fdholder_list.c @@ -5,7 +5,7 @@ #include <skalibs/error.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> int s6_fdholder_list (s6_fdholder_t *a, stralloc *sa, tain const *deadline, tain *stamp) { diff --git a/src/libs6/s6_fdholder_list_async.c b/src/libs6/s6_fdholder_list_async.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> int s6_fdholder_list_async (s6_fdholder_t *a) { diff --git a/src/libs6/s6_fdholder_list_cb.c b/src/libs6/s6_fdholder_list_cb.c @@ -7,7 +7,7 @@ #include <skalibs/bytestr.h> #include <skalibs/stralloc.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #include <skalibs/posixishard.h> diff --git a/src/libs6/s6_fdholder_retrieve.c b/src/libs6/s6_fdholder_retrieve.c @@ -4,7 +4,7 @@ #include <skalibs/allreadwrite.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> int s6_fdholder_retrieve_maybe_delete (s6_fdholder_t *a, char const *id, int dodelete, tain const *deadline, tain *stamp) { diff --git a/src/libs6/s6_fdholder_retrieve_async.c b/src/libs6/s6_fdholder_retrieve_async.c @@ -4,7 +4,7 @@ #include <string.h> #include <errno.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> int s6_fdholder_retrieve_maybe_delete_async (s6_fdholder_t *a, char const *id, int dodelete) { diff --git a/src/libs6/s6_fdholder_retrieve_cb.c b/src/libs6/s6_fdholder_retrieve_cb.c @@ -4,7 +4,7 @@ #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #include <skalibs/posixishard.h> diff --git a/src/libs6/s6_fdholder_setdump.c b/src/libs6/s6_fdholder_setdump.c @@ -12,7 +12,7 @@ #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #include <skalibs/posixishard.h> diff --git a/src/libs6/s6_fdholder_start.c b/src/libs6/s6_fdholder_start.c @@ -3,7 +3,7 @@ #include <skalibs/djbunix.h> #include <skalibs/socket.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> int s6_fdholder_start (s6_fdholder_t *a, char const *path, tain const *deadline, tain *stamp) { diff --git a/src/libs6/s6_fdholder_store.c b/src/libs6/s6_fdholder_store.c @@ -6,7 +6,7 @@ #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> #include <skalibs/posixishard.h> diff --git a/src/libs6/s6_fdholder_store_async.c b/src/libs6/s6_fdholder_store_async.c @@ -5,7 +5,7 @@ #include <errno.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -#include <s6/s6-fdholder.h> +#include <s6/fdholder.h> int s6_fdholder_store_async (s6_fdholder_t *a, int fd, char const *id, tain const *limit) { diff --git a/src/libs6/s6_supervise_link.c b/src/libs6/s6_supervise_link.c @@ -5,7 +5,7 @@ #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> int s6_supervise_link (char const *scdir, char const *const *servicedirs, size_t n, char const *prefix, uint32_t options, tain const *deadline, tain *stamp) { diff --git a/src/libs6/s6_supervise_link_names.c b/src/libs6/s6_supervise_link_names.c @@ -6,6 +6,7 @@ #include <errno.h> #include <sys/stat.h> +#include <skalibs/posixplz.h> #include <skalibs/bitarray.h> #include <skalibs/tai.h> #include <skalibs/stralloc.h> @@ -13,7 +14,7 @@ #include <s6/ftrigr.h> #include <s6/ftrigw.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> static inline void do_unlink (char const *scdir, char const *const *names, size_t n, uint32_t killopts) { @@ -36,6 +37,13 @@ static uint16_t registerit (ftrigr_t *a, char *fn, size_t len, gid_t gid, uint32 return ftrigr_subscribe(a, fn, "s", 0, deadline, stamp) ; } +/* + options: bit 0: force event/ mode + bit 1: make event/ public + bit 2: don't start the service + bit 3: remove down files after starting supervisors +*/ + int s6_supervise_link_names (char const *scdir, char const *const *servicedirs, char const *const *names, size_t n, uint32_t options, tain const *deadline, tain *stamp) { size_t maxnlen = 0, maxlen = 0 ; @@ -86,7 +94,7 @@ int s6_supervise_link_names (char const *scdir, char const *const *servicedirs, uint32_t killopts = 0 ; int r ; uint16_t ids[ntotal] ; - char lname[scdirlen + maxnlen + 2] ; + char lname[scdirlen + maxnlen + 7] ; char fn[maxlen + 5 + (sizeof(S6_SUPERVISE_EVENTDIR) > 5 ? sizeof(S6_SUPERVISE_EVENTDIR) : 5)] ; if (!ftrigr_startf(&a, deadline, stamp)) return -1 ; memcpy(lname, scdir, scdirlen) ; @@ -124,6 +132,16 @@ int s6_supervise_link_names (char const *scdir, char const *const *servicedirs, killopts = 3 ; if (ftrigr_wait_and(&a, ids, m, deadline, stamp) < 0) goto errsa ; ftrigr_end(&a) ; + if (options & 8) + { + for (size_t i = 0 ; i < n ; i++) + { + size_t nlen = strlen(names[i]) ; + memcpy(lname + scdirlen + 1, names[i], nlen) ; + memcpy(lname + scdirlen + 1 + nlen, "/down", 6) ; + unlink_void(lname) ; + } + } return m ; err: diff --git a/src/libs6/s6_supervise_unlink.c b/src/libs6/s6_supervise_unlink.c @@ -9,7 +9,7 @@ #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> void s6_supervise_unlink (char const *scdir, char const *name, uint32_t options) { diff --git a/src/libs6/s6_supervise_unlink_names.c b/src/libs6/s6_supervise_unlink_names.c @@ -0,0 +1,98 @@ +/* ISC license. */ + +#include <stdint.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <sys/stat.h> + +#include <skalibs/posixplz.h> +#include <skalibs/bitarray.h> + +#include <s6/ftrigr.h> +#include <s6/supervise.h> + +static uint16_t registerit (ftrigr_t *a, char *fn, size_t len, tain const *deadline, tain *stamp) +{ + memcpy(fn + len, "/" S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR) + 1) ; + return ftrigr_subscribe(a, fn, "x", 0, deadline, stamp) ; +} + +/* + options: bit 0: wait for s6-supervise to exit +*/ + +int s6_supervise_unlink_names (char const *scdir, char const *const *names, size_t n, uint32_t options, tain const *deadline, tain *stamp) +{ + size_t scdirlen = strlen(scdir) ; + size_t ntotal = n ; + unsigned char locked[bitarray_div8(n)] ; + unsigned char logged[bitarray_div8(n)] ; + if (!n) return 0 ; + memset(locked, 0, bitarray_div8(n)) ; + memset(logged, 0, bitarray_div8(n)) ; + + if (options & 1) for (size_t i = 0 ; i < n ; i++) + { + struct stat st ; + size_t nlen = strlen(names[i]) ; + int h ; + char fn[scdirlen + nlen + 6] ; + memcpy(fn, scdir, scdirlen) ; + fn[scdirlen] = '/' ; + memcpy(fn + scdirlen + 1, names[i], nlen + 1) ; + h = s6_svc_ok(fn) ; + if (h < 0) return -1 ; + if (h) bitarray_set(locked, i) ; + memcpy(fn + scdirlen + 1 + nlen, "/log", 5) ; + if (stat(fn, &st) < 0) + { + if (errno != ENOENT) return -1 ; + } + else + { + int r ; + if (!S_ISDIR(st.st_mode)) return (errno = ENOTDIR, -1) ; + r = s6_svc_ok(fn) ; + if (r < 0) return -1 ; + if (r != h) return (errno = EINVAL, -1) ; + bitarray_set(logged, i) ; + ntotal++ ; + } + } + + { + ftrigr_t a = FTRIGR_ZERO ; + unsigned int m = 0 ; + uint16_t ids[ntotal] ; + if (options & 1 && !ftrigr_startf(&a, deadline, stamp)) return -1 ; + for (size_t i = 0 ; i < n ; i++) + { + size_t nlen = strlen(names[i]) ; + char fn[scdirlen + nlen + 6 + sizeof(S6_SUPERVISE_EVENTDIR)] ; + memcpy(fn, scdir, scdirlen) ; + fn[scdirlen] = '/' ; + memcpy(fn + scdirlen + 1, names[i], nlen) ; + if (options & 1 && bitarray_peek(locked, i)) + { + ids[m] = registerit(&a, fn, scdirlen + 1 + nlen, deadline, stamp) ; + if (ids[m]) m++ ; + if (bitarray_peek(logged, i)) + { + memcpy(fn + scdirlen + 1 + nlen, "/log", 4) ; + ids[m] = registerit(&a, fn, scdirlen + 5 + nlen, deadline, stamp) ; + if (ids[m]) m++ ; + } + } + fn[scdirlen + 1 + nlen] = 0 ; + unlink_void(fn) ; + } + s6_svc_writectl(scdir, S6_SVSCAN_CTLDIR, "an", 2) ; + if (options & 1) + { + ftrigr_wait_and(&a, ids, m, deadline, stamp) ; + ftrigr_end(&a) ; + } + return m ; + } +} diff --git a/src/libs6/s6_svc_ok.c b/src/libs6/s6_svc_ok.c @@ -5,7 +5,7 @@ #include <skalibs/djbunix.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> int s6_svc_ok (char const *dir) { diff --git a/src/libs6/s6_svc_write.c b/src/libs6/s6_svc_write.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> int s6_svc_write (char const *fifo, char const *data, size_t datalen) { diff --git a/src/libs6/s6_svc_writectl.c b/src/libs6/s6_svc_writectl.c @@ -7,7 +7,7 @@ #include <string.h> #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> int s6_svc_writectl (char const *service, char const *subdir, char const *s, size_t len) { diff --git a/src/libs6/s6_svstatus_pack.c b/src/libs6/s6_svstatus_pack.c @@ -4,7 +4,7 @@ #include <skalibs/uint16.h> #include <skalibs/uint64.h> #include <skalibs/tai.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> void s6_svstatus_pack (char *pack, s6_svstatus_t const *sv) { @@ -15,8 +15,6 @@ void s6_svstatus_pack (char *pack, s6_svstatus_t const *sv) pack[34] = sv->flagpaused | (sv->flagfinishing << 1) | - (sv->flagwant << 2) | - (sv->flagwantup << 3) | - (sv->flagready << 4) | - (sv->flagthrottled << 5) ; + (sv->flagwantup << 2) | + (sv->flagready << 3) ; } diff --git a/src/libs6/s6_svstatus_read.c b/src/libs6/s6_svstatus_read.c @@ -2,7 +2,7 @@ #include <string.h> #include <skalibs/djbunix.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> int s6_svstatus_read (char const *dir, s6_svstatus_t *status) { diff --git a/src/libs6/s6_svstatus_unpack.c b/src/libs6/s6_svstatus_unpack.c @@ -4,7 +4,7 @@ #include <skalibs/uint16.h> #include <skalibs/uint64.h> #include <skalibs/tai.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> void s6_svstatus_unpack (char const *pack, s6_svstatus_t *sv) { @@ -18,8 +18,6 @@ void s6_svstatus_unpack (char const *pack, s6_svstatus_t *sv) sv->wstat = wstat ; sv->flagpaused = pack[34] & 1 ; sv->flagfinishing = !!(pack[34] & 2) ; - sv->flagwant = !!(pack[34] & 4) ; - sv->flagwantup = !!(pack[34] & 8) ; - sv->flagready = !!(pack[34] & 16) ; - sv->flagthrottled = !!(pack[34] & 32) ; + sv->flagwantup = !!(pack[34] & 4) ; + sv->flagready = !!(pack[34] & 8) ; } diff --git a/src/libs6/s6_svstatus_write.c b/src/libs6/s6_svstatus_write.c @@ -2,7 +2,7 @@ #include <string.h> #include <skalibs/djbunix.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> int s6_svstatus_write (char const *dir, s6_svstatus_t const *status) { diff --git a/src/libs6/s6lock_acquire.c b/src/libs6/s6lock_acquire.c @@ -9,7 +9,7 @@ #include <skalibs/tai.h> #include <skalibs/gensetdyn.h> #include <skalibs/textclient.h> -#include <s6/s6lock.h> +#include <s6/lock.h> int s6lock_acquire (s6lock_t *a, uint16_t *u, char const *path, uint32_t options, tain const *limit, tain const *deadline, tain *stamp) { diff --git a/src/libs6/s6lock_check.c b/src/libs6/s6lock_check.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/error.h> #include <skalibs/gensetdyn.h> -#include <s6/s6lock.h> +#include <s6/lock.h> int s6lock_check (s6lock_t *a, uint16_t id) { diff --git a/src/libs6/s6lock_end.c b/src/libs6/s6lock_end.c @@ -4,7 +4,7 @@ #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> #include <skalibs/textclient.h> -#include <s6/s6lock.h> +#include <s6/lock.h> void s6lock_end (s6lock_t *a) { diff --git a/src/libs6/s6lock_release.c b/src/libs6/s6lock_release.c @@ -5,7 +5,7 @@ #include <skalibs/uint16.h> #include <skalibs/gensetdyn.h> #include <skalibs/textclient.h> -#include <s6/s6lock.h> +#include <s6/lock.h> int s6lock_release (s6lock_t *a, uint16_t i, tain const *deadline, tain *stamp) { diff --git a/src/libs6/s6lock_start.c b/src/libs6/s6lock_start.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/textclient.h> -#include <s6/s6lock.h> +#include <s6/lock.h> int s6lock_start (s6lock_t *a, char const *path, tain const *deadline, tain *stamp) { diff --git a/src/libs6/s6lock_startf.c b/src/libs6/s6lock_startf.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/posixplz.h> #include <skalibs/textclient.h> -#include <s6/s6lock.h> +#include <s6/lock.h> int s6lock_startf (s6lock_t *a, char const *lockdir, tain const *deadline, tain *stamp) { diff --git a/src/libs6/s6lock_update.c b/src/libs6/s6lock_update.c @@ -10,7 +10,7 @@ #include <skalibs/gensetdyn.h> #include <skalibs/textclient.h> -#include <s6/s6lock.h> +#include <s6/lock.h> #include <skalibs/posixishard.h> diff --git a/src/libs6/s6lock_wait_and.c b/src/libs6/s6lock_wait_and.c @@ -2,7 +2,7 @@ #include <errno.h> #include <skalibs/iopause.h> -#include <s6/s6lock.h> +#include <s6/lock.h> int s6lock_wait_and (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain const *deadline, tain *stamp) { diff --git a/src/libs6/s6lock_wait_or.c b/src/libs6/s6lock_wait_or.c @@ -4,7 +4,7 @@ #include <skalibs/iopause.h> -#include <s6/s6lock.h> +#include <s6/lock.h> #include <skalibs/posixishard.h> diff --git a/src/libs6/s6lock_zero.c b/src/libs6/s6lock_zero.c @@ -1,5 +1,5 @@ /* ISC license. */ -#include <s6/s6lock.h> +#include <s6/lock.h> s6lock_t const s6lock_zero = S6LOCK_ZERO ; diff --git a/src/libs6/s6lockd.c b/src/libs6/s6lockd.c @@ -20,7 +20,7 @@ #include <skalibs/textmessage.h> #include <skalibs/textclient.h> -#include <s6/s6lock.h> +#include <s6/lock.h> #define USAGE "s6lockd lockdir" #define X() strerr_dief1x(101, "internal inconsistency, please submit a bug-report.") diff --git a/src/supervision/deps-exe/s6-svdir-unlink b/src/supervision/deps-exe/s6-svdir-unlink @@ -1,2 +0,0 @@ -${LIBS6} --lskarnet diff --git a/src/supervision/deps-exe/s6-svdir-link b/src/supervision/deps-exe/s6-svlink diff --git a/src/supervision/deps-exe/s6-svdir-link b/src/supervision/deps-exe/s6-svunlink diff --git a/src/supervision/s6-permafailon.c b/src/supervision/s6-permafailon.c @@ -11,7 +11,7 @@ #include <skalibs/tai.h> #include <skalibs/exec.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-permafailon seconds deathcount statuslist prog..." #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c @@ -25,7 +25,7 @@ #include <skalibs/skamisc.h> #include <s6/ftrigw.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-supervise dir" #define CTL S6_SUPERVISE_CTLDIR "/control" @@ -416,7 +416,6 @@ static int uplastup_z (void) status.wstat = (int)status.pid ; status.flagpaused = 0 ; status.flagready = 0 ; - status.flagthrottled = 0 ; flagdying = 0 ; tain_wallclock_read(&status.stamp) ; if (notifyfd >= 0) diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c @@ -10,7 +10,7 @@ #include <skalibs/exec.h> #include <s6/config.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -abqhkti12pcyroduxOX ] servicedir" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/supervision/s6-svdir-link.c b/src/supervision/s6-svdir-link.c @@ -1,105 +0,0 @@ -/* ISC license. */ - -#include <errno.h> -#include <stdint.h> -#include <string.h> -#include <sys/stat.h> - -#include <skalibs/types.h> -#include <skalibs/sgetopt.h> -#include <skalibs/tai.h> -#include <skalibs/strerr2.h> -#include <skalibs/djbunix.h> - -#include <s6/s6-supervise.h> - -#define USAGE "s6-svdir-link [ -d ] [ -f ] [ -P | -p ] [ -t timeout ] scandir name servicedir" -#define dieusage() strerr_dieusage(100, USAGE) - -static inline void checkscandir (char const *s) -{ - int r ; - int fd ; - size_t len = strlen(s) ; - char fn[len + 6 + sizeof(S6_SVSCAN_CTLDIR)] ; - memcpy(fn, s, len) ; - memcpy(fn + len, "/" S6_SVSCAN_CTLDIR "/lock", 6 + sizeof(S6_SVSCAN_CTLDIR)) ; - fd = open_read(fn) ; - if (fd < 0) strerr_diefu2sys(111, "open ", fn) ; - r = fd_islocked(fd) ; - if (r < 0) strerr_diefu2sys(111, "check lock on ", fn) ; - if (!r) strerr_dief2x(1, "s6-svscan not running on ", s) ; - fd_close(fd) ; -} - -static inline void checkservicedir (char const *s) -{ - int r ; - struct stat st ; - size_t len = strlen(s) ; - char fn[len + 9] ; - memcpy(fn, s, len) ; - memcpy(fn + len, "/run", 4) ; - if (stat(fn, &st) == -1) strerr_diefu2sys(111, "stat ", fn) ; - if (!(st.st_mode & S_IXUSR)) strerr_dief2x(100, fn, " is not executable") ; - r = s6_svc_ok(s) ; - if (r < 0) strerr_diefu2sys(111, "check supervision status of ", s) ; - if (r) strerr_warnw2x("supervisor already running on ", s) ; - memcpy(fn + len + 1, "log", 4) ; - if (stat(fn, &st) == -1) - { - if (errno != ENOENT) strerr_diefu2sys(111, "stat ", fn) ; - } - else - { - if (!S_ISDIR(st.st_mode)) strerr_dief2x(100, fn, " is not a directory") ; - memcpy(fn + len + 4, "/run", 5) ; - if (stat(fn, &st) == -1) strerr_diefu2sys(111, "stat ", fn) ; - if (!(st.st_mode & S_IXUSR)) strerr_dief2x(100, fn, " is not executable") ; - fn[len + 4] = 0 ; - r = s6_svc_ok(fn) ; - if (r < 0) strerr_diefu2sys(111, "check supervision status of ", fn) ; - if (r) strerr_warnw2x("supervisor already running on ", fn) ; - } -} - -int main (int argc, char const *const *argv) -{ - tain tto = TAIN_INFINITE_RELATIVE ; - uint32_t options = 0 ; - PROG = "s6-svdir-link" ; - { - unsigned int t = 0 ; - subgetopt l = SUBGETOPT_ZERO ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "dfPpt:", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'd' : options |= 4 ; break ; - case 'f' : options |= 1 ; break ; - case 'P' : options |= 2 ; break ; - case 'p' : options &= ~2U ; break ; - case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - if (t) tain_from_millisecs(&tto, t) ; - } - if (argc < 3) dieusage() ; - - if (!argv[0][0]) strerr_dief1x(100, "invalid scandir") ; - if (!argv[1][0] || argv[1][0] == '.' || argv[1][0] == '/') - strerr_dief1x(100, "invalid name") ; - if (!argv[2][0]) strerr_dief1x(100, "invalid servicedir") ; - checkscandir(argv[0]) ; - - tain_now_set_stopwatch_g() ; - tain_add_g(&tto, &tto) ; - - if (s6_supervise_link_names_g(argv[0], argv + 2, argv + 1, 1, options, &tto) == -1) - strerr_diefu6sys(111, "link servicedir ", argv[2], " into scandir ", argv[0], " with name ", argv[1]) ; - return 0 ; -} diff --git a/src/supervision/s6-svdir-unlink.c b/src/supervision/s6-svdir-unlink.c @@ -1,38 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> - -#include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> - -#include <s6/s6-supervise.h> - -#define USAGE "s6-svdir-unlink [ -d ] [ -x ] scandir servicename" -#define dieusage() strerr_dieusage(100, USAGE) - -int main (int argc, char const *const *argv) -{ - uint32_t options = 0 ; - PROG = "s6-svdir-link" ; - { - subgetopt l = SUBGETOPT_ZERO ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "dx", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'd' : options = 3 ; break ; - case 'x' : options = 1 ; break ; - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - } - if (argc < 2) dieusage() ; - - if (!argv[1][0] || argv[1][0] == '.' || argv[1][0] == '/') - strerr_dief1x(100, "invalid service name") ; - s6_supervise_unlink(argv[0], argv[1], options) ; - return 0 ; -} diff --git a/src/supervision/s6-svdt-clear.c b/src/supervision/s6-svdt-clear.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/strerr2.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-svdt-clear servicedir" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/supervision/s6-svdt.c b/src/supervision/s6-svdt.c @@ -6,7 +6,7 @@ #include <skalibs/strerr2.h> #include <skalibs/sgetopt.h> #include <skalibs/sig.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-svdt [ -S | -s ] [ -n maxentries ] servicedir" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/supervision/s6-svlink.c b/src/supervision/s6-svlink.c @@ -0,0 +1,117 @@ +/* ISC license. */ + +#include <errno.h> +#include <stdint.h> +#include <string.h> +#include <sys/stat.h> +#include <libgen.h> + +#include <skalibs/posixplz.h> +#include <skalibs/types.h> +#include <skalibs/sgetopt.h> +#include <skalibs/tai.h> +#include <skalibs/strerr2.h> +#include <skalibs/stralloc.h> +#include <skalibs/djbunix.h> + +#include <s6/supervise.h> + +#define USAGE "s6-svlink [ -d | -D ] [ -f ] [ -P ] [ -t timeout ] scandir servicedir [ name ]" +#define dieusage() strerr_dieusage(100, USAGE) + +static inline void checkscandir (char const *s) +{ + int r ; + int fd ; + size_t len = strlen(s) ; + char fn[len + 6 + sizeof(S6_SVSCAN_CTLDIR)] ; + memcpy(fn, s, len) ; + memcpy(fn + len, "/" S6_SVSCAN_CTLDIR "/lock", 6 + sizeof(S6_SVSCAN_CTLDIR)) ; + fd = open_read(fn) ; + if (fd < 0) strerr_diefu2sys(111, "open ", fn) ; + r = fd_islocked(fd) ; + if (r < 0) strerr_diefu2sys(111, "check lock on ", fn) ; + if (!r) strerr_dief2x(1, "s6-svscan not running on ", s) ; + fd_close(fd) ; +} + +static inline void checkservicedir (char const *s) +{ + int r ; + struct stat st ; + size_t len = strlen(s) ; + char fn[len + 9] ; + memcpy(fn, s, len) ; + memcpy(fn + len, "/run", 4) ; + if (stat(fn, &st) == -1) strerr_diefu2sys(111, "stat ", fn) ; + if (!(st.st_mode & S_IXUSR)) strerr_dief2x(100, fn, " is not executable") ; + r = s6_svc_ok(s) ; + if (r < 0) strerr_diefu2sys(111, "check supervision status of ", s) ; + if (r) strerr_warnw2x("supervisor already running on ", s) ; + memcpy(fn + len + 1, "log", 4) ; + if (stat(fn, &st) == -1) + { + if (errno != ENOENT) strerr_diefu2sys(111, "stat ", fn) ; + } + else + { + if (!S_ISDIR(st.st_mode)) strerr_dief2x(100, fn, " is not a directory") ; + memcpy(fn + len + 4, "/run", 5) ; + if (stat(fn, &st) == -1) strerr_diefu2sys(111, "stat ", fn) ; + if (!(st.st_mode & S_IXUSR)) strerr_dief2x(100, fn, " is not executable") ; + fn[len + 4] = 0 ; + r = s6_svc_ok(fn) ; + if (r < 0) strerr_diefu2sys(111, "check supervision status of ", fn) ; + if (r) strerr_warnw2x("supervisor already running on ", fn) ; + } +} + +int main (int argc, char const *const *argv) +{ + tain tto = TAIN_INFINITE_RELATIVE ; + uint32_t options = 0 ; + char const *name ; + PROG = "s6-svlink" ; + { + unsigned int t = 0 ; + subgetopt l = SUBGETOPT_ZERO ; + for (;;) + { + int opt = subgetopt_r(argc, argv, "dDfPt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'd' : options |= 12 ; break ; + case 'D' : options |= 4 ; options &= ~8U ; break ; + case 'f' : options |= 1 ; break ; + case 'P' : options |= 2 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } + } + argc -= l.ind ; argv += l.ind ; + if (t) tain_from_millisecs(&tto, t) ; + } + if (argc < 2) dieusage() ; + + if (argv[2]) name = argv[2] ; + else + { + stralloc sa = STRALLOC_ZERO ; + if (!stralloc_cats(&sa, argv[1]) || !stralloc_0(&sa)) + strerr_diefu1sys(111, "stralloc_cats") ; + name = basename(sa.s) ; + } + if (!argv[0][0]) strerr_dief1x(100, "invalid scandir") ; + if (!argv[1][0]) strerr_dief1x(100, "invalid servicedir") ; + if (!name[0] || name[0] == '.' || name[0] == '/') + strerr_dief1x(100, "invalid name") ; + checkscandir(argv[0]) ; + + tain_now_set_stopwatch_g() ; + tain_add_g(&tto, &tto) ; + + if (s6_supervise_link_names_g(argv[0], argv + 1, &name, 1, options, &tto) == -1) + strerr_diefu6sys(errno == ETIMEDOUT ? 99 : 111, "link servicedir ", argv[1], " into scandir ", argv[0], " with name ", name) ; + return 0 ; +} diff --git a/src/supervision/s6-svok.c b/src/supervision/s6-svok.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/strerr2.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-svok servicedir" diff --git a/src/supervision/s6-svperms.c b/src/supervision/s6-svperms.c @@ -12,7 +12,7 @@ #include <skalibs/buffer.h> #include <skalibs/strerr2.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-svperms [ -v ] [ -u | -g group | -G group | -o | -O group ] [ -e | -E group ] servicedir..." #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c @@ -22,7 +22,7 @@ #include <skalibs/exec.h> #include <s6/config.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-svscan [ -c maxservices ] [ -t timeout ] [ -d notif ] [ -X consoleholder ] [ dir ]" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/supervision/s6-svscanctl.c b/src/supervision/s6-svscanctl.c @@ -2,7 +2,7 @@ #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-svscanctl [ -zabhitqnN ] svscandir" #define dieusage() strerr_dieusage(100, USAGE) diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c @@ -13,7 +13,7 @@ #include <skalibs/sig.h> #include <skalibs/tai.h> #include <skalibs/djbunix.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #define USAGE "s6-svstat [ -uwNrpest | -o up,wantedup,normallyup,ready,paused,pid,exitcode,signal,signum,updownsince,readysince,updownfor,readyfor ] [ -n ] servicedir" #define dieusage() strerr_dieusage(100, USAGE) @@ -35,7 +35,7 @@ struct funcmap_s static void pr_up (buffer *b, s6_svstatus_t const *st) { - buffer_putsnoflush(b, st->pid && !st->flagfinishing ? st->flagthrottled ? "throttled" : "true" : "false") ; + buffer_putsnoflush(b, st->pid && !st->flagfinishing ? "true" : "false") ; } static void pr_wantedup (buffer *b, s6_svstatus_t const *st) @@ -210,8 +210,6 @@ static void legacy (s6_svstatus_t *st, int flagnum) buffer_putnoflush(buffer_1small, fmt, uint64_fmt(fmt, status.stamp.sec.x)) ; buffer_putnoflush(buffer_1small, " seconds", 8) ; - if (isup && status.flagthrottled) - buffer_putnoflush(buffer_1small, ", throttled", 11) ; if (isup && !normallyup) buffer_putnoflush(buffer_1small, ", normally down", 15) ; if (!isup && normallyup) diff --git a/src/supervision/s6-svunlink.c b/src/supervision/s6-svunlink.c @@ -0,0 +1,49 @@ +/* ISC license. */ + +#include <stdint.h> + +#include <skalibs/posixplz.h> +#include <skalibs/types.h> +#include <skalibs/sgetopt.h> +#include <skalibs/strerr2.h> +#include <skalibs/tai.h> + +#include <s6/supervise.h> + +#define USAGE "s6-svdir-unlink [ -X ] [ -t timeout ] scandir servicename" +#define dieusage() strerr_dieusage(100, USAGE) + +int main (int argc, char const *const *argv) +{ + tain tto = TAIN_INFINITE_RELATIVE ; + uint32_t options = 1 ; + PROG = "s6-svdir-link" ; + { + unsigned int t = 0 ; + subgetopt l = SUBGETOPT_ZERO ; + for (;;) + { + int opt = subgetopt_r(argc, argv, "Xt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'X' : options &= ~1U ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } + } + argc -= l.ind ; argv += l.ind ; + if (t) tain_from_millisecs(&tto, t) ; + } + if (argc < 2) dieusage() ; + + if (!argv[1][0] || argv[1][0] == '.' || argv[1][0] == '/') + strerr_dief1x(100, "invalid service name") ; + + tain_now_set_stopwatch_g() ; + tain_add_g(&tto, &tto) ; + + if (s6_supervise_unlink_names_g(argv[0], argv + 1, 1, options, &tto) == -1) + strerr_diefu4sys(111, "prepare unlinking of service ", argv[1], " in scandir ", argv[0]) ; + return 0 ; +} diff --git a/src/supervision/s6_svlisten_loop.c b/src/supervision/s6_svlisten_loop.c @@ -8,7 +8,7 @@ #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> #include <s6/ftrigr.h> -#include <s6/s6-supervise.h> +#include <s6/supervise.h> #include "s6-svlisten.h" void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, uint16_t *ids, unsigned char *upstate, unsigned char *readystate, tain const *deadline)