summaryrefslogtreecommitdiff
path: root/src/libs6rc/s6rc_servicedir_manage.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs6rc/s6rc_servicedir_manage.c')
-rw-r--r--src/libs6rc/s6rc_servicedir_manage.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/libs6rc/s6rc_servicedir_manage.c b/src/libs6rc/s6rc_servicedir_manage.c
index c665564..e4a6692 100644
--- a/src/libs6rc/s6rc_servicedir_manage.c
+++ b/src/libs6rc/s6rc_servicedir_manage.c
@@ -1,11 +1,9 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <stdint.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/tai.h>
#include <skalibs/direntry.h>
#include <skalibs/djbunix.h>
@@ -20,7 +18,7 @@ static void rollback (char const *live, char const *s, size_t len)
{
while (len)
{
- size_t n = str_len(s) + 1 ;
+ size_t n = strlen(s) + 1 ;
s6rc_servicedir_unsupervise(live, s, 0) ;
s += n ; len -= n ;
}
@@ -32,14 +30,14 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st
stralloc newnames = STRALLOC_ZERO ;
genalloc ids = GENALLOC_ZERO ; /* uint16_t */
gid_t gid = getgid() ;
- size_t livelen = str_len(live) ;
+ size_t livelen = strlen(live) ;
int ok = 1 ;
int e = 0 ;
DIR *dir ;
char dirfn[livelen + 13] ;
if (!ftrigr_startf(&a, deadline, stamp)) return 0 ;
- byte_copy(dirfn, livelen, live) ;
- byte_copy(dirfn + livelen, 13, "/servicedirs") ;
+ memcpy(dirfn, live, livelen) ;
+ memcpy(dirfn + livelen, "/servicedirs", 13) ;
dir = opendir(dirfn) ;
if (!dir) goto closederr ;
for (;;)
@@ -50,30 +48,30 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st
if (!d) break ;
if (d->d_name[0] == '.') continue ;
{
- size_t len = str_len(d->d_name) ;
+ size_t len = strlen(d->d_name) ;
int r ;
uint16_t id ;
char srcfn[livelen + 20 + len] ;
char dstfn[livelen + 10 + len] ;
- byte_copy(srcfn, livelen + 12, dirfn) ;
+ memcpy(srcfn, dirfn, livelen + 12) ;
srcfn[livelen + 12] = '/' ;
- byte_copy(srcfn + livelen + 13, len + 1, d->d_name) ;
+ memcpy(srcfn + livelen + 13, d->d_name, len + 1) ;
r = s6_svc_ok(srcfn) ;
if (r < 0) { e = errno ; goto err ; }
if (!r)
{
- byte_copy(srcfn + livelen + 13 + len, 6, "/down") ;
+ memcpy(srcfn + livelen + 13 + len, "/down", 6) ;
if (!touch(srcfn)) { e = errno ; goto err ; }
- byte_copy(srcfn + livelen + 14 + len, 6, "event") ;
+ memcpy(srcfn + livelen + 14 + len, "event", 6) ;
if (!ftrigw_fifodir_make(srcfn, gid, 0)) { e = errno ; goto err ; }
id = ftrigr_subscribe(&a, srcfn, "s", 0, deadline, stamp) ;
if (!id) { e = errno ; goto err ; }
- if (!genalloc_append(uint16, &ids, &id)) { e = errno ; goto err ; }
+ if (!genalloc_append(uint16_t, &ids, &id)) { e = errno ; goto err ; }
srcfn[livelen + 13 + len] = 0 ;
}
- byte_copy(dstfn, livelen, live) ;
- byte_copy(dstfn + livelen, 9, "/scandir/") ;
- byte_copy(dstfn + livelen + 9, len + 1, d->d_name) ;
+ memcpy(dstfn, live, livelen) ;
+ memcpy(dstfn + livelen, "/scandir/", 9) ;
+ memcpy(dstfn + livelen + 9, d->d_name, len + 1) ;
if (symlink(srcfn, dstfn) < 0)
{
if (!r || errno != EEXIST) { e = errno ; goto err ; }
@@ -93,9 +91,9 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st
dir_close(dir) ;
{
char scanfn[livelen + 9] ;
- register int r ;
- byte_copy(scanfn, livelen, live) ;
- byte_copy(scanfn + livelen, 9, "/scandir") ;
+ int r ;
+ memcpy(scanfn, live, livelen) ;
+ memcpy(scanfn + livelen, "/scandir", 9) ;
r = s6_svc_writectl(scanfn, S6_SVSCAN_CTLDIR, "a", 1) ;
if (r < 0) { e = errno ; goto closederr ; }
if (!r) ok = 3 ;