diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-10-08 15:39:57 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-10-08 15:39:57 +0000 |
commit | f9940bb7d1a6ce7d7772e8cbdbbd55a321cc5c18 (patch) | |
tree | 352798ff6073e18a467a9ffeab548485070dc568 /src/libs6rc/s6rc_livedir_suffix.c | |
parent | 8c341bbaca5e89a9620702bc0025641e815e4195 (diff) | |
download | s6-rc-f9940bb7d1a6ce7d7772e8cbdbbd55a321cc5c18.tar.xz |
Add -s to s6-rc-init; prepare for 0.3.0.0
Diffstat (limited to 'src/libs6rc/s6rc_livedir_suffix.c')
-rw-r--r-- | src/libs6rc/s6rc_livedir_suffix.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libs6rc/s6rc_livedir_suffix.c b/src/libs6rc/s6rc_livedir_suffix.c new file mode 100644 index 0000000..98236cd --- /dev/null +++ b/src/libs6rc/s6rc_livedir_suffix.c @@ -0,0 +1,19 @@ +/* ISC license. */ + +#include <string.h> +#include <errno.h> +#include <skalibs/djbunix.h> +#include <s6-rc/s6rc-utils.h> + +ssize_t s6rc_livedir_suffix (char const *live, char *s, size_t n) +{ + size_t llen = strlen(live) ; + size_t r ; + char sfn[llen + 8] ; + memcpy(sfn, live, llen) ; + memcpy(sfn + llen, "/suffix", 8) ; + r = openreadnclose(sfn, s, n) ; + if (r < 0) return r ; + if (memchr(s, '/', r)) return (errno = EINVAL, 0) ; + return r ; +} |