summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2015-12-20 23:05:20 +0000
committerjilles <jilles@FreeBSD.org>2015-12-20 23:05:20 +0000
commit0acd4707c2de0395810f64d41cb2462db1f8f5ee (patch)
tree8451e66135b6a257734793d2f264fa2d6723f72e /lib
parentd49c59ad67c87e6b8ef4aec175b43b736fca749e (diff)
downloadFreeBSD-src-0acd4707c2de0395810f64d41cb2462db1f8f5ee.zip
FreeBSD-src-0acd4707c2de0395810f64d41cb2462db1f8f5ee.tar.gz
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()).
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/getpeereid.c4
-rw-r--r--lib/libc/gen/sysconf.c6
-rw-r--r--lib/libc/iconv/citrus_mmap.c8
-rw-r--r--lib/libc/net/rcmdsh.c12
4 files changed, 19 insertions, 11 deletions
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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "namespace.h"
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ucred.h>
@@ -34,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <unistd.h>
+#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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "namespace.h"
#include <sys/param.h>
#include <sys/time.h>
#include <sys/sysctl.h>
@@ -49,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <pthread.h> /* we just need the limits */
#include <time.h>
#include <unistd.h>
+#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 <sys/cdefs.h>
#include <sys/mman.h>
#include <sys/types.h>
@@ -40,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
@@ -48,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#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 */
OpenPOWER on IntegriCloud