diff options
| author | christos <christos@NetBSD.org> | 2011-06-26 16:42:39 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2011-06-26 16:42:39 +0000 |
| commit | bbeb5403be5330b145ad01ccdbfa305d3bf8a76d (patch) | |
| tree | d1be829e69cabc22b138aada13975946ca6ac102 | |
| parent | 8b2572853f09a752d637652a9e7abb15ea88c254 (diff) | |
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).
- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.
* Fix the system calls that take socklen_t arguments to actually do so.
* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).
* Bump libc version for the new syscalls.
43 files changed, 454 insertions, 163 deletions
diff --git a/distrib/sets/lists/base/ad.mips64eb b/distrib/sets/lists/base/ad.mips64eb index 66340902994..649ee0b9469 100644 --- a/distrib/sets/lists/base/ad.mips64eb +++ b/distrib/sets/lists/base/ad.mips64eb @@ -1,4 +1,4 @@ -# $NetBSD: ad.mips64eb,v 1.54 2011/06/25 00:42:57 agc Exp $ +# $NetBSD: ad.mips64eb,v 1.55 2011/06/26 16:42:39 christos Exp $ ./libexec/ld.elf_so-64 base-compat-shlib compat,pic ./libexec/ld.elf_so-o32 base-sysutil-bin compat,pic ./usr/lib/64 base-compat-lib @@ -66,7 +66,7 @@ ./usr/lib/64/libbz2.so.1 base-compat-shlib compat,pic ./usr/lib/64/libbz2.so.1.1 base-compat-shlib compat,pic ./usr/lib/64/libc.so.12 base-compat-shlib compat,pic -./usr/lib/64/libc.so.12.177 base-compat-shlib compat,pic +./usr/lib/64/libc.so.12.178 base-compat-shlib compat,pic ./usr/lib/64/libcom_err.so.7 base-compat-shlib compat,pic,kerberos ./usr/lib/64/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos ./usr/lib/64/libcrypt.so.1 base-compat-shlib compat,pic @@ -343,7 +343,7 @@ ./usr/lib/o32/libbz2.so.1 base-compat-shlib compat,pic ./usr/lib/o32/libbz2.so.1.1 base-compat-shlib compat,pic ./usr/lib/o32/libc.so.12 base-compat-shlib compat,pic -./usr/lib/o32/libc.so.12.177 base-compat-shlib compat,pic +./usr/lib/o32/libc.so.12.178 base-compat-shlib compat,pic ./usr/lib/o32/libcom_err.so.7 base-compat-shlib compat,pic,kerberos ./usr/lib/o32/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos ./usr/lib/o32/libcrypt.so.1 base-compat-shlib compat,pic diff --git a/distrib/sets/lists/base/ad.mips64el b/distrib/sets/lists/base/ad.mips64el index 93d316b01ff..3f5e6d2e630 100644 --- a/distrib/sets/lists/base/ad.mips64el +++ b/distrib/sets/lists/base/ad.mips64el @@ -1,4 +1,4 @@ -# $NetBSD: ad.mips64el,v 1.51 2011/06/25 00:42:58 agc Exp $ +# $NetBSD: ad.mips64el,v 1.52 2011/06/26 16:42:39 christos Exp $ ./libexec/ld.elf_so-64 base-compat-shlib compat,pic ./libexec/ld.elf_so-o32 base-sysutil-bin compat,pic ./usr/lib/64 base-compat-lib @@ -66,7 +66,7 @@ ./usr/lib/64/libbz2.so.1 base-compat-shlib compat,pic ./usr/lib/64/libbz2.so.1.1 base-compat-shlib compat,pic ./usr/lib/64/libc.so.12 base-compat-shlib compat,pic -./usr/lib/64/libc.so.12.177 base-compat-shlib compat,pic +./usr/lib/64/libc.so.12.178 base-compat-shlib compat,pic ./usr/lib/64/libcom_err.so.7 base-compat-shlib compat,pic,kerberos ./usr/lib/64/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos ./usr/lib/64/libcrypt.so.1 base-compat-shlib compat,pic @@ -343,7 +343,7 @@ ./usr/lib/o32/libbz2.so.1 base-compat-shlib compat,pic ./usr/lib/o32/libbz2.so.1.1 base-compat-shlib compat,pic ./usr/lib/o32/libc.so.12 base-compat-shlib compat,pic -./usr/lib/o32/libc.so.12.177 base-compat-shlib compat,pic +./usr/lib/o32/libc.so.12.178 base-compat-shlib compat,pic ./usr/lib/o32/libcom_err.so.7 base-compat-shlib compat,pic,kerberos ./usr/lib/o32/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos ./usr/lib/o32/libcrypt.so.1 base-compat-shlib compat,pic diff --git a/distrib/sets/lists/base/md.amd64 b/distrib/sets/lists/base/md.amd64 index 47a9e87cec2..894b76e3538 100644 --- a/distrib/sets/lists/base/md.amd64 +++ b/distrib/sets/lists/base/md.amd64 @@ -1,4 +1,4 @@ -# $NetBSD: md.amd64,v 1.125 2011/06/25 00:42:58 agc Exp $ +# $NetBSD: md.amd64,v 1.126 2011/06/26 16:42:39 christos Exp $ ./dev/lms0 base-obsolete obsolete ./dev/mms0 base-obsolete obsolete ./libexec/ld.elf_so-i386 base-sys-shlib compat,pic @@ -69,7 +69,7 @@ ./usr/lib/i386/libbz2.so.1 base-compat-shlib compat,pic ./usr/lib/i386/libbz2.so.1.1 base-compat-shlib compat,pic ./usr/lib/i386/libc.so.12 base-compat-shlib compat,pic -./usr/lib/i386/libc.so.12.177 base-compat-shlib compat,pic +./usr/lib/i386/libc.so.12.178 base-compat-shlib compat,pic ./usr/lib/i386/libcom_err.so.7 base-compat-shlib compat,pic,kerberos ./usr/lib/i386/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos ./usr/lib/i386/libcrypt.so.1 base-compat-shlib compat,pic diff --git a/distrib/sets/lists/base/md.sparc64 b/distrib/sets/lists/base/md.sparc64 index 01fbbb5be06..18d3ff79266 100644 --- a/distrib/sets/lists/base/md.sparc64 +++ b/distrib/sets/lists/base/md.sparc64 @@ -1,4 +1,4 @@ -# $NetBSD: md.sparc64,v 1.118 2011/06/25 00:42:58 agc Exp $ +# $NetBSD: md.sparc64,v 1.119 2011/06/26 16:42:39 christos Exp $ ./libexec/ld.elf_so-sparc base-sysutil-bin compat,pic ./sbin/edlabel base-sysutil-root obsolete ./usr/bin/fdformat base-util-bin @@ -67,7 +67,7 @@ ./usr/lib/sparc/libbz2.so.1 base-compat-shlib compat,pic ./usr/lib/sparc/libbz2.so.1.1 base-compat-shlib compat,pic ./usr/lib/sparc/libc.so.12 base-compat-shlib compat,pic -./usr/lib/sparc/libc.so.12.177 base-compat-shlib compat,pic +./usr/lib/sparc/libc.so.12.178 base-compat-shlib compat,pic ./usr/lib/sparc/libcom_err.so.7 base-compat-shlib compat,pic,kerberos ./usr/lib/sparc/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos ./usr/lib/sparc/libcrypt.so.1 base-compat-shlib compat,pic diff --git a/distrib/sets/lists/base/shl.mi b/distrib/sets/lists/base/shl.mi index ee48423e77b..ed384e6814a 100644 --- a/distrib/sets/lists/base/shl.mi +++ b/distrib/sets/lists/base/shl.mi @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.588 2011/06/25 00:42:58 agc Exp $ +# $NetBSD: shl.mi,v 1.589 2011/06/26 16:42:39 christos Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -15,7 +15,7 @@ # ./lib/libc.so base-sys-shlib dynamicroot ./lib/libc.so.12 base-sys-shlib dynamicroot -./lib/libc.so.12.177 base-sys-shlib dynamicroot +./lib/libc.so.12.178 base-sys-shlib dynamicroot ./lib/libcrypt.so base-sys-shlib dynamicroot ./lib/libcrypt.so.1 base-sys-shlib dynamicroot ./lib/libcrypt.so.1.0 base-sys-shlib dynamicroot @@ -170,7 +170,7 @@ ./usr/lib/libbz2.so.1.1 base-sys-shlib ./usr/lib/libc.so base-sys-shlib ./usr/lib/libc.so.12 base-sys-shlib -./usr/lib/libc.so.12.177 base-sys-shlib +./usr/lib/libc.so.12.178 base-sys-shlib ./usr/lib/libcdk.so base-obsolete obsolete ./usr/lib/libcom_err.so base-krb5-shlib kerberos ./usr/lib/libcom_err.so.7 base-krb5-shlib kerberos diff --git a/distrib/sets/lists/comp/ad.mips64eb b/distrib/sets/lists/comp/ad.mips64eb index 86afcc6553f..b8fcb2e9c1b 100644 --- a/distrib/sets/lists/comp/ad.mips64eb +++ b/distrib/sets/lists/comp/ad.mips64eb @@ -1,4 +1,4 @@ -# $NetBSD: ad.mips64eb,v 1.36 2011/06/26 10:14:13 njoly Exp $ +# $NetBSD: ad.mips64eb,v 1.37 2011/06/26 16:42:40 christos Exp $ ./usr/bin/elf2aout comp-obsolete obsolete ./usr/bin/elf2ecoff comp-sysutil-bin ./usr/include/mips comp-c-include @@ -1202,7 +1202,7 @@ ./usr/libdata/debug/usr/lib/64/libbluetooth.so.4.2.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/64/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/64/libbz2.so.1.1.debug comp-sys-debug debug,compat -./usr/libdata/debug/usr/lib/64/libc.so.12.177.debug comp-sys-debug debug,compat +./usr/libdata/debug/usr/lib/64/libc.so.12.178.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/64/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete ./usr/libdata/debug/usr/lib/64/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug ./usr/libdata/debug/usr/lib/64/libcrypt.so.1.0.debug comp-sys-debug debug,compat @@ -1409,7 +1409,7 @@ ./usr/libdata/debug/usr/lib/o32/libbluetooth.so.4.2.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/o32/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/o32/libbz2.so.1.1.debug comp-sys-debug debug,compat -./usr/libdata/debug/usr/lib/o32/libc.so.12.177.debug comp-sys-debug debug,compat +./usr/libdata/debug/usr/lib/o32/libc.so.12.178.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/o32/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete ./usr/libdata/debug/usr/lib/o32/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug ./usr/libdata/debug/usr/lib/o32/libcrypt.so.1.0.debug comp-sys-debug debug,compat diff --git a/distrib/sets/lists/comp/ad.mips64el b/distrib/sets/lists/comp/ad.mips64el index fae9008bb33..1ef294d81ab 100644 --- a/distrib/sets/lists/comp/ad.mips64el +++ b/distrib/sets/lists/comp/ad.mips64el @@ -1,4 +1,4 @@ -# $NetBSD: ad.mips64el,v 1.36 2011/06/26 10:14:13 njoly Exp $ +# $NetBSD: ad.mips64el,v 1.37 2011/06/26 16:42:40 christos Exp $ ./usr/bin/elf2aout comp-obsolete obsolete ./usr/bin/elf2ecoff comp-sysutil-bin ./usr/include/mips comp-c-include @@ -1202,7 +1202,7 @@ ./usr/libdata/debug/usr/lib/64/libbluetooth.so.4.2.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/64/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/64/libbz2.so.1.1.debug comp-sys-debug debug,compat -./usr/libdata/debug/usr/lib/64/libc.so.12.177.debug comp-sys-debug debug,compat +./usr/libdata/debug/usr/lib/64/libc.so.12.178.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/64/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete ./usr/libdata/debug/usr/lib/64/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug ./usr/libdata/debug/usr/lib/64/libcrypt.so.1.0.debug comp-sys-debug debug,compat @@ -1409,7 +1409,7 @@ ./usr/libdata/debug/usr/lib/o32/libbluetooth.so.4.2.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/o32/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/o32/libbz2.so.1.1.debug comp-sys-debug debug,compat -./usr/libdata/debug/usr/lib/o32/libc.so.12.177.debug comp-sys-debug debug,compat +./usr/libdata/debug/usr/lib/o32/libc.so.12.178.debug comp-sys-debug debug,compat ./usr/libdata/debug/usr/lib/o32/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete ./usr/libdata/debug/usr/lib/o32/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug ./usr/libdata/debug/usr/lib/o32/libcrypt.so.1.0.debug comp-sys-debug debug,compat diff --git a/distrib/sets/lists/comp/md.amd64 b/distrib/sets/lists/comp/md.amd64 index 1ccb69924ba..e5e3e3dc263 100644 --- a/distrib/sets/lists/comp/md.amd64 +++ b/distrib/sets/lists/comp/md.amd64 @@ -1,4 +1,4 @@ -# $NetBSD: md.amd64,v 1.118 2011/06/26 10:14:13 njoly Exp $ +# $NetBSD: md.amd64,v 1.119 2011/06/26 16:42:40 christos Exp $ ./usr/include/amd64 comp-c-include ./usr/include/amd64/ansi.h comp-c-include ./usr/include/amd64/aout_machdep.h comp-c-include @@ -973,7 +973,7 @@ ./usr/libdata/debug/usr/lib/i386/libbluetooth.so.4.2.debug comp-compat-shlib compat,pic,debug ./usr/libdata/debug/usr/lib/i386/libbsdmalloc.so.0.0.debug comp-compat-shlib compat,pic,debug ./usr/libdata/debug/usr/lib/i386/libbz2.so.1.1.debug comp-compat-shlib compat,pic,debug -./usr/libdata/debug/usr/lib/i386/libc.so.12.177.debug comp-compat-shlib compat,pic,debug +./usr/libdata/debug/usr/lib/i386/libc.so.12.178.debug comp-compat-shlib compat,pic,debug ./usr/libdata/debug/usr/lib/i386/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete ./usr/libdata/debug/usr/lib/i386/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug ./usr/libdata/debug/usr/lib/i386/libcrypt.so.1.0.debug comp-compat-shlib compat,pic,debug diff --git a/distrib/sets/lists/comp/md.sparc64 b/distrib/sets/lists/comp/md.sparc64 index d8355f609f2..16a10d7ed8f 100644 --- a/distrib/sets/lists/comp/md.sparc64 +++ b/distrib/sets/lists/comp/md.sparc64 @@ -1,4 +1,4 @@ -# $NetBSD: md.sparc64,v 1.103 2011/06/26 10:14:14 njoly Exp $ +# $NetBSD: md.sparc64,v 1.104 2011/06/26 16:42:40 christos Exp $ ./usr/include/ieeefp.h comp-c-include ./usr/include/sparc comp-c-include ./usr/include/sparc/_G_config.h comp-obsolete obsolete @@ -861,7 +861,7 @@ ./usr/libdata/debug/usr/lib/sparc/libbluetooth.so.4.2.debug comp-compat-shlib compat,pic,debug ./usr/libdata/debug/usr/lib/sparc/libbsdmalloc.so.0.0.debug comp-compat-shlib compat,pic,debug ./usr/libdata/debug/usr/lib/sparc/libbz2.so.1.1.debug comp-compat-shlib compat,pic,debug -./usr/libdata/debug/usr/lib/sparc/libc.so.12.177.debug comp-compat-shlib compat,pic,debug +./usr/libdata/debug/usr/lib/sparc/libc.so.12.178.debug comp-compat-shlib compat,pic,debug ./usr/libdata/debug/usr/lib/sparc/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete ./usr/libdata/debug/usr/lib/sparc/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug ./usr/libdata/debug/usr/lib/sparc/libcrypt.so.1.0.debug comp-compat-shlib compat,pic,debug diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi index 525b3d6c207..d12dc6001d8 100644 --- a/distrib/sets/lists/comp/mi +++ b/distrib/sets/lists/comp/mi @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1631 2011/06/25 05:45:11 nonaka Exp $ +# $NetBSD: mi,v 1.1632 2011/06/26 16:42:40 christos Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4303,6 +4303,7 @@ ./usr/share/man/cat2/connect.0 comp-c-catman .cat ./usr/share/man/cat2/dup.0 comp-c-catman .cat ./usr/share/man/cat2/dup2.0 comp-c-catman .cat +./usr/share/man/cat2/dup3.0 comp-c-catman .cat ./usr/share/man/cat2/errno.0 comp-c-catman .cat ./usr/share/man/cat2/execve.0 comp-c-catman .cat ./usr/share/man/cat2/extattr_delete_fd.0 comp-c-catman .cat @@ -4424,8 +4425,10 @@ ./usr/share/man/cat2/ntp_adjtime.0 comp-c-catman .cat ./usr/share/man/cat2/ntp_gettime.0 comp-c-catman .cat ./usr/share/man/cat2/open.0 comp-c-catman .cat +./usr/share/man/cat2/paccept.0 comp-c-catman .cat ./usr/share/man/cat2/pathconf.0 comp-c-catman .cat ./usr/share/man/cat2/pipe.0 comp-c-catman .cat +./usr/share/man/cat2/pipe2.0 comp-c-catman .cat ./usr/share/man/cat2/pmc_control.0 comp-c-catman .cat ./usr/share/man/cat2/pmc_get_info.0 comp-c-catman .cat ./usr/share/man/cat2/poll.0 comp-c-catman .cat @@ -10469,6 +10472,7 @@ ./usr/share/man/html2/connect.html comp-c-htmlman html ./usr/share/man/html2/dup.html comp-c-htmlman html ./usr/share/man/html2/dup2.html comp-c-htmlman html +./usr/share/man/html2/dup3.html comp-c-htmlman html ./usr/share/man/html2/errno.html comp-c-htmlman html ./usr/share/man/html2/execve.html comp-c-htmlman html ./usr/share/man/html2/extattr_delete_fd.html comp-c-htmlman html @@ -10584,8 +10588,10 @@ ./usr/share/man/html2/ntp_adjtime.html comp-c-htmlman html ./usr/share/man/html2/ntp_gettime.html comp-c-htmlman html ./usr/share/man/html2/open.html comp-c-htmlman html +./usr/share/man/html2/paccept.html comp-c-htmlman html ./usr/share/man/html2/pathconf.html comp-c-htmlman html ./usr/share/man/html2/pipe.html comp-c-htmlman html +./usr/share/man/html2/pipe2.html comp-c-htmlman html ./usr/share/man/html2/pmc_control.html comp-c-htmlman html ./usr/share/man/html2/pmc_get_info.html comp-c-htmlman html ./usr/share/man/html2/poll.html comp-c-htmlman html @@ -16404,6 +16410,7 @@ ./usr/share/man/man2/connect.2 comp-c-man .man ./usr/share/man/man2/dup.2 comp-c-man .man ./usr/share/man/man2/dup2.2 comp-c-man .man +./usr/share/man/man2/dup3.2 comp-c-man .man ./usr/share/man/man2/errno.2 comp-c-man .man ./usr/share/man/man2/execve.2 comp-c-man .man ./usr/share/man/man2/extattr_delete_fd.2 comp-c-man .man @@ -16524,8 +16531,10 @@ ./usr/share/man/man2/ntp_adjtime.2 comp-c-man .man ./usr/share/man/man2/ntp_gettime.2 comp-c-man .man ./usr/share/man/man2/open.2 comp-c-man .man +./usr/share/man/man2/paccept.2 comp-c-man .man ./usr/share/man/man2/pathconf.2 comp-c-man .man ./usr/share/man/man2/pipe.2 comp-c-man .man +./usr/share/man/man2/pipe2.2 comp-c-man .man ./usr/share/man/man2/pmc_control.2 comp-c-man .man ./usr/share/man/man2/pmc_get_info.2 comp-c-man .man ./usr/share/man/man2/poll.2 comp-c-man .man diff --git a/distrib/sets/lists/comp/shl.mi b/distrib/sets/lists/comp/shl.mi index c5a3f87c797..dd9f162bf55 100644 --- a/distrib/sets/lists/comp/shl.mi +++ b/distrib/sets/lists/comp/shl.mi @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.176 2011/06/26 10:14:14 njoly Exp $ +# $NetBSD: shl.mi,v 1.177 2011/06/26 16:42:40 christos Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -230,7 +230,7 @@ ./usr/libdata/debug/usr/lib/libbluetooth.so.4.2.debug comp-sys-debug debug ./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug comp-sys-debug debug ./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug comp-sys-debug debug -./usr/libdata/debug/usr/lib/libc.so.12.177.debug comp-sys-debug debug +./usr/libdata/debug/usr/lib/libc.so.12.178.debug comp-sys-debug debug ./usr/libdata/debug/usr/lib/libcom_err.so.7.0.debug comp-krb5-debug kerberos,debug ./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug comp-sys-debug debug ./usr/libdata/debug/usr/lib/libcrypto.so.6.2.debug comp-crypto-debug crypto,debug diff --git a/include/unistd.h b/include/unistd.h index 32dbb29adfe..f9d5b669ce7 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -1,4 +1,4 @@ -/* $NetBSD: unistd.h,v 1.125 2011/01/19 19:21:29 christos Exp $ */ +/* $NetBSD: unistd.h,v 1.126 2011/06/26 16:42:40 christos Exp $ */ /*- * Copyright (c) 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -300,6 +300,7 @@ int acct(const char *); int closefrom(int); int des_cipher(const char *, char *, long, int); int des_setkey(const char *); +int dup3(int, int, int); void endusershell(void); int exect(const char *, char * const *, char * const *); int fchroot(int); @@ -315,11 +316,12 @@ int initgroups(const char *, gid_t); int iruserok(uint32_t, int, const char *, const char *); int issetugid(void); int nfssvc(int, void *); +int pipe2(int *, int); int profil(char *, size_t, u_long, u_int); #ifndef __PSIGNAL_DECLARED #define __PSIGNAL_DECLARED /* also in signal.h */ -void psignal(int, const char *); +void psignal(int, const char *); #endif /* __PSIGNAL_DECLARED */ int rcmd(char **, int, const char *, const char *, const char *, int *); int reboot(int, char *); diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3 index d5cf7bb28fe..707f85f2e8a 100644 --- a/lib/libc/gen/popen.3 +++ b/lib/libc/gen/popen.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: popen.3,v 1.16 2007/08/02 23:45:10 wiz Exp $ +.\" $NetBSD: popen.3,v 1.17 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)popen.3 8.2 (Berkeley) 5/3/95 .\" -.Dd August 2, 2007 +.Dd June 24, 2011 .Dt POPEN 3 .Os .Sh NAME @@ -76,6 +76,12 @@ for reading, for writing, or .Ql r+ for reading and writing. +In addition if the character +.Ql e +is present in the +.Fa type +string, the file descriptor used internally is set to be closed on +.Xr exec 2 . .Pp The .Fa command diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index edd85d5d041..a7e9a30594a 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -1,4 +1,4 @@ -/* $NetBSD: popen.c,v 1.30 2010/11/14 18:11:42 tron Exp $ */ +/* $NetBSD: popen.c,v 1.31 2011/06/26 16:42:41 christos Exp $ */ /* * Copyright (c) 1988, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: popen.c,v 1.30 2010/11/14 18:11:42 tron Exp $"); +__RCSID("$NetBSD: popen.c,v 1.31 2011/06/26 16:42:41 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -54,6 +54,7 @@ __RCSID("$NetBSD: popen.c,v 1.30 2010/11/14 18:11:42 tron Exp $"); #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <fcntl.h> #include "env.h" #include "reentrant.h" @@ -84,22 +85,23 @@ popen(const char *command, const char *type) const char * volatile xtype = type; int pdes[2], pid, serrno; volatile int twoway; + int flags; _DIAGASSERT(command != NULL); _DIAGASSERT(xtype != NULL); + flags = strchr(xtype, 'e') ? O_CLOEXEC : 0; if (strchr(xtype, '+')) { + int stype = flags ? (SOCK_STREAM | SOCK_CLOEXEC) : SOCK_STREAM; twoway = 1; - type = "r+"; - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, pdes) < 0) - return (NULL); + xtype = "r+"; + if (socketpair(AF_LOCAL, stype, 0, pdes) < 0) + return NULL; } else { twoway = 0; - if ((*xtype != 'r' && *xtype != 'w') || xtype[1] || - (pipe(pdes) < 0)) { - errno = EINVAL; - return (NULL); - } + xtype = strrchr(xtype, 'r') ? "r" : "w"; + if (pipe2(pdes, flags) == -1) + return NULL; } if ((cur = malloc(sizeof(struct pid))) == NULL) { diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version index 3c883577f2a..e76fb87fc98 100644 --- a/lib/libc/shlib_version +++ b/lib/libc/shlib_version @@ -1,4 +1,4 @@ -# $NetBSD: shlib_version,v 1.222 2011/03/12 19:52:47 christos Exp $ +# $NetBSD: shlib_version,v 1.223 2011/06/26 16:42:40 christos Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # # things we wish to do on next major version bump: @@ -31,4 +31,4 @@ # it's insufficient bitwidth to implement all ctype class. # see isblank's comment in ctype.h. major=12 -minor=177 +minor=178 diff --git a/lib/libc/stdio/flags.c b/lib/libc/stdio/flags.c index d9772672ed4..191bd23e8b9 100644 --- a/lib/libc/stdio/flags.c +++ b/lib/libc/stdio/flags.c @@ -1,4 +1,4 @@ -/* $NetBSD: flags.c,v 1.14 2003/08/07 16:43:23 agc Exp $ */ +/* $NetBSD: flags.c,v 1.15 2011/06/26 16:42:41 christos Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)flags.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: flags.c,v 1.14 2003/08/07 16:43:23 agc Exp $"); +__RCSID("$NetBSD: flags.c,v 1.15 2011/06/26 16:42:41 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -55,9 +55,7 @@ __RCSID("$NetBSD: flags.c,v 1.14 2003/08/07 16:43:23 agc Exp $"); * Return 0 on error. */ int -__sflags(mode, optr) - const char *mode; - int *optr; +__sflags(const char *mode, int *optr) { int ret, m, o; @@ -90,7 +88,8 @@ __sflags(mode, optr) /* * [rwa]\+ or [rwa]b\+ means read and write - * f means open only plain files. + * f means open only plain files, + * e means set close on exec. */ for (; *mode; mode++) switch (*mode) { @@ -101,6 +100,9 @@ __sflags(mode, optr) case 'f': o |= O_NONBLOCK; break; + case 'e': + o |= O_CLOEXEC; + break; case 'b': break; default: /* We could produce a warning here */ diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3 index ad897b6ab36..b17ae124a12 100644 --- a/lib/libc/stdio/fopen.3 +++ b/lib/libc/stdio/fopen.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: fopen.3,v 1.24 2010/04/05 21:34:47 joerg Exp $ +.\" $NetBSD: fopen.3,v 1.25 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,7 +33,7 @@ .\" .\" @(#)fopen.3 8.1 (Berkeley) 6/4/93 .\" -.Dd June 4, 1993 +.Dd June 24, 2011 .Dt FOPEN 3 .Os .Sh NAME @@ -84,14 +84,20 @@ The file is created if it does not exist. .Pp The .Fa mode -string can also include the letter ``b'' either as a last character or +string can also include the letter +.Dq b +either as a last character or as a character between the characters in any of the two-character strings described above. This is strictly for compatibility with .St -ansiC -and has no effect; the ``b'' is ignored. +and has no effect; the +.Dq b +is ignored. .Pp -The letter ``f'' in the mode string restricts fopen to regular +The letter +.Dq f +in the mode string restricts fopen to regular files; if the file opened is not a regular file, .Fn fopen will fail. @@ -99,6 +105,16 @@ This is a non .St -ansiC extension. .Pp +the letter +.Dq e +in the mode string sets the close-on-exec flag in the file descriptors of +the newly opened file files; if the operation fails, +.Fn fopen +will fail. +This is a non +.St -ansiC +extension. +.Pp Any created files will have mode .Pf \*q Dv S_IRUSR \&| diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index d68043f055e..56554af7c47 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.205 2011/03/06 17:08:15 bouyer Exp $ +# $NetBSD: Makefile.inc,v 1.206 2011/06/26 16:42:41 christos Exp $ # @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 # sys sources @@ -77,7 +77,7 @@ ASM= access.S acct.S \ bind.S \ chdir.S chflags.S chmod.S chown.S chroot.S __clock_getres50.S \ __clock_gettime50.S \ - dup.S dup2.S \ + dup.S dup2.S dup3.S \ extattrctl.S \ extattr_delete_fd.S extattr_delete_file.S \ extattr_delete_link.S extattr_get_fd.S extattr_get_file.S \ @@ -92,7 +92,7 @@ ASM= access.S acct.S \ getpriority.S getrlimit.S __getrusage50.S getsid.S \ getsockname.S getsockopt.S __gettimeofday50.S \ ioctl.S \ - kqueue.S ktrace.S \ + kqueue.S kqueue1.S ktrace.S \ _ksem_close.S _ksem_destroy.S _ksem_getvalue.S _ksem_init.S \ _ksem_post.S _ksem_trywait.S _ksem_unlink.S _ksem_wait.S \ _ksem_open.S \ @@ -107,8 +107,9 @@ ASM= access.S acct.S \ mlock.S mlockall.S modctl.S __mount50.S mprotect.S \ __msgctl50.S msgget.S munlock.S munlockall.S munmap.S \ nfssvc.S __ntp_gettime50.S \ - pathconf.S pmc_get_info.S pmc_control.S __posix_chown.S \ - __posix_fchown.S __posix_lchown.S __posix_rename.S profil.S \ + paccept.S pathconf.S pipe2.S pmc_get_info.S pmc_control.S \ + __posix_chown.S __posix_fchown.S __posix_lchown.S \ + __posix_rename.S profil.S \ __quotactl50.S \ rasctl.S reboot.S recvfrom.S recvmsg.S rename.S revoke.S \ rmdir.S \ @@ -242,6 +243,7 @@ MLINKS+=_exit.2 _Exit.2 MLINKS+=brk.2 sbrk.2 MLINKS+=clone.2 __clone.2 MLINKS+=dup.2 dup2.2 +MLINKS+=dup.2 dup3.2 MLINKS+=chdir.2 fchdir.2 MLINKS+=chflags.2 fchflags.2 chflags.2 lchflags.2 MLINKS+=chmod.2 fchmod.2 chmod.2 lchmod.2 @@ -308,3 +310,5 @@ MLINKS+=truncate.2 ftruncate.2 MLINKS+=utimes.2 futimes.2 utimes.2 lutimes.2 MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2 MLINKS+=write.2 writev.2 write.2 pwrite.2 write.2 pwritev.2 +MLINKS+=pipe.2 pipe2.2 +MLINKS+=accept.2 paccept.2 diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2 index 9c7ea975d5b..d9b02af6cdd 100644 --- a/lib/libc/sys/accept.2 +++ b/lib/libc/sys/accept.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: accept.2,v 1.26 2011/06/02 01:04:18 yamt Exp $ +.\" $NetBSD: accept.2,v 1.27 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1983, 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,7 +33,8 @@ .Dt ACCEPT 2 .Os .Sh NAME -.Nm accept +.Nm accept , +.Nm paccept .Nd accept a connection on a socket .Sh LIBRARY .Lb libc @@ -41,6 +42,8 @@ .In sys/socket.h .Ft int .Fn accept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" +.Ft int +.Fn paccept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" "const sigset_t * restrict sigmask" "int flags" .Sh DESCRIPTION The argument .Fa s @@ -131,12 +134,41 @@ by issuing a call with providing only the control information, or by calling .Xr setsockopt 2 . +.Pp +The +.Fn paccept +function behaves exactly like +.Fn accept , +but it also allows to set the following +.Fa flags +on the returned file descriptor: +.Bl -column SOCK_NONBLOCK -offset indent +.It Dv SOCK_CLOEXEC +Set the close on exec property. +.It Dv SOCK_NONBLOCK +Sets non-blocking I/O. +.El +.Pp +It can also temporarily replace the signal mask of the calling thread if +.Fa sigmask +is a non-null pointer, then the +.Fn paccept +function shall replace the signal mask of the caller by the set of +signals pointed to by +.Fa sigmask +before waiting for a connection, and shall restore the signal mask +of the calling thread before returning. .Sh RETURN VALUES -The call returns \-1 on error. -If it succeeds, it returns a non-negative +The +.Fn accept +and +.Fn paccept calls return \-1 on error. +If they succeed, they return a non-negative integer that is a descriptor for the accepted socket. .Sh COMPATIBILITY -This implementation makes the new file descriptor inherit file flags +The +.Fn accept +implementation makes the new file descriptor inherit file flags (like .Dv O_NONBLOCK ) from the listening socket. @@ -192,3 +224,7 @@ The .Fn accept function appeared in .Bx 4.2 . +The +.Fn pselect +function is inspired from Linux and appeared in +.Nx 6.0 . diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2 index 6cf0d51849a..2edfb4e7151 100644 --- a/lib/libc/sys/dup.2 +++ b/lib/libc/sys/dup.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: dup.2,v 1.21 2009/01/11 02:46:30 christos Exp $ +.\" $NetBSD: dup.2,v 1.22 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,12 +29,13 @@ .\" .\" @(#)dup.2 8.1 (Berkeley) 6/4/93 .\" -.Dd December 2, 2008 +.Dd June 24, 2011 .Dt DUP 2 .Os .Sh NAME .Nm dup , -.Nm dup2 +.Nm dup2 , +.Nm dup3 .Nd duplicate an existing file descriptor .Sh LIBRARY .Lb libc @@ -44,6 +45,8 @@ .Fn dup "int oldd" .Ft int .Fn dup2 "int oldd" "int newd" +.Ft int +.Fn dup3 "int oldd" "int newd" "int flags" .Sh DESCRIPTION .Fn dup duplicates an existing object descriptor and returns its value to @@ -100,6 +103,20 @@ If and .Fa oldd are the same, the call has no effect. +.Pp +.Fn dup3 +behaves exactly like +.Fn dup2 +only it allows extra +.Fa flags +to be set on the returned file descriptor. +The following flags are valid: +.Bl -column O_NONBLOCK -offset indent +.It Dv O_CLOEXEC +Set the close on exec property. +.It Dv O_NONBLOCK +Sets non-blocking I/O. +.El .Sh RETURN VALUES The value \-1 is returned if an error occurs in either call. The external variable @@ -107,8 +124,9 @@ The external variable indicates the cause of the error. .Sh ERRORS .Fn dup -and .Fn dup2 +and +.Fn dup3 fail if: .Bl -tag -width Er .It Bq Er EBADF @@ -136,3 +154,8 @@ and .Fn dup2 functions conform to .St -p1003.1-90 . +.Sh HISTORY +The +.Fn dup3 +function is inspired from Linux and appeared in +.Nx 6.0 . diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2 index a22fe0496f6..c9bc29f4f15 100644 --- a/lib/libc/sys/fcntl.2 +++ b/lib/libc/sys/fcntl.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: fcntl.2,v 1.37 2010/05/17 12:16:43 jruoho Exp $ +.\" $NetBSD: fcntl.2,v 1.38 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94 .\" -.Dd May 17, 2010 +.Dd June 25, 2011 .Dt FCNTL 2 .Os .Sh NAME @@ -55,7 +55,7 @@ and is technically a pointer to void, but it is interpreted as an int by some commands and ignored by others. .Pp Commands are: -.Bl -tag -width F_GETOWNX +.Bl -tag -width F_DUPFD_CLOEXEC .It Dv F_DUPFD Return a new descriptor as follows: .Pp @@ -80,6 +80,9 @@ is cleared to remain open across .Xr execve 2 system calls. .El +.It Dv F_DUPFD_CLOEXEC +Same as F_DUPFD, but sets the close-on-exec property on the file descriptor +created. .It Dv F_GETFD Get the close-on-exec flag associated with the file descriptor .Fa fd diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index 37e263bd11b..cbda791346d 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: kqueue.2,v 1.30 2011/05/24 02:31:11 ryo Exp $ +.\" $NetBSD: kqueue.2,v 1.31 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 2000 Jonathan Lemon .\" All rights reserved. @@ -32,11 +32,12 @@ .\" .\" $FreeBSD: src/lib/libc/sys/kqueue.2,v 1.22 2001/06/27 19:55:57 dd Exp $ .\" -.Dd April 13, 2010 +.Dd June 24, 2011 .Dt KQUEUE 2 .Os .Sh NAME .Nm kqueue , +.Nm kqueue1 , .Nm kevent .Nd kernel event notification mechanism .Sh LIBRARY @@ -47,6 +48,8 @@ .Ft int .Fn kqueue "void" .Ft int +.Fn kqueue1 "int flags" +.Ft int .Fn kevent "int kq" "const struct kevent *changelist" "size_t nchanges" "struct kevent *eventlist" "size_t nevents" "const struct timespec *timeout" .Fn EV_SET "\*[Am]kev" ident filter flags fflags data udata .Sh DESCRIPTION @@ -78,6 +81,18 @@ on a file descriptor will remove any kevents that reference the descriptor. .Pp .Fn kqueue creates a new kernel event queue and returns a descriptor. +.Pp +The +.Fn kqueue1 +also allows to set the following +.Fa flags +on the returned file descriptor: +.Bl -column O_NONBLOCK -offset indent +.It Dv O_CLOEXEC +Set the close on exec property. +.It Dv O_NONBLOCK +Sets non-blocking I/O. +.El The queue is not inherited by a child created with .Xr fork 2 . .\" However, if @@ -617,3 +632,7 @@ functions first appeared in .Fx 4.1 , and then in .Nx 2.0 . +The +.Fn kqueue1 +function first appeared in +.Nx 6.0 . diff --git a/lib/libc/sys/pipe.2 b/lib/libc/sys/pipe.2 index 98dac5a51c6..e11af9e39d6 100644 --- a/lib/libc/sys/pipe.2 +++ b/lib/libc/sys/pipe.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: pipe.2,v 1.22 2004/05/13 10:20:58 wiz Exp $ +.\" $NetBSD: pipe.2,v 1.23 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)pipe.2 8.1 (Berkeley) 6/4/93 .\" -.Dd July 17, 1994 +.Dd June 24, 2011 .Dt PIPE 2 .Os .Sh NAME @@ -41,6 +41,8 @@ .In unistd.h .Ft int .Fn pipe "int fildes[2]" +.Ft int +.Fn pipe2 "int fildes[2]" "int flags" .Sh DESCRIPTION The .Fn pipe @@ -78,6 +80,22 @@ signal. Widowing a pipe is the only way to deliver end-of-file to a reader: after the reader consumes any buffered data, reading a widowed pipe returns a zero count. +.Pp +The +.Fn pipe2 +function +behaves exactly like +.Fn pipe +only it allows extra +.Fa flags +to be set on the returned file descriptor. +The following flags are valid: +.Bl -column O_NONBLOCK -offset indent +.It Dv O_CLOEXEC +Set the close on exec property. +.It Dv O_NONBLOCK +Sets non-blocking I/O. +.El .Sh RETURN VALUES On successful creation of the pipe, zero is returned. Otherwise, a value of \-1 is returned and the variable @@ -87,7 +105,9 @@ error. .Sh ERRORS The .Fn pipe -call will fail if: +and +.Fn pipe2 +calls will fail if: .Bl -tag -width Er .It Bq Er EMFILE Too many descriptors are active. @@ -117,3 +137,7 @@ A .Fn pipe function call appeared in .At v6 . +The +.Fn pipe2 +function is inspired from Linux and appeared in +.Nx 6.0 . diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2 index 134cdb17dce..5152788c39c 100644 --- a/lib/libc/sys/recv.2 +++ b/lib/libc/sys/recv.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: recv.2,v 1.27 2006/04/23 19:06:59 wiz Exp $ +.\" $NetBSD: recv.2,v 1.28 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1983, 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)recv.2 8.3 (Berkeley) 2/21/94 .\" -.Dd April 23, 2006 +.Dd June 24, 2011 .Dt RECV 2 .Os .Sh NAME @@ -116,7 +116,8 @@ The argument to a recv call is formed by .Em or Ap ing one or more of the values: -.Bl -column MSG_WAITALL -offset indent +.Bl -column MSG_CMSG_CLOEXEC -offset indent +.It Dv MSG_CMSG_CLOEXEC Ta set the close on exec property for passed file descriptors .It Dv MSG_OOB Ta process out-of-band data .It Dv MSG_PEEK Ta peek at incoming message .It Dv MSG_WAITALL Ta wait for full request or error diff --git a/lib/libc/sys/socket.2 b/lib/libc/sys/socket.2 index e13148b630d..f1966908900 100644 --- a/lib/libc/sys/socket.2 +++ b/lib/libc/sys/socket.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: socket.2,v 1.36 2007/09/06 09:32:52 jnemeth Exp $ +.\" $NetBSD: socket.2,v 1.37 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -78,6 +78,16 @@ SOCK_SEQPACKET SOCK_RDM .Ed .Pp +The following flags can be or'ed to the type to condition the returned +file descriptor: +The following flags are valid: +.Bl -column SOCK_NONBLOCK -offset indent +.It Dv SOCK_CLOEXEC +Set the close on exec property. +.It Dv SOCK_NONBLOCK +Sets non-blocking I/O. +.El +.Pp A .Dv SOCK_STREAM type provides sequenced, reliable, diff --git a/lib/libc/sys/socketpair.2 b/lib/libc/sys/socketpair.2 index ac64b0cf932..b7ec20a11a1 100644 --- a/lib/libc/sys/socketpair.2 +++ b/lib/libc/sys/socketpair.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: socketpair.2,v 1.21 2009/12/20 02:16:40 wiz Exp $ +.\" $NetBSD: socketpair.2,v 1.22 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)socketpair.2 8.1 (Berkeley) 6/4/93 .\" -.Dd December 20, 2009 +.Dd June 24, 2011 .Dt SOCKETPAIR 2 .Os .Sh NAME @@ -57,6 +57,13 @@ are returned in and .Fa sv Ns [1] . The two sockets are indistinguishable. +.Pp +The +.Fa type +and +.Fa protocol +argument values are described in +.Xr socket 2 . .Sh RETURN VALUES A 0 is returned if the call succeeds, \-1 if it fails. .Sh ERRORS @@ -81,6 +88,7 @@ The specified protocol is not supported on this machine. .Sh SEE ALSO .Xr pipe 2 , .Xr read 2 , +.Xr socket 2 , .Xr write 2 .Sh HISTORY The diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c index c94e9dcacfa..bf356760aa9 100644 --- a/sys/compat/svr4/svr4_stream.c +++ b/sys/compat/svr4/svr4_stream.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_stream.c,v 1.78 2010/11/19 06:44:38 dholland Exp $ */ +/* $NetBSD: svr4_stream.c,v 1.79 2011/06/26 16:42:41 christos Exp $ */ /*- * Copyright (c) 1994, 2008 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.78 2010/11/19 06:44:38 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.79 2011/06/26 16:42:41 christos Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -1682,7 +1682,8 @@ svr4_sys_getmsg(struct lwp *l, const struct svr4_sys_getmsg_args *uap, register_ * We are after a listen, so we try to accept... */ - error = do_sys_accept(l, SCARG(uap, fd), &name, retval); + error = do_sys_accept(l, SCARG(uap, fd), &name, retval, + NULL, 0, FNONBLOCK); if (error != 0) { DPRINTF(("getmsg: accept failed %d\n", error)); goto out; diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 0703d4e26e2..cdef77eaba9 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_descrip.c,v 1.214 2011/04/24 20:30:38 rmind Exp $ */ +/* $NetBSD: kern_descrip.c,v 1.215 2011/06/26 16:42:41 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.214 2011/04/24 20:30:38 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.215 2011/06/26 16:42:41 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -729,7 +729,7 @@ fd_dup(file_t *fp, int minfd, int *newp, bool exclose) * dup2 operation. */ int -fd_dup2(file_t *fp, unsigned new) +fd_dup2(file_t *fp, unsigned new, int flags) { filedesc_t *fdp = curlwp->l_fd; fdfile_t *ff; @@ -773,6 +773,8 @@ fd_dup2(file_t *fp, unsigned new) fd_used(fdp, new); mutex_exit(&fdp->fd_lock); + dt->dt_ff[new]->ff_exclose = (flags & O_CLOEXEC) != 0; + fp->f_flag |= flags & FNONBLOCK; /* Slot is now allocated. Insert copy of the file. */ fd_affix(curproc, fp, new); if (ff != NULL) { diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index f426a8ce9ce..bdce62a2760 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_event.c,v 1.71 2010/09/10 10:23:46 drochner Exp $ */ +/* $NetBSD: kern_event.c,v 1.72 2011/06/26 16:42:42 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.71 2010/09/10 10:23:46 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.72 2011/06/26 16:42:42 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -714,8 +714,8 @@ seltrue_kqfilter(dev_t dev, struct knote *kn) /* * kqueue(2) system call. */ -int -sys_kqueue(struct lwp *l, const void *v, register_t *retval) +static int +kqueue1(struct lwp *l, int flags, register_t *retval) { struct kqueue *kq; file_t *fp; @@ -723,7 +723,7 @@ sys_kqueue(struct lwp *l, const void *v, register_t *retval) if ((error = fd_allocfile(&fp, &fd)) != 0) return error; - fp->f_flag = FREAD | FWRITE; + fp->f_flag = FREAD | FWRITE | (flags & FNONBLOCK); fp->f_type = DTYPE_KQUEUE; fp->f_ops = &kqueueops; kq = kmem_zalloc(sizeof(*kq), KM_SLEEP); @@ -734,11 +734,31 @@ sys_kqueue(struct lwp *l, const void *v, register_t *retval) fp->f_data = kq; *retval = fd; kq->kq_fdp = curlwp->l_fd; + fd_set_exclose(l, fd, (flags & O_CLOEXEC) != 0); fd_affix(curproc, fp, fd); return error; } /* + * kqueue(2) system call. + */ +int +sys_kqueue(struct lwp *l, const void *v, register_t *retval) +{ + return kqueue1(l, 0, retval); +} + +int +sys_kqueue1(struct lwp *l, const struct sys_kqueue1_args *uap, + register_t *retval) +{ + /* { + syscallarg(int) flags; + } */ + return kqueue1(l, SCARG(uap, flags), retval); +} + +/* * kevent(2) system call. */ int diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh index 8c2eb6d889c..0bd6e81e302 100644 --- a/sys/kern/makesyscalls.sh +++ b/sys/kern/makesyscalls.sh @@ -1,5 +1,5 @@ #! /bin/sh - -# $NetBSD: makesyscalls.sh,v 1.118 2011/06/05 14:13:53 njoly Exp $ +# $NetBSD: makesyscalls.sh,v 1.119 2011/06/26 16:42:42 christos Exp $ # # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou # All rights reserved. @@ -283,8 +283,9 @@ NR == 1 { printf "#error Interface not supported inside kernel\n" > rumpcallshdr printf "#endif /* _KERNEL */\n\n" > rumpcallshdr printf "#include <sys/types.h> /* typedefs */\n" > rumpcallshdr - printf "#include <sys/select.h> /* typedefs */\n\n" > rumpcallshdr - printf "#include <signal.h> /* typedefs */\n\n" > rumpcallshdr + printf "#include <sys/select.h> /* typedefs */\n" > rumpcallshdr + printf "#include <sys/sigtypes.h> /* typedefs */\n" > rumpcallshdr + printf "#include <sys/socket.h> /* typedefs */\n\n" > rumpcallshdr printf "#include <rump/rump_syscalls_compat.h>\n\n" > rumpcallshdr printf "%s", sysarghdrextra > sysarghdr diff --git a/sys/kern/sys_descrip.c b/sys/kern/sys_descrip.c index fdce6c8ed93..37948e79c69 100644 --- a/sys/kern/sys_descrip.c +++ b/sys/kern/sys_descrip.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_descrip.c,v 1.21 2011/06/12 03:35:56 rmind Exp $ */ +/* $NetBSD: sys_descrip.c,v 1.22 2011/06/26 16:42:42 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.21 2011/06/12 03:35:56 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.22 2011/06/26 16:42:42 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -122,41 +122,54 @@ sys_dup(struct lwp *l, const struct sys_dup_args *uap, register_t *retval) /* * Duplicate a file descriptor to a particular value. */ -int -sys_dup2(struct lwp *l, const struct sys_dup2_args *uap, register_t *retval) +static int +dodup(struct lwp *l, int from, int to, int flags, register_t *retval) { - /* { - syscallarg(int) from; - syscallarg(int) to; - } */ - int old, new, error; + int error; file_t *fp; - old = SCARG(uap, from); - new = SCARG(uap, to); - - if ((fp = fd_getfile(old)) == NULL) { + if ((fp = fd_getfile(from)) == NULL) return EBADF; - } mutex_enter(&fp->f_lock); fp->f_count++; mutex_exit(&fp->f_lock); - fd_putfile(old); + fd_putfile(from); - if ((u_int)new >= curproc->p_rlimit[RLIMIT_NOFILE].rlim_cur || - (u_int)new >= maxfiles) { + if ((u_int)to >= curproc->p_rlimit[RLIMIT_NOFILE].rlim_cur || + (u_int)to >= maxfiles) error = EBADF; - } else if (old == new) { + else if (from == to) error = 0; - } else { - error = fd_dup2(fp, new); - } + else + error = fd_dup2(fp, to, flags); closef(fp); - *retval = new; + *retval = to; return error; } +int +sys_dup3(struct lwp *l, const struct sys_dup3_args *uap, register_t *retval) +{ + /* { + syscallarg(int) from; + syscallarg(int) to; + syscallarg(int) flags; + } */ + return dodup(l, SCARG(uap, from), SCARG(uap, to), SCARG(uap, flags), + retval); +} + +int +sys_dup2(struct lwp *l, const struct sys_dup2_args *uap, register_t *retval) +{ + /* { + syscallarg(int) from; + syscallarg(int) to; + } */ + return dodup(l, SCARG(uap, from), SCARG(uap, to), 0, retval); +} + /* * fcntl call which is being passed to the file's fs. */ @@ -316,6 +329,7 @@ sys_fcntl(struct lwp *l, const struct sys_fcntl_args *uap, register_t *retval) filedesc_t *fdp; file_t *fp; struct flock fl; + bool cloexec = false; fd = SCARG(uap, fd); cmd = SCARG(uap, cmd); @@ -365,6 +379,9 @@ sys_fcntl(struct lwp *l, const struct sys_fcntl_args *uap, register_t *retval) } switch (cmd) { + case F_DUPFD_CLOEXEC: + cloexec = true; + /*FALLTHROUGH*/ case F_DUPFD: newmin = (long)SCARG(uap, arg); if ((u_int)newmin >= @@ -373,7 +390,7 @@ sys_fcntl(struct lwp *l, const struct sys_fcntl_args *uap, register_t *retval) fd_putfile(fd); return EINVAL; } - error = fd_dup(fp, newmin, &i, false); + error = fd_dup(fp, newmin, &i, cloexec); *retval = i; break; @@ -722,3 +739,25 @@ sys___posix_fadvise50(struct lwp *l, return 0; } + +int +sys_pipe(struct lwp *l, const void *v, register_t *retval) +{ + return pipe1(l, retval, 0); +} + +int +sys_pipe2(struct lwp *l, const struct sys_pipe2_args *uap, register_t *retval) +{ + /* { + syscallarg(int[2]) fildes; + syscallarg(int) flags; + } */ + int fd[2], error; + + if ((error = pipe1(l, retval, SCARG(uap, flags))) != 0) + return error; + fd[0] = retval[0]; + fd[1] = retval[1]; + return copyout(fd, SCARG(uap, fildes), sizeof(fd)); +} diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 0a902f917fb..f798f1418d6 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_pipe.c,v 1.130 2011/04/10 15:45:33 christos Exp $ */ +/* $NetBSD: sys_pipe.c,v 1.131 2011/06/26 16:42:42 christos Exp $ */ /*- * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.130 2011/04/10 15:45:33 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.131 2011/06/26 16:42:42 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -295,12 +295,6 @@ free2: return (error); } -int -sys_pipe(struct lwp *l, const void *v, register_t *retval) -{ - return pipe1(l, retval, 0); -} - /* * Allocate kva for pipe circular buffer, the space is pageable * This routine will 'realloc' the size of a pipe safely, if it fails diff --git a/sys/kern/syscalls.conf b/sys/kern/syscalls.conf index a63a9b5f2ee..61598b3c235 100644 --- a/sys/kern/syscalls.conf +++ b/sys/kern/syscalls.conf @@ -1,10 +1,10 @@ -# $NetBSD: syscalls.conf,v 1.16 2011/01/18 17:33:05 pooka Exp $ +# $NetBSD: syscalls.conf,v 1.17 2011/06/26 16:42:42 christos Exp $ sysnames="syscalls.c" sysnumhdr="../sys/syscall.h" syssw="init_sysent.c" sysarghdr="../sys/syscallargs.h" -sysarghdrextra='#include <sys/mount.h>\n#include <sys/sched.h>\n\n' +sysarghdrextra='#include <sys/mount.h>\n#include <sys/sched.h>\n#include <sys/socket.h>\n\n' sysalign=1 rumpcalls="../rump/librump/rumpkern/rump_syscalls.c" rumpcallshdr="../rump/include/rump/rump_syscalls.h" diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 11a9b426888..fc7aebf176b 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.203 2011/02/01 01:39:20 matt Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.204 2011/06/26 16:42:42 christos Exp $ */ /*- * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.203 2011/02/01 01:39:20 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.204 2011/06/26 16:42:42 christos Exp $"); #include "opt_compat_netbsd.h" #include "opt_sock_counters.h" @@ -598,10 +598,13 @@ fsocreate(int domain, struct socket **sop, int type, int protocol, struct socket *so; struct file *fp; int fd, error; + int flags = type & SOCK_FLAGS_MASK; + type &= ~SOCK_FLAGS_MASK; if ((error = fd_allocfile(&fp, &fd)) != 0) - return (error); - fp->f_flag = FREAD|FWRITE; + return error; + fd_set_exclose(l, fd, (flags & SOCK_CLOEXEC) != 0); + fp->f_flag = FREAD|FWRITE|((flags & SOCK_NONBLOCK) ? FNONBLOCK : 0); fp->f_type = DTYPE_SOCKET; fp->f_ops = &socketops; error = socreate(domain, &so, type, protocol, l, NULL); @@ -1379,7 +1382,9 @@ soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, type == SCM_RIGHTS) { sounlock(so); splx(s); - error = (*dom->dom_externalize)(cm, l); + error = (*dom->dom_externalize)(cm, l, + (flags & MSG_CMSG_CLOEXEC) ? + O_CLOEXEC : 0); s = splsoftnet(); solock(so); } diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 6de306c38f9..a835899c475 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_syscalls.c,v 1.143 2011/04/24 18:46:23 rmind Exp $ */ +/* $NetBSD: uipc_syscalls.c,v 1.144 2011/06/26 16:42:42 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.143 2011/04/24 18:46:23 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.144 2011/06/26 16:42:42 christos Exp $"); #include "opt_pipe.h" @@ -164,7 +164,8 @@ sys_listen(struct lwp *l, const struct sys_listen_args *uap, register_t *retval) } int -do_sys_accept(struct lwp *l, int sock, struct mbuf **name, register_t *new_sock) +do_sys_accept(struct lwp *l, int sock, struct mbuf **name, register_t *new_sock, + const sigset_t *mask, int flags, int clrflags) { file_t *fp, *fp2; struct mbuf *nam; @@ -186,6 +187,10 @@ do_sys_accept(struct lwp *l, int sock, struct mbuf **name, register_t *new_sock) *new_sock = fd; so = fp->f_data; solock(so); + + if (__predict_false(mask)) + sigsuspendsetup(l, mask); + if (!(so->so_proto->pr_flags & PR_LISTEN)) { error = EOPNOTSUPP; goto bad; @@ -224,7 +229,8 @@ do_sys_accept(struct lwp *l, int sock, struct mbuf **name, register_t *new_sock) if (soqremque(so2, 1) == 0) panic("accept"); fp2->f_type = DTYPE_SOCKET; - fp2->f_flag = fp->f_flag; + fp2->f_flag = (fp->f_flag & ~clrflags) | + ((flags & SOCK_NONBLOCK) ? FNONBLOCK : 0); fp2->f_ops = &socketops; fp2->f_data = so2; error = soaccept(so2, nam); @@ -239,16 +245,21 @@ do_sys_accept(struct lwp *l, int sock, struct mbuf **name, register_t *new_sock) closef(fp2); fd_abort(curproc, NULL, fd); } else { + fd_set_exclose(l, fd, (flags & SOCK_CLOEXEC) != 0); fd_affix(curproc, fp2, fd); *name = nam; } fd_putfile(sock); + if (__predict_false(mask)) + sigsuspendteardown(l); return (error); bad: sounlock(so); m_freem(nam); fd_putfile(sock); fd_abort(curproc, fp2, fd); + if (__predict_false(mask)) + sigsuspendteardown(l); return (error); } @@ -263,7 +274,46 @@ sys_accept(struct lwp *l, const struct sys_accept_args *uap, register_t *retval) int error, fd; struct mbuf *name; - error = do_sys_accept(l, SCARG(uap, s), &name, retval); + error = do_sys_accept(l, SCARG(uap, s), &name, retval, NULL, 0, 0); + if (error != 0) + return error; + error = copyout_sockname(SCARG(uap, name), SCARG(uap, anamelen), + MSG_LENUSRSPACE, name); + if (name != NULL) + m_free(name); + if (error != 0) { + fd = (int)*retval; + if (fd_getfile(fd) != NULL) + (void)fd_close(fd); + } + return error; +} + +int +sys_paccept(struct lwp *l, const struct sys_paccept_args *uap, + register_t *retval) +{ + /* { + syscallarg(int) s; + syscallarg(struct sockaddr *) name; + syscallarg(unsigned int *) anamelen; + syscallarg(const sigset_t *) mask; + syscallarg(int) flags; + } */ + int error, fd; + struct mbuf *name; + sigset_t *mask, amask; + + if (SCARG(uap, mask) != NULL) { + error = copyin(SCARG(uap, mask), &amask, sizeof(amask)); + if (error) + return error; + mask = &amask; + } else + mask = NULL; + + error = do_sys_accept(l, SCARG(uap, s), &name, retval, mask, + SCARG(uap, flags), FNONBLOCK); if (error != 0) return error; error = copyout_sockname(SCARG(uap, name), SCARG(uap, anamelen), @@ -364,26 +414,31 @@ sys_socketpair(struct lwp *l, const struct sys_socketpair_args *uap, register_t struct socket *so1, *so2; int fd, error, sv[2]; proc_t *p; + int flags = SCARG(uap, type) & SOCK_FLAGS_MASK; + int type = SCARG(uap, type) & ~SOCK_FLAGS_MASK; + int fnonblock = (flags & SOCK_NONBLOCK) ? FNONBLOCK : 0; p = curproc; - error = socreate(SCARG(uap, domain), &so1, SCARG(uap, type), + error = socreate(SCARG(uap, domain), &so1, type, SCARG(uap, protocol), l, NULL); if (error) return (error); - error = socreate(SCARG(uap, domain), &so2, SCARG(uap, type), + error = socreate(SCARG(uap, domain), &so2, type, SCARG(uap, protocol), l, so1); if (error) goto free1; if ((error = fd_allocfile(&fp1, &fd)) != 0) goto free2; + fd_set_exclose(l, fd, (flags & SOCK_CLOEXEC) != 0); sv[0] = fd; - fp1->f_flag = FREAD|FWRITE; + fp1->f_flag = FREAD|FWRITE|fnonblock; fp1->f_type = DTYPE_SOCKET; fp1->f_ops = &socketops; fp1->f_data = so1; if ((error = fd_allocfile(&fp2, &fd)) != 0) goto free3; - fp2->f_flag = FREAD|FWRITE; + fd_set_exclose(l, fd, (flags & SOCK_CLOEXEC) != 0); + fp2->f_flag = FREAD|FWRITE|fnonblock; fp2->f_type = DTYPE_SOCKET; fp2->f_ops = &socketops; fp2->f_data = so2; @@ -1006,12 +1061,6 @@ pipe1(struct lwp *l, register_t *retval, int flags) (void)soclose(rso); return (error); } - -int -sys_pipe(struct lwp *l, const void *v, register_t *retval) -{ - return pipe1(l, retval, 0); -} #endif /* PIPE_SOCKETPAIR */ /* diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 7b798d257ab..79aaf2ddd12 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_usrreq.c,v 1.135 2011/06/12 03:35:56 rmind Exp $ */ +/* $NetBSD: uipc_usrreq.c,v 1.136 2011/06/26 16:42:43 christos Exp $ */ /*- * Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.135 2011/06/12 03:35:56 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.136 2011/06/26 16:42:43 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1233,7 +1233,7 @@ unp_drain(void) #endif int -unp_externalize(struct mbuf *rights, struct lwp *l) +unp_externalize(struct mbuf *rights, struct lwp *l, int flags) { struct cmsghdr *cm = mtod(rights, struct cmsghdr *); struct proc *p = l->l_proc; @@ -1316,9 +1316,11 @@ unp_externalize(struct mbuf *rights, struct lwp *l) */ rp = (file_t **)CMSG_DATA(cm); for (i = 0; i < nfds; i++) { + int fd = fdp[i]; fp = *rp++; atomic_dec_uint(&unp_rights); - fd_affix(p, fp, fdp[i]); + fd_set_exclose(l, fd, (flags & O_CLOEXEC) != 0); + fd_affix(p, fp, fd); mutex_enter(&fp->f_lock); fp->f_msgcount--; mutex_exit(&fp->f_lock); diff --git a/sys/sys/domain.h b/sys/sys/domain.h index 8313b4861e0..f979afc4bea 100644 --- a/sys/sys/domain.h +++ b/sys/sys/domain.h @@ -1,4 +1,4 @@ -/* $NetBSD: domain.h,v 1.30 2011/03/31 19:40:54 dyoung Exp $ */ +/* $NetBSD: domain.h,v 1.31 2011/06/26 16:43:12 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -58,7 +58,7 @@ struct domain { void (*dom_init) /* initialize domain data structures */ (void); int (*dom_externalize) /* externalize access rights */ - (struct mbuf *, struct lwp *); + (struct mbuf *, struct lwp *, int); void (*dom_dispose) /* dispose of internalized rights */ (struct mbuf *); const struct protosw *dom_protosw, *dom_protoswNPROTOSW; diff --git a/sys/sys/event.h b/sys/sys/event.h index 4e8a9b12778..6909fabdb54 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -1,4 +1,4 @@ -/* $NetBSD: event.h,v 1.22 2011/04/24 18:46:24 rmind Exp $ */ +/* $NetBSD: event.h,v 1.23 2011/06/26 16:43:12 christos Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> @@ -246,6 +246,7 @@ struct timespec; __BEGIN_DECLS #if defined(_NETBSD_SOURCE) int kqueue(void); +int kqueue1(int); #ifndef __LIBC12_SOURCE__ int kevent(int, const struct kevent *, size_t, struct kevent *, size_t, const struct timespec *) __RENAME(__kevent50); diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index b3e7fdea31f..a2df62538a2 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -1,4 +1,4 @@ -/* $NetBSD: fcntl.h,v 1.37 2011/04/10 15:45:33 christos Exp $ */ +/* $NetBSD: fcntl.h,v 1.38 2011/06/26 16:43:12 christos Exp $ */ /*- * Copyright (c) 1983, 1990, 1993 @@ -180,6 +180,7 @@ #if defined(_NETBSD_SOURCE) #define F_CLOSEM 10 /* close all fds >= to the one given */ #define F_MAXFD 11 /* return the max open fd */ +#define F_DUPFD_CLOEXEC 12 /* close on exec duplicated fd */ #endif /* file descriptor flags (F_GETFD, F_SETFD) */ diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 91d8964171d..773b4401bf0 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -1,4 +1,4 @@ -/* $NetBSD: filedesc.h,v 1.60 2011/06/01 21:25:02 alnsn Exp $ */ +/* $NetBSD: filedesc.h,v 1.61 2011/06/26 16:43:12 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -204,7 +204,7 @@ void fd_putvnode(unsigned); void fd_putsock(unsigned); int fd_close(unsigned); int fd_dup(file_t *, int, int *, bool); -int fd_dup2(file_t *, unsigned); +int fd_dup2(file_t *, unsigned, int); int fd_clone(file_t *, unsigned, int, const struct fileops *, void *); void fd_set_exclose(struct lwp *, int, bool); int pipe1(struct lwp *, register_t *, int); diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 26de37e0218..dbfb007a65b 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -1,4 +1,4 @@ -/* $NetBSD: socket.h,v 1.99 2011/02/01 01:39:21 matt Exp $ */ +/* $NetBSD: socket.h,v 1.100 2011/06/26 16:43:12 christos Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -97,6 +97,7 @@ typedef _BSD_SSIZE_T_ ssize_t; #endif #include <sys/uio.h> +#include <sys/sigtypes.h> /* * Socket types. @@ -107,6 +108,10 @@ typedef _BSD_SSIZE_T_ ssize_t; #define SOCK_RDM 4 /* reliably-delivered message */ #define SOCK_SEQPACKET 5 /* sequenced packet stream */ +#define SOCK_CLOEXEC 0x10000000 /* set close on exec on socket */ +#define SOCK_NONBLOCK 0x20000000 /* set non blocking i/o socket */ +#define SOCK_FLAGS_MASK 0xf0000000 /* flags mask */ + /* * Option flags per-socket. */ @@ -485,6 +490,9 @@ struct msghdr { #define MSG_BCAST 0x0100 /* this message was rcvd using link-level brdcst */ #define MSG_MCAST 0x0200 /* this message was rcvd using link-level mcast */ #define MSG_NOSIGNAL 0x0400 /* do not generate SIGPIPE on EOF */ +#if defined(_NETBSD_SOURCE) +#define MSG_CMSG_CLOEXEC 0x0800 /* close on exec receiving fd */ +#endif /* Extra flags used internally only */ #define MSG_USERFLAGS 0x0ffffff @@ -603,6 +611,8 @@ int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict); int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict); int getsockopt(int, int, int, void *__restrict, socklen_t * __restrict); int listen(int, int); +int paccept(int, struct sockaddr * __restrict, socklen_t * __restrict, + const sigset_t * __restrict, int); ssize_t recv(int, void *, size_t, int); ssize_t recvfrom(int, void *__restrict, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict); diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 040aae1d057..a0774369a45 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: socketvar.h,v 1.124 2009/12/29 04:23:43 elad Exp $ */ +/* $NetBSD: socketvar.h,v 1.125 2011/06/26 16:43:12 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -350,7 +350,8 @@ int do_sys_recvmsg(struct lwp *, int, struct msghdr *, struct mbuf **, int do_sys_bind(struct lwp *, int, struct mbuf *); int do_sys_connect(struct lwp *, int, struct mbuf *); -int do_sys_accept(struct lwp *, int, struct mbuf **, register_t *); +int do_sys_accept(struct lwp *, int, struct mbuf **, register_t *, + const sigset_t *, int, int); /* * Inline functions for sockets and socket buffering. diff --git a/sys/sys/un.h b/sys/sys/un.h index 0dae3eabeed..0a4aee56eaf 100644 --- a/sys/sys/un.h +++ b/sys/sys/un.h @@ -1,4 +1,4 @@ -/* $NetBSD: un.h,v 1.45 2009/03/11 06:05:30 mrg Exp $ */ +/* $NetBSD: un.h,v 1.46 2011/06/26 16:43:12 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -92,7 +92,7 @@ void unp_discard (struct file *); void unp_disconnect (struct unpcb *); bool unp_drop (struct unpcb *, int); void unp_shutdown (struct unpcb *); -int unp_externalize (struct mbuf *, struct lwp *); +int unp_externalize (struct mbuf *, struct lwp *, int); int unp_internalize (struct mbuf **); void unp_dispose (struct mbuf *); int unp_output (struct mbuf *, struct mbuf *, struct unpcb *, |
