--- old/usr/src/lib/libzfs/common/libzfs_util.c	2015-03-18 15:00:31.046172740 +0100
+++ new/usr/src/lib/libzfs/common/libzfs_util.c	2015-03-18 15:00:31.049971072 +0100
@@ -624,13 +624,13 @@
 		return (NULL);
 	}
 
-	if ((hdl->libzfs_mnttab = fopen(MNTTAB, "r")) == NULL) {
+	if ((hdl->libzfs_mnttab = fopen(MNTTAB, "rF")) == NULL) {
 		(void) close(hdl->libzfs_fd);
 		free(hdl);
 		return (NULL);
 	}
 
-	hdl->libzfs_sharetab = fopen("/etc/dfs/sharetab", "r");
+	hdl->libzfs_sharetab = fopen("/etc/dfs/sharetab", "rF");
 
 	if (libzfs_core_init() != 0) {
 		(void) close(hdl->libzfs_fd);
--- old/usr/src/pkg/manifests/system-test-zfstest.mf	2015-03-18 15:00:31.170602231 +0100
+++ new/usr/src/pkg/manifests/system-test-zfstest.mf	2015-03-18 15:00:31.174029909 +0100
@@ -101,6 +101,7 @@
 dir path=opt/zfs-tests/tests/functional/inuse
 dir path=opt/zfs-tests/tests/functional/large_files
 dir path=opt/zfs-tests/tests/functional/largest_pool
+dir path=opt/zfs-tests/tests/functional/libzfs
 dir path=opt/zfs-tests/tests/functional/link_count
 dir path=opt/zfs-tests/tests/functional/mdb
 dir path=opt/zfs-tests/tests/functional/migration
@@ -1775,6 +1776,7 @@
     mode=0555
 file path=opt/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos \
     mode=0555
+file path=opt/zfs-tests/tests/functional/libzfs/many_fds mode=0555
 file path=opt/zfs-tests/tests/functional/link_count/cleanup mode=0555
 file path=opt/zfs-tests/tests/functional/link_count/link_count_001 mode=0555
 file path=opt/zfs-tests/tests/functional/link_count/setup mode=0555
--- old/usr/src/test/zfs-tests/runfiles/delphix.run	2015-03-18 15:00:31.336935129 +0100
+++ new/usr/src/test/zfs-tests/runfiles/delphix.run	2015-03-18 15:00:31.340312522 +0100
@@ -524,3 +524,8 @@
 [/opt/zfs-tests/tests/functional/zvol/zvol_swap]
 tests = ['zvol_swap_001_pos', 'zvol_swap_002_pos', 'zvol_swap_003_pos',
     'zvol_swap_004_pos', 'zvol_swap_005_pos', 'zvol_swap_006_pos']
+
+[/opt/zfs-tests/tests/functional/libzfs]
+tests = ['many_fds']
+pre =
+post =
--- old/usr/src/test/zfs-tests/runfiles/omnios.run	2015-03-18 15:00:31.442941065 +0100
+++ new/usr/src/test/zfs-tests/runfiles/omnios.run	2015-03-18 15:00:31.446307572 +0100
@@ -524,3 +524,8 @@
 [/opt/zfs-tests/tests/functional/zvol/zvol_swap]
 tests = ['zvol_swap_001_pos', 'zvol_swap_002_pos', 'zvol_swap_003_pos',
     'zvol_swap_004_pos', 'zvol_swap_005_pos', 'zvol_swap_006_pos']
+
+[/opt/zfs-tests/tests/functional/libzfs]
+tests = ['many_fds']
+pre =
+post =
--- old/usr/src/test/zfs-tests/runfiles/openindiana.run	2015-03-18 15:00:31.549033969 +0100
+++ new/usr/src/test/zfs-tests/runfiles/openindiana.run	2015-03-18 15:00:31.552564330 +0100
@@ -524,3 +524,8 @@
 [/opt/zfs-tests/tests/functional/zvol/zvol_swap]
 tests = ['zvol_swap_001_pos', 'zvol_swap_002_pos', 'zvol_swap_003_pos',
     'zvol_swap_004_pos', 'zvol_swap_005_pos', 'zvol_swap_006_pos']
+
+[/opt/zfs-tests/tests/functional/libzfs]
+tests = ['many_fds']
+pre =
+post =
--- old/usr/src/test/zfs-tests/tests/functional/Makefile	2015-03-18 15:00:31.654249827 +0100
+++ new/usr/src/test/zfs-tests/tests/functional/Makefile	2015-03-18 15:00:31.657601904 +0100
@@ -38,6 +38,7 @@
 	inuse \
 	large_files \
 	largest_pool \
+	libzfs \
 	link_count \
 	mdb \
 	migration \
--- /dev/null	2015-03-18 15:00:31.000000000 +0100
+++ new/usr/src/test/zfs-tests/tests/functional/libzfs/Makefile	2015-03-18 15:00:31.755367626 +0100
@@ -0,0 +1,60 @@
+#
+# 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 (C) 2015 STRATO AG. All rights reserved.
+#
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/zfs-tests
+TESTDIR = $(ROOTOPTPKG)/tests/functional/libzfs
+PROG = many_fds
+SCRIPTS =
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+OBJS = $(PROG:%=%.o)
+SRCS = $(OBJS:%.o=%.c)
+LDLIBS += -lzfs
+
+CMDS = $(PROG:%=$(TESTDIR)/%) $(SCRIPTS:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
+	$(POST_PROCESS)
+
+%.o: ../%.c
+	$(COMPILE.c) $<
+
+install: all $(CMDS)
+
+lint: lint_SRCS
+
+clobber: clean
+	-$(RM) $(PROG)
+
+clean:
+	-$(RM) $(OBJS)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+	$(INS.dir)
+
+$(TESTDIR)/%: %
+	$(INS.file)
+
+$(TESTDIR)/%: %.ksh
+	$(INS.rename)
--- /dev/null	2015-03-18 15:00:31.000000000 +0100
+++ new/usr/src/test/zfs-tests/tests/functional/libzfs/many_fds.c	2015-03-18 15:00:31.801175651 +0100
@@ -0,0 +1,66 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (C) 2015 STRATO AG.
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <libzfs.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+/*
+ * Check if libzfs works with more than 255 held file handles.
+ */
+int
+main(int argc, char **argv)
+{
+	int i;
+	struct rlimit limit;
+	limit.rlim_cur = 65535;
+	limit.rlim_max = 65535;
+	if (setrlimit(RLIMIT_NOFILE, &limit) != 0) {
+		printf("many_fds: setrlimit() failed with errno=%d\n", errno);
+		exit(1);
+	}
+
+	for (i = 0; i < 255; ++i) {
+		int fd = open("/dev/null", O_RDONLY);
+		if (fd == -1) {
+			printf("open failed with errno=%d\n", errno);
+			exit(1);
+		}
+	}
+
+	libzfs_handle_t *h = libzfs_init();
+	if (h) {
+		libzfs_fini(h);
+		exit(0);
+	} else {
+		printf("many_fds: libzfs_init() failed with errno=%d\n", errno);
+		exit(1);
+	}
+}
