summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/fs/tmpfs
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/fs/tmpfs')
-rw-r--r--contrib/netbsd-tests/fs/tmpfs/README17
-rw-r--r--contrib/netbsd-tests/fs/tmpfs/h_funcs.subr96
-rw-r--r--contrib/netbsd-tests/fs/tmpfs/h_tools.c299
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_create.sh122
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_devices.sh60
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_dots.sh67
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_exec.sh52
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_link.sh129
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_mkdir.sh159
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_mknod.sh143
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_mount.sh140
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_pipes.sh52
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_read_write.sh87
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_readdir.sh116
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_remove.sh110
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_rename.sh278
-rw-r--r--contrib/netbsd-tests/fs/tmpfs/t_renamerace.c115
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_rmdir.sh204
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_setattr.sh216
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_sizes.sh131
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_sockets.sh52
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_statvfs.sh59
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_symlink.sh114
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_times.sh141
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_trail_slash.sh52
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_truncate.sh56
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_vnd.sh78
-rwxr-xr-xcontrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh60
28 files changed, 3205 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/fs/tmpfs/README b/contrib/netbsd-tests/fs/tmpfs/README
new file mode 100644
index 0000000..cdc3f2d
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/README
@@ -0,0 +1,17 @@
+The tests in this directory where written at the same time tmpfs was
+developed. This is why, if you follow the order of tests in the Atffile,
+you will notice that they start checking the most basic things and end
+checking the less common ones. Furthermore, tests try not to use features
+tested by further tests in the lists.
+
+However, the above is not the most appropriate testing procedure when you
+have a working file system because some separation in test programs does
+not make sense afterwards.
+
+Many of the tests here are applicable to any file system. They should be
+refactored to be reusable on any mounted file system, which could also
+remove the need to do the mount/unmount steps in each and every test case.
+
+Possibly take a look at the file system tests in FreeBSD. They seem to be
+much more complete, even though they are written in Perl and therefore not
+directly usable.
diff --git a/contrib/netbsd-tests/fs/tmpfs/h_funcs.subr b/contrib/netbsd-tests/fs/tmpfs/h_funcs.subr
new file mode 100644
index 0000000..07c1644
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/h_funcs.subr
@@ -0,0 +1,96 @@
+#!/bin/sh
+#
+# $NetBSD: h_funcs.subr,v 1.5 2013/03/17 01:16:45 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+Mount_Point=
+
+#
+# test_mount [args]
+#
+# Mounts tmpfs over ${Mount_Point} and changes the current directory
+# to the mount point. Optional arguments may be passed to the
+# mount command.
+#
+test_mount() {
+ require_fs tmpfs
+
+ Mount_Point=$(pwd)/mntpt
+ atf_check -s eq:0 -o empty -e empty mkdir "${Mount_Point}"
+ echo "mount -t tmpfs ${*} tmpfs ${Mount_Point}"
+ mount -t tmpfs "${@}" tmpfs "${Mount_Point}" 2>mounterr
+ if [ "${?}" -ne 0 ]; then
+ cat mounterr 1>&2
+ if grep 'Operation not supported' mounterr > /dev/null; then
+ atf_skip "tmpfs not supported"
+ fi
+ atf_fail "Failed to mount a tmpfs file system"
+ fi
+ cd "${Mount_Point}"
+}
+
+#
+# test_unmount
+#
+# Unmounts the file system mounted by test_mount.
+#
+test_unmount() {
+ cd - >/dev/null
+ atf_check -s eq:0 -o empty -e empty umount ${Mount_Point}
+ atf_check -s eq:0 -o empty -e empty rmdir ${Mount_Point}
+ Mount_Point=
+}
+
+#
+# kqueue_monitor expected_nevents file1 [.. fileN]
+#
+# Monitors the commands given through stdin (one per line) using
+# kqueue and stores the events raised in a log that can be later
+# verified with kqueue_check.
+#
+kqueue_monitor() {
+ nev=${1}; shift
+ echo "Running kqueue-monitored commands and expecting" \
+ "${nev} events"
+ $(atf_get_srcdir)/h_tools kqueue ${*} >kqueue.log || \
+ atf_fail "Could not launch kqueue monitor"
+ got=$(wc -l kqueue.log | awk '{ print $1 }')
+ test ${got} -eq ${nev} || \
+ atf_fail "Got ${got} events but expected ${nev}"
+}
+
+#
+# kqueue_check file event
+#
+# Checks if kqueue raised the given event when monitoring the
+# given file.
+#
+kqueue_check() {
+ echo "Checking if ${1} received ${2}"
+ grep "^${1} - ${2}$" kqueue.log >/dev/null || \
+ atf_fail "${1} did not receive ${2}"
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/h_tools.c b/contrib/netbsd-tests/fs/tmpfs/h_tools.c
new file mode 100644
index 0000000..6a7b8fd
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/h_tools.c
@@ -0,0 +1,299 @@
+/* $NetBSD: h_tools.c,v 1.4 2011/06/11 18:03:17 christos Exp $ */
+
+/*
+ * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Helper tools for several tests. These are kept in a single file due
+ * to the limitations of bsd.prog.mk to build a single program in a
+ * given directory.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/event.h>
+#include <sys/mount.h>
+#include <sys/statvfs.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/un.h>
+
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* --------------------------------------------------------------------- */
+
+static int getfh_main(int, char **);
+static int kqueue_main(int, char **);
+static int rename_main(int, char **);
+static int sockets_main(int, char **);
+static int statvfs_main(int, char **);
+
+/* --------------------------------------------------------------------- */
+
+int
+getfh_main(int argc, char **argv)
+{
+ int error;
+ void *fh;
+ size_t fh_size;
+
+ if (argc < 2)
+ return EXIT_FAILURE;
+
+ fh_size = 0;
+ fh = NULL;
+ for (;;) {
+ if (fh_size) {
+ fh = malloc(fh_size);
+ if (fh == NULL) {
+ fprintf(stderr, "out of memory");
+ return EXIT_FAILURE;
+ }
+ }
+ /*
+ * The kernel provides the necessary size in fh_size -
+ * but it may change if someone moves things around,
+ * so retry untill we have enough memory.
+ */
+ error = getfh(argv[1], fh, &fh_size);
+ if (error == 0) {
+ break;
+ } else {
+ if (fh != NULL)
+ free(fh);
+ if (errno != E2BIG) {
+ warn("getfh");
+ return EXIT_FAILURE;
+ }
+ }
+ }
+
+ error = write(STDOUT_FILENO, fh, fh_size);
+ if (error == -1) {
+ warn("write");
+ return EXIT_FAILURE;
+ }
+ free(fh);
+
+ return 0;
+}
+
+/* --------------------------------------------------------------------- */
+
+int
+kqueue_main(int argc, char **argv)
+{
+ char *line;
+ int i, kq;
+ size_t len;
+ struct kevent *changes, event;
+
+ if (argc < 2)
+ return EXIT_FAILURE;
+
+ argc--;
+ argv++;
+
+ changes = malloc(sizeof(struct kevent) * argc);
+ if (changes == NULL)
+ errx(EXIT_FAILURE, "not enough memory");
+
+ for (i = 0; i < argc; i++) {
+ int fd;
+
+ fd = open(argv[i], O_RDONLY);
+ if (fd == -1)
+ err(EXIT_FAILURE, "cannot open %s", argv[i]);
+
+ EV_SET(&changes[i], fd, EVFILT_VNODE,
+ EV_ADD | EV_ENABLE | EV_ONESHOT,
+ NOTE_ATTRIB | NOTE_DELETE | NOTE_EXTEND | NOTE_LINK |
+ NOTE_RENAME | NOTE_REVOKE | NOTE_WRITE,
+ 0, 0);
+ }
+
+ kq = kqueue();
+ if (kq == -1)
+ err(EXIT_FAILURE, "kqueue");
+
+ while ((line = fgetln(stdin, &len)) != NULL) {
+ int ec, nev;
+ struct timespec to;
+
+ to.tv_sec = 0;
+ to.tv_nsec = 100000;
+
+ (void)kevent(kq, changes, argc, &event, 1, &to);
+
+ assert(len > 0);
+ assert(line[len - 1] == '\n');
+ line[len - 1] = '\0';
+ ec = system(line);
+ if (ec != EXIT_SUCCESS)
+ errx(ec, "%s returned %d", line, ec);
+
+ do {
+ nev = kevent(kq, changes, argc, &event, 1, &to);
+ if (nev == -1)
+ err(EXIT_FAILURE, "kevent");
+ else if (nev > 0) {
+ for (i = 0; i < argc; i++)
+ if (event.ident == changes[i].ident)
+ break;
+
+ if (event.fflags & NOTE_ATTRIB)
+ printf("%s - NOTE_ATTRIB\n", argv[i]);
+ if (event.fflags & NOTE_DELETE)
+ printf("%s - NOTE_DELETE\n", argv[i]);
+ if (event.fflags & NOTE_EXTEND)
+ printf("%s - NOTE_EXTEND\n", argv[i]);
+ if (event.fflags & NOTE_LINK)
+ printf("%s - NOTE_LINK\n", argv[i]);
+ if (event.fflags & NOTE_RENAME)
+ printf("%s - NOTE_RENAME\n", argv[i]);
+ if (event.fflags & NOTE_REVOKE)
+ printf("%s - NOTE_REVOKE\n", argv[i]);
+ if (event.fflags & NOTE_WRITE)
+ printf("%s - NOTE_WRITE\n", argv[i]);
+ }
+ } while (nev > 0);
+ }
+
+ for (i = 0; i < argc; i++)
+ close(changes[i].ident);
+ free(changes);
+
+ return EXIT_SUCCESS;
+}
+
+/* --------------------------------------------------------------------- */
+
+int
+rename_main(int argc, char **argv)
+{
+
+ if (argc < 3)
+ return EXIT_FAILURE;
+
+ if (rename(argv[1], argv[2]) == -1) {
+ warn("rename");
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+
+/* --------------------------------------------------------------------- */
+
+int
+sockets_main(int argc, char **argv)
+{
+ int error, fd;
+ struct sockaddr_un addr;
+
+ if (argc < 2)
+ return EXIT_FAILURE;
+
+ fd = socket(PF_LOCAL, SOCK_STREAM, 0);
+ if (fd == -1) {
+ warn("socket");
+ return EXIT_FAILURE;
+ }
+
+ (void)strlcpy(addr.sun_path, argv[1], sizeof(addr.sun_path));
+ addr.sun_family = PF_UNIX;
+
+ error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+ if (error == -1) {
+ warn("connect");
+ return EXIT_FAILURE;
+ }
+
+ close(fd);
+
+ return EXIT_SUCCESS;
+}
+
+/* --------------------------------------------------------------------- */
+
+int
+statvfs_main(int argc, char **argv)
+{
+ int error;
+ struct statvfs buf;
+
+ if (argc < 2)
+ return EXIT_FAILURE;
+
+ error = statvfs(argv[1], &buf);
+ if (error != 0) {
+ warn("statvfs");
+ return EXIT_FAILURE;
+ }
+
+ (void)printf("f_bsize=%lu\n", buf.f_bsize);
+ (void)printf("f_blocks=%" PRId64 "\n", buf.f_blocks);
+ (void)printf("f_bfree=%" PRId64 "\n", buf.f_bfree);
+ (void)printf("f_files=%" PRId64 "\n", buf.f_files);
+
+ return EXIT_SUCCESS;
+}
+
+/* --------------------------------------------------------------------- */
+
+int
+main(int argc, char **argv)
+{
+ int error;
+
+ if (argc < 2)
+ return EXIT_FAILURE;
+
+ argc -= 1;
+ argv += 1;
+
+ if (strcmp(argv[0], "getfh") == 0)
+ error = getfh_main(argc, argv);
+ else if (strcmp(argv[0], "kqueue") == 0)
+ error = kqueue_main(argc, argv);
+ else if (strcmp(argv[0], "rename") == 0)
+ error = rename_main(argc, argv);
+ else if (strcmp(argv[0], "sockets") == 0)
+ error = sockets_main(argc, argv);
+ else if (strcmp(argv[0], "statvfs") == 0)
+ error = statvfs_main(argc, argv);
+ else
+ error = EXIT_FAILURE;
+
+ return error;
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_create.sh b/contrib/netbsd-tests/fs/tmpfs/t_create.sh
new file mode 100755
index 0000000..f1f894d
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_create.sh
@@ -0,0 +1,122 @@
+# $NetBSD: t_create.sh,v 1.8 2011/03/05 07:41:11 pooka Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the create operation works.
+#
+
+atf_test_case create
+create_head() {
+ atf_set "descr" "Verifies that files can be created"
+ atf_set "require.user" "root"
+}
+create_body() {
+ test_mount
+
+ atf_check -s eq:1 -o empty -e empty test -f a
+ atf_check -s eq:0 -o empty -e empty touch a
+ atf_check -s eq:0 -o empty -e empty test -f a
+
+ test_unmount
+}
+
+atf_test_case attrs
+attrs_head() {
+ atf_set "descr" "Verifies that a new file gets the correct" \
+ "attributes"
+ atf_set "require.config" "unprivileged-user"
+ atf_set "require.user" "root"
+}
+attrs_body() {
+ user=$(atf_config_get unprivileged-user)
+ # Allow the unprivileged user to access the work directory.
+ chown ${user} .
+
+ test_mount
+
+ umask 022
+ atf_check -s eq:1 -o empty -e empty test -f a
+ atf_check -s eq:0 -o empty -e empty touch a
+ atf_check -s eq:0 -o empty -e empty test -f a
+
+ eval $(stat -s . | sed -e 's|st_|dst_|g')
+ eval $(stat -s a)
+ test ${st_flags} -eq 0 || atf_fail "Incorrect flags"
+ test ${st_size} -eq 0 || atf_fail "Incorrect size"
+ test ${st_uid} -eq $(id -u) || atf_fail "Incorrect uid"
+ test ${st_gid} -eq ${dst_gid} || atf_fail "Incorrect gid"
+ test ${st_mode} = 0100644 || atf_fail "Incorrect mode"
+
+ atf_check -s eq:0 -o empty -e empty mkdir b c
+
+ atf_check -s eq:0 -o empty -e empty chown ${user}:0 b
+ eval $(stat -s b)
+ [ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
+ [ ${st_gid} -eq 0 ] || atf_fail "Incorrect group"
+
+ atf_check -s eq:0 -o empty -e empty chown ${user}:100 c
+ eval $(stat -s c)
+ [ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
+ [ ${st_gid} -eq 100 ] || atf_fail "Incorrect group"
+
+ atf_check -s eq:0 -o empty -e empty su -m ${user} -c 'touch b/a'
+ eval $(stat -s b/a)
+ [ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
+ [ ${st_gid} -eq 0 ] || atf_fail "Incorrect group"
+
+ atf_check -s eq:0 -o empty -e empty su -m ${user} -c 'touch c/a'
+ eval $(stat -s c/a)
+ [ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
+ [ ${st_gid} -eq 100 ] || atf_fail "Incorrect group"
+
+ test_unmount
+}
+
+atf_test_case kqueue
+kqueue_head() {
+ atf_set "descr" "Verifies that creating a file raises the correct" \
+ "kqueue events"
+ atf_set "require.user" "root"
+}
+kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ echo 'touch dir/a' | kqueue_monitor 1 dir
+ kqueue_check dir NOTE_WRITE
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case create
+ atf_add_test_case attrs
+ atf_add_test_case kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_devices.sh b/contrib/netbsd-tests/fs/tmpfs/t_devices.sh
new file mode 100755
index 0000000..472d378
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_devices.sh
@@ -0,0 +1,60 @@
+# $NetBSD: t_devices.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+atf_test_case basic
+basic_head() {
+ atf_set "descr" "Tests that special devices work"
+ atf_set "require.user" "root"
+}
+basic_body() {
+ test_mount
+
+ umask 022
+
+ atf_check -s eq:0 -o ignore -e ignore /dev/MAKEDEV std
+ atf_check -s eq:0 -o empty -e empty test -e zero
+ atf_check -s eq:0 -o empty -e empty test -e null
+
+ echo "Reading from the 'zero' character device"
+ atf_check -s eq:0 -o ignore -e ignore dd if=zero of=a bs=10k count=1
+ [ $(md5 a | cut -d ' ' -f 4) = 1276481102f218c981e0324180bafd9f ] || \
+ atf_fail "Data read is invalid"
+
+ echo "Writing to the 'null' device"
+ echo foo >null
+ eval $(stat -s null)
+ [ ${st_size} -eq 0 ] || atf_fail "Invalid size for device"
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case basic
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_dots.sh b/contrib/netbsd-tests/fs/tmpfs/t_dots.sh
new file mode 100755
index 0000000..e480de7
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_dots.sh
@@ -0,0 +1,67 @@
+# $NetBSD: t_dots.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+atf_test_case topdir
+topdir_head() {
+ atf_set "descr" "Verifies that looking up '.' and '..' in" \
+ "top-level directories works"
+ atf_set "require.user" "root"
+}
+topdir_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty test -d ./a
+ atf_check -s eq:0 -o empty -e empty test -d a/../a
+
+ test_unmount
+}
+
+atf_test_case nesteddir
+nesteddir_head() {
+ atf_set "descr" "Verifies that looking up '.' and '..' in" \
+ "top-level directories works"
+ atf_set "require.user" "root"
+}
+nesteddir_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty mkdir a/b
+ atf_check -s eq:0 -o empty -e empty test -d a/b/../b
+ atf_check -s eq:0 -o empty -e empty test -d a/b/../../a
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case topdir
+ atf_add_test_case nesteddir
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_exec.sh b/contrib/netbsd-tests/fs/tmpfs/t_exec.sh
new file mode 100755
index 0000000..9ffc600
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_exec.sh
@@ -0,0 +1,52 @@
+# $NetBSD: t_exec.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+atf_test_case basic
+basic_head() {
+ atf_set "descr" "Verifies that binary files can be executed from" \
+ "within the file system (i.e., whether getpages" \
+ "works)"
+ atf_set "require.user" "root"
+}
+basic_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty cp /bin/cp .
+ echo "Verifying copied file"
+ [ $(md5 cp | cut -d ' ' -f 4) = $(md5 /bin/cp | cut -d ' ' -f 4) ] || \
+ atf_file "New binary file does not match original"
+ atf_check -s eq:0 -o empty -e empty ./cp cp foo
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case basic
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_link.sh b/contrib/netbsd-tests/fs/tmpfs/t_link.sh
new file mode 100755
index 0000000..660f3f2
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_link.sh
@@ -0,0 +1,129 @@
+# $NetBSD: t_link.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the link operation works.
+#
+
+atf_test_case basic
+basic_head() {
+ atf_set "descr" "Verifies that the link operation works on files" \
+ "at the top directory"
+ atf_set "require.user" "root"
+}
+basic_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty touch a
+ atf_check -s eq:0 -o empty -e empty touch z
+ eval $(stat -s a | sed -e 's|st_|sta_|g')
+ eval $(stat -s z | sed -e 's|st_|stz_|g')
+ test ${sta_ino} != ${stz_ino} || \
+ atf_fail "Node numbers are not different"
+ test ${sta_nlink} -eq 1 || atf_fail "Number of links is incorrect"
+ atf_check -s eq:0 -o empty -e empty ln a b
+
+ echo "Checking if link count is correct after links are created"
+ eval $(stat -s a | sed -e 's|st_|sta_|g')
+ eval $(stat -s b | sed -e 's|st_|stb_|g')
+ test ${sta_ino} = ${stb_ino} || atf_fail "Node number changed"
+ test ${sta_nlink} -eq 2 || atf_fail "Link count is incorrect"
+ test ${stb_nlink} -eq 2 || atf_fail "Link count is incorrect"
+
+ echo "Checking if link count is correct after links are deleted"
+ atf_check -s eq:0 -o empty -e empty rm a
+ eval $(stat -s b | sed -e 's|st_|stb_|g')
+ test ${stb_nlink} -eq 1 || atf_fail "Link count is incorrect"
+ atf_check -s eq:0 -o empty -e empty rm b
+
+ test_unmount
+}
+
+atf_test_case subdirs
+subdirs_head() {
+ atf_set "descr" "Verifies that the link operation works if used" \
+ "in subdirectories"
+ atf_set "require.user" "root"
+}
+subdirs_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty touch a
+ atf_check -s eq:0 -o empty -e empty mkdir c
+ atf_check -s eq:0 -o empty -e empty ln a c/b
+
+ echo "Checking if link count is correct after links are created"
+ eval $(stat -s a | sed -e 's|st_|sta_|g')
+ eval $(stat -s c/b | sed -e 's|st_|stb_|g')
+ test ${sta_ino} = ${stb_ino} || atf_fail "Node number changed"
+ test ${sta_nlink} -eq 2 || atf_fail "Link count is incorrect"
+ test ${stb_nlink} -eq 2 || atf_fail "Link count is incorrect"
+
+ echo "Checking if link count is correct after links are deleted"
+ atf_check -s eq:0 -o empty -e empty rm a
+ eval $(stat -s c/b | sed -e 's|st_|stb_|g')
+ test ${stb_nlink} -eq 1 || atf_fail "Link count is incorrect"
+ atf_check -s eq:0 -o empty -e empty rm c/b
+ atf_check -s eq:0 -o empty -e empty rmdir c
+
+ test_unmount
+}
+
+atf_test_case kqueue
+kqueue_head() {
+ atf_set "descr" "Verifies that creating a link raises the correct" \
+ "kqueue events"
+ atf_set "require.user" "root"
+}
+kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ atf_check -s eq:0 -o empty -e empty touch dir/a
+ echo 'ln dir/a dir/b' | kqueue_monitor 2 dir dir/a
+ kqueue_check dir/a NOTE_LINK
+ kqueue_check dir NOTE_WRITE
+
+ echo 'rm dir/a' | kqueue_monitor 2 dir dir/b
+ # XXX According to the (short) kqueue(2) documentation, the following
+ # should raise a NOTE_LINK but FFS raises a NOTE_DELETE...
+ kqueue_check dir/b NOTE_LINK
+ kqueue_check dir NOTE_WRITE
+ atf_check -s eq:0 -o empty -e empty rm dir/b
+ atf_check -s eq:0 -o empty -e empty rmdir dir
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case basic
+ atf_add_test_case subdirs
+ atf_add_test_case kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_mkdir.sh b/contrib/netbsd-tests/fs/tmpfs/t_mkdir.sh
new file mode 100755
index 0000000..db0d1e3
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_mkdir.sh
@@ -0,0 +1,159 @@
+# $NetBSD: t_mkdir.sh,v 1.8 2011/03/05 07:41:11 pooka Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that mkdir works by creating some nested directories. It also
+# checks, in part, the lookup operation.
+#
+
+atf_test_case single
+single_head() {
+ atf_set "descr" "Creates a single directory and checks the" \
+ "mount point's hard link count"
+ atf_set "require.user" "root"
+}
+single_body() {
+ test_mount
+
+ atf_check -s eq:1 -o empty -e empty test -d a
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty test -d a
+ test -d a
+ eval $(stat -s ${Mount_Point})
+ [ ${st_nlink} = 3 ] || atf_fail "Link count is not 3"
+
+ test_unmount
+}
+
+atf_test_case many
+many_head() {
+ atf_set "descr" "Creates multiple directories and checks the" \
+ "mount point's hard link count"
+ atf_set "require.user" "root"
+}
+many_body() {
+ test_mount
+
+ for d in $(jot 100); do
+ atf_check -s eq:1 -o empty -e empty test -d ${d}
+ atf_check -s eq:0 -o empty -e empty mkdir ${d}
+ atf_check -s eq:0 -o empty -e empty test -d ${d}
+ done
+ eval $(stat -s ${Mount_Point})
+ [ ${st_nlink} = 102 ] || atf_fail "Link count is not 102"
+
+ test_unmount
+}
+
+atf_test_case nested
+nested_head() {
+ atf_set "descr" "Checks if nested directories can be created"
+ atf_set "require.user" "root"
+}
+nested_body() {
+ test_mount
+
+ atf_check -s eq:1 -o empty -e empty test -d a/b/c/d/e
+ atf_check -s eq:0 -o empty -e empty mkdir -p a/b/c/d/e
+ atf_check -s eq:0 -o empty -e empty test -d a/b/c/d/e
+
+ test_unmount
+}
+
+atf_test_case attrs
+attrs_head() {
+ atf_set "descr" "Checks that new directories get the proper" \
+ "attributes (owner and group)"
+ atf_set "require.config" "unprivileged-user"
+ atf_set "require.user" "root"
+}
+attrs_body() {
+ user=$(atf_config_get unprivileged-user)
+ # Allow the unprivileged user to access the work directory.
+ chown ${user} .
+
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir b c
+
+ atf_check -s eq:0 -o empty -e empty chown ${user}:0 b
+ eval $(stat -s b)
+ [ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
+ [ ${st_gid} -eq 0 ] || atf_fail "Incorrect group"
+
+ atf_check -s eq:0 -o empty -e empty chown ${user}:100 c
+ eval $(stat -s c)
+ [ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
+ [ ${st_gid} -eq 100 ] || atf_fail "Incorrect group"
+
+ atf_check -s eq:0 -o empty -e empty su -m ${user} -c 'mkdir b/a'
+ eval $(stat -s b/a)
+ [ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
+ [ ${st_gid} -eq 0 ] || atf_fail "Incorrect group"
+
+ atf_check -s eq:0 -o empty -e empty su -m ${user} -c 'mkdir c/a'
+ eval $(stat -s c/a)
+ [ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
+ [ ${st_gid} -eq 100 ] || atf_fail "Incorrect group"
+
+ test_unmount
+}
+
+atf_test_case kqueue
+kqueue_head() {
+ atf_set "descr" "Creates a directory and checks the kqueue events" \
+ "raised"
+ atf_set "require.user" "root"
+}
+kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ echo 'mkdir dir/a' | kqueue_monitor 2 dir
+
+ # Creating a directory raises NOTE_LINK on the parent directory
+ kqueue_check dir NOTE_LINK
+
+ # Creating a directory raises NOTE_WRITE on the parent directory
+ kqueue_check dir NOTE_WRITE
+
+ atf_check -s eq:0 -o empty -e empty rmdir dir/a
+ atf_check -s eq:0 -o empty -e empty rmdir dir
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case single
+ atf_add_test_case many
+ atf_add_test_case nested
+ atf_add_test_case attrs
+ atf_add_test_case kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh b/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh
new file mode 100755
index 0000000..62c7cce
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh
@@ -0,0 +1,143 @@
+# $NetBSD: t_mknod.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the mknod operation works.
+#
+
+atf_test_case block
+block_head() {
+ atf_set "descr" "Tests that block devices can be created"
+ atf_set "require.user" "root"
+}
+block_body() {
+ test_mount
+ umask 022
+
+ atf_check -s eq:0 -o empty -e empty mknod fd0a b 2 0
+ eval $(stat -s fd0a)
+ [ ${st_mode} = 060644 ] || atf_fail "Invalid mode"
+ [ ${st_rdev} -eq 512 ] || atf_fail "Invalid device"
+
+ test_unmount
+}
+
+atf_test_case block_kqueue
+block_kqueue_head() {
+ atf_set "descr" "Tests that creating a block device raises the" \
+ "appropriate kqueue events"
+ atf_set "require.user" "root"
+}
+block_kqueue_body() {
+ test_mount
+ umask 022
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ echo 'mknod dir/fd0a b 2 0' | kqueue_monitor 1 dir
+ kqueue_check dir NOTE_WRITE
+
+ test_unmount
+}
+
+atf_test_case char
+char_head() {
+ atf_set "descr" "Tests that character devices can be created"
+ atf_set "require.user" "root"
+}
+char_body() {
+ test_mount
+ umask 022
+
+ atf_check -s eq:0 -o empty -e empty mknod null c 2 2
+ eval $(stat -s null)
+ [ ${st_mode} = 020644 ] || atf_fail "Invalid mode"
+ [ ${st_rdev} -eq 514 ] || atf_fail "Invalid device"
+
+ test_unmount
+}
+
+atf_test_case char_kqueue
+char_kqueue_head() {
+ atf_set "descr" "Tests that creating a character device raises the" \
+ "appropriate kqueue events"
+ atf_set "require.user" "root"
+}
+char_kqueue_body() {
+ test_mount
+ umask 022
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ echo 'mknod dir/null c 2 2' | kqueue_monitor 1 dir
+ kqueue_check dir NOTE_WRITE
+
+ test_unmount
+}
+
+atf_test_case pipe
+pipe_head() {
+ atf_set "descr" "Tests that named pipes can be created"
+ atf_set "require.user" "root"
+}
+pipe_body() {
+ test_mount
+ umask 022
+
+ atf_check -s eq:0 -o empty -e empty mknod pipe p
+ eval $(stat -s pipe)
+ [ ${st_mode} = 010644 ] || atf_fail "Invalid mode"
+
+ test_unmount
+}
+
+atf_test_case pipe_kqueue
+pipe_kqueue_head() {
+ atf_set "descr" "Tests that creating a named pipe raises the" \
+ "appropriate kqueue events"
+ atf_set "require.user" "root"
+}
+pipe_kqueue_body() {
+ test_mount
+ umask 022
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ echo 'mknod dir/pipe p' | kqueue_monitor 1 dir
+ kqueue_check dir NOTE_WRITE
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case block
+ atf_add_test_case block_kqueue
+ atf_add_test_case char
+ atf_add_test_case char_kqueue
+ atf_add_test_case pipe
+ atf_add_test_case pipe_kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_mount.sh b/contrib/netbsd-tests/fs/tmpfs/t_mount.sh
new file mode 100755
index 0000000..11a77d4
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_mount.sh
@@ -0,0 +1,140 @@
+# $NetBSD: t_mount.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that an execution of mount and umount works correctly without
+# causing errors and that the root node gets correct attributes.
+# Also verifies command line parsing from mount_tmpfs.
+#
+
+atf_test_case plain
+plain_head() {
+ atf_set "descr" "Tests a mount and unmount without any options"
+ atf_set "require.user" "root"
+}
+plain_body() {
+ test_mount
+ test_unmount
+}
+
+atf_test_case links
+links_head() {
+ atf_set "descr" "Tests that the mount point has two hard links"
+ atf_set "require.user" "root"
+}
+links_body() {
+ test_mount
+ eval $(stat -s ${Mount_Point})
+ [ ${st_nlink} = 2 ] || \
+ atf_fail "Root directory does not have two hard links"
+ test_unmount
+}
+
+atf_test_case options
+options_head() {
+ atf_set "descr" "Tests the read-only mount option"
+ atf_set "require.user" "root"
+}
+options_body() {
+ test_mount -o ro
+ mount | grep ${Mount_Point} | grep -q read-only || \
+ atf_fail "read-only option (ro) does not work"
+ test_unmount
+}
+
+atf_test_case attrs
+attrs_head() {
+ atf_set "descr" "Tests that root directory attributes are set" \
+ "correctly"
+ atf_set "require.user" "root"
+}
+attrs_body() {
+ test_mount -o -u1000 -o -g100 -o -m755
+ eval $(stat -s ${Mount_Point})
+ [ ${st_uid} = 1000 ] || atf_fail "uid is incorrect"
+ [ ${st_gid} = 100 ] || atf_fail "gid is incorrect"
+ [ ${st_mode} = 040755 ] || atf_fail "mode is incorrect"
+ test_unmount
+}
+
+atf_test_case negative
+negative_head() {
+ atf_set "descr" "Tests that negative values passed to to -s are" \
+ "handled correctly"
+ atf_set "require.user" "root"
+}
+negative_body() {
+ mkdir tmp
+ test_mount -o -s-10
+ test_unmount
+}
+
+atf_test_case large
+large_head() {
+ atf_set "descr" "Tests that extremely long values passed to -s" \
+ "are handled correctly"
+ atf_set "require.user" "root"
+}
+large_body() {
+ test_mount -o -s9223372036854775807
+ test_unmount
+
+ mkdir tmp
+ atf_check -s eq:1 -o empty -e ignore \
+ mount -t tmpfs -o -s9223372036854775808 tmpfs tmp
+ atf_check -s eq:1 -o empty -e ignore \
+ mount -t tmpfs -o -s9223372036854775808g tmpfs tmp
+ rmdir tmp
+}
+
+atf_test_case mntpt
+mntpt_head() {
+ atf_set "descr" "Tests that the error messages printed when the" \
+ "mount point is invalid do not show the source" \
+ "unused parameter"
+}
+mntpt_body() {
+ mount_tmpfs unused $(pwd)/mnt >out 2>&1
+ atf_check -s eq:1 -o empty -e empty grep unused out
+ atf_check -s eq:0 -o ignore -e empty grep "$(pwd)/mnt" out
+
+ mount_tmpfs unused mnt >out 2>&1
+ atf_check -s eq:1 -o empty -e empty grep unused out
+ atf_check -s eq:0 -o ignore -e empty grep mnt out
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case plain
+ atf_add_test_case options
+ atf_add_test_case attrs
+ atf_add_test_case negative
+ atf_add_test_case large
+ atf_add_test_case mntpt
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_pipes.sh b/contrib/netbsd-tests/fs/tmpfs/t_pipes.sh
new file mode 100755
index 0000000..7c0065a
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_pipes.sh
@@ -0,0 +1,52 @@
+# $NetBSD: t_pipes.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+atf_test_case basic
+basic_head() {
+ atf_set "descr" "Verifies that pipes work"
+ atf_set "require.user" "root"
+}
+basic_body() {
+ test_mount
+
+ umask 022
+
+ atf_check -s eq:0 -o empty -e empty mknod pipe p
+
+ echo "Writing to pipe and waiting for response"
+ echo -n foo >pipe &
+ [ "$(cat pipe)" = foo ] || atf_fail "Received data is incorrect"
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case basic
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_read_write.sh b/contrib/netbsd-tests/fs/tmpfs/t_read_write.sh
new file mode 100755
index 0000000..13cc256
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_read_write.sh
@@ -0,0 +1,87 @@
+# $NetBSD: t_read_write.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the read and write operations work.
+#
+
+atf_test_case basic
+basic_head() {
+ atf_set "descr" "Checks that file removal works"
+ atf_set "require.user" "root"
+}
+basic_body() {
+ test_mount
+
+ echo "Testing write to a small file"
+ echo foo >a || atf_fail "Failed to write to file"
+ [ $(md5 a | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || \
+ atf_fail "Invalid file contents"
+
+ echo "Testing appending to a small file"
+ echo bar >>a || atf_fail "Failed to append data to file"
+ [ $(md5 a | cut -d ' ' -f 4) = f47c75614087a8dd938ba4acff252494 ] || \
+ atf_fail "Invalid file contents"
+
+ echo "Testing write to a big file (bigger than a page)"
+ jot 10000 >b || atf_fail "Failed to create a big file"
+ [ $(md5 b | cut -d ' ' -f 4) = 72d4ff27a28afbc066d5804999d5a504 ] || \
+ atf_fail "Invalid file contents"
+
+ test_unmount
+}
+
+atf_test_case kqueue
+kqueue_head() {
+ atf_set "descr" "Checks that writing to a file raises the" \
+ "appropriate kqueue events"
+ atf_set "require.user" "root"
+}
+kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o ignore -e ignore \
+ dd if=/dev/zero of=c bs=1k count=10
+ echo 'dd if=/dev/zero of=c seek=2 bs=1k count=1 conv=notrunc' \
+ '>/dev/null 2>&1' | kqueue_monitor 1 c
+ kqueue_check c NOTE_WRITE
+
+ echo foo >d
+ echo 'echo bar >>d' | kqueue_monitor 2 d
+ kqueue_check d NOTE_EXTEND
+ kqueue_check d NOTE_WRITE
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case basic
+ atf_add_test_case kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh b/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh
new file mode 100755
index 0000000..6f5dc3e
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh
@@ -0,0 +1,116 @@
+# $NetBSD: t_readdir.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the readdir operation works.
+#
+
+atf_test_case dots
+dots_head() {
+ atf_set "descr" "Verifies that readdir returns the '.' and '..'" \
+ "entries"
+ atf_set "require.user" "root"
+}
+dots_body() {
+ test_mount
+
+ atf_check -s eq:0 -o save:stdout -e empty /bin/ls -a
+ atf_check -s eq:0 -o ignore -e empty grep '^\.$' stdout
+ atf_check -s eq:0 -o ignore -e empty grep '^\..$' stdout
+
+ test_unmount
+}
+
+atf_test_case types
+types_head() {
+ atf_set "descr" "Verifies that readdir works for all different" \
+ "file types"
+ atf_set "require.user" "root"
+}
+types_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ atf_check -s eq:0 -o empty -e empty touch reg
+ atf_check -s eq:0 -o empty -e empty ln -s reg lnk
+ atf_check -s eq:0 -o empty -e empty mknod blk b 0 0
+ atf_check -s eq:0 -o empty -e empty mknod chr c 0 0
+ atf_check -s eq:0 -o empty -e empty mknod fifo p
+ atf_check -s eq:0 -o empty -e empty \
+ $(atf_get_srcdir)/h_tools sockets sock
+
+ atf_check -s eq:0 -o ignore -e empty ls
+ atf_check -s eq:0 -o empty -e empty rm -rf *
+
+ test_unmount
+}
+
+atf_test_case caching
+caching_head() {
+ atf_set "descr" "Catch a bug caused by incorrect invalidation of" \
+ "readdir caching variables"
+ atf_set "require.user" "root"
+}
+caching_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty touch $(jot 10)
+ atf_check -s eq:0 -o empty -e empty rm *
+ atf_check -s eq:0 -o empty -e empty touch $(jot 20)
+ atf_check -s eq:0 -o empty -e empty -x "ls >/dev/null"
+
+ test_unmount
+}
+
+atf_test_case many
+many_head() {
+ atf_set "descr" "Verifies that readdir works with many files"
+ atf_set "require.user" "root"
+}
+many_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ echo "Creating 500 files"
+ for f in $(jot 500); do
+ touch a/$f
+ done
+ atf_check -s eq:0 -o empty -e empty rm a/*
+ atf_check -s eq:0 -o empty -e empty rmdir a
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case dots
+ atf_add_test_case types
+ atf_add_test_case caching
+ atf_add_test_case many
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_remove.sh b/contrib/netbsd-tests/fs/tmpfs/t_remove.sh
new file mode 100755
index 0000000..df868f9
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_remove.sh
@@ -0,0 +1,110 @@
+# $NetBSD: t_remove.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the remove operation works.
+#
+
+atf_test_case single
+single_head() {
+ atf_set "descr" "Checks that file removal works"
+ atf_set "require.user" "root"
+}
+single_body() {
+ test_mount
+
+ atf_check -s eq:1 -o empty -e empty test -f a
+ atf_check -s eq:0 -o empty -e empty touch a
+ atf_check -s eq:0 -o empty -e empty test -f a
+ atf_check -s eq:0 -o empty -e empty rm a
+ atf_check -s eq:1 -o empty -e empty test -f a
+
+ test_unmount
+}
+
+atf_test_case uchg
+uchg_head() {
+ atf_set "descr" "Checks that files with the uchg flag set cannot" \
+ "be removed"
+ atf_set "require.user" "root"
+}
+uchg_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty touch a
+ atf_check -s eq:0 -o empty -e empty chflags uchg a
+ atf_check -s eq:1 -o empty -e ignore rm -f a
+ atf_check -s eq:0 -o empty -e empty chflags nouchg a
+ atf_check -s eq:0 -o empty -e empty rm a
+ atf_check -s eq:1 -o empty -e empty test -f a
+
+ test_unmount
+}
+
+atf_test_case dot
+dot_head() {
+ atf_set "descr" "Checks that '.' cannot be removed"
+ atf_set "require.user" "root"
+}
+dot_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:1 -o empty -e ignore unlink a/.
+ atf_check -s eq:0 -o empty -e empty rmdir a
+
+ test_unmount
+}
+
+atf_test_case kqueue
+kqueue_head() {
+ atf_set "descr" "Removes a file and checks the kqueue events" \
+ "raised"
+ atf_set "require.user" "root"
+}
+kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ atf_check -s eq:0 -o empty -e empty touch dir/a
+ echo 'rm dir/a' | kqueue_monitor 2 dir dir/a
+ kqueue_check dir/a NOTE_DELETE
+ kqueue_check dir NOTE_WRITE
+ atf_check -s eq:0 -o empty -e empty rmdir dir
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case single
+ atf_add_test_case uchg
+ atf_add_test_case dot
+ atf_add_test_case kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_rename.sh b/contrib/netbsd-tests/fs/tmpfs/t_rename.sh
new file mode 100755
index 0000000..7613f1f
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_rename.sh
@@ -0,0 +1,278 @@
+# $NetBSD: t_rename.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the rename operation works (either by renaming entries or
+# by moving them).
+#
+
+atf_test_case dots
+dots_head() {
+ atf_set "descr" "Tests that '.' and '..' cannot be renamed"
+ atf_set "require.user" "root"
+}
+dots_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:1 -o empty -e ignore mv a/. c
+ atf_check -s eq:1 -o empty -e ignore mv a/.. c
+ atf_check -s eq:0 -o empty -e empty rmdir a
+
+ test_unmount
+}
+
+atf_test_case crossdev
+crossdev_head() {
+ atf_set "descr" "Tests that cross-device renames do not work"
+ atf_set "require.user" "root"
+}
+crossdev_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:1 -o empty -e save:stderr \
+ $(atf_get_srcdir)/h_tools rename a /var/tmp/a
+ atf_check -s eq:0 -o ignore -e empty grep "Cross-device link" stderr
+ atf_check -s eq:0 -o empty -e empty test -d a
+ atf_check -s eq:0 -o empty -e empty rmdir a
+
+ test_unmount
+}
+
+atf_test_case basic
+basic_head() {
+ atf_set "descr" "Tests that basic renames work"
+ atf_set "require.user" "root"
+}
+basic_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty mv a c
+ atf_check -s eq:1 -o empty -e empty test -d a
+ atf_check -s eq:0 -o empty -e empty test -d c
+ atf_check -s eq:0 -o empty -e empty rmdir c
+
+ test_unmount
+}
+
+atf_test_case dotdot
+dotdot_head() {
+ atf_set "descr" "Tests that the '..' entry is properly updated" \
+ "during moves"
+ atf_set "require.user" "root"
+}
+dotdot_body() {
+ test_mount
+
+ echo "Checking if the '..' entry is updated after moves"
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty mkdir b
+ atf_check -s eq:0 -o empty -e empty mv b a
+ atf_check -s eq:0 -o empty -e empty test -d a/b/../b
+ atf_check -s eq:0 -o empty -e empty test -d a/b/../../a
+ eval $(stat -s a/b)
+ [ ${st_nlink} = 2 ] || atf_fail "Incorrect number of links"
+ eval $(stat -s a)
+ [ ${st_nlink} = 3 ] || atf_fail "Incorrect number of links"
+ atf_check -s eq:0 -o empty -e empty rmdir a/b
+ atf_check -s eq:0 -o empty -e empty rmdir a
+
+ echo "Checking if the '..' entry is correct after renames"
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty mkdir b
+ atf_check -s eq:0 -o empty -e empty mv b a
+ atf_check -s eq:0 -o empty -e empty mv a c
+ atf_check -s eq:0 -o empty -e empty test -d c/b/../b
+ atf_check -s eq:0 -o empty -e empty test -d c/b/../../c
+ atf_check -s eq:0 -o empty -e empty rmdir c/b
+ atf_check -s eq:0 -o empty -e empty rmdir c
+
+ echo "Checking if the '..' entry is correct after multiple moves"
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty mkdir b
+ atf_check -s eq:0 -o empty -e empty mv b a
+ atf_check -s eq:0 -o empty -e empty mv a c
+ atf_check -s eq:0 -o empty -e empty mv c/b d
+ atf_check -s eq:0 -o empty -e empty test -d d/../c
+ atf_check -s eq:0 -o empty -e empty rmdir d
+ atf_check -s eq:0 -o empty -e empty rmdir c
+
+ test_unmount
+}
+
+atf_test_case dir_to_emptydir
+dir_to_emptydir_head() {
+ atf_set "descr" "Tests that renaming a directory to override an" \
+ "empty directory works"
+ atf_set "require.user" "root"
+}
+dir_to_emptydir_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty touch a/c
+ atf_check -s eq:0 -o empty -e empty mkdir b
+ atf_check -s eq:0 -o empty -e empty \
+ $(atf_get_srcdir)/h_tools rename a b
+ atf_check -s eq:1 -o empty -e empty test -e a
+ atf_check -s eq:0 -o empty -e empty test -d b
+ atf_check -s eq:0 -o empty -e empty test -f b/c
+ rm b/c
+ rmdir b
+
+ test_unmount
+}
+
+atf_test_case dir_to_fulldir
+dir_to_fulldir_head() {
+ atf_set "descr" "Tests that renaming a directory to override a" \
+ "non-empty directory fails"
+ atf_set "require.user" "root"
+}
+dir_to_fulldir_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty touch a/c
+ atf_check -s eq:0 -o empty -e empty mkdir b
+ atf_check -s eq:0 -o empty -e empty touch b/d
+ atf_check -s eq:1 -o empty -e save:stderr \
+ $(atf_get_srcdir)/h_tools rename a b
+ atf_check -s eq:0 -o ignore -e empty grep "Directory not empty" stderr
+ atf_check -s eq:0 -o empty -e empty test -d a
+ atf_check -s eq:0 -o empty -e empty test -f a/c
+ atf_check -s eq:0 -o empty -e empty test -d b
+ atf_check -s eq:0 -o empty -e empty test -f b/d
+ rm a/c
+ rm b/d
+ rmdir a
+ rmdir b
+
+ test_unmount
+}
+
+atf_test_case dir_to_file
+dir_to_file_head() {
+ atf_set "descr" "Tests that renaming a directory to override a" \
+ "file fails"
+ atf_set "require.user" "root"
+}
+dir_to_file_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty touch b
+ atf_check -s eq:1 -o empty -e save:stderr \
+ $(atf_get_srcdir)/h_tools rename a b
+ atf_check -s eq:0 -o ignore -e empty grep "Not a directory" stderr
+ atf_check -s eq:0 -o empty -e empty test -d a
+ atf_check -s eq:0 -o empty -e empty test -f b
+ rmdir a
+ rm b
+
+ test_unmount
+}
+
+atf_test_case file_to_dir
+file_to_dir_head() {
+ atf_set "descr" "Tests that renaming a file to override a" \
+ "directory fails"
+ atf_set "require.user" "root"
+}
+file_to_dir_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty touch a
+ atf_check -s eq:0 -o empty -e empty mkdir b
+ atf_check -s eq:1 -o empty -e save:stderr \
+ $(atf_get_srcdir)/h_tools rename a b
+ atf_check -s eq:0 -o ignore -e empty grep "Is a directory" stderr
+ atf_check -s eq:0 -o empty -e empty test -f a
+ atf_check -s eq:0 -o empty -e empty test -d b
+ rm a
+ rmdir b
+
+ test_unmount
+}
+
+atf_test_case kqueue
+kqueue_head() {
+ atf_set "descr" "Tests that moving and renaming files raise the" \
+ "correct kqueue events"
+ atf_set "require.user" "root"
+}
+kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ atf_check -s eq:0 -o empty -e empty touch dir/a
+ echo 'mv dir/a dir/b' | kqueue_monitor 2 dir dir/a
+ kqueue_check dir/a NOTE_RENAME
+ kqueue_check dir NOTE_WRITE
+ atf_check -s eq:0 -o empty -e empty rm dir/b
+ atf_check -s eq:0 -o empty -e empty rmdir dir
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ atf_check -s eq:0 -o empty -e empty touch dir/a
+ atf_check -s eq:0 -o empty -e empty touch dir/b
+ echo 'mv dir/a dir/b' | kqueue_monitor 3 dir dir/a dir/b
+ kqueue_check dir/a NOTE_RENAME
+ kqueue_check dir NOTE_WRITE
+ kqueue_check dir/b NOTE_DELETE
+ atf_check -s eq:0 -o empty -e empty rm dir/b
+ atf_check -s eq:0 -o empty -e empty rmdir dir
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir1
+ atf_check -s eq:0 -o empty -e empty mkdir dir2
+ atf_check -s eq:0 -o empty -e empty touch dir1/a
+ echo 'mv dir1/a dir2/a' | kqueue_monitor 3 dir1 dir1/a dir2
+ kqueue_check dir1/a NOTE_RENAME
+ kqueue_check dir1 NOTE_WRITE
+ kqueue_check dir2 NOTE_WRITE
+ atf_check -s eq:0 -o empty -e empty rm dir2/a
+ atf_check -s eq:0 -o empty -e empty rmdir dir1
+ atf_check -s eq:0 -o empty -e empty rmdir dir2
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case dots
+ atf_add_test_case crossdev
+ atf_add_test_case basic
+ atf_add_test_case dotdot
+ atf_add_test_case dir_to_emptydir
+ atf_add_test_case dir_to_fulldir
+ atf_add_test_case dir_to_file
+ atf_add_test_case file_to_dir
+ atf_add_test_case kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_renamerace.c b/contrib/netbsd-tests/fs/tmpfs/t_renamerace.c
new file mode 100644
index 0000000..044937a
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_renamerace.c
@@ -0,0 +1,115 @@
+/* $NetBSD: t_renamerace.c,v 1.13 2011/08/18 21:44:55 riastradh Exp $ */
+
+/*
+ * Modified for rump and atf from a program supplied
+ * by Nicolas Joly in kern/40948
+ */
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <sys/utsname.h>
+
+#include <atf-c.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include <fs/tmpfs/tmpfs_args.h>
+
+#include "../../h_macros.h"
+
+ATF_TC(renamerace2);
+ATF_TC_HEAD(renamerace2, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "rename(2) lock order inversion");
+ atf_tc_set_md_var(tc, "timeout", "6");
+}
+
+static volatile int quittingtime = 0;
+static pid_t wrkpid;
+
+static void *
+r2w1(void *arg)
+{
+ int fd;
+
+ rump_pub_lwproc_newlwp(wrkpid);
+
+ fd = rump_sys_open("/file", O_CREAT | O_RDWR, 0777);
+ if (fd == -1)
+ atf_tc_fail_errno("creat");
+ rump_sys_close(fd);
+
+ while (!quittingtime) {
+ if (rump_sys_rename("/file", "/dir/file") == -1)
+ atf_tc_fail_errno("rename 1");
+ if (rump_sys_rename("/dir/file", "/file") == -1)
+ atf_tc_fail_errno("rename 2");
+ }
+
+ return NULL;
+}
+
+static void *
+r2w2(void *arg)
+{
+ int fd;
+
+ rump_pub_lwproc_newlwp(wrkpid);
+
+ while (!quittingtime) {
+ fd = rump_sys_open("/dir/file1", O_RDWR);
+ if (fd != -1)
+ rump_sys_close(fd);
+ }
+
+ return NULL;
+}
+
+ATF_TC_BODY(renamerace2, tc)
+{
+ struct tmpfs_args args;
+ pthread_t pt[2];
+
+ /*
+ * Force SMP regardless of how many host CPUs there are.
+ * Deadlock is highly unlikely to trigger otherwise.
+ */
+ setenv("RUMP_NCPU", "2", 1);
+
+ rump_init();
+ memset(&args, 0, sizeof(args));
+ args.ta_version = TMPFS_ARGS_VERSION;
+ args.ta_root_mode = 0777;
+ if (rump_sys_mount(MOUNT_TMPFS, "/", 0, &args, sizeof(args)) == -1)
+ atf_tc_fail_errno("could not mount tmpfs");
+
+ if (rump_sys_mkdir("/dir", 0777) == -1)
+ atf_tc_fail_errno("cannot create directory");
+
+ RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
+ RL(wrkpid = rump_sys_getpid());
+ pthread_create(&pt[0], NULL, r2w1, NULL);
+ pthread_create(&pt[1], NULL, r2w2, NULL);
+
+ /* usually triggers in <<1s for me */
+ sleep(4);
+ quittingtime = 1;
+
+ pthread_join(pt[0], NULL);
+ pthread_join(pt[1], NULL);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, renamerace2);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_rmdir.sh b/contrib/netbsd-tests/fs/tmpfs/t_rmdir.sh
new file mode 100755
index 0000000..9e5d761
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_rmdir.sh
@@ -0,0 +1,204 @@
+# $NetBSD: t_rmdir.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that rmdir works by creating and removing directories. Also
+# checks multiple error conditions.
+#
+
+atf_test_case mntpt
+mntpt_head() {
+ atf_set "descr" "Checks that the mount point cannot be removed"
+ atf_set "require.user" "root"
+}
+mntpt_body() {
+ test_mount
+
+ atf_check -s eq:1 -o empty -e ignore rmdir ${Mount_Point}
+
+ test_unmount
+}
+
+atf_test_case non_existent
+non_existent_head() {
+ atf_set "descr" "Checks that non-existent directories cannot" \
+ "be removed"
+ atf_set "require.user" "root"
+}
+non_existent_body() {
+ test_mount
+
+ atf_check -s eq:1 -o empty -e ignore rmdir non-existent
+
+ test_unmount
+}
+
+atf_test_case single
+single_head() {
+ atf_set "descr" "Checks that removing a single directory works"
+ atf_set "require.user" "root"
+}
+single_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ eval $(stat -s ${Mount_Point})
+ [ ${st_nlink} = 3 ] || \
+ atf_fail "Incorrect number of links after creation"
+ atf_check -s eq:0 -o empty -e empty rmdir a
+ eval $(stat -s ${Mount_Point})
+ [ ${st_nlink} = 2 ] || \
+ atf_fail "Incorrect number of links after removal"
+
+ test_unmount
+}
+
+atf_test_case nested
+nested_head() {
+ atf_set "descr" "Checks that removing nested directories works"
+ atf_set "require.user" "root"
+}
+nested_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir -p a/b/c
+ atf_check -s eq:0 -o empty -e empty rmdir a/b/c
+ atf_check -s eq:0 -o empty -e empty rmdir a/b
+ atf_check -s eq:0 -o empty -e empty rmdir a
+
+ test_unmount
+}
+
+atf_test_case dots
+dots_head() {
+ atf_set "descr" "Checks that '.' and '..' cannot be removed"
+ atf_set "require.user" "root"
+}
+dots_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:1 -o empty -e ignore rmdir a/.
+ atf_check -s eq:1 -o empty -e ignore rmdir a/..
+ atf_check -s eq:0 -o empty -e empty rmdir a
+
+ test_unmount
+}
+
+atf_test_case non_empty
+non_empty_head() {
+ atf_set "descr" "Checks that non-empty directories cannot be removed"
+ atf_set "require.user" "root"
+}
+non_empty_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty mkdir a/b
+ atf_check -s eq:0 -o empty -e empty mkdir a/c
+ atf_check -s eq:1 -o empty -e ignore rmdir a
+ atf_check -s eq:0 -o empty -e empty rmdir a/b
+ atf_check -s eq:0 -o empty -e empty rmdir a/c
+ atf_check -s eq:0 -o empty -e empty rmdir a
+
+ test_unmount
+}
+
+atf_test_case links
+links_head() {
+ atf_set "descr" "Checks the root directory's links after removals"
+ atf_set "require.user" "root"
+}
+links_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ atf_check -s eq:0 -o empty -e empty mkdir a/b
+ atf_check -s eq:0 -o empty -e empty mkdir c
+
+ atf_check -s eq:0 -o empty -e empty rmdir c
+ atf_check -s eq:0 -o empty -e empty rmdir a/b
+ atf_check -s eq:0 -o empty -e empty rmdir a
+
+ eval $(stat -s ${Mount_Point})
+ [ ${st_nlink} = 2 ] || atf_fail "Incorrect number of links"
+
+ test_unmount
+}
+
+atf_test_case curdir
+curdir_head() {
+ atf_set "descr" "Checks that the current directory cannot be removed"
+ atf_set "require.user" "root"
+}
+curdir_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a
+ # Catch a bug that would panic the system when accessing the
+ # current directory after being deleted: vop_open cannot assume
+ # that open files are still linked to a directory.
+ atf_check -s eq:1 -o empty -e ignore -x '( cd a && rmdir ../a && ls )'
+ atf_check -s eq:1 -o empty -e empty test -e a
+
+ test_unmount
+}
+
+atf_test_case kqueue
+kqueue_head() {
+ atf_set "descr" "Checks that removing a directory raises the" \
+ "correct kqueue events"
+ atf_set "require.user" "root"
+}
+kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ atf_check -s eq:0 -o empty -e empty mkdir dir/a
+ echo 'rmdir dir/a' | kqueue_monitor 3 dir dir/a
+ kqueue_check dir/a NOTE_DELETE
+ kqueue_check dir NOTE_LINK
+ kqueue_check dir NOTE_WRITE
+ atf_check -s eq:0 -o empty -e empty rmdir dir
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case mntpt
+ atf_add_test_case non_existent
+ atf_add_test_case single
+ atf_add_test_case nested
+ atf_add_test_case dots
+ atf_add_test_case non_empty
+ atf_add_test_case links
+ atf_add_test_case curdir
+ atf_add_test_case kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_setattr.sh b/contrib/netbsd-tests/fs/tmpfs/t_setattr.sh
new file mode 100755
index 0000000..f643446
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_setattr.sh
@@ -0,0 +1,216 @@
+# $NetBSD: t_setattr.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the setattr vnode operation works, using several commands
+# that require this function.
+#
+
+atf_test_case chown
+chown_head() {
+ atf_set "descr" "Tests that the file owner can be changed"
+ atf_set "require.user" "root"
+}
+chown_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir own
+ eval $(stat -s own | sed -e 's|st_|ost_|g')
+ atf_check -s eq:0 -o empty -e empty chown 1234 own
+ eval $(stat -s own)
+ [ ${st_uid} -eq 1234 ] || atf_fail "uid was not set"
+ [ ${st_gid} -eq ${ost_gid} ] || atf_fail "gid was modified"
+
+ test_unmount
+}
+
+atf_test_case chown_kqueue
+chown_kqueue_head() {
+ atf_set "descr" "Tests that changing the file owner raises" \
+ "NOTE_ATTRIB on it"
+ atf_set "require.user" "root"
+}
+chown_kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir ownq
+ echo 'chown 1234 ownq' | kqueue_monitor 1 ownq
+ kqueue_check ownq NOTE_ATTRIB
+
+ test_unmount
+}
+
+atf_test_case chgrp
+chgrp_head() {
+ atf_set "descr" "Tests that the file group can be changed"
+ atf_set "require.user" "root"
+}
+chgrp_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir grp
+ eval $(stat -s grp | sed -e 's|st_|ost_|g')
+ atf_check -s eq:0 -o empty -e empty chgrp 5678 grp
+ eval $(stat -s grp)
+ [ ${st_uid} -eq ${ost_uid} ] || atf_fail "uid was modified"
+ [ ${st_gid} -eq 5678 ] || atf_fail "gid was not set"
+
+ test_unmount
+}
+
+atf_test_case chgrp_kqueue
+chgrp_kqueue_head() {
+ atf_set "descr" "Tests that changing the file group raises" \
+ "NOTE_ATTRIB on it"
+ atf_set "require.user" "root"
+}
+chgrp_kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir grpq
+ echo 'chgrp 1234 grpq' | kqueue_monitor 1 grpq
+ kqueue_check grpq NOTE_ATTRIB
+
+ test_unmount
+}
+
+atf_test_case chowngrp
+chowngrp_head() {
+ atf_set "descr" "Tests that the file owner and group can be" \
+ "changed at once"
+ atf_set "require.user" "root"
+}
+chowngrp_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir owngrp
+ atf_check -s eq:0 -o empty -e empty chown 1234:5678 owngrp
+ eval $(stat -s owngrp)
+ [ ${st_uid} -eq 1234 ] || atf_fail "uid was not modified"
+ [ ${st_gid} -eq 5678 ] || atf_fail "gid was not modified"
+
+ test_unmount
+}
+
+atf_test_case chowngrp_kqueue
+chowngrp_kqueue_head() {
+ atf_set "descr" "Tests that changing the file owner and group" \
+ "raises NOTE_ATTRIB on it"
+ atf_set "require.user" "root"
+}
+chowngrp_kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir owngrpp
+ echo 'chown 1234:5678 owngrpp' | kqueue_monitor 1 owngrpp
+ kqueue_check owngrpp NOTE_ATTRIB
+
+ test_unmount
+}
+
+atf_test_case chmod
+chmod_head() {
+ atf_set "descr" "Tests that the file mode can be changed"
+ atf_set "require.user" "root"
+}
+chmod_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir mode
+ atf_check -s eq:0 -o empty -e empty chmod 0000 mode
+ eval $(stat -s mode)
+ [ ${st_mode} -eq 40000 ] || af_fail "mode was not set"
+
+ test_unmount
+}
+
+atf_test_case chmod_kqueue
+chmod_kqueue_head() {
+ atf_set "descr" "Tests that changing the file mode raises" \
+ "NOTE_ATTRIB on it"
+ atf_set "require.user" "root"
+}
+chmod_kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir modeq
+ echo 'chmod 0000 modeq' | kqueue_monitor 1 modeq
+ kqueue_check modeq NOTE_ATTRIB
+
+ test_unmount
+}
+
+atf_test_case chtimes
+chtimes_head() {
+ atf_set "descr" "Tests that file times can be changed"
+ atf_set "require.user" "root"
+}
+chtimes_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir times
+ atf_check -s eq:0 -o empty -e empty \
+ -x 'TZ=GMT touch -t 200501010101 times'
+ eval $(stat -s times)
+ [ ${st_atime} = ${st_mtime} ] || \
+ atf_fail "atime does not match mtime"
+ [ ${st_atime} = 1104541260 ] || atf_fail "atime does not match"
+
+ test_unmount
+}
+
+atf_test_case chtimes_kqueue
+chtimes_kqueue_head() {
+ atf_set "descr" "Tests that changing the file times raises" \
+ "NOTE_ATTRIB on it"
+ atf_set "require.user" "root"
+}
+chtimes_kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir timesq
+ echo 'touch timesq' | kqueue_monitor 1 timesq
+ kqueue_check timesq NOTE_ATTRIB
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case chown
+ atf_add_test_case chown_kqueue
+ atf_add_test_case chgrp
+ atf_add_test_case chgrp_kqueue
+ atf_add_test_case chowngrp
+ atf_add_test_case chowngrp_kqueue
+ atf_add_test_case chmod
+ atf_add_test_case chmod_kqueue
+ atf_add_test_case chtimes
+ atf_add_test_case chtimes_kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh b/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh
new file mode 100755
index 0000000..9673b91
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh
@@ -0,0 +1,131 @@
+# $NetBSD: t_sizes.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the file system controls memory usage correctly.
+#
+
+atf_test_case small
+small_head() {
+ atf_set "descr" "Checks the status after creating a small file"
+ atf_set "require.user" "root"
+}
+small_body() {
+ test_mount -o -s10M
+
+ echo a >a || atf_fail "Could not create file"
+ eval $($(atf_get_srcdir)/h_tools statvfs .)
+ f_bused=$((${f_blocks} - ${f_bfree}))
+ [ ${f_bused} -gt 1 ] || atf_fail "Incorrect bused count"
+ atf_check -s eq:0 -o empty -e empty rm a
+
+ test_unmount
+}
+
+atf_test_case big
+big_head() {
+ atf_set "descr" "Checks the status after creating a big file"
+ atf_set "require.user" "root"
+}
+big_body() {
+ test_mount -o -s10M
+
+ pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3)
+ eval $($(atf_get_srcdir)/h_tools statvfs . | sed -e 's|^f_|cf_|')
+ cf_bused=$((${cf_blocks} - ${cf_bfree}))
+
+ atf_check -s eq:0 -o ignore -e ignore \
+ dd if=/dev/zero of=a bs=1m count=5
+ eval $($(atf_get_srcdir)/h_tools statvfs .)
+ f_bused=$((${f_blocks} - ${f_bfree}))
+ [ ${f_bused} -ne ${cf_bused} ] || atf_fail "bused did not change"
+ [ ${f_bused} -gt $((5 * 1024 * 1024 / ${pagesize})) ] || \
+ atf_fail "bused too big"
+ of_bused=${f_bused}
+ atf_check -s eq:0 -o empty -e empty rm a
+ eval $($(atf_get_srcdir)/h_tools statvfs .)
+ f_bused=$((${f_blocks} - ${f_bfree}))
+ [ ${f_bused} -lt ${of_bused} ] || \
+ atf_fail "bused was not correctly restored"
+
+ test_unmount
+}
+
+atf_test_case overflow
+overflow_head() {
+ atf_set "descr" "Checks the status after creating a big file that" \
+ "overflows the file system limits"
+ atf_set "require.user" "root"
+}
+overflow_body() {
+ test_mount -o -s10M
+
+ atf_check -s eq:0 -o empty -e empty touch a
+ atf_check -s eq:0 -o empty -e empty rm a
+ eval $($(atf_get_srcdir)/h_tools statvfs .)
+ of_bused=$((${f_blocks} - ${f_bfree}))
+ atf_check -s eq:1 -o ignore -e ignore \
+ dd if=/dev/zero of=a bs=1m count=15
+ atf_check -s eq:0 -o empty -e empty rm a
+ eval $($(atf_get_srcdir)/h_tools statvfs .)
+ f_bused=$((${f_blocks} - ${f_bfree}))
+ [ ${f_bused} -ge ${of_bused} -a ${f_bused} -le $((${of_bused} + 1)) ] \
+ || atf_fail "Incorrect bused"
+
+ test_unmount
+}
+
+atf_test_case overwrite
+overwrite_head() {
+ atf_set "descr" "Checks that writing to the middle of a file" \
+ "does not change its size"
+ atf_set "require.user" "root"
+}
+overwrite_body() {
+ test_mount -o -s10M
+
+ atf_check -s eq:0 -o ignore -e ignore \
+ dd if=/dev/zero of=a bs=1024 count=10
+ sync
+ atf_check -s eq:0 -o ignore -e ignore \
+ dd if=/dev/zero of=a bs=1024 conv=notrunc seek=1 count=1
+ sync
+ eval $(stat -s a)
+ [ ${st_size} -eq 10240 ] || atf_fail "Incorrect file size"
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case small
+ atf_add_test_case big
+ atf_add_test_case overflow
+ atf_add_test_case overwrite
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_sockets.sh b/contrib/netbsd-tests/fs/tmpfs/t_sockets.sh
new file mode 100755
index 0000000..6b97248
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_sockets.sh
@@ -0,0 +1,52 @@
+# $NetBSD: t_sockets.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+atf_test_case basic
+basic_head() {
+ atf_set "descr" "Verifies that sockets can be created using" \
+ "socket/bind"
+ atf_set "require.user" "root"
+}
+basic_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty $(atf_get_srcdir)/h_tools sockets a
+ atf_check -s eq:0 -o empty -e empty rm a
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ echo "$(atf_get_srcdir)/h_tools sockets dir/a" | kqueue_monitor 1 dir
+ kqueue_check dir NOTE_WRITE
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case basic
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh b/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh
new file mode 100755
index 0000000..21290b6
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh
@@ -0,0 +1,59 @@
+# $NetBSD: t_statvfs.sh,v 1.4 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the statvfs system call works properly (returning the
+# correct values) over a tmpfs mount point.
+#
+
+atf_test_case values
+values_head() {
+ atf_set "descr" "Tests that statvfs(2) returns correct values"
+ atf_set "require.user" "root"
+}
+values_body() {
+ test_mount -o -s10M
+
+ pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3)
+ eval $($(atf_get_srcdir)/h_tools statvfs .)
+ [ ${pagesize} -eq ${f_bsize} ] || \
+ atf_fail "Invalid bsize"
+ [ $((${f_bsize} * ${f_blocks})) -ge $((10 * 1024 * 1024)) ] || \
+ atf_file "bsize * blocks too small"
+ [ $((${f_bsize} * ${f_blocks})) -le \
+ $((10 * 1024 * 1024 + ${pagesize})) ] || \
+ atf_fail "bsize * blocks too big"
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case values
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_symlink.sh b/contrib/netbsd-tests/fs/tmpfs/t_symlink.sh
new file mode 100755
index 0000000..2cc66c0
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_symlink.sh
@@ -0,0 +1,114 @@
+# $NetBSD: t_symlink.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that the symlink and readlink operations work.
+#
+
+atf_test_case file
+file_head() {
+ atf_set "descr" "Tests that symlinks to files work"
+ atf_set "require.user" "root"
+}
+file_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty touch a
+ atf_check -s eq:0 -o empty -e empty ln -s a b
+ [ $(md5 b | cut -d ' ' -f 4) = d41d8cd98f00b204e9800998ecf8427e ] || \
+ atf_fail "Symlink points to an incorrect file"
+
+ atf_check -s eq:0 -o empty -e empty -x 'echo foo >a'
+ [ $(md5 b | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || \
+ atf_fail "Symlink points to an incorrect file"
+
+ test_unmount
+}
+
+atf_test_case exec
+exec_head() {
+ atf_set "descr" "Tests symlinking to a known system binary and" \
+ "executing it through the symlink"
+ atf_set "require.user" "root"
+}
+exec_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty touch b
+ atf_check -s eq:0 -o empty -e empty ln -s /bin/cp cp
+ atf_check -s eq:0 -o empty -e empty ./cp b c
+ atf_check -s eq:0 -o empty -e empty test -f c
+
+ test_unmount
+}
+
+atf_test_case dir
+dir_head() {
+ atf_set "descr" "Tests that symlinks to directories work"
+ atf_set "require.user" "root"
+}
+dir_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir d
+ atf_check -s eq:1 -o empty -e empty test -f d/foo
+ atf_check -s eq:1 -o empty -e empty test -f e/foo
+ atf_check -s eq:0 -o empty -e empty ln -s d e
+ atf_check -s eq:0 -o empty -e empty touch d/foo
+ atf_check -s eq:0 -o empty -e empty test -f d/foo
+ atf_check -s eq:0 -o empty -e empty test -f e/foo
+
+ test_unmount
+}
+
+atf_test_case kqueue
+kqueue_head() {
+ atf_set "descr" "Tests that creating a symlink raises the" \
+ "appropriate kqueue events"
+ atf_set "require.user" "root"
+}
+kqueue_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir dir
+ echo 'ln -s non-existent dir/a' | kqueue_monitor 1 dir
+ kqueue_check dir NOTE_WRITE
+ atf_check -s eq:0 -o empty -e empty rm dir/a
+ atf_check -s eq:0 -o empty -e empty rmdir dir
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case file
+ atf_add_test_case exec
+ atf_add_test_case dir
+ atf_add_test_case kqueue
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_times.sh b/contrib/netbsd-tests/fs/tmpfs/t_times.sh
new file mode 100755
index 0000000..f83dfe8
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_times.sh
@@ -0,0 +1,141 @@
+# $NetBSD: t_times.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that node times are properly handled.
+#
+
+atf_test_case empty
+empty_head() {
+ atf_set "descr" "Tests that creating an empty file and later" \
+ "manipulating it updates times correctly"
+ atf_set "require.user" "root"
+}
+empty_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty touch a
+ eval $(stat -s a | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
+ [ ${ost_birthtime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
+ [ ${ost_birthtime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
+ [ ${ost_birthtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
+
+ sleep 1
+ atf_check -s eq:0 -o ignore -e empty cat a
+ eval $(stat -s a) || atf_fail "stat failed"
+ [ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
+ [ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
+ [ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
+
+ sleep 1
+ echo foo >a || atf_fail "Write failed"
+ eval $(stat -s a) || atf_fail "stat failed"
+ [ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
+ [ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
+ [ ${st_mtime} -gt ${ost_mtime} ] || atf_fail "Incorrect mtime"
+
+ test_unmount
+}
+
+atf_test_case non_empty
+non_empty_head() {
+ atf_set "descr" "Tests that creating a non-empty file and later" \
+ "manipulating it updates times correctly"
+ atf_set "require.user" "root"
+}
+non_empty_body() {
+ test_mount
+
+ echo foo >b || atf_fail "Non-empty creation failed"
+ eval $(stat -s b | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
+
+ sleep 1
+ atf_check -s eq:0 -o ignore -e empty cat b
+ eval $(stat -s b) || atf_fail "stat failed"
+ [ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
+ [ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
+ [ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
+
+ test_unmount
+}
+
+atf_test_case link
+link_head() {
+ atf_set "descr" "Tests that linking to an existing file updates" \
+ "times correctly"
+ atf_set "require.user" "root"
+}
+link_body() {
+ test_mount
+
+ echo foo >c || atf_fail "Non-empty creation failed"
+ eval $(stat -s c | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
+
+ sleep 1
+ atf_check -s eq:0 -o empty -e empty ln c d
+ eval $(stat -s c) || atf_fail "stat failed"
+ [ ${st_atime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
+ [ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
+ [ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
+
+ test_unmount
+}
+
+atf_test_case rename
+rename_head() {
+ atf_set "descr" "Tests that renaming an existing file updates" \
+ "times correctly"
+ atf_set "require.user" "root"
+}
+rename_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir e
+ echo foo >e/a || atf_fail "Creation failed"
+ eval $(stat -s e | sed -e 's|st_|dost_|g') || atf_fail "stat failed"
+ eval $(stat -s e/a | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
+ sleep 1
+ atf_check -s eq:0 -o empty -e empty mv e/a e/b
+ eval $(stat -s e | sed -e 's|st_|dst_|g') || atf_fail "stat failed"
+ eval $(stat -s e/b) || atf_fail "stat failed"
+ [ ${st_atime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
+ [ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
+ [ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
+ [ ${dst_mtime} -gt ${dost_mtime} ] || atf_fail "Incorrect mtime"
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case empty
+ atf_add_test_case non_empty
+ atf_add_test_case link
+ atf_add_test_case rename
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_trail_slash.sh b/contrib/netbsd-tests/fs/tmpfs/t_trail_slash.sh
new file mode 100755
index 0000000..df5b023
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_trail_slash.sh
@@ -0,0 +1,52 @@
+# $NetBSD: t_trail_slash.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+atf_test_case main
+main_head() {
+ atf_set "descr" "Verifies that trailing slashes are not stored" \
+ "in directory names and that they do not cause" \
+ "crashes"
+ atf_set "require.user" "root"
+}
+main_body() {
+ test_mount
+
+ atf_check -s eq:0 -o empty -e empty mkdir a/
+ atf_check -s eq:0 -o empty -e empty touch a/b
+ atf_check -s eq:0 -o empty -e empty test -f a/b
+ atf_check -s eq:0 -o empty -e empty rm a/b
+ atf_check -s eq:0 -o empty -e empty rmdir a/
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case main
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_truncate.sh b/contrib/netbsd-tests/fs/tmpfs/t_truncate.sh
new file mode 100755
index 0000000..2bc1902
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_truncate.sh
@@ -0,0 +1,56 @@
+# $NetBSD: t_truncate.sh,v 1.4 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+atf_test_case basic
+basic_head() {
+ atf_set "descr" "Verifies that the truncate operation works"
+ atf_set "require.user" "root"
+}
+basic_body() {
+ test_mount
+
+ echo "Creating big file"
+ jot 10000 >a || atf_fail "Failed to create big file"
+ echo "Trunctaing the file to a smaller size"
+ echo foo >a || atf_fail "Failed to truncate file to a smaller size"
+ [ $(md5 a | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || \
+ echo "Truncated file is incorrect"
+
+ echo "Truncating to zero bytes"
+ >a || atf_fail "Failed to truncate to 0"
+ echo "Truncating to zero bytes, second try"
+ >a || atf_fail "Failed to re-truncate to 0"
+
+ test_unmount
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case basic
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_vnd.sh b/contrib/netbsd-tests/fs/tmpfs/t_vnd.sh
new file mode 100755
index 0000000..2c97fa9
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_vnd.sh
@@ -0,0 +1,78 @@
+# $NetBSD: t_vnd.sh,v 1.8 2011/04/21 22:26:46 haad Exp $
+#
+# Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Verifies that vnd works with files stored in tmpfs.
+#
+
+atf_test_case basic cleanup
+basic_head() {
+ atf_set "descr" "Verifies that vnd works with files stored in tmpfs"
+ atf_set "require.user" "root"
+}
+basic_body() {
+ test_mount
+
+ atf_check -s eq:0 -o ignore -e ignore \
+ dd if=/dev/zero of=disk.img bs=1m count=10
+ atf_check -s eq:0 -o empty -e empty vnconfig /dev/vnd3 disk.img
+
+ atf_check -s eq:0 -o ignore -e ignore newfs /dev/rvnd3a
+
+ atf_check -s eq:0 -o empty -e empty mkdir mnt
+ atf_check -s eq:0 -o empty -e empty mount /dev/vnd3a mnt
+
+ echo "Creating test files"
+ for f in $(jot -w %u 100 | uniq); do
+ jot 1000 >mnt/${f} || atf_fail "Failed to create file ${f}"
+ done
+
+ echo "Verifying created files"
+ for f in $(jot -w %u 100 | uniq); do
+ [ $(md5 mnt/${f} | cut -d ' ' -f 4) = \
+ 53d025127ae99ab79e8502aae2d9bea6 ] || \
+ atf_fail "Invalid checksum for file ${f}"
+ done
+
+ atf_check -s eq:0 -o empty -e empty umount mnt
+ atf_check -s eq:0 -o empty -e empty vnconfig -u /dev/vnd3
+
+ test_unmount
+ touch done
+}
+basic_cleanup() {
+ if [ ! -f done ]; then
+ umount mnt 2>/dev/null 1>&2
+ vnconfig -u /dev/vnd3 2>/dev/null 1>&2
+ fi
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case basic
+}
diff --git a/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh b/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh
new file mode 100755
index 0000000..c505ffd
--- /dev/null
+++ b/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh
@@ -0,0 +1,60 @@
+# $NetBSD: t_vnode_leak.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $
+#
+# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+atf_test_case main cleanup
+main_head() {
+ atf_set "descr" "Verifies that vnodes are not leaked and that" \
+ "their reclaim operation works as expected: i.e.," \
+ "when all free vnodes are exhausted, unused ones" \
+ "have to be recycled, which is what the reclaim" \
+ "operation does."
+ atf_set "require.user" "root"
+}
+main_body() {
+ echo "Lowering kern.maxvnodes to 2000"
+ sysctl kern.maxvnodes | awk '{ print $3; }' >oldvnodes
+ atf_check -s eq:0 -o ignore -e empty sysctl -w kern.maxvnodes=2000
+
+ test_mount -o -s$(((4000 + 2) * 4096))
+ echo "Creating 4000 directories"
+ for f in $(jot 4000); do
+ mkdir ${f}
+ done
+ test_unmount
+}
+main_cleanup() {
+ oldvnodes=$(cat oldvnodes)
+ echo "Restoring kern.maxvnodes to ${oldvnodes}"
+ sysctl -w kern.maxvnodes=${oldvnodes}
+}
+
+atf_init_test_cases() {
+ . $(atf_get_srcdir)/../h_funcs.subr
+ . $(atf_get_srcdir)/h_funcs.subr
+
+ atf_add_test_case main
+}
OpenPOWER on IntegriCloud