diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-08 12:17:31 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-08 12:17:31 +0000 |
commit | 495d625add9e52b29a98c4fa2627a45d20d44849 (patch) | |
tree | 4927b430b4115c3217965fa08a9aba76fe809422 /src/minutils/s6ps_ttycache.c | |
parent | fa3f206449c7c54afedbc2c7d4107a73e55c204a (diff) | |
download | s6-linux-utils-495d625add9e52b29a98c4fa2627a45d20d44849.tar.gz s6-linux-utils-495d625add9e52b29a98c4fa2627a45d20d44849.tar.xz s6-linux-utils-495d625add9e52b29a98c4fa2627a45d20d44849.zip |
Make it build with skalibs-2.5.0.0
Diffstat (limited to 'src/minutils/s6ps_ttycache.c')
-rw-r--r-- | src/minutils/s6ps_ttycache.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/minutils/s6ps_ttycache.c b/src/minutils/s6ps_ttycache.c index dcbbc54..df59334 100644 --- a/src/minutils/s6ps_ttycache.c +++ b/src/minutils/s6ps_ttycache.c @@ -4,11 +4,11 @@ #define _BSD_SOURCE #endif -#include <sys/types.h> +#include <string.h> #include <sys/stat.h> #include <errno.h> -#include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> +#include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> @@ -55,8 +55,8 @@ static int ttyguess (stralloc *sa, dev_t ttynr) } else if (maj >= 136 && maj < 144) { + unsigned int n = ((maj - 136) << 20) | min ; char tmp[9 + UINT_FMT] = "/dev/pts/" ; - register unsigned int n = ((maj - 136) << 20) | min ; tmp[9 + uint_fmt(tmp+9, n)] = 0 ; if (check(tmp, ttynr)) return stralloc_cats(sa, tmp+5) && stralloc_0(sa) ; } @@ -64,32 +64,32 @@ static int ttyguess (stralloc *sa, dev_t ttynr) /* Use /sys/dev/char/maj:min if it exists */ { int fd ; + size_t pos = 14 ; char path[23 + 2 * UINT_FMT] = "/sys/dev/char/" ; - register size_t pos = 14 ; pos += uint_fmt(path + pos, maj) ; path[pos++] = ':' ; pos += uint_fmt(path + pos, min) ; - byte_copy(path + pos, 8, "/uevent") ; + memcpy(path + pos, "/uevent", 8) ; fd = open_read(path) ; if (fd >= 0) { char buf[4097] ; - buffer b = BUFFER_INIT(&buffer_read, fd, buf, 4097) ; + buffer b = BUFFER_INIT(&fd_readv, fd, buf, 4097) ; size_t start = satmp.len ; - register int r ; + int r ; for (;;) { satmp.len = start ; r = skagetln(&b, &satmp, '\n') ; if (r <= 0) break ; - if ((satmp.len - start) > 8 && !byte_diff(satmp.s + start, 8, "DEVNAME=")) break ; + if ((satmp.len - start) > 8 && !memcmp(satmp.s + start, "DEVNAME=", 8)) break ; } fd_close(fd) ; if (r > 0) { satmp.s[satmp.len - 1] = 0 ; satmp.len = start ; - byte_copy(satmp.s + start + 3, 5, "/dev/") ; + memcpy(satmp.s + start + 3, "/dev/", 5) ; if (check(satmp.s + start + 3, ttynr)) return stralloc_cats(sa, satmp.s + start + 8) && stralloc_0(sa) ; } @@ -98,8 +98,8 @@ static int ttyguess (stralloc *sa, dev_t ttynr) /* Fallback: print explicit maj:min */ { + size_t pos = 1 ; char tmp[3 + 2 * UINT_FMT] = "(" ; - register size_t pos = 1 ; pos += uint_fmt(tmp + pos, maj) ; tmp[pos++] = ':' ; pos += uint_fmt(tmp + pos, min) ; @@ -116,7 +116,7 @@ int s6ps_ttycache_lookup (stralloc *sa, dev_t ttynr) unsigned int i ; if (!avltree_search(&ttycache_tree, &d.left, &i)) { - size_t n = genalloc_len(dius_t, &ttycache_index) ; + unsigned int n = genalloc_len(dius_t, &ttycache_index) ; if (!ttyguess(&satmp, ttynr)) return 0 ; if (!genalloc_append(dius_t, &ttycache_index, &d)) goto err ; if (!avltree_insert(&ttycache_tree, n)) @@ -129,7 +129,7 @@ int s6ps_ttycache_lookup (stralloc *sa, dev_t ttynr) return stralloc_cats(sa, satmp.s + genalloc_s(dius_t, &ttycache_index)[i].right) ; err: { - register int e = errno ; + int e = errno ; if (wasnull) stralloc_free(&satmp) ; else satmp.len = d.right ; errno = e ; |