From 0acd4707c2de0395810f64d41cb2462db1f8f5ee Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 20 Dec 2015 23:05:20 +0000 Subject: libc: Use namespace.h in a few more files. libc now no longer calls fstat(), socketpair() and wait(), only the underscore-prefixed versions (_waitpid() instead of wait()). --- lib/libc/gen/getpeereid.c | 4 +++- lib/libc/gen/sysconf.c | 6 ++++-- lib/libc/iconv/citrus_mmap.c | 8 +++++--- lib/libc/net/rcmdsh.c | 12 +++++++----- 4 files changed, 19 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/libc/gen/getpeereid.c b/lib/libc/gen/getpeereid.c index 5ecb243..cedaee6 100644 --- a/lib/libc/gen/getpeereid.c +++ b/lib/libc/gen/getpeereid.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include "namespace.h" #include #include #include @@ -34,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include "un-namespace.h" int getpeereid(int s, uid_t *euid, gid_t *egid) @@ -43,7 +45,7 @@ getpeereid(int s, uid_t *euid, gid_t *egid) int error; xuclen = sizeof(xuc); - error = getsockopt(s, 0, LOCAL_PEERCRED, &xuc, &xuclen); + error = _getsockopt(s, 0, LOCAL_PEERCRED, &xuc, &xuclen); if (error != 0) return (error); if (xuc.cr_version != XUCRED_VERSION) diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index be3d4af..71f2321 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -36,6 +36,7 @@ static char sccsid[] = "@(#)sysconf.c 8.2 (Berkeley) 3/20/94"; #include __FBSDID("$FreeBSD$"); +#include "namespace.h" #include #include #include @@ -49,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include /* we just need the limits */ #include #include +#include "un-namespace.h" #include "../stdlib/atexit.h" #include "tzfile.h" /* from ../../../contrib/tzcode/stdtime */ @@ -575,10 +577,10 @@ yesno: case _SC_IPV6: #if _POSIX_IPV6 == 0 sverrno = errno; - value = socket(PF_INET6, SOCK_DGRAM, 0); + value = _socket(PF_INET6, SOCK_DGRAM, 0); errno = sverrno; if (value >= 0) { - close(value); + _close(value); return (200112L); } else return (0); diff --git a/lib/libc/iconv/citrus_mmap.c b/lib/libc/iconv/citrus_mmap.c index f8e96d1..83dd70b 100644 --- a/lib/libc/iconv/citrus_mmap.c +++ b/lib/libc/iconv/citrus_mmap.c @@ -27,6 +27,7 @@ * SUCH DAMAGE. */ +#include "namespace.h" #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include "un-namespace.h" #include "citrus_namespace.h" #include "citrus_region.h" @@ -57,10 +59,10 @@ _citrus_map_file(struct _citrus_region * __restrict r, _region_init(r, NULL, 0); - if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1) + if ((fd = _open(path, O_RDONLY | O_CLOEXEC)) == -1) return (errno); - if (fstat(fd, &st) == -1) { + if (_fstat(fd, &st) == -1) { ret = errno; goto error; } @@ -78,7 +80,7 @@ _citrus_map_file(struct _citrus_region * __restrict r, _region_init(r, head, (size_t)st.st_size); error: - (void)close(fd); + (void)_close(fd); return (ret); } diff --git a/lib/libc/net/rcmdsh.c b/lib/libc/net/rcmdsh.c index f30ad14..13278df 100644 --- a/lib/libc/net/rcmdsh.c +++ b/lib/libc/net/rcmdsh.c @@ -36,6 +36,7 @@ #include __FBSDID("$FreeBSD$"); +#include "namespace.h" #include #include #include @@ -48,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include "un-namespace.h" /* * This is a replacement rcmd() function that uses the rsh(1) @@ -99,7 +101,7 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser, } /* Get a socketpair we'll use for stdin and stdout. */ - if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) == -1) { + if (_socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) == -1) { perror("rcmdsh: socketpair"); return (-1); } @@ -112,8 +114,8 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser, /* * Child. We use sp[1] to be stdin/stdout, and close sp[0]. */ - (void)close(sp[0]); - if (dup2(sp[1], 0) == -1 || dup2(0, 1) == -1) { + (void)_close(sp[0]); + if (_dup2(sp[1], 0) == -1 || _dup2(0, 1) == -1) { perror("rcmdsh: dup2 failed"); _exit(255); } @@ -156,9 +158,9 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser, _exit(255); } else { /* Parent. close sp[1], return sp[0]. */ - (void)close(sp[1]); + (void)_close(sp[1]); /* Reap child. */ - (void)wait(NULL); + (void)_waitpid(cpid, NULL, 0); return (sp[0]); } /* NOTREACHED */ -- cgit v1.1