Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Mar 2013 01:00:27 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r247606 - in head/tools/regression/capsicum: . syscalls
Message-ID:  <201303020100.r2210RLG064831@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Sat Mar  2 01:00:26 2013
New Revision: 247606
URL: http://svnweb.freebsd.org/changeset/base/247606

Log:
  Add regression tests for the new Capsicum system calls.
  
  Sponsored by:	The FreeBSD Foundation

Added:
  head/tools/regression/capsicum/
  head/tools/regression/capsicum/syscalls/
  head/tools/regression/capsicum/syscalls/Makefile   (contents, props changed)
  head/tools/regression/capsicum/syscalls/cap_fcntls_limit.c   (contents, props changed)
  head/tools/regression/capsicum/syscalls/cap_getmode.c   (contents, props changed)
  head/tools/regression/capsicum/syscalls/cap_ioctls_limit.c   (contents, props changed)
  head/tools/regression/capsicum/syscalls/misc.c   (contents, props changed)
  head/tools/regression/capsicum/syscalls/misc.h   (contents, props changed)

Added: head/tools/regression/capsicum/syscalls/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/capsicum/syscalls/Makefile	Sat Mar  2 01:00:26 2013	(r247606)
@@ -0,0 +1,28 @@
+# $FreeBSD$
+
+SYSCALLS=	cap_fcntls_limit cap_getmode cap_ioctls_limit
+
+CFLAGS=		-O2 -pipe -std=gnu99 -fstack-protector
+CFLAGS+=	-Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter
+CFLAGS+=	-Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type
+CFLAGS+=	-Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter
+CFLAGS+=	-Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
+CFLAGS+=	-Wold-style-definition -Wno-pointer-sign
+
+all:	${SYSCALLS} ${SYSCALLS:=.t}
+
+.for SYSCALL in ${SYSCALLS}
+
+${SYSCALL}:	${SYSCALL}.c misc.c
+	${CC} ${CFLAGS} ${@}.c misc.c -o $@
+
+${SYSCALL}.t:	${SYSCALL}
+	@printf "#!/bin/sh\n\n%s/%s\n" ${.CURDIR} ${@:.t=} > $@
+
+.endfor
+
+test:	all
+	@prove -r ${.CURDIR}
+
+clean:
+	rm -f ${SYSCALLS} ${SYSCALLS:=.t}

