summaryrefslogtreecommitdiff
path: root/src/libs6
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-03-12 11:59:43 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-03-12 11:59:43 +0000
commitc60ebd422171808ad58b936914055397bb205bef (patch)
tree7db3e5728d72ad209f8e22b9eb9f337e0b0c3e58 /src/libs6
parente28fe5908a91d8795ca9923d64eeed7d3e898434 (diff)
downloads6-c60ebd422171808ad58b936914055397bb205bef.tar.xz
Adapt to skalibs-2.5.0.0
Diffstat (limited to 'src/libs6')
-rw-r--r--src/libs6/ftrig1_make.c11
-rw-r--r--src/libs6/ftrigr_check.c2
-rw-r--r--src/libs6/ftrigr_subscribe.c24
-rw-r--r--src/libs6/ftrigr_unsubscribe.c2
-rw-r--r--src/libs6/ftrigr_update.c2
-rw-r--r--src/libs6/ftrigr_wait_and.c2
-rw-r--r--src/libs6/ftrigr_wait_or.c4
-rw-r--r--src/libs6/ftrigw_clean.c13
-rw-r--r--src/libs6/ftrigw_fifodir_make.c3
-rw-r--r--src/libs6/ftrigw_notifyb_nosig.c15
-rw-r--r--src/libs6/s6-ftrigrd.c14
-rw-r--r--src/libs6/s6_accessrules_backend_cdb.c9
-rw-r--r--src/libs6/s6_accessrules_backend_fs.c20
-rw-r--r--src/libs6/s6_accessrules_keycheck_ip4.c7
-rw-r--r--src/libs6/s6_accessrules_keycheck_ip6.c9
-rw-r--r--src/libs6/s6_accessrules_keycheck_reversedns.c10
-rw-r--r--src/libs6/s6_accessrules_keycheck_uidgid.c4
-rw-r--r--src/libs6/s6_fdholder_delete.c2
-rw-r--r--src/libs6/s6_fdholder_delete_async.c11
-rw-r--r--src/libs6/s6_fdholder_getdump.c13
-rw-r--r--src/libs6/s6_fdholder_list.c2
-rw-r--r--src/libs6/s6_fdholder_list_async.c3
-rw-r--r--src/libs6/s6_fdholder_list_cb.c6
-rw-r--r--src/libs6/s6_fdholder_retrieve.c2
-rw-r--r--src/libs6/s6_fdholder_retrieve_async.c12
-rw-r--r--src/libs6/s6_fdholder_retrieve_cb.c4
-rw-r--r--src/libs6/s6_fdholder_setdump.c22
-rw-r--r--src/libs6/s6_fdholder_store.c2
-rw-r--r--src/libs6/s6_fdholder_store_async.c11
-rw-r--r--src/libs6/s6_supervise_lock.c1
-rw-r--r--src/libs6/s6_supervise_lock_mode.c13
-rw-r--r--src/libs6/s6_svc_ok.c11
-rw-r--r--src/libs6/s6_svc_write.c2
-rw-r--r--src/libs6/s6_svc_writectl.c13
-rw-r--r--src/libs6/s6_svstatus_pack.c4
-rw-r--r--src/libs6/s6_svstatus_read.c9
-rw-r--r--src/libs6/s6_svstatus_unpack.c8
-rw-r--r--src/libs6/s6_svstatus_write.c9
-rw-r--r--src/libs6/s6lock_acquire.c17
-rw-r--r--src/libs6/s6lock_release.c2
-rw-r--r--src/libs6/s6lock_update.c2
-rw-r--r--src/libs6/s6lock_wait_and.c2
-rw-r--r--src/libs6/s6lock_wait_or.c4
-rw-r--r--src/libs6/s6lockd.c22
44 files changed, 171 insertions, 189 deletions
diff --git a/src/libs6/ftrig1_make.c b/src/libs6/ftrig1_make.c
index d22a76f..8cac6b2 100644
--- a/src/libs6/ftrig1_make.c
+++ b/src/libs6/ftrig1_make.c
@@ -1,11 +1,10 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <stdio.h> /* for rename() */
+#include <stdio.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/tai.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
@@ -32,13 +31,13 @@ static inline void surfname (char *s, size_t n)
int ftrig1_make (ftrig1_t *f, char const *path)
{
ftrig1_t ff = FTRIG1_ZERO ;
- size_t pathlen = str_len(path) ;
+ size_t pathlen = strlen(path) ;
int e = 0 ;
char tmp[pathlen + 46 + FTRIG1_PREFIXLEN] ;
- byte_copy(tmp, pathlen, path) ;
+ memcpy(tmp, path, pathlen) ;
tmp[pathlen] = '/' ; tmp[pathlen+1] = '.' ;
- byte_copy(tmp + pathlen + 2, FTRIG1_PREFIXLEN, FTRIG1_PREFIX) ;
+ memcpy(tmp + pathlen + 2, FTRIG1_PREFIX, FTRIG1_PREFIXLEN) ;
tmp[pathlen + 2 + FTRIG1_PREFIXLEN] = ':' ;
if (!timestamp(tmp + pathlen + 3 + FTRIG1_PREFIXLEN)) return 0 ;
tmp[pathlen + 28 + FTRIG1_PREFIXLEN] = ':' ;
diff --git a/src/libs6/ftrigr_check.c b/src/libs6/ftrigr_check.c
index 8db7d7f..ba0a6f1 100644
--- a/src/libs6/ftrigr_check.c
+++ b/src/libs6/ftrigr_check.c
@@ -22,7 +22,7 @@ int ftrigr_check (ftrigr_t *a, uint16_t id, char *c)
}
case FR1STATE_LISTENING :
{
- register unsigned int r = p->count ;
+ unsigned int r = p->count ;
if (r) *c = p->what ;
p->count = 0 ;
return (int)r ;
diff --git a/src/libs6/ftrigr_subscribe.c b/src/libs6/ftrigr_subscribe.c
index ddb706f..97e1931 100644
--- a/src/libs6/ftrigr_subscribe.c
+++ b/src/libs6/ftrigr_subscribe.c
@@ -1,11 +1,10 @@
/* ISC license. */
-#include <sys/types.h>
+#include <sys/uio.h>
+#include <string.h>
#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
-#include <skalibs/siovec.h>
+#include <skalibs/types.h>
#include <skalibs/tai.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/skaclient.h>
@@ -13,20 +12,25 @@
uint16_t ftrigr_subscribe (ftrigr_t *a, char const *path, char const *re, uint32_t options, tain_t const *deadline, tain_t *stamp)
{
- size_t pathlen = str_len(path) ;
- size_t relen = str_len(re) ;
+ size_t pathlen = strlen(path) ;
+ size_t relen = strlen(re) ;
unsigned int i ;
char err ;
char tmp[15] = "--L" ;
- siovec_t v[3] = { { .s = tmp, .len = 15 }, { .s = (char *)path, .len = pathlen + 1 }, { .s = (char *)re, .len = relen + 1 } } ;
+ struct iovec v[3] = { { .iov_base = tmp, .iov_len = 15 }, { .iov_base = (char *)path, .iov_len = pathlen + 1 }, { .iov_base = (char *)re, .iov_len = relen + 1 } } ;
if (!gensetdyn_new(&a->data, &i)) return 0 ;
+ if (i >= UINT16_MAX)
+ {
+ gensetdyn_delete(&a->data, i) ;
+ return (errno = EMFILE, 0) ;
+ }
uint16_pack_big(tmp, (uint16_t)i) ;
uint32_pack_big(tmp+3, options) ;
uint32_pack_big(tmp+7, (uint32_t)pathlen) ;
uint32_pack_big(tmp+11, (uint32_t)relen) ;
if (!skaclient_sendv(&a->connection, v, 3, &skaclient_default_cb, &err, deadline, stamp))
{
- register int e = errno ;
+ int e = errno ;
gensetdyn_delete(&a->data, i) ;
errno = e ;
return 0 ;
@@ -37,11 +41,11 @@ uint16_t ftrigr_subscribe (ftrigr_t *a, char const *path, char const *re, uint32
return (errno = err, 0) ;
}
{
- register ftrigr1_t *p = GENSETDYN_P(ftrigr1_t, &a->data, i) ;
+ ftrigr1_t *p = GENSETDYN_P(ftrigr1_t, &a->data, i) ;
p->options = options ;
p->state = FR1STATE_LISTENING ;
p->count = 0 ;
p->what = 0 ;
}
- return (uint16)(i+1) ;
+ return (uint16_t)(i+1) ;
}
diff --git a/src/libs6/ftrigr_unsubscribe.c b/src/libs6/ftrigr_unsubscribe.c
index 1c44905..949bc50 100644
--- a/src/libs6/ftrigr_unsubscribe.c
+++ b/src/libs6/ftrigr_unsubscribe.c
@@ -2,7 +2,7 @@
#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/tai.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/skaclient.h>
diff --git a/src/libs6/ftrigr_update.c b/src/libs6/ftrigr_update.c
index 52f79b9..7f494c6 100644
--- a/src/libs6/ftrigr_update.c
+++ b/src/libs6/ftrigr_update.c
@@ -5,7 +5,7 @@
#include <errno.h>
#include <skalibs/gccattributes.h>
#include <skalibs/error.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/unixmessage.h>
diff --git a/src/libs6/ftrigr_wait_and.c b/src/libs6/ftrigr_wait_and.c
index 961d0ba..dc633a9 100644
--- a/src/libs6/ftrigr_wait_and.c
+++ b/src/libs6/ftrigr_wait_and.c
@@ -15,7 +15,7 @@ int ftrigr_wait_and (ftrigr_t *a, uint16_t const *idlist, unsigned int n, tain_t
for (;;)
{
char dummy ;
- register int r = ftrigr_check(a, *idlist, &dummy) ;
+ int r = ftrigr_check(a, *idlist, &dummy) ;
if (r < 0) return r ;
else if (r) break ;
r = iopause_stamp(&x, 1, deadline, stamp) ;
diff --git a/src/libs6/ftrigr_wait_or.c b/src/libs6/ftrigr_wait_or.c
index 188a97e..9d0be0f 100644
--- a/src/libs6/ftrigr_wait_or.c
+++ b/src/libs6/ftrigr_wait_or.c
@@ -14,8 +14,8 @@ int ftrigr_wait_or (ftrigr_t *a, uint16_t const *idlist, unsigned int n, tain_t
if (x.fd < 0) return -1 ;
for (;;)
{
- register unsigned int i = 0 ;
- register int r ;
+ unsigned int i = 0 ;
+ int r ;
for (; i < n ; i++)
{
r = ftrigr_check(a, idlist[i], c) ;
diff --git a/src/libs6/ftrigw_clean.c b/src/libs6/ftrigw_clean.c
index 5e344eb..3253f7a 100644
--- a/src/libs6/ftrigw_clean.c
+++ b/src/libs6/ftrigw_clean.c
@@ -1,23 +1,22 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/direntry.h>
-#include <skalibs/bytestr.h>
#include <skalibs/djbunix.h>
#include "ftrig1.h"
#include <s6/ftrigw.h>
int ftrigw_clean (char const *path)
{
- size_t pathlen = str_len(path) ;
+ size_t pathlen = strlen(path) ;
int e = 0 ;
DIR *dir = opendir(path) ;
if (!dir) return 0 ;
{
char tmp[pathlen + FTRIG1_PREFIXLEN + 45] ;
- byte_copy(tmp, pathlen, path) ;
+ memcpy(tmp, path, pathlen) ;
tmp[pathlen] = '/' ; tmp[pathlen + FTRIG1_PREFIXLEN + 44] = 0 ;
for (;;)
{
@@ -26,9 +25,9 @@ int ftrigw_clean (char const *path)
errno = 0 ;
d = readdir(dir) ;
if (!d) break ;
- if (str_diffn(d->d_name, FTRIG1_PREFIX, FTRIG1_PREFIXLEN)) continue ;
- if (str_len(d->d_name) != FTRIG1_PREFIXLEN + 43) continue ;
- byte_copy(tmp + pathlen + 1, FTRIG1_PREFIXLEN + 43, d->d_name) ;
+ if (strncmp(d->d_name, FTRIG1_PREFIX, FTRIG1_PREFIXLEN)) continue ;
+ if (strlen(d->d_name) != FTRIG1_PREFIXLEN + 43) continue ;
+ memcpy(tmp + pathlen + 1, d->d_name, FTRIG1_PREFIXLEN + 43) ;
fd = open_write(tmp) ;
if (fd >= 0) fd_close(fd) ;
else if ((errno == ENXIO) && (unlink(tmp) < 0)) e = errno ;
diff --git a/src/libs6/ftrigw_fifodir_make.c b/src/libs6/ftrigw_fifodir_make.c
index 1a69a8e..c7b93a5 100644
--- a/src/libs6/ftrigw_fifodir_make.c
+++ b/src/libs6/ftrigw_fifodir_make.c
@@ -1,12 +1,11 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <s6/ftrigw.h>
-int ftrigw_fifodir_make (char const *path, int gid, int force)
+int ftrigw_fifodir_make (char const *path, gid_t gid, int force)
{
mode_t m = umask(0) ;
if (mkdir(path, 0700) == -1)
diff --git a/src/libs6/ftrigw_notifyb_nosig.c b/src/libs6/ftrigw_notifyb_nosig.c
index 0a21419..0ba38a6 100644
--- a/src/libs6/ftrigw_notifyb_nosig.c
+++ b/src/libs6/ftrigw_notifyb_nosig.c
@@ -1,11 +1,10 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/direntry.h>
#include <skalibs/allreadwrite.h>
-#include <skalibs/bytestr.h>
#include <skalibs/djbunix.h>
#include "ftrig1.h"
#include <s6/ftrigw.h>
@@ -16,9 +15,9 @@ int ftrigw_notifyb_nosig (char const *path, char const *s, size_t len)
DIR *dir = opendir(path) ;
if (!dir) return -1 ;
{
- size_t pathlen = str_len(path) ;
+ size_t pathlen = strlen(path) ;
char tmp[pathlen + FTRIG1_PREFIXLEN + 45] ;
- byte_copy(tmp, pathlen, path) ;
+ memcpy(tmp, path, pathlen) ;
tmp[pathlen] = '/' ; tmp[pathlen + FTRIG1_PREFIXLEN + 44] = 0 ;
for (;;)
{
@@ -27,9 +26,9 @@ int ftrigw_notifyb_nosig (char const *path, char const *s, size_t len)
errno = 0 ;
d = readdir(dir) ;
if (!d) break ;
- if (str_diffn(d->d_name, FTRIG1_PREFIX, FTRIG1_PREFIXLEN)) continue ;
- if (str_len(d->d_name) != FTRIG1_PREFIXLEN + 43) continue ;
- byte_copy(tmp + pathlen + 1, FTRIG1_PREFIXLEN + 43, d->d_name) ;
+ if (strncmp(d->d_name, FTRIG1_PREFIX, FTRIG1_PREFIXLEN)) continue ;
+ if (strlen(d->d_name) != FTRIG1_PREFIXLEN + 43) continue ;
+ memcpy(tmp + pathlen + 1, d->d_name, FTRIG1_PREFIXLEN + 43) ;
fd = open_write(tmp) ;
if (fd == -1)
{
@@ -37,7 +36,7 @@ int ftrigw_notifyb_nosig (char const *path, char const *s, size_t len)
}
else
{
- register ssize_t r = fd_write(fd, s, len) ;
+ ssize_t r = fd_write(fd, s, len) ;
if ((r < 0) || (size_t)r < len)
{
if (errno == EPIPE) unlink(tmp) ;
diff --git a/src/libs6/s6-ftrigrd.c b/src/libs6/s6-ftrigrd.c
index 1bbe856..5afec98 100644
--- a/src/libs6/s6-ftrigrd.c
+++ b/src/libs6/s6-ftrigrd.c
@@ -1,13 +1,11 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <signal.h>
#include <regex.h>
-#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
+#include <skalibs/types.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/error.h>
#include <skalibs/strerr2.h>
@@ -53,7 +51,7 @@ static void ftrigio_deepfree (ftrigio_t *p)
static void cleanup (void)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++) ftrigio_deepfree(a + i) ;
n = 0 ;
}
@@ -95,7 +93,7 @@ static inline int ftrigio_read (ftrigio_t *p)
{
regmatch_t pmatch ;
size_t blen ;
- register ssize_t r = sanitize_read(buffer_fill(&p->b)) ;
+ ssize_t r = sanitize_read(buffer_fill(&p->b)) ;
if (!r) break ;
if (r < 0) return (trig(p->id, 'd', errno), 0) ;
blen = buffer_len(&p->b) ;
@@ -107,7 +105,7 @@ static inline int ftrigio_read (ftrigio_t *p)
{
trig(p->id, '!', p->sa.s[pmatch.rm_eo - 1]) ;
if (!(p->options & FTRIGR_REPEAT)) return 0 ;
- byte_copy(p->sa.s, p->sa.len + 1 - pmatch.rm_eo, p->sa.s + pmatch.rm_eo) ;
+ memcpy(p->sa.s, p->sa.s + pmatch.rm_eo, p->sa.len + 1 - pmatch.rm_eo) ;
p->sa.len -= pmatch.rm_eo ;
}
}
@@ -127,7 +125,7 @@ static int parse_protocol (unixmessage_t const *m, void *context)
{
case 'U' : /* unsubscribe */
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++) if (a[i].id == id) break ;
if (i < n)
{
diff --git a/src/libs6/s6_accessrules_backend_cdb.c b/src/libs6/s6_accessrules_backend_cdb.c
index 1187485..64e95d2 100644
--- a/src/libs6/s6_accessrules_backend_cdb.c
+++ b/src/libs6/s6_accessrules_backend_cdb.c
@@ -1,11 +1,10 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/cdb.h>
#include <skalibs/stralloc.h>
#include <s6/accessrules.h>
@@ -16,7 +15,7 @@ s6_accessrules_result_t s6_accessrules_backend_cdb (char const *key, size_t keyl
size_t execbase ;
unsigned int n ;
uint16_t envlen, execlen ;
- register int r = cdb_find(c, key, keylen) ;
+ int r = cdb_find(c, key, keylen) ;
if (r < 0) return S6_ACCESSRULES_ERROR ;
else if (!r) return S6_ACCESSRULES_NOTFOUND ;
n = cdb_datalen(c) ;
@@ -31,7 +30,7 @@ s6_accessrules_result_t s6_accessrules_backend_cdb (char const *key, size_t keyl
uint16_unpack_big(params->exec.s + execbase + 3 + envlen, &execlen) ;
if ((execlen > 4096U) || (5U + envlen + execlen != n)) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ;
if (!stralloc_catb(&params->env, params->exec.s + execbase + 3U, envlen)) return S6_ACCESSRULES_ERROR ;
- byte_copy(params->exec.s + execbase, execlen, params->exec.s + execbase + 5U + envlen) ;
+ memcpy(params->exec.s + execbase, params->exec.s + execbase + 5U + envlen, execlen) ;
if (execlen)
{
params->exec.len += execlen ;
diff --git a/src/libs6/s6_accessrules_backend_fs.c b/src/libs6/s6_accessrules_backend_fs.c
index 17119c9..614f42b 100644
--- a/src/libs6/s6_accessrules_backend_fs.c
+++ b/src/libs6/s6_accessrules_backend_fs.c
@@ -1,10 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
-#include <skalibs/fmtscan.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
#include <s6/accessrules.h>
@@ -12,25 +10,25 @@
s6_accessrules_result_t s6_accessrules_backend_fs (char const *key, size_t keylen, void *data, s6_accessrules_params_t *params)
{
char *dir = data ;
- size_t dirlen = str_len(dir) ;
+ size_t dirlen = strlen(dir) ;
size_t envbase = params->env.len ;
int wasnull = !params->env.s ;
{
char tmp[dirlen + keylen + 10] ;
- byte_copy(tmp, dirlen, dir) ;
+ memcpy(tmp, dir, dirlen) ;
tmp[dirlen] = '/' ;
- byte_copy(tmp + dirlen + 1, keylen, key) ;
- byte_copy(tmp + dirlen + keylen + 1, 7, "/allow") ;
+ memcpy(tmp + dirlen + 1, key, keylen) ;
+ memcpy(tmp + dirlen + keylen + 1, "/allow", 7) ;
if (access(tmp, R_OK) < 0)
{
if ((errno != EACCES) && (errno != ENOENT))
return S6_ACCESSRULES_ERROR ;
- byte_copy(tmp + dirlen + keylen + 2, 5, "deny") ;
+ memcpy(tmp + dirlen + keylen + 2, "deny", 5) ;
return (access(tmp, R_OK) == 0) ? S6_ACCESSRULES_DENY :
(errno != EACCES) && (errno != ENOENT) ? S6_ACCESSRULES_ERROR :
S6_ACCESSRULES_NOTFOUND ;
}
- byte_copy(tmp + dirlen + keylen + 2, 4, "env") ;
+ memcpy(tmp + dirlen + keylen + 2, "env", 4) ;
if ((envdir(tmp, &params->env) < 0) && (errno != ENOENT))
return S6_ACCESSRULES_ERROR ;
if (!stralloc_readyplus(&params->exec, 4097))
@@ -39,9 +37,9 @@ s6_accessrules_result_t s6_accessrules_backend_fs (char const *key, size_t keyle
else params->env.len = envbase ;
return S6_ACCESSRULES_ERROR ;
}
- byte_copy(tmp + dirlen + keylen + 2, 5, "exec") ;
+ memcpy(tmp + dirlen + keylen + 2, "exec", 5) ;
{
- register ssize_t r = openreadnclose(tmp, params->exec.s + params->exec.len, 4096) ;
+ ssize_t r = openreadnclose(tmp, params->exec.s + params->exec.len, 4096) ;
if ((r < 0) && (errno != EACCES) && (errno != ENOENT))
{
if (wasnull) stralloc_free(&params->env) ;
diff --git a/src/libs6/s6_accessrules_keycheck_ip4.c b/src/libs6/s6_accessrules_keycheck_ip4.c
index 4942e8e..2bd620d 100644
--- a/src/libs6/s6_accessrules_keycheck_ip4.c
+++ b/src/libs6/s6_accessrules_keycheck_ip4.c
@@ -2,8 +2,7 @@
#include <sys/types.h>
#include <stdint.h>
-#include <skalibs/uint32.h>
-#include <skalibs/uint.h>
+#include <skalibs/types.h>
#include <skalibs/fmtscan.h>
#include <s6/accessrules.h>
@@ -15,8 +14,8 @@ s6_accessrules_result_t s6_accessrules_keycheck_ip4 (void const *key, void *data
uint32_unpack_big((char const *)key, &ip) ;
for (; i <= 32 ; i++)
{
- register s6_accessrules_result_t r ;
- register size_t len = 4 + ip4_fmtu32(fmt+4, (i == 32) ? 0 : ip & ~((1U << i) - 1)) ;
+ s6_accessrules_result_t r ;
+ size_t len = 4 + ip4_fmtu32(fmt+4, (i == 32) ? 0 : ip & ~((1U << i) - 1)) ;
fmt[len++] = '_' ;
len += uint_fmt(fmt + len, 32 - i) ;
r = (*check1)(fmt, len, data, params) ;
diff --git a/src/libs6/s6_accessrules_keycheck_ip6.c b/src/libs6/s6_accessrules_keycheck_ip6.c
index cd7fe02..93418d3 100644
--- a/src/libs6/s6_accessrules_keycheck_ip6.c
+++ b/src/libs6/s6_accessrules_keycheck_ip6.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/uint.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
+#include <skalibs/types.h>
#include <skalibs/bitarray.h>
#include <skalibs/fmtscan.h>
#include <s6/accessrules.h>
@@ -12,11 +11,11 @@ s6_accessrules_result_t s6_accessrules_keycheck_ip6 (void const *key, void *data
char fmt[IP6_FMT + UINT_FMT + 6] = "ip6/" ;
char ip6[16] ;
unsigned int i = 0 ;
- byte_copy(ip6, 16, (char const *)key) ;
+ memcpy(ip6, (char const *)key, 16) ;
for (; i <= 128 ; i++)
{
size_t len ;
- register s6_accessrules_result_t r ;
+ s6_accessrules_result_t r ;
if (i) bitarray_clear(ip6, 128 - i) ;
len = 4 + ip6_fmt(fmt+4, ip6) ;
fmt[len++] = '_' ;
diff --git a/src/libs6/s6_accessrules_keycheck_reversedns.c b/src/libs6/s6_accessrules_keycheck_reversedns.c
index 5c44e47..34da90f 100644
--- a/src/libs6/s6_accessrules_keycheck_reversedns.c
+++ b/src/libs6/s6_accessrules_keycheck_reversedns.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/bytestr.h>
#include <s6/accessrules.h>
@@ -8,17 +8,17 @@
s6_accessrules_result_t s6_accessrules_keycheck_reversedns (void const *key, void *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_t_ref check1)
{
char const *name = key ;
- size_t len = str_len(name) ;
+ size_t len = strlen(name) ;
if (!len) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ;
if (name[len-1] == '.') len-- ;
{
size_t i = 0 ;
char tmp[len + 11] ;
- byte_copy(tmp, 11, "reversedns/") ;
+ memcpy(tmp, "reversedns/", 11) ;
while (i < len)
{
- register s6_accessrules_result_t r ;
- byte_copy(tmp+11, len-i, name+i) ;
+ s6_accessrules_result_t r ;
+ memcpy(tmp+11, name+i, len-i) ;
r = (*check1)(tmp, 11+len-i, data, params) ;
if (r != S6_ACCESSRULES_NOTFOUND) return r ;
i += byte_chr(name+i, len-i, '.') + 1 ;
diff --git a/src/libs6/s6_accessrules_keycheck_uidgid.c b/src/libs6/s6_accessrules_keycheck_uidgid.c
index 7a2cd0a..61a6229 100644
--- a/src/libs6/s6_accessrules_keycheck_uidgid.c
+++ b/src/libs6/s6_accessrules_keycheck_uidgid.c
@@ -1,13 +1,13 @@
/* ISC license. */
#include <skalibs/uint64.h>
-#include <skalibs/gidstuff.h>
+#include <skalibs/types.h>
#include <s6/accessrules.h>
s6_accessrules_result_t s6_accessrules_keycheck_uidgid (void const *key, void *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_t_ref check1)
{
char fmt[4 + UINT64_FMT] = "uid/" ;
- register s6_accessrules_result_t r = (*check1)(fmt, 4 + uint64_fmt(fmt+4, ((uidgid_t const *)key)->left), data, params) ;
+ s6_accessrules_result_t r = (*check1)(fmt, 4 + uid_fmt(fmt+4, ((uidgid_t const *)key)->left), data, params) ;
if (r != S6_ACCESSRULES_NOTFOUND) return r ;
fmt[0] = 'g' ;
r = (*check1)(fmt, 4 + gid_fmt(fmt+4, ((uidgid_t const *)key)->right), data, params) ;
diff --git a/src/libs6/s6_fdholder_delete.c b/src/libs6/s6_fdholder_delete.c
index fd7aa4e..f6f2c2b 100644
--- a/src/libs6/s6_fdholder_delete.c
+++ b/src/libs6/s6_fdholder_delete.c
@@ -1,4 +1,4 @@
- /* ISC license. */
+/* ISC license. */
#include <errno.h>
#include <skalibs/allreadwrite.h>
diff --git a/src/libs6/s6_fdholder_delete_async.c b/src/libs6/s6_fdholder_delete_async.c
index 21caab3..e234cfd 100644
--- a/src/libs6/s6_fdholder_delete_async.c
+++ b/src/libs6/s6_fdholder_delete_async.c
@@ -1,17 +1,16 @@
- /* ISC license. */
+/* ISC license. */
-#include <sys/types.h>
+#include <sys/uio.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
-#include <skalibs/siovec.h>
#include <skalibs/unixmessage.h>
#include <s6/s6-fdholder.h>
int s6_fdholder_delete_async (s6_fdholder_t *a, char const *id)
{
- size_t idlen = str_len(id) ;
+ size_t idlen = strlen(id) ;
char pack[2] = "D" ;
- siovec_t v[2] = { { .s = pack, .len = 2 }, { .s = (char *)id, .len = idlen + 1 } } ;
+ struct iovec v[2] = { { .iov_base = pack, .iov_len = 2 }, { .iov_base = (char *)id, .iov_len = idlen + 1 } } ;
unixmessage_v_t m = { .v = v, .vlen = 2, .fds = 0, .nfds = 0 } ;
if (idlen > S6_FDHOLDER_ID_SIZE) return (errno = ENAMETOOLONG, 0) ;
pack[1] = (unsigned char)idlen ;
diff --git a/src/libs6/s6_fdholder_getdump.c b/src/libs6/s6_fdholder_getdump.c
index 213cad8..e201e6e 100644
--- a/src/libs6/s6_fdholder_getdump.c
+++ b/src/libs6/s6_fdholder_getdump.c
@@ -1,12 +1,11 @@
- /* ISC license. */
+/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
+#include <skalibs/types.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/error.h>
-#include <skalibs/bytestr.h>
#include <skalibs/tai.h>
#include <skalibs/genalloc.h>
#include <skalibs/djbunix.h>
@@ -17,7 +16,7 @@ int s6_fdholder_getdump (s6_fdholder_t *a, genalloc *g, tain_t const *deadline,
{
unixmessage_t m = { .s = "?", .len = 1, .fds = 0, .nfds = 0 } ;
uint32_t ntot, n ;
- unsigned int oldlen = genalloc_len(s6_fdholder_fd_t, g) ;
+ size_t oldlen = genalloc_len(s6_fdholder_fd_t, g) ;
unsigned int i = 0 ;
int ok ;
if (!unixmessage_put(&a->connection.out, &m)) return 0 ;
@@ -48,8 +47,8 @@ int s6_fdholder_getdump (s6_fdholder_t *a, genalloc *g, tain_t const *deadline,
m.s += TAIN_PACK ; m.len -= TAIN_PACK + 1 ;
thislen = *m.s++ ;
if (thislen > m.len - 1 || m.s[thislen]) goto droperr ;
- byte_copy(tab[j].id, thislen, m.s) ;
- byte_zero(tab[j].id + thislen, S6_FDHOLDER_ID_SIZE + 1 - thislen) ;
+ memcpy(tab[j].id, m.s, thislen) ;
+ memset(tab[j].id + thislen, 0, S6_FDHOLDER_ID_SIZE + 1 - thislen) ;
m.s += (size_t)thislen + 1 ; m.len -= (size_t)thislen + 1 ;
tab[j].fd = m.fds[j] ;
}
diff --git a/src/libs6/s6_fdholder_list.c b/src/libs6/s6_fdholder_list.c
index 868a3e6..d86049f 100644
--- a/src/libs6/s6_fdholder_list.c
+++ b/src/libs6/s6_fdholder_list.c
@@ -1,4 +1,4 @@
- /* ISC license. */
+/* ISC license. */
#include <errno.h>
#include <skalibs/allreadwrite.h>
diff --git a/src/libs6/s6_fdholder_list_async.c b/src/libs6/s6_fdholder_list_async.c
index fc62ff8..8275f23 100644
--- a/src/libs6/s6_fdholder_list_async.c
+++ b/src/libs6/s6_fdholder_list_async.c
@@ -1,6 +1,5 @@
- /* ISC license. */
+/* ISC license. */
-#include <errno.h>
#include <skalibs/unixmessage.h>
#include <s6/s6-fdholder.h>
diff --git a/src/libs6/s6_fdholder_list_cb.c b/src/libs6/s6_fdholder_list_cb.c
index 8bf5faf..9daaff7 100644
--- a/src/libs6/s6_fdholder_list_cb.c
+++ b/src/libs6/s6_fdholder_list_cb.c
@@ -1,8 +1,8 @@
- /* ISC license. */
+/* ISC license. */
#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
+#include <skalibs/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/error.h>
#include <skalibs/stralloc.h>
@@ -12,7 +12,7 @@
int s6_fdholder_list_cb (unixmessage_t const *m, void *p)
{
uint32_t n ;
- register s6_fdholder_list_result_t *res = p ;
+ s6_fdholder_list_result_t *res = p ;
if (m->nfds) goto droperr ;
if (!m->len) goto err ;
if (m->s[0])
diff --git a/src/libs6/s6_fdholder_retrieve.c b/src/libs6/s6_fdholder_retrieve.c
index caf2426..9bdb8ad 100644
--- a/src/libs6/s6_fdholder_retrieve.c
+++ b/src/libs6/s6_fdholder_retrieve.c
@@ -1,4 +1,4 @@
- /* ISC license. */
+/* ISC license. */
#include <errno.h>
#include <skalibs/allreadwrite.h>
diff --git a/src/libs6/s6_fdholder_retrieve_async.c b/src/libs6/s6_fdholder_retrieve_async.c
index 5336544..e258772 100644
--- a/src/libs6/s6_fdholder_retrieve_async.c
+++ b/src/libs6/s6_fdholder_retrieve_async.c
@@ -1,18 +1,16 @@
- /* ISC license. */
+/* ISC license. */
-#include <sys/types.h>
+#include <sys/uio.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
-#include <skalibs/tai.h>
-#include <skalibs/siovec.h>
#include <skalibs/unixmessage.h>
#include <s6/s6-fdholder.h>
int s6_fdholder_retrieve_maybe_delete_async (s6_fdholder_t *a, char const *id, int dodelete)
{
- size_t idlen = str_len(id) ;
+ size_t idlen = strlen(id) ;
char pack[3] = "R" ;
- siovec_t v[2] = { { .s = pack, .len = 3 }, { .s = (char *)id, .len = idlen + 1 } } ;
+ struct iovec v[2] = { { .iov_base = pack, .iov_len = 3 }, { .iov_base = (char *)id, .iov_len = idlen + 1 } } ;
unixmessage_v_t m = { .v = v, .vlen = 2, .fds = 0, .nfds = 0 } ;
if (idlen > S6_FDHOLDER_ID_SIZE) return (errno = ENAMETOOLONG, 0) ;
pack[1] = !!dodelete ;
diff --git a/src/libs6/s6_fdholder_retrieve_cb.c b/src/libs6/s6_fdholder_retrieve_cb.c
index 9197b22..f009ff6 100644
--- a/src/libs6/s6_fdholder_retrieve_cb.c
+++ b/src/libs6/s6_fdholder_retrieve_cb.c
@@ -1,4 +1,4 @@
- /* ISC license. */
+/* ISC license. */
#include <errno.h>
#include <skalibs/error.h>
@@ -7,7 +7,7 @@
int s6_fdholder_retrieve_cb (unixmessage_t const *m, void *p)
{
- register s6_fdholder_retrieve_result_t *res = p ;
+ s6_fdholder_retrieve_result_t *res = p ;
if (m->len != 1) goto err ;
if (m->s[0])
{
diff --git a/src/libs6/s6_fdholder_setdump.c b/src/libs6/s6_fdholder_setdump.c
index 5982b95..1548409 100644
--- a/src/libs6/s6_fdholder_setdump.c
+++ b/src/libs6/s6_fdholder_setdump.c
@@ -1,14 +1,14 @@
- /* ISC license. */
+/* ISC license. */
-#include <sys/types.h>
+#include <sys/uio.h>
#include <stdint.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/uint32.h>
+#include <skalibs/types.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/bytestr.h>
#include <skalibs/error.h>
#include <skalibs/tai.h>
-#include <skalibs/siovec.h>
#include <skalibs/unixmessage.h>
#include <s6/s6-fdholder.h>
@@ -40,20 +40,20 @@ int s6_fdholder_setdump (s6_fdholder_t *a, s6_fdholder_fd_t const *list, unsigne
{
unsigned int n = ntot > UNIXMESSAGE_MAXFDS ? UNIXMESSAGE_MAXFDS : ntot ;
unsigned int j = 0 ;
- siovec_t v[1 + (n<<1)] ;
+ struct iovec v[1 + (n<<1)] ;
int fds[n] ;
unixmessage_v_t m = { .v = v, .vlen = 1 + (n<<1), .fds = fds, .nfds = n } ;
char pack[n * (TAIN_PACK+1)] ;
- v[0].s = "." ; v[0].len = 1 ;
+ v[0].iov_base = "." ; v[0].iov_len = 1 ;
for (; j < n ; j++, list++, ntot--)
{
- size_t len = str_len(list->id) ;
- v[1 + (j<<1)].s = pack + j * (TAIN_PACK+1) ;
- v[1 + (j<<1)].len = TAIN_PACK + 1 ;
+ size_t len = strlen(list->id) ;
+ v[1 + (j<<1)].iov_base = pack + j * (TAIN_PACK+1) ;
+ v[1 + (j<<1)].iov_len = TAIN_PACK + 1 ;
tain_pack(pack + j * (TAIN_PACK+1), &list->limit) ;
pack[j * (TAIN_PACK+1) + TAIN_PACK] = (unsigned char)len ;
- v[2 + (j<<1)].s = (char *)list->id ;
- v[2 + (j<<1)].len = len + 1 ;
+ v[2 + (j<<1)].iov_base = (char *)list->id ;
+ v[2 + (j<<1)].iov_len = len + 1 ;
fds[j] = list->fd ;
}
if (!unixmessage_putv(&a->connection.out, &m)) return 0 ;
diff --git a/src/libs6/s6_fdholder_store.c b/src/libs6/s6_fdholder_store.c
index 7b8f6dc..b13d854 100644
--- a/src/libs6/s6_fdholder_store.c
+++ b/src/libs6/s6_fdholder_store.c
@@ -1,4 +1,4 @@
- /* ISC license. */
+/* ISC license. */
#include <errno.h>
#include <skalibs/allreadwrite.h>
diff --git a/src/libs6/s6_fdholder_store_async.c b/src/libs6/s6_fdholder_store_async.c
index 6a5482a..a782d2d 100644
--- a/src/libs6/s6_fdholder_store_async.c
+++ b/src/libs6/s6_fdholder_store_async.c
@@ -1,18 +1,17 @@
- /* ISC license. */
+/* ISC license. */
-#include <sys/types.h>
+#include <sys/uio.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/tai.h>
-#include <skalibs/siovec.h>
#include <skalibs/unixmessage.h>
#include <s6/s6-fdholder.h>
int s6_fdholder_store_async (s6_fdholder_t *a, int fd, char const *id, tain_t const *limit)
{
- size_t idlen = str_len(id) ;
+ size_t idlen = strlen(id) ;
char pack[2 + TAIN_PACK] = "S" ;
- siovec_t v[2] = { { .s = pack, .len = 2 + TAIN_PACK }, { .s = (char *)id, .len = idlen + 1 } } ;
+ struct iovec v[2] = { { .iov_base = pack, .iov_len = 2 + TAIN_PACK }, { .iov_base = (char *)id, .iov_len = idlen + 1 } } ;
unixmessage_v_t m = { .v = v, .vlen = 2, .fds = &fd, .nfds = 1 } ;
if (idlen > S6_FDHOLDER_ID_SIZE) return (errno = ENAMETOOLONG, 0) ;
tain_pack(pack + 1, limit) ;
diff --git a/src/libs6/s6_supervise_lock.c b/src/libs6/s6_supervise_lock.c
index 5c9ca30..e241320 100644
--- a/src/libs6/s6_supervise_lock.c
+++ b/src/libs6/s6_supervise_lock.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/stat.h>
#include <s6/s6-supervise.h>
diff --git a/src/libs6/s6_supervise_lock_mode.c b/src/libs6/s6_supervise_lock_mode.c
index cda4ac2..039760c 100644
--- a/src/libs6/s6_supervise_lock_mode.c
+++ b/src/libs6/s6_supervise_lock_mode.c
@@ -1,23 +1,22 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/stat.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>
#include <s6/s6-supervise.h>
int s6_supervise_lock_mode (char const *subdir, unsigned int subdirmode, unsigned int controlmode)
{
- size_t subdirlen = str_len(subdir) ;
+ size_t subdirlen = strlen(subdir) ;
int fdctl, fdctlw, fdlock ;
char control[subdirlen + 9] ;
char lock[subdirlen + 6] ;
- byte_copy(control, subdirlen, subdir) ;
- byte_copy(control + subdirlen, 9, "/control") ;
- byte_copy(lock, subdirlen, subdir) ;
- byte_copy(lock + subdirlen, 6, "/lock") ;
+ memcpy(control, subdir, subdirlen) ;
+ memcpy(control + subdirlen, "/control", 9) ;
+ memcpy(lock, subdir, subdirlen) ;
+ memcpy(lock + subdirlen, "/lock", 6) ;
if ((mkdir(subdir, (mode_t)subdirmode) == -1) && (errno != EEXIST))
strerr_diefu2sys(111, "mkdir ", subdir) ;
if (mkfifo(control, controlmode) < 0)
diff --git a/src/libs6/s6_svc_ok.c b/src/libs6/s6_svc_ok.c
index de30fd7..5e6aa27 100644
--- a/src/libs6/s6_svc_ok.c
+++ b/src/libs6/s6_svc_ok.c
@@ -1,20 +1,19 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/djbunix.h>
#include <s6/s6-supervise.h>
int s6_svc_ok (char const *dir)
{
- size_t dirlen = str_len(dir) ;
+ size_t dirlen = strlen(dir) ;
int fd ;
char fn[dirlen + 9 + sizeof(S6_SUPERVISE_CTLDIR)] ;
- byte_copy(fn, dirlen, dir) ;
+ memcpy(fn, dir, dirlen) ;
fn[dirlen] = '/' ;
- byte_copy(fn + dirlen + 1, sizeof(S6_SUPERVISE_CTLDIR) - 1, S6_SUPERVISE_CTLDIR) ;
- byte_copy(fn + dirlen + sizeof(S6_SUPERVISE_CTLDIR), 9, "/control") ;
+ memcpy(fn + dirlen + 1, S6_SUPERVISE_CTLDIR, sizeof(S6_SUPERVISE_CTLDIR) - 1) ;
+ memcpy(fn + dirlen + sizeof(S6_SUPERVISE_CTLDIR), "/control", 9) ;
fd = open_write(fn) ;
if (fd < 0)
{
diff --git a/src/libs6/s6_svc_write.c b/src/libs6/s6_svc_write.c
index 03bf648..b7d2a27 100644
--- a/src/libs6/s6_svc_write.c
+++ b/src/libs6/s6_svc_write.c
@@ -13,7 +13,7 @@ int s6_svc_write (char const *fifo, char const *data, size_t datalen)
else if (ndelay_off(fd) == -1) return -1 ;
else if (fd_write(fd, data, datalen) == -1)
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
return -1 ;
diff --git a/src/libs6/s6_svc_writectl.c b/src/libs6/s6_svc_writectl.c
index 26c0fb6..b4d8e15 100644
--- a/src/libs6/s6_svc_writectl.c
+++ b/src/libs6/s6_svc_writectl.c
@@ -1,17 +1,16 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <s6/s6-supervise.h>
int s6_svc_writectl (char const *service, char const *subdir, char const *s, size_t len)
{
- size_t svlen = str_len(service) ;
- size_t sublen = str_len(subdir) ;
+ size_t svlen = strlen(service) ;
+ size_t sublen = strlen(subdir) ;
char fn[svlen + sublen + 10] ;
- byte_copy(fn, svlen, service) ;
+ memcpy(fn, service, svlen) ;
fn[svlen] = '/' ;
- byte_copy(fn + svlen + 1, sublen, subdir) ;
- byte_copy(fn + svlen + 1 + sublen, 9, "/control") ;
+ memcpy(fn + svlen + 1, subdir, sublen) ;
+ memcpy(fn + svlen + 1 + sublen, "/control", 9) ;
return s6_svc_write(fn, s, len) ;
}
diff --git a/src/libs6/s6_svstatus_pack.c b/src/libs6/s6_svstatus_pack.c
index c7afe24..f6e6e92 100644
--- a/src/libs6/s6_svstatus_pack.c
+++ b/src/libs6/s6_svstatus_pack.c
@@ -1,8 +1,8 @@
/* ISC license. */
#include <stdint.h>
-#include <skalibs/uint16.h>
#include <skalibs/uint64.h>
+#include <skalibs/types.h>
#include <skalibs/tai.h>
#include <s6/s6-supervise.h>
@@ -10,7 +10,7 @@ void s6_svstatus_pack (char *pack, s6_svstatus_t const *sv)
{
tain_pack(pack, &sv->stamp) ;
tain_pack(pack + 12, &sv->readystamp) ;
- uint64_pack_big(pack + 24, (uint64)sv->pid) ;
+ uint64_pack_big(pack + 24, (uint64_t)sv->pid) ;
uint16_pack_big(pack + 32, (uint16_t)sv->wstat) ;
pack[34] =
sv->flagpaused |
diff --git a/src/libs6/s6_svstatus_read.c b/src/libs6/s6_svstatus_read.c
index 6b6ae4e..edcf38b 100644
--- a/src/libs6/s6_svstatus_read.c
+++ b/src/libs6/s6_svstatus_read.c
@@ -1,17 +1,16 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/djbunix.h>
#include <s6/s6-supervise.h>
int s6_svstatus_read (char const *dir, s6_svstatus_t *status)
{
- size_t n = str_len(dir) ;
+ size_t n = strlen(dir) ;
char pack[S6_SVSTATUS_SIZE] ;
char tmp[n + 1 + sizeof(S6_SVSTATUS_FILENAME)] ;
- byte_copy(tmp, n, dir) ;
- byte_copy(tmp + n, 1 + sizeof(S6_SVSTATUS_FILENAME), "/" S6_SVSTATUS_FILENAME) ;
+ memcpy(tmp, dir, n) ;
+ memcpy(tmp + n, "/" S6_SVSTATUS_FILENAME, 1 + sizeof(S6_SVSTATUS_FILENAME)) ;
if (openreadnclose(tmp, pack, S6_SVSTATUS_SIZE) < S6_SVSTATUS_SIZE) return 0 ;
s6_svstatus_unpack(pack, status) ;
return 1 ;
diff --git a/src/libs6/s6_svstatus_unpack.c b/src/libs6/s6_svstatus_unpack.c
index 6ec2f02..dcd923a 100644
--- a/src/libs6/s6_svstatus_unpack.c
+++ b/src/libs6/s6_svstatus_unpack.c
@@ -1,21 +1,21 @@
/* ISC license. */
#include <stdint.h>
-#include <skalibs/uint16.h>
#include <skalibs/uint64.h>
+#include <skalibs/types.h>
#include <skalibs/tai.h>
#include <s6/s6-supervise.h>
void s6_svstatus_unpack (char const *pack, s6_svstatus_t *sv)
{
- uint64 pid ;
+ uint64_t pid ;
uint16_t wstat ;
tain_unpack(pack, &sv->stamp) ;
tain_unpack(pack + 12, &sv->readystamp) ;
uint64_unpack_big(pack + 24, &pid) ;
- sv->pid = (pid_t)pid ;
+ sv->pid = pid ;
uint16_unpack_big(pack + 32, &wstat) ;
- sv->wstat = (int)wstat ;
+ sv->wstat = wstat ;
sv->flagpaused = pack[34] & 1 ;
sv->flagfinishing = !!(pack[34] & 2) ;
sv->flagwant = !!(pack[34] & 4) ;
diff --git a/src/libs6/s6_svstatus_write.c b/src/libs6/s6_svstatus_write.c
index 935db9c..29d4f40 100644
--- a/src/libs6/s6_svstatus_write.c
+++ b/src/libs6/s6_svstatus_write.c
@@ -1,17 +1,16 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/djbunix.h>
#include <s6/s6-supervise.h>
int s6_svstatus_write (char const *dir, s6_svstatus_t const *status)
{
- size_t n = str_len(dir) ;
+ size_t n = strlen(dir) ;
char pack[S6_SVSTATUS_SIZE] ;
char tmp[n + 1 + sizeof(S6_SVSTATUS_FILENAME)] ;
- byte_copy(tmp, n, dir) ;
- byte_copy(tmp + n, 1 + sizeof(S6_SVSTATUS_FILENAME), "/" S6_SVSTATUS_FILENAME) ;
+ memcpy(tmp, dir, n) ;
+ memcpy(tmp + n, "/" S6_SVSTATUS_FILENAME, 1 + sizeof(S6_SVSTATUS_FILENAME)) ;
s6_svstatus_pack(pack, status) ;
return openwritenclose_suffix(tmp, pack, S6_SVSTATUS_SIZE, ".new") ;
}
diff --git a/src/libs6/s6lock_acquire.c b/src/libs6/s6lock_acquire.c
index 2bf6171..d9b4170 100644
--- a/src/libs6/s6lock_acquire.c
+++ b/src/libs6/s6lock_acquire.c
@@ -1,12 +1,10 @@
/* ISC license. */
-#include <sys/types.h>
+#include <sys/uio.h>
+#include <string.h>
#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
-#include <skalibs/siovec.h>
+#include <skalibs/types.h>
#include <skalibs/tai.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/skaclient.h>
@@ -14,13 +12,18 @@
int s6lock_acquire (s6lock_t *a, uint16_t *u, char const *path, uint32_t options, tain_t const *limit, tain_t const *deadline, tain_t *stamp)
{
- size_t pathlen = str_len(path) ;
+ size_t pathlen = strlen(path) ;
char err ;
char tmp[23] = "--<" ;
- siovec_t v[2] = { { .s = tmp, .len = 23 }, { .s = (char *)path, .len = pathlen + 1 } } ;
+ struct iovec v[2] = { { .iov_base = tmp, .iov_len = 23 }, { .iov_base = (char *)path, .iov_len = pathlen + 1 } } ;
unsigned int i ;
if (pathlen > UINT32_MAX) return (errno = ENAMETOOLONG, 0) ;
if (!gensetdyn_new(&a->data, &i)) return 0 ;
+ if (i > UINT16_MAX)
+ {
+ gensetdyn_delete(&a->data, i) ;
+ return (errno = EMFILE, 0) ;
+ }
uint16_pack_big(tmp, (uint16_t)i) ;
uint32_pack_big(tmp+3, options) ;
tain_pack(tmp+7, limit) ;
diff --git a/src/libs6/s6lock_release.c b/src/libs6/s6lock_release.c
index 344ace4..5be66e2 100644
--- a/src/libs6/s6lock_release.c
+++ b/src/libs6/s6lock_release.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/tai.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/skaclient.h>
diff --git a/src/libs6/s6lock_update.c b/src/libs6/s6lock_update.c
index a56c276..128f9cc 100644
--- a/src/libs6/s6lock_update.c
+++ b/src/libs6/s6lock_update.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/unixmessage.h>
diff --git a/src/libs6/s6lock_wait_and.c b/src/libs6/s6lock_wait_and.c
index 30c7a43..22ec63b 100644
--- a/src/libs6/s6lock_wait_and.c
+++ b/src/libs6/s6lock_wait_and.c
@@ -14,7 +14,7 @@ int s6lock_wait_and (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t
{
for (;;)
{
- register int r = s6lock_check(a, *idlist) ;
+ int r = s6lock_check(a, *idlist) ;
if (r < 0) return r ;
else if (r) break ;
r = iopause_stamp(&x, 1, deadline, stamp) ;
diff --git a/src/libs6/s6lock_wait_or.c b/src/libs6/s6lock_wait_or.c
index 1a4d468..f098339 100644
--- a/src/libs6/s6lock_wait_or.c
+++ b/src/libs6/s6lock_wait_or.c
@@ -14,8 +14,8 @@ int s6lock_wait_or (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t
if (x.fd < 0) return -1 ;
for (;;)
{
- register unsigned int i = 0 ;
- register int r ;
+ unsigned int i = 0 ;
+ int r ;
for (; i < n ; i++)
{
r = s6lock_check(a, idlist[i]) ;
diff --git a/src/libs6/s6lockd.c b/src/libs6/s6lockd.c
index e8c8cb6..5899b46 100644
--- a/src/libs6/s6lockd.c
+++ b/src/libs6/s6lockd.c
@@ -1,12 +1,10 @@
/* ISC license. */
-#include <sys/types.h>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
-#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
+#include <skalibs/types.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/error.h>
#include <skalibs/strerr2.h>
@@ -39,7 +37,7 @@ static genalloc a = GENALLOC_ZERO ; /* array of s6lockio_t */
static void s6lockio_free (s6lockio_t *p)
{
- register int e = errno ;
+ int e = errno ;
fd_close(p->p[1]) ;
fd_close(p->p[0]) ;
kill(p->pid, SIGTERM) ;
@@ -49,7 +47,7 @@ static void s6lockio_free (s6lockio_t *p)
static void cleanup (void)
{
- register size_t i = genalloc_len(s6lockio_t, &a) ;
+ size_t i = genalloc_len(s6lockio_t, &a) ;
for (; i ; i--) s6lockio_free(genalloc_s(s6lockio_t, &a) + i - 1) ;
genalloc_setlen(s6lockio_t, &a, 0) ;
}
@@ -79,7 +77,7 @@ static void answer (char c)
static void remove (unsigned int i)
{
- register size_t n = genalloc_len(s6lockio_t, &a) - 1 ;
+ size_t n = genalloc_len(s6lockio_t, &a) - 1 ;
s6lockio_free(genalloc_s(s6lockio_t, &a) + i) ;
genalloc_s(s6lockio_t, &a)[i] = genalloc_s(s6lockio_t, &a)[n] ;
genalloc_setlen(s6lockio_t, &a, n) ;
@@ -117,7 +115,7 @@ static int parse_protocol (unixmessage_t const *m, void *context)
{
case '>' : /* release */
{
- register size_t i = genalloc_len(s6lockio_t, &a) ;
+ size_t i = genalloc_len(s6lockio_t, &a) ;
for (; i ; i--) if (genalloc_s(s6lockio_t, &a)[i-1].id == id) break ;
if (i)
{
@@ -211,7 +209,7 @@ int main (int argc, char const *const *argv)
for (;;)
{
- register size_t n = genalloc_len(s6lockio_t, &a) ;
+ size_t n = genalloc_len(s6lockio_t, &a) ;
iopause_fd x[4 + n] ;
unsigned int i = 0 ;
int r ;
@@ -224,7 +222,7 @@ int main (int argc, char const *const *argv)
x[3].fd = sfd ; x[3].events = IOPAUSE_READ ;
for (; i < n ; i++)
{
- register s6lockio_t_ref p = genalloc_s(s6lockio_t, &a) + i ;
+ s6lockio_t *p = genalloc_s(s6lockio_t, &a) + i ;
x[4+i].fd = p->p[0] ;
x[4+i].events = IOPAUSE_READ ;
if (p->limit.sec.x && tain_less(&p->limit, &deadline)) deadline = p->limit ;
@@ -243,7 +241,7 @@ int main (int argc, char const *const *argv)
{
for (i = 0 ; i < n ; i++)
{
- register s6lockio_t_ref p = genalloc_s(s6lockio_t, &a) + i ;
+ s6lockio_t *p = genalloc_s(s6lockio_t, &a) + i ;
if (p->limit.sec.x && !tain_future(&p->limit)) break ;
}
if (i < n)
@@ -274,12 +272,12 @@ int main (int argc, char const *const *argv)
/* scan children for successes */
for (i = 0 ; i < genalloc_len(s6lockio_t, &a) ; i++)
{
- register s6lockio_t *p = genalloc_s(s6lockio_t, &a) + i ;
+ s6lockio_t *p = genalloc_s(s6lockio_t, &a) + i ;
if (p->p[0] < 0) continue ;
if (x[p->xindex].revents & IOPAUSE_READ)
{
char c ;
- register ssize_t r = sanitize_read(fd_read(p->p[0], &c, 1)) ;
+ ssize_t r = sanitize_read(fd_read(p->p[0], &c, 1)) ;
if (!r) continue ;
if (r < 0)
{