svn commit: r292521 - in head/lib/libc: gen iconv net

Jilles Tjoelker jilles at FreeBSD.org
Sun Dec 20 23:05:22 UTC 2015


Author: jilles
Date: Sun Dec 20 23:05:20 2015
New Revision: 292521
URL: https://svnweb.freebsd.org/changeset/base/292521

Log:
  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()).

Modified:
  head/lib/libc/gen/getpeereid.c
  head/lib/libc/gen/sysconf.c
  head/lib/libc/iconv/citrus_mmap.c
  head/lib/libc/net/rcmdsh.c

Modified: head/lib/libc/gen/getpeereid.c
==============================================================================
--- head/lib/libc/gen/getpeereid.c	Sun Dec 20 20:58:49 2015	(r292520)
+++ head/lib/libc/gen/getpeereid.c	Sun Dec 20 23:05:20 2015	(r292521)
@@ -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 *eg
 	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)

Modified: head/lib/libc/gen/sysconf.c
==============================================================================
--- head/lib/libc/gen/sysconf.c	Sun Dec 20 20:58:49 2015	(r292520)
+++ head/lib/libc/gen/sysconf.c	Sun Dec 20 23:05:20 2015	(r292521)
@@ -36,6 +36,7 @@ static char sccsid[] = "@(#)sysconf.c	8.
 #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);

Modified: head/lib/libc/iconv/citrus_mmap.c
==============================================================================
--- head/lib/libc/iconv/citrus_mmap.c	Sun Dec 20 20:58:49 2015	(r292520)
+++ head/lib/libc/iconv/citrus_mmap.c	Sun Dec 20 23:05:20 2015	(r292521)
@@ -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 *
 
 	_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 *
 	_region_init(r, head, (size_t)st.st_size);
 
 error:
-	(void)close(fd);
+	(void)_close(fd);
 	return (ret);
 }
 

Modified: head/lib/libc/net/rcmdsh.c
==============================================================================
--- head/lib/libc/net/rcmdsh.c	Sun Dec 20 20:58:49 2015	(r292520)
+++ head/lib/libc/net/rcmdsh.c	Sun Dec 20 23:05:20 2015	(r292521)
@@ -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 ch
 	}
 
 	/* 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 ch
 		/*
 		 * 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 ch
 		_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 */


More information about the svn-src-head mailing list