Added: head/tools/regression/capsicum/syscalls/cap_fcntls_limit.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/capsicum/syscalls/cap_fcntls_limit.c	Sat Mar  2 01:00:26 2013	(r247606)
@@ -0,0 +1,540 @@
+/*-
+ * Copyright (c) 2012 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/capability.h>
+#include <sys/procdesc.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "misc.h"
+
+static void
+fcntl_tests_0(int fd)
+{
+	uint32_t fcntlrights;
+
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == CAP_FCNTL_ALL);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == 0);
+	CHECK(fcntl(fd, F_GETFL) == (O_RDWR | O_NONBLOCK));
+	CHECK(fcntl(fd, F_SETFL, 0) == 0);
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, ~CAP_FCNTL_ALL) == -1);
+	CHECK(errno == EINVAL);
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == 0);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == (CAP_FCNTL_GETFL | CAP_FCNTL_SETFL));
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == 0);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == (CAP_FCNTL_GETFL | CAP_FCNTL_SETFL));
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == 0);
+	CHECK(fcntl(fd, F_GETFL) == (O_RDWR | O_NONBLOCK));
+	CHECK(fcntl(fd, F_SETFL, 0) == 0);
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL) == 0);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == CAP_FCNTL_GETFL);
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == CAP_FCNTL_GETFL);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, 0) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+
+	CHECK(cap_fcntls_limit(fd, 0) == 0);
+	fcntlrights = CAP_FCNTL_ALL;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = CAP_FCNTL_ALL;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = CAP_FCNTL_ALL;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	errno = 0;
+	CHECK(fcntl(fd, F_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, 0) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+}
+
+static void
+fcntl_tests_1(int fd)
+{
+	uint32_t fcntlrights;
+
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL) == 0);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == CAP_FCNTL_GETFL);
+
+	CHECK(cap_rights_limit(fd, CAP_ALL & ~CAP_FCNTL) == 0);
+
+	fcntlrights = CAP_FCNTL_ALL;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = CAP_FCNTL_ALL;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = CAP_FCNTL_ALL;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	errno = 0;
+	CHECK(fcntl(fd, F_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, 0) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+}
+
+static void
+fcntl_tests_2(int fd)
+{
+	uint32_t fcntlrights;
+
+	CHECK(cap_rights_limit(fd, CAP_ALL & ~CAP_FCNTL) == 0);
+
+	fcntlrights = CAP_FCNTL_ALL;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = CAP_FCNTL_ALL;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = CAP_FCNTL_ALL;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	errno = 0;
+	CHECK(fcntl(fd, F_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, 0) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+}
+
+static void
+fcntl_tests_send_0(int sock)
+{
+	int fd;
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK(descriptor_send(sock, fd) == 0);
+	CHECK(close(fd) == 0);
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == 0);
+	CHECK(descriptor_send(sock, fd) == 0);
+	CHECK(close(fd) == 0);
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL) == 0);
+	CHECK(descriptor_send(sock, fd) == 0);
+	CHECK(close(fd) == 0);
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK(cap_fcntls_limit(fd, 0) == 0);
+	CHECK(descriptor_send(sock, fd) == 0);
+	CHECK(close(fd) == 0);
+}
+
+static void
+fcntl_tests_recv_0(int sock)
+{
+	uint32_t fcntlrights;
+	int fd;
+
+	CHECK(descriptor_recv(sock, &fd) == 0);
+
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == CAP_FCNTL_ALL);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == 0);
+	CHECK(fcntl(fd, F_GETFL) == (O_RDWR | O_NONBLOCK));
+	CHECK(fcntl(fd, F_SETFL, 0) == 0);
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+
+	CHECK(close(fd) == 0);
+
+	CHECK(descriptor_recv(sock, &fd) == 0);
+
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == (CAP_FCNTL_GETFL | CAP_FCNTL_SETFL));
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == 0);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == (CAP_FCNTL_GETFL | CAP_FCNTL_SETFL));
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == 0);
+	CHECK(fcntl(fd, F_GETFL) == (O_RDWR | O_NONBLOCK));
+	CHECK(fcntl(fd, F_SETFL, 0) == 0);
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+
+	CHECK(close(fd) == 0);
+
+	CHECK(descriptor_recv(sock, &fd) == 0);
+
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == CAP_FCNTL_GETFL);
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == CAP_FCNTL_GETFL);
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL) == 0);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == CAP_FCNTL_GETFL);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, 0) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFL) == O_RDWR);
+
+	CHECK(close(fd) == 0);
+
+	CHECK(descriptor_recv(sock, &fd) == 0);
+
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL | CAP_FCNTL_SETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+	errno = 0;
+	CHECK(cap_fcntls_limit(fd, CAP_FCNTL_SETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	fcntlrights = 0;
+	CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
+	CHECK(fcntlrights == 0);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	errno = 0;
+	CHECK(fcntl(fd, F_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, O_NONBLOCK) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_SETFL, 0) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	errno = 0;
+	CHECK(fcntl(fd, F_GETFL) == -1);
+	CHECK(errno == ENOTCAPABLE);
+
+	CHECK(close(fd) == 0);
+}
+
+int
+main(void)
+{
+	int fd, pfd, sp[2];
+	pid_t pid;
+
+	printf("1..870\n");
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	fcntl_tests_0(fd);
+	CHECK(close(fd) == 0);
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	fcntl_tests_1(fd);
+	CHECK(close(fd) == 0);
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	fcntl_tests_2(fd);
+	CHECK(close(fd) == 0);
+
+	/* Child inherits descriptor and operates on it first. */
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK((pid = fork()) >= 0);
+	if (pid == 0) {
+		fcntl_tests_0(fd);
+		CHECK(close(fd) == 0);
+		exit(0);
+	} else {
+		CHECK(waitpid(pid, NULL, 0) == pid);
+		fcntl_tests_0(fd);
+	}
+	CHECK(close(fd) == 0);
+
+	/* Child inherits descriptor, but operates on it after parent. */
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK((pid = fork()) >= 0);
+	if (pid == 0) {
+		sleep(1);
+		fcntl_tests_0(fd);
+		CHECK(close(fd) == 0);
+		exit(0);
+	} else {
+		fcntl_tests_0(fd);
+		CHECK(waitpid(pid, NULL, 0) == pid);
+	}
+	CHECK(close(fd) == 0);
+
+	/* Child inherits descriptor and operates on it first. */
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK((pid = pdfork(&pfd, 0)) >= 0);
+	if (pid == 0) {
+		fcntl_tests_1(fd);
+		exit(0);
+	} else {
+		CHECK(pdwait(pfd) == 0);
+/*
+		It fails with EBADF, which I believe is a bug.
+		CHECK(close(pfd) == 0);
+*/
+		fcntl_tests_1(fd);
+	}
+	CHECK(close(fd) == 0);
+
+	/* Child inherits descriptor, but operates on it after parent. */
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK((pid = pdfork(&pfd, 0)) >= 0);
+	if (pid == 0) {
+		sleep(1);
+		fcntl_tests_1(fd);
+		exit(0);
+	} else {
+		fcntl_tests_1(fd);
+		CHECK(pdwait(pfd) == 0);
+/*
+		It fails with EBADF, which I believe is a bug.
+		CHECK(close(pfd) == 0);
+*/
+	}
+	CHECK(close(fd) == 0);
+
+	/* Child inherits descriptor and operates on it first. */
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK((pid = fork()) >= 0);
+	if (pid == 0) {
+		fcntl_tests_2(fd);
+		exit(0);
+	} else {
+		CHECK(waitpid(pid, NULL, 0) == pid);
+		fcntl_tests_2(fd);
+	}
+	CHECK(close(fd) == 0);
+
+	/* Child inherits descriptor, but operates on it after parent. */
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK((pid = fork()) >= 0);
+	if (pid == 0) {
+		sleep(1);
+		fcntl_tests_2(fd);
+		exit(0);
+	} else {
+		fcntl_tests_2(fd);
+		CHECK(waitpid(pid, NULL, 0) == pid);
+	}
+	CHECK(close(fd) == 0);
+
+	/* Send descriptors from parent to child. */
+	CHECK(socketpair(AF_UNIX, SOCK_STREAM, 0, sp) == 0);
+	CHECK((pid = fork()) >= 0);
+	if (pid == 0) {
+		CHECK(close(sp[0]) == 0);
+		fcntl_tests_recv_0(sp[1]);
+		CHECK(close(sp[1]) == 0);
+		exit(0);
+	} else {
+		CHECK(close(sp[1]) == 0);
+		fcntl_tests_send_0(sp[0]);
+		CHECK(waitpid(pid, NULL, 0) == pid);
+		CHECK(close(sp[0]) == 0);
+	}
+
+	/* Send descriptors from child to parent. */
+	CHECK(socketpair(AF_UNIX, SOCK_STREAM, 0, sp) == 0);
+	CHECK((pid = fork()) >= 0);
+	if (pid == 0) {
+		CHECK(close(sp[0]) == 0);
+		fcntl_tests_send_0(sp[1]);
+		CHECK(close(sp[1]) == 0);
+		exit(0);
+	} else {
+		CHECK(close(sp[1]) == 0);
+		fcntl_tests_recv_0(sp[0]);
+		CHECK(waitpid(pid, NULL, 0) == pid);
+		CHECK(close(sp[0]) == 0);
+	}
+
+	exit(0);
+}

