From 1d69f26f58e72ceaab5aeda7df874faf7b46a5f3 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 3 Jul 2019 12:43:13 +0000 Subject: Remove s6-fdholder-*c programs The doc still needs to be updated. --- src/fdholder/deps-exe/s6-fdholder-daemon | 3 + src/fdholder/deps-exe/s6-fdholder-delete | 3 + src/fdholder/deps-exe/s6-fdholder-deletec | 4 -- src/fdholder/deps-exe/s6-fdholder-getdump | 3 + src/fdholder/deps-exe/s6-fdholder-getdumpc | 4 -- src/fdholder/deps-exe/s6-fdholder-list | 3 + src/fdholder/deps-exe/s6-fdholder-listc | 4 -- src/fdholder/deps-exe/s6-fdholder-retrieve | 3 + src/fdholder/deps-exe/s6-fdholder-retrievec | 4 -- src/fdholder/deps-exe/s6-fdholder-setdump | 3 + src/fdholder/deps-exe/s6-fdholder-setdumpc | 4 -- src/fdholder/deps-exe/s6-fdholder-store | 3 + src/fdholder/deps-exe/s6-fdholder-storec | 4 -- src/fdholder/deps-exe/s6-fdholder-transferdump | 3 + src/fdholder/deps-exe/s6-fdholder-transferdumpc | 4 -- src/fdholder/s6-fdholder-delete.c | 40 +++++------- src/fdholder/s6-fdholder-deletec.c | 42 ------------ src/fdholder/s6-fdholder-getdump.c | 83 ++++++++++++++++-------- src/fdholder/s6-fdholder-getdumpc.c | 85 ------------------------- src/fdholder/s6-fdholder-list.c | 64 +++++++++++-------- src/fdholder/s6-fdholder-listc.c | 61 ------------------ src/fdholder/s6-fdholder-retrieve.c | 52 +++++++-------- src/fdholder/s6-fdholder-retrievec.c | 51 --------------- src/fdholder/s6-fdholder-setdump.c | 71 +++++++++++++++------ src/fdholder/s6-fdholder-setdumpc.c | 77 ---------------------- src/fdholder/s6-fdholder-store.c | 59 +++++++---------- src/fdholder/s6-fdholder-storec.c | 46 ------------- src/fdholder/s6-fdholder-transferdump.c | 73 ++++++++------------- src/fdholder/s6-fdholder-transferdumpc.c | 51 --------------- src/libs6/s6_fdholder_start.c | 2 +- 30 files changed, 258 insertions(+), 651 deletions(-) delete mode 100644 src/fdholder/deps-exe/s6-fdholder-deletec delete mode 100644 src/fdholder/deps-exe/s6-fdholder-getdumpc delete mode 100644 src/fdholder/deps-exe/s6-fdholder-listc delete mode 100644 src/fdholder/deps-exe/s6-fdholder-retrievec delete mode 100644 src/fdholder/deps-exe/s6-fdholder-setdumpc delete mode 100644 src/fdholder/deps-exe/s6-fdholder-storec delete mode 100644 src/fdholder/deps-exe/s6-fdholder-transferdumpc delete mode 100644 src/fdholder/s6-fdholder-deletec.c delete mode 100644 src/fdholder/s6-fdholder-getdumpc.c delete mode 100644 src/fdholder/s6-fdholder-listc.c delete mode 100644 src/fdholder/s6-fdholder-retrievec.c delete mode 100644 src/fdholder/s6-fdholder-setdumpc.c delete mode 100644 src/fdholder/s6-fdholder-storec.c delete mode 100644 src/fdholder/s6-fdholder-transferdumpc.c (limited to 'src') diff --git a/src/fdholder/deps-exe/s6-fdholder-daemon b/src/fdholder/deps-exe/s6-fdholder-daemon index e7187fe..f3a3143 100644 --- 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 index e7187fe..f3a3143 100644 --- 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 deleted file mode 100644 index f3a3143..0000000 --- a/src/fdholder/deps-exe/s6-fdholder-deletec +++ /dev/null @@ -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 index e7187fe..f3a3143 100644 --- 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 deleted file mode 100644 index f3a3143..0000000 --- a/src/fdholder/deps-exe/s6-fdholder-getdumpc +++ /dev/null @@ -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 index e7187fe..f3a3143 100644 --- 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 deleted file mode 100644 index f3a3143..0000000 --- a/src/fdholder/deps-exe/s6-fdholder-listc +++ /dev/null @@ -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 index e7187fe..f3a3143 100644 --- 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 deleted file mode 100644 index f3a3143..0000000 --- a/src/fdholder/deps-exe/s6-fdholder-retrievec +++ /dev/null @@ -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 index e7187fe..f3a3143 100644 --- 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 deleted file mode 100644 index f3a3143..0000000 --- a/src/fdholder/deps-exe/s6-fdholder-setdumpc +++ /dev/null @@ -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 index e7187fe..f3a3143 100644 --- 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 deleted file mode 100644 index f3a3143..0000000 --- a/src/fdholder/deps-exe/s6-fdholder-storec +++ /dev/null @@ -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 index e7187fe..f3a3143 100644 --- 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 deleted file mode 100644 index f3a3143..0000000 --- a/src/fdholder/deps-exe/s6-fdholder-transferdumpc +++ /dev/null @@ -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 index def559f..09d3a2c 100644 --- a/src/fdholder/s6-fdholder-delete.c +++ b/src/fdholder/s6-fdholder-delete.c @@ -3,20 +3,19 @@ #include #include #include -#include -#include +#include +#include #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 deleted file mode 100644 index 2b9820e..0000000 --- a/src/fdholder/s6-fdholder-deletec.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include -#include - -#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 index 5e0e3f6..89069e9 100644 --- a/src/fdholder/s6-fdholder-getdump.c +++ b/src/fdholder/s6-fdholder-getdump.c @@ -1,20 +1,27 @@ /* ISC license. */ +#include +#include #include -#include #include +#include +#include +#include #include -#include -#include +#include +#include #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 deleted file mode 100644 index 12c7ac1..0000000 --- a/src/fdholder/s6-fdholder-getdumpc.c +++ /dev/null @@ -1,85 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index ffda680..d6981d0 100644 --- a/src/fdholder/s6-fdholder-list.c +++ b/src/fdholder/s6-fdholder-list.c @@ -1,51 +1,63 @@ /* ISC license. */ +#include #include -#include +#include #include -#include -#include +#include +#include +#include +#include +#include -#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 deleted file mode 100644 index 8c746c3..0000000 --- a/src/fdholder/s6-fdholder-listc.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index de98612..dacc072 100644 --- a/src/fdholder/s6-fdholder-retrieve.c +++ b/src/fdholder/s6-fdholder-retrieve.c @@ -1,21 +1,24 @@ /* ISC license. */ #include -#include #include +#include +#include #include -#include -#include +#include #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 deleted file mode 100644 index d358e1c..0000000 --- a/src/fdholder/s6-fdholder-retrievec.c +++ /dev/null @@ -1,51 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include -#include -#include - -#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 index 289c8c0..41a1c07 100644 --- a/src/fdholder/s6-fdholder-setdump.c +++ b/src/fdholder/s6-fdholder-setdump.c @@ -1,22 +1,25 @@ /* ISC license. */ +#include +#include #include -#include #include -#include -#include +#include +#include +#include #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 deleted file mode 100644 index ff01384..0000000 --- a/src/fdholder/s6-fdholder-setdumpc.c +++ /dev/null @@ -1,77 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include -#include -#include -#include - -#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 index 7404bac..75510d2 100644 --- a/src/fdholder/s6-fdholder-store.c +++ b/src/fdholder/s6-fdholder-store.c @@ -1,24 +1,22 @@ /* ISC license. */ #include -#include #include -#include -#include +#include +#include +#include #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 deleted file mode 100644 index 32af82c..0000000 --- a/src/fdholder/s6-fdholder-storec.c +++ /dev/null @@ -1,46 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include -#include - -#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 index 9cd7ca8..83d1e80 100644 --- a/src/fdholder/s6-fdholder-transferdump.c +++ b/src/fdholder/s6-fdholder-transferdump.c @@ -1,26 +1,23 @@ /* ISC license. */ -#include #include -#include -#include #include -#include -#include -#include +#include +#include +#include +#include #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 deleted file mode 100644 index 9b53fac..0000000 --- a/src/fdholder/s6-fdholder-transferdumpc.c +++ /dev/null @@ -1,51 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include -#include -#include - -#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 index d887247..2fb81d8 100644 --- 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 ; } -- cgit v1.2.3