summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/lib/libc/port/llib-lc1
-rw-r--r--usr/src/lib/libc/port/sys/epoll.c9
-rw-r--r--usr/src/pkg/manifests/system-test-ostest.mf1
-rw-r--r--usr/src/test/os-tests/runfiles/default.run1
-rw-r--r--usr/src/test/os-tests/tests/poll/Makefile20
-rw-r--r--usr/src/test/os-tests/tests/poll/epoll_test.c51
6 files changed, 72 insertions, 11 deletions
diff --git a/usr/src/lib/libc/port/llib-lc b/usr/src/lib/libc/port/llib-lc
index b86f23280c..d33a1d39c2 100644
--- a/usr/src/lib/libc/port/llib-lc
+++ b/usr/src/lib/libc/port/llib-lc
@@ -99,6 +99,7 @@
#include <sys/cladm.h>
#include <sys/corectl.h>
#include <sys/dl.h>
+#include <sys/epoll.h>
#include <sys/exacct.h>
#include <sys/fcntl.h>
#include <sys/file.h>
diff --git a/usr/src/lib/libc/port/sys/epoll.c b/usr/src/lib/libc/port/sys/epoll.c
index 543856b2ec..34cb151135 100644
--- a/usr/src/lib/libc/port/sys/epoll.c
+++ b/usr/src/lib/libc/port/sys/epoll.c
@@ -95,8 +95,15 @@ epoll_create1(int flags)
{
int fd, oflags = O_RDWR;
- if (flags & EPOLL_CLOEXEC)
+ if (flags & EPOLL_CLOEXEC) {
oflags |= O_CLOEXEC;
+ flags ^= EPOLL_CLOEXEC;
+ }
+ /* Reject unrecognized flags */
+ if (flags != 0) {
+ errno = EINVAL;
+ return (-1);
+ }
if ((fd = open("/dev/poll", oflags)) == -1)
return (-1);
diff --git a/usr/src/pkg/manifests/system-test-ostest.mf b/usr/src/pkg/manifests/system-test-ostest.mf
index a2ad70c2de..4f037a7749 100644
--- a/usr/src/pkg/manifests/system-test-ostest.mf
+++ b/usr/src/pkg/manifests/system-test-ostest.mf
@@ -31,6 +31,7 @@ dir path=opt/os-tests/tests/sigqueue
file path=opt/os-tests/README mode=0444
file path=opt/os-tests/bin/ostest mode=0555
file path=opt/os-tests/runfiles/default.run mode=0444
+file path=opt/os-tests/tests/epoll_test mode=0555
file path=opt/os-tests/tests/file-locking/acquire-lock.32 mode=0555
file path=opt/os-tests/tests/file-locking/acquire-lock.64 mode=0555
file path=opt/os-tests/tests/file-locking/runtests.32 mode=0555
diff --git a/usr/src/test/os-tests/runfiles/default.run b/usr/src/test/os-tests/runfiles/default.run
index 16a67706ec..8f36276de4 100644
--- a/usr/src/test/os-tests/runfiles/default.run
+++ b/usr/src/test/os-tests/runfiles/default.run
@@ -23,6 +23,7 @@ outputdir = /var/tmp/test_results
[/opt/os-tests/tests/poll_test]
user = root
+tests = ['poll_test', 'epoll_test']
[/opt/os-tests/tests/secflags]
user = root
diff --git a/usr/src/test/os-tests/tests/poll/Makefile b/usr/src/test/os-tests/tests/poll/Makefile
index 5e2d6e8ad9..14cc28b056 100644
--- a/usr/src/test/os-tests/tests/poll/Makefile
+++ b/usr/src/test/os-tests/tests/poll/Makefile
@@ -11,16 +11,18 @@
#
# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2016 Joyent, Inc.
#
include $(SRC)/cmd/Makefile.cmd
include $(SRC)/test/Makefile.com
-PROG = poll_test
+PROG = poll_test epoll_test
OBJS = $(PROG:%=%.o)
SRCS = $(OBJS:%.o=%.c)
-LDLIBS += -lsocket
+poll_test := LDLIBS += -lsocket
+poll_test.ln := LDLIBS += -lsocket
C99MODE = -xc99=%all
ROOTOPTPKG = $(ROOT)/opt/os-tests
@@ -29,18 +31,13 @@ TESTDIR = $(ROOTOPTPKG)/tests
CMDS = $(PROG:%=$(TESTDIR)/%)
$(CMDS) := FILEMODE = 0555
-all: $(PROG)
-
-$(PROG): $(OBJS)
- $(LINK.c) $(OBJS) -o $@ $(LDLIBS)
- $(POST_PROCESS)
+LINTS = $(PROG:%=%.ln)
-%.o: ../%.c
- $(COMPILE.c) $<
+all: $(PROG)
install: all $(CMDS)
-lint: lint_SRCS
+lint: $(LINTS)
clobber: clean
-$(RM) $(PROG)
@@ -48,6 +45,9 @@ clobber: clean
clean:
-$(RM) $(OBJS)
+%.ln: %.c
+ $(LINT.c) $< $(UTILS) $(LDLIBS)
+
$(CMDS): $(TESTDIR) $(PROG)
$(TESTDIR):
diff --git a/usr/src/test/os-tests/tests/poll/epoll_test.c b/usr/src/test/os-tests/tests/poll/epoll_test.c
new file mode 100644
index 0000000000..bcdeef2ccf
--- /dev/null
+++ b/usr/src/test/os-tests/tests/poll/epoll_test.c
@@ -0,0 +1,51 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2016 Joyent, Inc.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/epoll.h>
+#include <errno.h>
+#include <assert.h>
+
+int
+main()
+{
+ int fd, flags;
+
+ fd = epoll_create1(0);
+ assert(fd >= 0);
+
+ flags = fcntl(fd, F_GETFD);
+ assert(flags != -1 && (flags & FD_CLOEXEC) == 0);
+ (void) close(fd);
+
+
+ fd = epoll_create1(EPOLL_CLOEXEC);
+ assert(fd >= 0);
+
+ flags = fcntl(fd, F_GETFD);
+ assert(flags != -1 && (flags & FD_CLOEXEC) == FD_CLOEXEC);
+ (void) close(fd);
+
+ fd = epoll_create1(EPOLL_CLOEXEC * 3);
+ assert(fd == -1 && errno == EINVAL);
+ fd = epoll_create1(EPOLL_CLOEXEC * 2);
+ assert(fd == -1 && errno == EINVAL);
+
+ return (0);
+}