Added: head/tools/regression/capsicum/syscalls/cap_getmode.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/capsicum/syscalls/cap_getmode.c	Sat Mar  2 01:00:26 2013	(r247606)
@@ -0,0 +1,167 @@
+/*-
+ * Copyright (c) 2012 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/capability.h>
+#include <sys/procdesc.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "misc.h"
+
+int
+main(void)
+{
+	unsigned int mode;
+	pid_t pid;
+	int pfd;
+
+	printf("1..27\n");
+
+	mode = 666;
+	CHECK(cap_getmode(&mode) == 0);
+	/* If cap_getmode() succeeded mode should be modified. */
+	CHECK(mode != 666);
+	/* We are not in capability mode. */
+	CHECK(mode == 0);
+
+	/* Expect EFAULT. */
+	errno = 0;
+	CHECK(cap_getmode(NULL) == -1);
+	CHECK(errno == EFAULT);
+	errno = 0;
+	CHECK(cap_getmode((void *)(uintptr_t)0xdeadc0de) == -1);
+	CHECK(errno == EFAULT);
+
+	/* If parent is not in capability mode, child after fork() also won't be. */
+	pid = fork();
+	switch (pid) {
+	case -1:
+		err(1, "fork() failed");
+	case 0:
+		mode = 666;
+		CHECK(cap_getmode(&mode) == 0);
+		/* If cap_getmode() succeeded mode should be modified. */
+		CHECK(mode != 666);
+		/* We are not in capability mode. */
+		CHECK(mode == 0);
+		exit(0);
+	default:
+		if (waitpid(pid, NULL, 0) == -1)
+			err(1, "waitpid() failed");
+	}
+
+	/* If parent is not in capability mode, child after pdfork() also won't be. */
+	pid = pdfork(&pfd, 0);
+	switch (pid) {
+	case -1:
+		err(1, "pdfork() failed");
+	case 0:
+		mode = 666;
+		CHECK(cap_getmode(&mode) == 0);
+		/* If cap_getmode() succeeded mode should be modified. */
+		CHECK(mode != 666);
+		/* We are not in capability mode. */
+		CHECK(mode == 0);
+		exit(0);
+	default:
+		if (pdwait(pfd) == -1)
+			err(1, "pdwait() failed");
+		close(pfd);
+	}
+
+	/* In capability mode... */
+
+	CHECK(cap_enter() == 0);
+
+	mode = 666;
+	CHECK(cap_getmode(&mode) == 0);
+	/* If cap_getmode() succeeded mode should be modified. */
+	CHECK(mode != 666);
+	/* We are in capability mode. */
+	CHECK(mode == 1);
+
+	/* Expect EFAULT. */
+	errno = 0;
+	CHECK(cap_getmode(NULL) == -1);
+	CHECK(errno == EFAULT);
+	errno = 0;
+	CHECK(cap_getmode((void *)(uintptr_t)0xdeadc0de) == -1);
+	CHECK(errno == EFAULT);
+
+	/* If parent is in capability mode, child after fork() also will be. */
+	pid = fork();
+	switch (pid) {
+	case -1:
+		err(1, "fork() failed");
+	case 0:
+		mode = 666;
+		CHECK(cap_getmode(&mode) == 0);
+		/* If cap_getmode() succeeded mode should be modified. */
+		CHECK(mode != 666);
+		/* We are in capability mode. */
+		CHECK(mode == 1);
+		exit(0);
+	default:
+		/*
+		 * wait(2) and friends are not permitted in the capability mode,
+		 * so we can only just wait for a while.
+		 */
+		sleep(1);
+	}
+
+	/* If parent is in capability mode, child after pdfork() also will be. */
+	pid = pdfork(&pfd, 0);
+	switch (pid) {
+	case -1:
+		err(1, "pdfork() failed");
+	case 0:
+		mode = 666;
+		CHECK(cap_getmode(&mode) == 0);
+		/* If cap_getmode() succeeded mode should be modified. */
+		CHECK(mode != 666);
+		/* We are in capability mode. */
+		CHECK(mode == 1);
+		exit(0);
+	default:
+		if (pdwait(pfd) == -1)
+			err(1, "pdwait() failed");
+		close(pfd);
+	}
+
+	exit(0);
+}

