commit 1d69f26f58e72ceaab5aeda7df874faf7b46a5f3
parent daef3467ef868740c1dc8d89f11c04b91b3fdb47
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Wed, 3 Jul 2019 12:43:13 +0000
Remove s6-fdholder-*c programs
The doc still needs to be updated.
Diffstat:
34 files changed, 292 insertions(+), 710 deletions(-)
diff --git a/NEWS b/NEWS
@@ -1,5 +1,15 @@
Changelog for s6.
+In 2.9.0.0
+----------
+
+ - Bugfixes.
+ - The s6-fdholder-*c programs have been removed. They were unused: the
+separation between (for instance) s6-fdholder-store and s6-fdholder-storec
+added more complexity and more code than it brought benefits. The s6
+package is now 7 binaries leaner.
+
+
In 2.8.0.1
----------
diff --git a/doc/index.html b/doc/index.html
@@ -100,7 +100,7 @@ library. </li>
<h3> Download </h3>
<ul>
- <li> The current released version of s6 is <a href="s6-2.8.0.1.tar.gz">2.8.0.1</a>. </li>
+ <li> The current released version of s6 is <a href="s6-2.9.0.0.tar.gz">2.9.0.0</a>. </li>
<li> Alternatively, you can checkout a copy of the
<a href="//git.skarnet.org/cgi-bin/cgit.cgi/s6/">s6
git repository</a>:
@@ -265,19 +265,12 @@ synchronization</a>.
<p></p>
<ul>
<li><a href="s6-fdholder-store.html">The <tt>s6-fdholder-store</tt> program</a></li>
-<li><a href="s6-fdholder-storec.html">The <tt>s6-fdholder-storec</tt> program</a></li>
<li><a href="s6-fdholder-retrieve.html">The <tt>s6-fdholder-retrieve</tt> program</a></li>
-<li><a href="s6-fdholder-retrievec.html">The <tt>s6-fdholder-retrievec</tt> program</a></li>
<li><a href="s6-fdholder-delete.html">The <tt>s6-fdholder-delete</tt> program</a></li>
-<li><a href="s6-fdholder-deletec.html">The <tt>s6-fdholder-deletec</tt> program</a></li>
<li><a href="s6-fdholder-list.html">The <tt>s6-fdholder-list</tt> program</a></li>
-<li><a href="s6-fdholder-listc.html">The <tt>s6-fdholder-listc</tt> program</a></li>
<li><a href="s6-fdholder-getdump.html">The <tt>s6-fdholder-getdump</tt> program</a></li>
-<li><a href="s6-fdholder-getdumpc.html">The <tt>s6-fdholder-getdumpc</tt> program</a></li>
<li><a href="s6-fdholder-setdump.html">The <tt>s6-fdholder-setdump</tt> program</a></li>
-<li><a href="s6-fdholder-setdumpc.html">The <tt>s6-fdholder-setdumpc</tt> program</a></li>
<li><a href="s6-fdholder-transferdump.html">The <tt>s6-fdholder-transferdump</tt> program</a></li>
-<li><a href="s6-fdholder-transferdumpc.html">The <tt>s6-fdholder-transferdumpc</tt> program</a></li>
</ul>
<h3> Libraries </h3>
diff --git a/package/deps.mak b/package/deps.mak
@@ -31,20 +31,13 @@ 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/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/config.h
-src/fdholder/s6-fdholder-deletec.o src/fdholder/s6-fdholder-deletec.lo: src/fdholder/s6-fdholder-deletec.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/config.h
-src/fdholder/s6-fdholder-getdumpc.o src/fdholder/s6-fdholder-getdumpc.lo: src/fdholder/s6-fdholder-getdumpc.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/config.h
-src/fdholder/s6-fdholder-listc.o src/fdholder/s6-fdholder-listc.lo: src/fdholder/s6-fdholder-listc.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/config.h
-src/fdholder/s6-fdholder-retrievec.o src/fdholder/s6-fdholder-retrievec.lo: src/fdholder/s6-fdholder-retrievec.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/config.h
-src/fdholder/s6-fdholder-setdumpc.o src/fdholder/s6-fdholder-setdumpc.lo: src/fdholder/s6-fdholder-setdumpc.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/config.h
-src/fdholder/s6-fdholder-storec.o src/fdholder/s6-fdholder-storec.lo: src/fdholder/s6-fdholder-storec.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/config.h
-src/fdholder/s6-fdholder-transferdumpc.o src/fdholder/s6-fdholder-transferdumpc.lo: src/fdholder/s6-fdholder-transferdumpc.c 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/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/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
@@ -188,36 +181,22 @@ s6-tai64nlocal: EXTRA_LIBS :=
s6-tai64nlocal: src/daemontools-extras/s6-tai64nlocal.o -lskarnet
ucspilogd: EXTRA_LIBS :=
ucspilogd: src/daemontools-extras/ucspilogd.o -lskarnet
-s6-fdholder-daemon: EXTRA_LIBS :=
-s6-fdholder-daemon: src/fdholder/s6-fdholder-daemon.o -lskarnet
-s6-fdholder-delete: EXTRA_LIBS :=
-s6-fdholder-delete: src/fdholder/s6-fdholder-delete.o -lskarnet
-s6-fdholder-deletec: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
-s6-fdholder-deletec: src/fdholder/s6-fdholder-deletec.o ${LIBS6} -lskarnet
-s6-fdholder-getdump: EXTRA_LIBS :=
-s6-fdholder-getdump: src/fdholder/s6-fdholder-getdump.o -lskarnet
-s6-fdholder-getdumpc: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
-s6-fdholder-getdumpc: src/fdholder/s6-fdholder-getdumpc.o ${LIBS6} -lskarnet
-s6-fdholder-list: EXTRA_LIBS :=
-s6-fdholder-list: src/fdholder/s6-fdholder-list.o -lskarnet
-s6-fdholder-listc: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
-s6-fdholder-listc: src/fdholder/s6-fdholder-listc.o ${LIBS6} -lskarnet
-s6-fdholder-retrieve: EXTRA_LIBS :=
-s6-fdholder-retrieve: src/fdholder/s6-fdholder-retrieve.o -lskarnet
-s6-fdholder-retrievec: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
-s6-fdholder-retrievec: src/fdholder/s6-fdholder-retrievec.o ${LIBS6} -lskarnet
-s6-fdholder-setdump: EXTRA_LIBS :=
-s6-fdholder-setdump: src/fdholder/s6-fdholder-setdump.o -lskarnet
-s6-fdholder-setdumpc: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
-s6-fdholder-setdumpc: src/fdholder/s6-fdholder-setdumpc.o ${LIBS6} -lskarnet
-s6-fdholder-store: EXTRA_LIBS :=
-s6-fdholder-store: src/fdholder/s6-fdholder-store.o -lskarnet
-s6-fdholder-storec: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
-s6-fdholder-storec: src/fdholder/s6-fdholder-storec.o ${LIBS6} -lskarnet
-s6-fdholder-transferdump: EXTRA_LIBS :=
-s6-fdholder-transferdump: src/fdholder/s6-fdholder-transferdump.o -lskarnet
-s6-fdholder-transferdumpc: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
-s6-fdholder-transferdumpc: src/fdholder/s6-fdholder-transferdumpc.o ${LIBS6} -lskarnet
+s6-fdholder-daemon: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
+s6-fdholder-daemon: src/fdholder/s6-fdholder-daemon.o ${LIBS6} -lskarnet
+s6-fdholder-delete: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
+s6-fdholder-delete: src/fdholder/s6-fdholder-delete.o ${LIBS6} -lskarnet
+s6-fdholder-getdump: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
+s6-fdholder-getdump: src/fdholder/s6-fdholder-getdump.o ${LIBS6} -lskarnet
+s6-fdholder-list: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
+s6-fdholder-list: src/fdholder/s6-fdholder-list.o ${LIBS6} -lskarnet
+s6-fdholder-retrieve: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
+s6-fdholder-retrieve: src/fdholder/s6-fdholder-retrieve.o ${LIBS6} -lskarnet
+s6-fdholder-setdump: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
+s6-fdholder-setdump: src/fdholder/s6-fdholder-setdump.o ${LIBS6} -lskarnet
+s6-fdholder-store: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
+s6-fdholder-store: src/fdholder/s6-fdholder-store.o ${LIBS6} -lskarnet
+s6-fdholder-transferdump: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
+s6-fdholder-transferdump: src/fdholder/s6-fdholder-transferdump.o ${LIBS6} -lskarnet
s6-fdholderd: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
s6-fdholderd: src/fdholder/s6-fdholderd.o ${LIBS6} -lskarnet
ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
diff --git a/package/targets.mak b/package/targets.mak
@@ -45,19 +45,12 @@ s6-sudod \
s6-fdholder-daemon \
s6-fdholderd \
s6-fdholder-delete \
-s6-fdholder-deletec \
s6-fdholder-store \
-s6-fdholder-storec \
s6-fdholder-retrieve \
-s6-fdholder-retrievec \
s6-fdholder-list \
-s6-fdholder-listc \
s6-fdholder-getdump \
-s6-fdholder-getdumpc \
s6-fdholder-setdump \
-s6-fdholder-setdumpc \
s6-fdholder-transferdump \
-s6-fdholder-transferdumpc \
s6-applyuidgid \
s6-setuidgid
diff --git a/src/fdholder/deps-exe/s6-fdholder-daemon b/src/fdholder/deps-exe/s6-fdholder-daemon
@@ -1 +1,4 @@
+${LIBS6}
-lskarnet
+${SOCKET_LIB}
+${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-delete b/src/fdholder/deps-exe/s6-fdholder-delete
@@ -1 +1,4 @@
+${LIBS6}
-lskarnet
+${SOCKET_LIB}
+${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-deletec b/src/fdholder/deps-exe/s6-fdholder-deletec
@@ -1,4 +0,0 @@
-${LIBS6}
--lskarnet
-${SOCKET_LIB}
-${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-getdump b/src/fdholder/deps-exe/s6-fdholder-getdump
@@ -1 +1,4 @@
+${LIBS6}
-lskarnet
+${SOCKET_LIB}
+${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-getdumpc b/src/fdholder/deps-exe/s6-fdholder-getdumpc
@@ -1,4 +0,0 @@
-${LIBS6}
--lskarnet
-${SOCKET_LIB}
-${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-list b/src/fdholder/deps-exe/s6-fdholder-list
@@ -1 +1,4 @@
+${LIBS6}
-lskarnet
+${SOCKET_LIB}
+${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-listc b/src/fdholder/deps-exe/s6-fdholder-listc
@@ -1,4 +0,0 @@
-${LIBS6}
--lskarnet
-${SOCKET_LIB}
-${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-retrieve b/src/fdholder/deps-exe/s6-fdholder-retrieve
@@ -1 +1,4 @@
+${LIBS6}
-lskarnet
+${SOCKET_LIB}
+${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-retrievec b/src/fdholder/deps-exe/s6-fdholder-retrievec
@@ -1,4 +0,0 @@
-${LIBS6}
--lskarnet
-${SOCKET_LIB}
-${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-setdump b/src/fdholder/deps-exe/s6-fdholder-setdump
@@ -1 +1,4 @@
+${LIBS6}
-lskarnet
+${SOCKET_LIB}
+${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-setdumpc b/src/fdholder/deps-exe/s6-fdholder-setdumpc
@@ -1,4 +0,0 @@
-${LIBS6}
--lskarnet
-${SOCKET_LIB}
-${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-store b/src/fdholder/deps-exe/s6-fdholder-store
@@ -1 +1,4 @@
+${LIBS6}
-lskarnet
+${SOCKET_LIB}
+${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-storec b/src/fdholder/deps-exe/s6-fdholder-storec
@@ -1,4 +0,0 @@
-${LIBS6}
--lskarnet
-${SOCKET_LIB}
-${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-transferdump b/src/fdholder/deps-exe/s6-fdholder-transferdump
@@ -1 +1,4 @@
+${LIBS6}
-lskarnet
+${SOCKET_LIB}
+${TAINNOW_LIB}
diff --git a/src/fdholder/deps-exe/s6-fdholder-transferdumpc b/src/fdholder/deps-exe/s6-fdholder-transferdumpc
@@ -1,4 +0,0 @@
-${LIBS6}
--lskarnet
-${SOCKET_LIB}
-${TAINNOW_LIB}
diff --git a/src/fdholder/s6-fdholder-delete.c b/src/fdholder/s6-fdholder-delete.c
@@ -3,20 +3,19 @@
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
-#include <s6/config.h>
+#include <skalibs/tai.h>
+#include <s6/s6-fdholder.h>
#define USAGE "s6-fdholder-delete [ -t timeout ] socket id"
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
- char const *newargv[10] ;
- unsigned int timeout = 0 ;
- unsigned int m = 0 ;
- char fmtt[UINT_FMT] ;
+ s6_fdholder_t a = S6_FDHOLDER_ZERO ;
+ tain_t deadline ;
PROG = "s6-fdholder-delete" ;
{
+ unsigned int t = 0 ;
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
@@ -24,27 +23,20 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (opt == -1) break ;
switch (opt)
{
- case 't' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ;
+ case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
default : dieusage() ;
}
}
argc -= l.ind ; argv += l.ind ;
+ if (t) tain_from_millisecs(&deadline, t) ;
+ else deadline = tain_infinite_relative ;
}
if (argc < 2) dieusage() ;
-
- newargv[m++] = S6_BINPREFIX "s6-ipcclient" ;
- newargv[m++] = "-l0" ;
- newargv[m++] = "--" ;
- newargv[m++] = argv[0] ;
- newargv[m++] = S6_BINPREFIX "s6-fdholder-deletec" ;
- if (timeout)
- {
- fmtt[uint_fmt(fmtt, timeout)] = 0 ;
- newargv[m++] = "-t" ;
- newargv[m++] = fmtt ;
- }
- newargv[m++] = "--" ;
- newargv[m++] = argv[1] ;
- newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ tain_now_g() ;
+ tain_add_g(&deadline, &deadline) ;
+ if (!s6_fdholder_start_g(&a, argv[0], &deadline))
+ strerr_diefu2sys(111, "connect to a fd-holder daemon at ", argv[0]) ;
+ if (!s6_fdholder_delete_g(&a, argv[1], &deadline))
+ strerr_diefu2sys(1, "delete fd for id ", argv[0]) ;
+ return 0 ;
}
diff --git a/src/fdholder/s6-fdholder-deletec.c b/src/fdholder/s6-fdholder-deletec.c
@@ -1,42 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/types.h>
-#include <skalibs/strerr2.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/tai.h>
-#include <s6/s6-fdholder.h>
-
-#define USAGE "s6-fdholder-deletec [ -t timeout ] id"
-#define dieusage() strerr_dieusage(100, USAGE)
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- s6_fdholder_t a = S6_FDHOLDER_ZERO ;
- tain_t deadline ;
- PROG = "s6-fdholder-deletec" ;
- {
- unsigned int t = 0 ;
- subgetopt_t l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "t:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- if (t) tain_from_millisecs(&deadline, t) ;
- else deadline = tain_infinite_relative ;
- }
- if (!argc) dieusage() ;
-
- s6_fdholder_init(&a, 6) ;
- tain_now_g() ;
- tain_add_g(&deadline, &deadline) ;
- if (!s6_fdholder_delete_g(&a, argv[0], &deadline))
- strerr_diefu2sys(1, "delete fd for id ", argv[0]) ;
- return 0 ;
-}
diff --git a/src/fdholder/s6-fdholder-getdump.c b/src/fdholder/s6-fdholder-getdump.c
@@ -1,20 +1,27 @@
/* ISC license. */
+#include <string.h>
+#include <limits.h>
#include <skalibs/types.h>
-#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
+#include <skalibs/sgetopt.h>
+#include <skalibs/tai.h>
+#include <skalibs/env.h>
#include <skalibs/djbunix.h>
-#include <execline/config.h>
-#include <s6/config.h>
+#include <skalibs/genalloc.h>
+#include <s6/s6-fdholder.h>
#define USAGE "s6-fdholder-getdump [ -t timeout ] socket prog..."
#define dieusage() strerr_dieusage(100, USAGE)
int main (int argc, char const *const *argv, char const *const *envp)
{
- unsigned int timeout = 0 ;
- PROG = "s6-fdholder-retrieve" ;
+ s6_fdholder_t a = S6_FDHOLDER_ZERO ;
+ genalloc dump = GENALLOC_ZERO ;
+ tain_t deadline, halfinfinite ;
+ PROG = "s6-fdholder-getdump" ;
{
+ unsigned int t = 0 ;
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
@@ -22,36 +29,58 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (opt == -1) break ;
switch (opt)
{
- case 't' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ;
+ case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
default : dieusage() ;
}
}
argc -= l.ind ; argv += l.ind ;
- if (argc < 2) dieusage() ;
+ if (t) tain_from_millisecs(&deadline, t) ;
+ else deadline = tain_infinite_relative ;
}
+ if (argc < 2) dieusage() ;
+ tain_now_g() ;
+ tain_add_g(&deadline, &deadline) ;
+ if (!s6_fdholder_start_g(&a, argv[0], &deadline))
+ strerr_diefu2sys(111, "connect to a fd-holder daemon at ", argv[0]) ;
+ if (!s6_fdholder_getdump_g(&a, &dump, &deadline))
+ strerr_diefu1sys(1, "get dump") ;
+ s6_fdholder_end(&a) ;
+ tain_half(&halfinfinite, &tain_infinite_relative) ;
+ tain_add_g(&halfinfinite, &halfinfinite) ;
{
- char const *newargv[12 + argc] ;
- unsigned int m = 0 ;
- char fmtt[UINT_FMT] ;
- newargv[m++] = S6_BINPREFIX "s6-ipcclient" ;
- newargv[m++] = "-l0" ;
- newargv[m++] = "--" ;
- newargv[m++] = *argv++ ;
- newargv[m++] = S6_BINPREFIX "s6-fdholder-getdumpc" ;
- if (timeout)
+ size_t n = genalloc_len(s6_fdholder_fd_t, &dump) ;
+ size_t pos = 0 ;
+ unsigned int i = 0 ;
+ char modifs[7 + UINT_FMT + (25 + TIMESTAMP + 4 * UINT_FMT) * n] ;
+ if (n > UINT_MAX) strerr_dief1x(100, "dump exceeds maximum size") ;
+ memcpy(modifs + pos, "S6_FD#=", 7) ; pos += 7 ;
+ pos += uint_fmt(modifs + pos, n) ;
+ modifs[pos++] = 0 ;
+ for (; i < n ; i++)
{
- fmtt[uint_fmt(fmtt, timeout)] = 0 ;
- newargv[m++] = "-t" ;
- newargv[m++] = fmtt ;
+ s6_fdholder_fd_t *p = genalloc_s(s6_fdholder_fd_t, &dump) + i ;
+ size_t len = strlen(p->id) + 1 ;
+ if (uncoe(p->fd) < 0) strerr_diefu1sys(111, "uncoe") ;
+ memcpy(modifs + pos, "S6_FD_", 6) ; pos += 6 ;
+ pos += uint_fmt(modifs + pos, i) ;
+ modifs[pos++] = '=' ;
+ pos += uint_fmt(modifs + pos, p->fd) ;
+ modifs[pos++] = 0 ;
+ memcpy(modifs + pos, "S6_FDID_", 8) ; pos += 8 ;
+ pos += uint_fmt(modifs + pos, i) ;
+ modifs[pos++] = '=' ;
+ memcpy(modifs + pos, p->id, len) ;
+ pos += len ;
+ memcpy(modifs + pos, "S6_FDLIMIT_", 11) ; pos += 11 ;
+ pos += uint_fmt(modifs + pos, i) ;
+ if (tain_less(&p->limit, &halfinfinite))
+ {
+ modifs[pos++] = '=' ;
+ pos += timestamp_fmt(modifs + pos, &p->limit) ;
+ }
+ modifs[pos++] = 0 ;
}
- newargv[m++] = "--" ;
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ;
- newargv[m++] = "6" ;
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ;
- newargv[m++] = "7" ;
- while (*argv) newargv[m++] = *argv++ ;
- newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ xpathexec_r(argv+1, envp, env_len(envp), modifs, pos) ;
}
}
diff --git a/src/fdholder/s6-fdholder-getdumpc.c b/src/fdholder/s6-fdholder-getdumpc.c
@@ -1,85 +0,0 @@
-/* ISC license. */
-
-#include <string.h>
-#include <limits.h>
-#include <skalibs/types.h>
-#include <skalibs/strerr2.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/tai.h>
-#include <skalibs/env.h>
-#include <skalibs/djbunix.h>
-#include <skalibs/genalloc.h>
-#include <s6/s6-fdholder.h>
-
-#define USAGE "s6-fdholder-getdumpc [ -t timeout ] prog..."
-#define dieusage() strerr_dieusage(100, USAGE)
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- s6_fdholder_t a = S6_FDHOLDER_ZERO ;
- genalloc dump = GENALLOC_ZERO ;
- tain_t deadline, halfinfinite ;
- PROG = "s6-fdholder-getdumpc" ;
- {
- unsigned int t = 0 ;
- subgetopt_t l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "t:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- if (t) tain_from_millisecs(&deadline, t) ;
- else deadline = tain_infinite_relative ;
- }
- if (!argc) dieusage() ;
-
- s6_fdholder_init(&a, 6) ;
- tain_now_g() ;
- tain_add_g(&deadline, &deadline) ;
- if (!s6_fdholder_getdump_g(&a, &dump, &deadline))
- strerr_diefu1sys(1, "get dump") ;
- s6_fdholder_free(&a) ;
- tain_half(&halfinfinite, &tain_infinite_relative) ;
- tain_add_g(&halfinfinite, &halfinfinite) ;
- {
- size_t n = genalloc_len(s6_fdholder_fd_t, &dump) ;
- size_t pos = 0 ;
- unsigned int i = 0 ;
- char modifs[7 + UINT_FMT + (25 + TIMESTAMP + 4 * UINT_FMT) * n] ;
- if (n > UINT_MAX) strerr_dief1x(100, "dump exceeds maximum size") ;
- memcpy(modifs + pos, "S6_FD#=", 7) ; pos += 7 ;
- pos += uint_fmt(modifs + pos, n) ;
- modifs[pos++] = 0 ;
- for (; i < n ; i++)
- {
- s6_fdholder_fd_t *p = genalloc_s(s6_fdholder_fd_t, &dump) + i ;
- size_t len = strlen(p->id) + 1 ;
- if (uncoe(p->fd) < 0) strerr_diefu1sys(111, "uncoe") ;
- memcpy(modifs + pos, "S6_FD_", 6) ; pos += 6 ;
- pos += uint_fmt(modifs + pos, i) ;
- modifs[pos++] = '=' ;
- pos += uint_fmt(modifs + pos, p->fd) ;
- modifs[pos++] = 0 ;
- memcpy(modifs + pos, "S6_FDID_", 8) ; pos += 8 ;
- pos += uint_fmt(modifs + pos, i) ;
- modifs[pos++] = '=' ;
- memcpy(modifs + pos, p->id, len) ;
- pos += len ;
- memcpy(modifs + pos, "S6_FDLIMIT_", 11) ; pos += 11 ;
- pos += uint_fmt(modifs + pos, i) ;
- if (tain_less(&p->limit, &halfinfinite))
- {
- modifs[pos++] = '=' ;
- pos += timestamp_fmt(modifs + pos, &p->limit) ;
- }
- modifs[pos++] = 0 ;
- }
- xpathexec_r(argv, envp, env_len(envp), modifs, pos) ;
- }
-}
diff --git a/src/fdholder/s6-fdholder-list.c b/src/fdholder/s6-fdholder-list.c
@@ -1,51 +1,63 @@
/* ISC license. */
+#include <string.h>
#include <skalibs/types.h>
-#include <skalibs/sgetopt.h>
+#include <skalibs/buffer.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
-#include <s6/config.h>
+#include <skalibs/sgetopt.h>
+#include <skalibs/tai.h>
+#include <skalibs/stralloc.h>
+#include <skalibs/skamisc.h>
+#include <s6/s6-fdholder.h>
-#define USAGE "s6-fdholder-list [ -t timeout ] [ -T ] socket"
+#define USAGE "s6-fdholder-list [ -t timeout ] socket"
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
- char const *newargv[9] ;
- unsigned int m = 0 ;
- unsigned int timeout = 0 ;
- int printexpire = 0 ;
- char fmtt[UINT_FMT] ;
+ s6_fdholder_t a = S6_FDHOLDER_ZERO ;
+ stralloc sa = STRALLOC_ZERO, sb = STRALLOC_ZERO ;
+ size_t pos = 0 ;
+ int n ;
+ tain_t deadline ;
PROG = "s6-fdholder-list" ;
{
+ unsigned int t = 0 ;
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- int opt = subgetopt_r(argc, argv, "d:t:T:", &l) ;
+ int opt = subgetopt_r(argc, argv, "t:", &l) ;
if (opt == -1) break ;
switch (opt)
{
- case 'T' : printexpire = 1 ; break ;
- case 't' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ;
+ case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
default : dieusage() ;
}
}
argc -= l.ind ; argv += l.ind ;
+ if (t) tain_from_millisecs(&deadline, t) ;
+ else deadline = tain_infinite_relative ;
}
- if (!argc) dieusage() ;
- newargv[m++] = S6_BINPREFIX "s6-ipcclient" ;
- newargv[m++] = "-l0" ;
- newargv[m++] = "--" ;
- newargv[m++] = argv[0] ;
- newargv[m++] = S6_BINPREFIX "s6-fdholder-listc" ;
- if (printexpire) newargv[m++] = "-T" ;
- if (timeout)
+ if (!argc) dieusage() ;
+ tain_now_g() ;
+ tain_add_g(&deadline, &deadline) ;
+ if (!s6_fdholder_start_g(&a, argv[0], &deadline))
+ strerr_diefu2sys(111, "connect to a fd-holder daemon at ", argv[0]) ;
+ n = s6_fdholder_list_g(&a, &sa, &deadline) ;
+ if (n < 0) strerr_diefu1sys(1, "get fd list") ;
+ while (n--)
{
- fmtt[uint_fmt(fmtt, timeout)] = 0 ;
- newargv[m++] = "-t" ;
- newargv[m++] = fmtt ;
+ size_t len = strlen(sa.s + pos) ;
+ sb.len = 0 ;
+ if (!string_quote_nodelim_mustquote(&sb, sa.s + pos, len, 0, 0))
+ strerr_diefu1sys(111, "quote string") ;
+ if (buffer_put(buffer_1, sb.s, sb.len) < sb.len || buffer_put(buffer_1, "\n", 1) < 1)
+ strerr_diefu1sys(111, "buffer_put") ;
+ pos += len+1 ;
}
- newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ stralloc_free(&sb) ;
+ stralloc_free(&sa) ;
+ if (!buffer_flush(buffer_1)) strerr_diefu1sys(111, "write to stdout") ;
+ return 0 ;
}
diff --git a/src/fdholder/s6-fdholder-listc.c b/src/fdholder/s6-fdholder-listc.c
@@ -1,61 +0,0 @@
-/* ISC license. */
-
-#include <string.h>
-#include <skalibs/types.h>
-#include <skalibs/buffer.h>
-#include <skalibs/strerr2.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/tai.h>
-#include <skalibs/stralloc.h>
-#include <skalibs/skamisc.h>
-#include <s6/s6-fdholder.h>
-
-#define USAGE "s6-fdholder-listc [ -t timeout ]"
-#define dieusage() strerr_dieusage(100, USAGE)
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- s6_fdholder_t a = S6_FDHOLDER_ZERO ;
- stralloc sa = STRALLOC_ZERO, sb = STRALLOC_ZERO ;
- size_t pos = 0 ;
- int n ;
- tain_t deadline ;
- PROG = "s6-fdholder-listc" ;
- {
- unsigned int t = 0 ;
- subgetopt_t l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "t:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- if (t) tain_from_millisecs(&deadline, t) ;
- else deadline = tain_infinite_relative ;
- }
-
- s6_fdholder_init(&a, 6) ;
- tain_now_g() ;
- tain_add_g(&deadline, &deadline) ;
- n = s6_fdholder_list_g(&a, &sa, &deadline) ;
- if (n < 0) strerr_diefu1sys(1, "get fd list") ;
- while (n--)
- {
- size_t len = strlen(sa.s + pos) ;
- sb.len = 0 ;
- if (!string_quote_nodelim_mustquote(&sb, sa.s + pos, len, 0, 0))
- strerr_diefu1sys(111, "quote string") ;
- if (buffer_put(buffer_1, sb.s, sb.len) < sb.len || buffer_put(buffer_1, "\n", 1) < 1)
- strerr_diefu1sys(111, "buffer_put") ;
- pos += len+1 ;
- }
- stralloc_free(&sb) ;
- stralloc_free(&sa) ;
- if (!buffer_flush(buffer_1)) strerr_diefu1sys(111, "write to stdout") ;
- return 0 ;
-}
diff --git a/src/fdholder/s6-fdholder-retrieve.c b/src/fdholder/s6-fdholder-retrieve.c
@@ -1,21 +1,24 @@
/* ISC license. */
#include <skalibs/types.h>
-#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
+#include <skalibs/sgetopt.h>
+#include <skalibs/tai.h>
#include <skalibs/djbunix.h>
-#include <execline/config.h>
-#include <s6/config.h>
+#include <s6/s6-fdholder.h>
#define USAGE "s6-fdholder-retrieve [ -D ] [ -t timeout ] socket id prog..."
#define dieusage() strerr_dieusage(100, USAGE)
int main (int argc, char const *const *argv, char const *const *envp)
{
- unsigned int timeout = 0 ;
+ s6_fdholder_t a = S6_FDHOLDER_ZERO ;
+ tain_t deadline ;
+ int fd ;
int dodelete = 0 ;
PROG = "s6-fdholder-retrieve" ;
{
+ unsigned int t = 0 ;
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
@@ -24,38 +27,27 @@ int main (int argc, char const *const *argv, char const *const *envp)
switch (opt)
{
case 'D' : dodelete = 1 ; break ;
- case 't' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ;
+ case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
default : dieusage() ;
}
}
argc -= l.ind ; argv += l.ind ;
- if (argc < 3) dieusage() ;
+ if (t) tain_from_millisecs(&deadline, t) ;
+ else deadline = tain_infinite_relative ;
}
+ if (argc < 3) dieusage() ;
+ tain_now_g() ;
+ tain_add_g(&deadline, &deadline) ;
+ if (!s6_fdholder_start_g(&a, argv[0], &deadline))
+ strerr_diefu2sys(111, "connect to a fd-holder daemon at ", argv[0]) ;
+ fd = s6_fdholder_retrieve_maybe_delete_g(&a, argv[1], dodelete, &deadline) ;
+ if (fd < 0) strerr_diefu2sys(1, "retrieve fd for id ", argv[1]) ;
+ s6_fdholder_end(&a) ;
+ if (!fd)
{
- char const *newargv[13 + argc] ;
- unsigned int m = 0 ;
- char fmtt[UINT_FMT] ;
- newargv[m++] = S6_BINPREFIX "s6-ipcclient" ;
- newargv[m++] = "-l0" ;
- newargv[m++] = "--" ;
- newargv[m++] = *argv++ ;
- newargv[m++] = S6_BINPREFIX "s6-fdholder-retrievec" ;
- if (dodelete) newargv[m++] = "-D" ;
- if (timeout)
- {
- fmtt[uint_fmt(fmtt, timeout)] = 0 ;
- newargv[m++] = "-t" ;
- newargv[m++] = fmtt ;
- }
- newargv[m++] = "--" ;
- newargv[m++] = *argv++ ;
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ;
- newargv[m++] = "6" ;
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ;
- newargv[m++] = "7" ;
- while (*argv) newargv[m++] = *argv++ ;
- newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ if (uncoe(0) < 0) strerr_diefu1sys(111, "uncoe stdin") ;
}
+ else if (fd_move(0, fd) < 0) strerr_diefu1sys(111, "move fd") ;
+ xpathexec_run(argv[2], argv+2, envp) ;
}
diff --git a/src/fdholder/s6-fdholder-retrievec.c b/src/fdholder/s6-fdholder-retrievec.c
@@ -1,51 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/types.h>
-#include <skalibs/strerr2.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/tai.h>
-#include <skalibs/djbunix.h>
-#include <s6/s6-fdholder.h>
-
-#define USAGE "s6-fdholder-retrievec [ -D ] [ -t timeout ] id prog..."
-#define dieusage() strerr_dieusage(100, USAGE)
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- s6_fdholder_t a = S6_FDHOLDER_ZERO ;
- tain_t deadline ;
- int fd ;
- int dodelete = 0 ;
- PROG = "s6-fdholder-retrievec" ;
- {
- unsigned int t = 0 ;
- subgetopt_t l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "Dt:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 'D' : dodelete = 1 ; break ;
- case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- if (t) tain_from_millisecs(&deadline, t) ;
- else deadline = tain_infinite_relative ;
- }
- if (!argc) dieusage() ;
-
- s6_fdholder_init(&a, 6) ;
- tain_now_g() ;
- tain_add_g(&deadline, &deadline) ;
- fd = s6_fdholder_retrieve_maybe_delete_g(&a, argv[0], dodelete, &deadline) ;
- if (fd < 0) strerr_diefu2sys(1, "retrieve fd for id ", argv[0]) ;
- else if (!fd)
- {
- if (uncoe(0) < 0) strerr_diefu1sys(111, "uncoe stdin") ;
- }
- else if (fd_move(0, fd) < 0) strerr_diefu1sys(111, "move fd") ;
- xpathexec_run(argv[1], argv+1, envp) ;
-}
diff --git a/src/fdholder/s6-fdholder-setdump.c b/src/fdholder/s6-fdholder-setdump.c
@@ -1,22 +1,25 @@
/* ISC license. */
+#include <string.h>
+#include <stdlib.h>
#include <skalibs/types.h>
-#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
-#include <s6/config.h>
+#include <skalibs/sgetopt.h>
+#include <skalibs/tai.h>
+#include <s6/s6-fdholder.h>
#define USAGE "s6-fdholder-setdump [ -t timeout ] socket"
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
- char const *newargv[8] ;
- unsigned int timeout = 0 ;
- unsigned int m = 0 ;
- char fmtt[UINT_FMT] ;
+ s6_fdholder_t a = S6_FDHOLDER_ZERO ;
+ tain_t deadline ;
+ unsigned int dumplen ;
+ char const *x ;
PROG = "s6-fdholder-setdump" ;
{
+ unsigned int t = 0 ;
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
@@ -24,25 +27,53 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (opt == -1) break ;
switch (opt)
{
- case 't' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ;
+ case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
default : dieusage() ;
}
}
argc -= l.ind ; argv += l.ind ;
+ if (t) tain_from_millisecs(&deadline, t) ;
+ else deadline = tain_infinite_relative ;
}
if (!argc) dieusage() ;
- newargv[m++] = S6_BINPREFIX "s6-ipcclient" ;
- newargv[m++] = "-l0" ;
- newargv[m++] = "--" ;
- newargv[m++] = argv[0] ;
- newargv[m++] = S6_BINPREFIX "s6-fdholder-setdumpc" ;
- if (timeout)
+ x = getenv("S6_FD#") ;
+ if (!x) strerr_dienotset(100, "S6_FD#") ;
+ if (!uint0_scan(x, &dumplen)) strerr_dieinvalid(100, "S6_FD#") ;
+ tain_now_g() ;
+ tain_add_g(&deadline, &deadline) ;
+ if (!s6_fdholder_start_g(&a, argv[0], &deadline))
+ strerr_diefu2sys(111, "connect to a fd-holder daemon at ", argv[0]) ;
+ if (dumplen)
{
- fmtt[uint_fmt(fmtt, timeout)] = 0 ;
- newargv[m++] = "-t" ;
- newargv[m++] = fmtt ;
+ unsigned int i = 0 ;
+ s6_fdholder_fd_t dump[dumplen] ;
+ char s[11 + UINT_FMT] ;
+ for (; i < dumplen ; i++)
+ {
+ size_t len ;
+ unsigned int fd ;
+ memcpy(s, "S6_FD_", 6) ;
+ s[6 + uint_fmt(s+6, i)] = 0 ;
+ x = getenv(s) ;
+ if (!x) strerr_dienotset(100, s) ;
+ if (!uint0_scan(x, &fd)) strerr_dieinvalid(100, s) ;
+ dump[i].fd = fd ;
+ memcpy(s, "S6_FDID_", 8) ;
+ s[8 + uint_fmt(s+8, i)] = 0 ;
+ x = getenv(s) ;
+ if (!x) strerr_dienotset(100, s) ;
+ len = strlen(x) ;
+ if (!len || len > S6_FDHOLDER_ID_SIZE) strerr_dieinvalid(100, s) ;
+ memcpy(dump[i].id, x, len+1) ;
+ memcpy(s, "S6_FDLIMIT_", 11) ;
+ s[11 + uint_fmt(s+11, i)] = 0 ;
+ x = getenv(s) ;
+ if (!x) tain_add_g(&dump[i].limit, &tain_infinite_relative) ;
+ else if (!timestamp_scan(x, &dump[i].limit)) strerr_dieinvalid(100, s) ;
+ }
+ if (!s6_fdholder_setdump_g(&a, dump, dumplen, &deadline))
+ strerr_diefu1sys(1, "set dump") ;
}
- newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ return 0 ;
}
diff --git a/src/fdholder/s6-fdholder-setdumpc.c b/src/fdholder/s6-fdholder-setdumpc.c
@@ -1,77 +0,0 @@
-/* ISC license. */
-
-#include <string.h>
-#include <skalibs/types.h>
-#include <skalibs/env.h>
-#include <skalibs/strerr2.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/tai.h>
-#include <s6/s6-fdholder.h>
-
-#define USAGE "s6-fdholder-setdumpc [ -t timeout ]"
-#define dieusage() strerr_dieusage(100, USAGE)
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- s6_fdholder_t a = S6_FDHOLDER_ZERO ;
- tain_t deadline ;
- unsigned int dumplen ;
- char const *x ;
- PROG = "s6-fdholder-setdumpc" ;
- {
- unsigned int t = 0 ;
- subgetopt_t l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "t:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- if (t) tain_from_millisecs(&deadline, t) ;
- else deadline = tain_infinite_relative ;
- }
-
- s6_fdholder_init(&a, 6) ;
- x = env_get2(envp, "S6_FD#") ;
- if (!x) strerr_dienotset(100, "S6_FD#") ;
- if (!uint0_scan(x, &dumplen)) strerr_dieinvalid(100, "S6_FD#") ;
- if (dumplen)
- {
- unsigned int i = 0 ;
- s6_fdholder_fd_t dump[dumplen] ;
- char s[11 + UINT_FMT] ;
- tain_now_g() ;
- tain_add_g(&deadline, &deadline) ;
- for (; i < dumplen ; i++)
- {
- size_t len ;
- unsigned int fd ;
- memcpy(s, "S6_FD_", 6) ;
- s[6 + uint_fmt(s+6, i)] = 0 ;
- x = env_get2(envp, s) ;
- if (!x) strerr_dienotset(100, s) ;
- if (!uint0_scan(x, &fd)) strerr_dieinvalid(100, s) ;
- dump[i].fd = fd ;
- memcpy(s, "S6_FDID_", 8) ;
- s[8 + uint_fmt(s+8, i)] = 0 ;
- x = env_get2(envp, s) ;
- if (!x) strerr_dienotset(100, s) ;
- len = strlen(x) ;
- if (!len || len > S6_FDHOLDER_ID_SIZE) strerr_dieinvalid(100, s) ;
- memcpy(dump[i].id, x, len+1) ;
- memcpy(s, "S6_FDLIMIT_", 11) ;
- s[11 + uint_fmt(s+11, i)] = 0 ;
- x = env_get2(envp, s) ;
- if (!x) tain_add_g(&dump[i].limit, &tain_infinite_relative) ;
- else if (!timestamp_scan(x, &dump[i].limit)) strerr_dieinvalid(100, s) ;
- }
- if (!s6_fdholder_setdump_g(&a, dump, dumplen, &deadline))
- strerr_diefu1sys(1, "set dump") ;
- }
- return 0 ;
-}
diff --git a/src/fdholder/s6-fdholder-store.c b/src/fdholder/s6-fdholder-store.c
@@ -1,24 +1,22 @@
/* ISC license. */
#include <skalibs/types.h>
-#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
-#include <s6/config.h>
+#include <skalibs/sgetopt.h>
+#include <skalibs/tai.h>
+#include <s6/s6-fdholder.h>
#define USAGE "s6-fdholder-store [ -d fd ] [ -t timeout ] [ -T fdtimeout ] socket id"
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
- char const *newargv[12] ;
- unsigned int timeout = 0, limit = 0 ;
- unsigned int m = 0 ;
- char fmtt[UINT_FMT] ;
- char fmtl[UINT_FMT] ;
+ s6_fdholder_t a = S6_FDHOLDER_ZERO ;
+ tain_t deadline, limit ;
+ unsigned int fd = 0 ;
PROG = "s6-fdholder-store" ;
{
- unsigned int fd = 0 ;
+ unsigned int t = 0, T = 0 ;
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
@@ -27,36 +25,25 @@ int main (int argc, char const *const *argv, char const *const *envp)
switch (opt)
{
case 'd' : if (!uint0_scan(l.arg, &fd)) dieusage() ; break ;
- case 't' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ;
- case 'T' : if (!uint0_scan(l.arg, &limit)) dieusage() ; break ;
+ case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
+ case 'T' : if (!uint0_scan(l.arg, &T)) dieusage() ; break ;
default : dieusage() ;
}
}
argc -= l.ind ; argv += l.ind ;
- if (argc < 2) dieusage() ;
- if (fd && fd_move(0, fd) < 0)
- strerr_diefu1sys(111, "move file descriptor") ;
+ if (t) tain_from_millisecs(&deadline, t) ;
+ else deadline = tain_infinite_relative ;
+ if (T) tain_from_millisecs(&limit, T) ;
+ else limit = tain_infinite_relative ;
}
+ if (argc < 2) dieusage() ;
- newargv[m++] = S6_BINPREFIX "s6-ipcclient" ;
- newargv[m++] = "-l0" ;
- newargv[m++] = "--" ;
- newargv[m++] = argv[0] ;
- newargv[m++] = S6_BINPREFIX "s6-fdholder-storec" ;
- if (timeout)
- {
- fmtt[uint_fmt(fmtt, timeout)] = 0 ;
- newargv[m++] = "-t" ;
- newargv[m++] = fmtt ;
- }
- if (limit)
- {
- fmtl[uint_fmt(fmtl, limit)] = 0 ;
- newargv[m++] = "-T" ;
- newargv[m++] = fmtl ;
- }
- newargv[m++] = "--" ;
- newargv[m++] = argv[1] ;
- newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ tain_now_g() ;
+ tain_add_g(&deadline, &deadline) ;
+ tain_add_g(&limit, &limit) ;
+ if (!s6_fdholder_start_g(&a, argv[0], &deadline))
+ strerr_diefu2sys(111, "connect to a fd-holder daemon at ", argv[0]) ;
+ if (!s6_fdholder_store_g(&a, fd, argv[1], &limit, &deadline))
+ strerr_diefu1sys(1, "store fd") ;
+ return 0 ;
}
diff --git a/src/fdholder/s6-fdholder-storec.c b/src/fdholder/s6-fdholder-storec.c
@@ -1,46 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/types.h>
-#include <skalibs/strerr2.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/tai.h>
-#include <s6/s6-fdholder.h>
-
-#define USAGE "s6-fdholder-storec [ -t timeout ] [ -T fdtimeout ] id"
-#define dieusage() strerr_dieusage(100, USAGE)
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- s6_fdholder_t a = S6_FDHOLDER_ZERO ;
- tain_t deadline, limit ;
- PROG = "s6-fdholder-storec" ;
- {
- unsigned int t = 0, T = 0 ;
- subgetopt_t l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "t:T:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
- case 'T' : if (!uint0_scan(l.arg, &T)) dieusage() ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- if (t) tain_from_millisecs(&deadline, t) ;
- else deadline = tain_infinite_relative ;
- if (T) tain_from_millisecs(&limit, T) ;
- else limit = tain_infinite_relative ;
- }
- if (!argc) dieusage() ;
-
- s6_fdholder_init(&a, 6) ;
- tain_now_g() ;
- tain_add_g(&deadline, &deadline) ;
- tain_add_g(&limit, &limit) ;
- if (!s6_fdholder_store_g(&a, 0, argv[0], &limit, &deadline))
- strerr_diefu1sys(1, "store fd") ;
- return 0 ;
-}
diff --git a/src/fdholder/s6-fdholder-transferdump.c b/src/fdholder/s6-fdholder-transferdump.c
@@ -1,26 +1,23 @@
/* ISC license. */
-#include <sys/types.h>
#include <skalibs/types.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/env.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
-#include <execline/config.h>
-#include <s6/config.h>
+#include <skalibs/sgetopt.h>
+#include <skalibs/tai.h>
+#include <skalibs/genalloc.h>
+#include <s6/s6-fdholder.h>
#define USAGE "s6-fdholder-transferdump [ -t timeoutfrom:timeoutto ] socketfrom socketto"
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
- char const *newargv[24] ;
- unsigned int timeoutfrom = 0, timeoutto = 0 ;
- unsigned int m = 0 ;
- char fmtfrom[UINT_FMT] ;
- char fmtto[UINT_FMT] ;
- PROG = "s6-fdholder-setdump" ;
+ s6_fdholder_t a = S6_FDHOLDER_ZERO ;
+ genalloc dump = GENALLOC_ZERO ; /* array of s6_fdholder_fd_t */
+ tain_t deadline, totto ;
+ PROG = "s6-fdholder-transferdump" ;
{
+ unsigned int timeoutfrom = 0, timeoutto = 0 ;
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
@@ -49,40 +46,24 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
}
argc -= l.ind ; argv += l.ind ;
+ if (timeoutfrom) tain_from_millisecs(&deadline, timeoutfrom) ;
+ else deadline = tain_infinite_relative ;
+ if (timeoutto) tain_from_millisecs(&totto, timeoutto) ;
+ else totto = tain_infinite_relative ;
}
if (argc < 2) dieusage() ;
- newargv[m++] = S6_BINPREFIX "s6-ipcclient" ;
- newargv[m++] = "-l0" ;
- newargv[m++] = "--" ;
- newargv[m++] = argv[0] ;
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ;
- newargv[m++] = "7" ;
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdmove" ;
- newargv[m++] = "0" ;
- newargv[m++] = "6" ;
- newargv[m++] = S6_BINPREFIX "s6-ipcclient" ;
- newargv[m++] = "-l0" ;
- newargv[m++] = "--" ;
- newargv[m++] = argv[1] ;
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ;
- newargv[m++] = "6" ;
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdmove" ;
- newargv[m++] = "1" ;
- newargv[m++] = "7" ;
- newargv[m++] = S6_BINPREFIX "s6-fdholder-transferdumpc" ;
- if (timeoutfrom)
- {
- fmtfrom[uint_fmt(fmtfrom, timeoutfrom)] = 0 ;
- newargv[m++] = "-t" ;
- newargv[m++] = fmtfrom ;
- }
- if (timeoutto)
- {
- fmtto[uint_fmt(fmtto, timeoutto)] = 0 ;
- newargv[m++] = "-T" ;
- newargv[m++] = fmtto ;
- }
- newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ tain_now_g() ;
+ tain_add_g(&deadline, &deadline) ;
+ if (!s6_fdholder_start_g(&a, argv[0], &deadline))
+ strerr_diefu2sys(111, "connect to a source fd-holder daemon at ", argv[0]) ;
+ if (!s6_fdholder_getdump_g(&a, &dump, &deadline))
+ strerr_diefu1sys(1, "get dump") ;
+ s6_fdholder_end(&a) ;
+ tain_add_g(&deadline, &totto) ;
+ if (!s6_fdholder_start_g(&a, argv[1], &deadline))
+ strerr_diefu2sys(111, "connect to a destination fd-holder daemon at ", argv[1]) ;
+ if (!s6_fdholder_setdump_g(&a, genalloc_s(s6_fdholder_fd_t, &dump), genalloc_len(s6_fdholder_fd_t, &dump), &deadline))
+ strerr_diefu1sys(1, "set dump") ;
+ return 0 ;
}
diff --git a/src/fdholder/s6-fdholder-transferdumpc.c b/src/fdholder/s6-fdholder-transferdumpc.c
@@ -1,51 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/types.h>
-#include <skalibs/strerr2.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/tai.h>
-#include <skalibs/genalloc.h>
-#include <s6/s6-fdholder.h>
-
-#define USAGE "s6-fdholder-transferdumpc [ -t timeoutfrom ] [ -T timeoutto ]"
-#define dieusage() strerr_dieusage(100, USAGE)
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- s6_fdholder_t a = S6_FDHOLDER_ZERO ;
- genalloc dump = GENALLOC_ZERO ;
- tain_t deadline, totto ;
- PROG = "s6-fdholder-transferdumpc" ;
- {
- unsigned int t = 0, T = 0 ;
- subgetopt_t l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "t:T:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
- case 'T' : if (!uint0_scan(l.arg, &T)) dieusage() ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- if (t) tain_from_millisecs(&deadline, t) ;
- else deadline = tain_infinite_relative ;
- if (T) tain_from_millisecs(&totto, T) ;
- else totto = tain_infinite_relative ;
- }
-
- s6_fdholder_init(&a, 0) ;
- tain_now_g() ;
- tain_add_g(&deadline, &deadline) ;
- if (!s6_fdholder_getdump_g(&a, &dump, &deadline))
- strerr_diefu1sys(1, "get dump") ;
- s6_fdholder_free(&a) ;
- s6_fdholder_init(&a, 1) ;
- tain_add_g(&deadline, &totto) ;
- if (!s6_fdholder_setdump_g(&a, genalloc_s(s6_fdholder_fd_t, &dump), genalloc_len(s6_fdholder_fd_t, &dump), &deadline))
- strerr_diefu1sys(1, "set dump") ;
- return 0 ;
-}
diff --git a/src/libs6/s6_fdholder_start.c b/src/libs6/s6_fdholder_start.c
@@ -14,6 +14,6 @@ int s6_fdholder_start (s6_fdholder_t *a, char const *path, tain_t const *deadlin
fd_close(fd) ;
return 0 ;
}
- unixconnection_init(&a->connection, fd, fd) ;
+ s6_fdholder_init(a, fd) ;
return 1 ;
}