Added: head/tools/regression/capsicum/syscalls/cap_ioctls_limit.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/capsicum/syscalls/cap_ioctls_limit.c	Sat Mar  2 01:00:26 2013	(r247606)
@@ -0,0 +1,462 @@
+/*-
+ * Copyright (c) 2012 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/capability.h>
+#include <sys/ioctl.h>
+#include <sys/procdesc.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "misc.h"
+
+static void
+ioctl_tests_0(int fd)
+{
+	unsigned long cmds[2];
+
+	CHECK(cap_ioctls_get(fd, NULL, 0) == INT_MAX);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(ioctl(fd, FIOCLEX) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(ioctl(fd, FIONCLEX) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	cmds[0] = FIOCLEX;
+	cmds[1] = FIONCLEX;
+	CHECK(cap_ioctls_limit(fd, cmds, nitems(cmds)) == 0);
+	cmds[0] = cmds[1] = 0;
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == nitems(cmds));
+	CHECK((cmds[0] == FIOCLEX && cmds[1] == FIONCLEX) ||
+	    (cmds[0] == FIONCLEX && cmds[1] == FIOCLEX));
+	cmds[0] = FIOCLEX;
+	cmds[1] = FIONCLEX;
+	CHECK(cap_ioctls_limit(fd, cmds, nitems(cmds)) == 0);
+	cmds[0] = cmds[1] = 0;
+	CHECK(cap_ioctls_get(fd, cmds, 1) == nitems(cmds));
+	CHECK(cmds[0] == FIOCLEX || cmds[0] == FIONCLEX);
+	CHECK(cmds[1] == 0);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(ioctl(fd, FIOCLEX) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(ioctl(fd, FIONCLEX) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	cmds[0] = FIOCLEX;
+	CHECK(cap_ioctls_limit(fd, cmds, 1) == 0);
+	cmds[0] = cmds[1] = 0;
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 1);
+	CHECK(cmds[0] == FIOCLEX);
+	cmds[0] = FIOCLEX;
+	cmds[1] = FIONCLEX;
+	errno = 0;
+	CHECK(cap_ioctls_limit(fd, cmds, nitems(cmds)) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	cmds[0] = cmds[1] = 0;
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 1);
+	CHECK(cmds[0] == FIOCLEX);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(ioctl(fd, FIOCLEX) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	errno = 0;
+	CHECK(ioctl(fd, FIONCLEX) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	CHECK(cap_ioctls_limit(fd, NULL, 0) == 0);
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
+	cmds[0] = FIOCLEX;
+	errno = 0;
+	CHECK(cap_ioctls_limit(fd, cmds, 1) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	errno = 0;
+	CHECK(ioctl(fd, FIOCLEX) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	errno = 0;
+	CHECK(ioctl(fd, FIONCLEX) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+}
+
+static void
+ioctl_tests_1(int fd)
+{
+	unsigned long cmds[2];
+
+	cmds[0] = FIOCLEX;
+	CHECK(cap_ioctls_limit(fd, cmds, 1) == 0);
+	cmds[0] = cmds[1] = 0;
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 1);
+	CHECK(cmds[0] == FIOCLEX);
+	CHECK(cmds[1] == 0);
+
+	CHECK(cap_rights_limit(fd, CAP_ALL & ~CAP_IOCTL) == 0);
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
+
+	cmds[0] = FIOCLEX;
+	cmds[1] = FIONCLEX;
+	errno = 0;
+	CHECK(cap_ioctls_limit(fd, cmds, nitems(cmds)) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
+	cmds[0] = FIOCLEX;
+	errno = 0;
+	CHECK(cap_ioctls_limit(fd, cmds, 1) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	errno = 0;
+	CHECK(ioctl(fd, FIOCLEX) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	errno = 0;
+	CHECK(ioctl(fd, FIONCLEX) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+}
+
+static void
+ioctl_tests_2(int fd)
+{
+	unsigned long cmds[2];
+
+	CHECK(cap_rights_limit(fd, CAP_ALL & ~CAP_IOCTL) == 0);
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
+
+	cmds[0] = FIOCLEX;
+	cmds[1] = FIONCLEX;
+	errno = 0;
+	CHECK(cap_ioctls_limit(fd, cmds, nitems(cmds)) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
+	cmds[0] = FIOCLEX;
+	errno = 0;
+	CHECK(cap_ioctls_limit(fd, cmds, 1) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	errno = 0;
+	CHECK(ioctl(fd, FIOCLEX) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(fcntl(fd, F_SETFD, FD_CLOEXEC) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	errno = 0;
+	CHECK(ioctl(fd, FIONCLEX) == -1);
+	CHECK(errno == ENOTCAPABLE);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(fcntl(fd, F_SETFD, 0) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+}
+
+static void
+ioctl_tests_send_0(int sock)
+{
+	unsigned long cmds[2];
+	int fd;
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK(descriptor_send(sock, fd) == 0);
+	CHECK(close(fd) == 0);
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	cmds[0] = FIOCLEX;
+	cmds[1] = FIONCLEX;
+	CHECK(cap_ioctls_limit(fd, cmds, nitems(cmds)) == 0);
+	CHECK(descriptor_send(sock, fd) == 0);
+	CHECK(close(fd) == 0);
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	cmds[0] = FIOCLEX;
+	CHECK(cap_ioctls_limit(fd, cmds, 1) == 0);
+	CHECK(descriptor_send(sock, fd) == 0);
+	CHECK(close(fd) == 0);
+
+	CHECK((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
+	CHECK(cap_ioctls_limit(fd, NULL, 0) == 0);
+	CHECK(descriptor_send(sock, fd) == 0);
+	CHECK(close(fd) == 0);
+}
+
+static void
+ioctl_tests_recv_0(int sock)
+{
+	unsigned long cmds[2];
+	int fd;
+
+	CHECK(descriptor_recv(sock, &fd) == 0);
+
+	CHECK(cap_ioctls_get(fd, NULL, 0) == INT_MAX);
+
+	CHECK(fcntl(fd, F_GETFD) == 0);
+	CHECK(ioctl(fd, FIOCLEX) == 0);
+	CHECK(fcntl(fd, F_GETFD) == FD_CLOEXEC);
+	CHECK(ioctl(fd, FIONCLEX) == 0);
+	CHECK(fcntl(fd, F_GETFD) == 0);
+
+	CHECK(close(fd) == 0);
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303020100.r2210RLG064831>