summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/fs/vfs
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/fs/vfs')
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_full.c4
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_io.c4
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_mtime_otrunc.c86
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_renamerace.c4
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_ro.c4
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_rwtoro.c233
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_union.c4
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_unpriv.c4
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_vfsops.c4
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_vnops.c4
10 files changed, 335 insertions, 16 deletions
diff --git a/contrib/netbsd-tests/fs/vfs/t_full.c b/contrib/netbsd-tests/fs/vfs/t_full.c
index f338a02..51347de 100644
--- a/contrib/netbsd-tests/fs/vfs/t_full.c
+++ b/contrib/netbsd-tests/fs/vfs/t_full.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_full.c,v 1.8 2013/03/16 05:45:37 jmmv Exp $ */
+/* $NetBSD: t_full.c,v 1.9 2017/01/13 21:30:40 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
#include <rump/rump.h>
#include "../common/h_fsmacros.h"
-#include "../../h_macros.h"
+#include "h_macros.h"
/*
* Write this much over the image size. This is to force an NFS commit,
diff --git a/contrib/netbsd-tests/fs/vfs/t_io.c b/contrib/netbsd-tests/fs/vfs/t_io.c
index 23c3a15..b7f6529 100644
--- a/contrib/netbsd-tests/fs/vfs/t_io.c
+++ b/contrib/netbsd-tests/fs/vfs/t_io.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_io.c,v 1.16 2015/04/04 12:34:44 riastradh Exp $ */
+/* $NetBSD: t_io.c,v 1.17 2017/01/13 21:30:40 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
#include <rump/rump.h>
#include "../common/h_fsmacros.h"
-#include "../../h_macros.h"
+#include "h_macros.h"
#define TESTSTR "this is a string. collect enough and you'll have Em"
#define TESTSZ sizeof(TESTSTR)
diff --git a/contrib/netbsd-tests/fs/vfs/t_mtime_otrunc.c b/contrib/netbsd-tests/fs/vfs/t_mtime_otrunc.c
new file mode 100644
index 0000000..bb07609
--- /dev/null
+++ b/contrib/netbsd-tests/fs/vfs/t_mtime_otrunc.c
@@ -0,0 +1,86 @@
+/*-
+ * Copyright (c) 2017 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.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2013\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_mtime_otrunc.c,v 1.1 2017/02/02 22:07:05 martin Exp $");
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <atf-c.h>
+
+#include <rump/rump_syscalls.h>
+#include <rump/rump.h>
+
+#include "../common/h_fsmacros.h"
+
+#define LOCKFILE "lock"
+
+static time_t
+lock_it(void)
+{
+ struct stat st;
+
+ if (rump_sys_stat(LOCKFILE, &st) != 0)
+ st.st_mtime = 0;
+
+ int f = rump_sys_open(LOCKFILE, O_WRONLY|O_CREAT|O_TRUNC, 0666);
+ if (f == -1) return 0;
+ rump_sys_close(f);
+
+ return st.st_mtime;
+}
+
+static void
+otrunc_mtime_update(const atf_tc_t *tc, const char *path)
+{
+ time_t last_ts = 0;
+ int res;
+
+ /* atf_tc_expect_fail("PR kern/51762"); */
+
+ res = rump_sys_chdir(path);
+ if (res == -1)
+ atf_tc_fail("chdir failed");
+
+ for (int i = 0; i < 5; i++) {
+ time_t l = lock_it();
+ printf("last lock: %ld\n", (long)l);
+ ATF_REQUIRE_MSG(i == 0 || l > last_ts,
+ "iteration %d: lock time did not increase, old time %lu, "
+ "new time %lu", i,
+ (unsigned long)last_ts, (unsigned long)l);
+ last_ts = l;
+ sleep(2);
+ }
+ rump_sys_chdir("/");
+}
+
+ATF_FSAPPLY(otrunc_mtime_update, "Checks for mtime updates by open(O_TRUNC) (PR kern/51762)");
diff --git a/contrib/netbsd-tests/fs/vfs/t_renamerace.c b/contrib/netbsd-tests/fs/vfs/t_renamerace.c
index 809c380..63cfb44 100644
--- a/contrib/netbsd-tests/fs/vfs/t_renamerace.c
+++ b/contrib/netbsd-tests/fs/vfs/t_renamerace.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_renamerace.c,v 1.33 2016/05/04 08:30:22 dholland Exp $ */
+/* $NetBSD: t_renamerace.c,v 1.34 2017/01/13 21:30:40 christos Exp $ */
/*
* Modified for rump and atf from a program supplied
@@ -34,7 +34,7 @@
#define FSTEST_IMGSIZE (50000 * 512)
#include "../common/h_fsmacros.h"
-#include "../../h_macros.h"
+#include "h_macros.h"
static volatile int quittingtime;
pid_t wrkpid;
diff --git a/contrib/netbsd-tests/fs/vfs/t_ro.c b/contrib/netbsd-tests/fs/vfs/t_ro.c
index b1e1179..f7f4581 100644
--- a/contrib/netbsd-tests/fs/vfs/t_ro.c
+++ b/contrib/netbsd-tests/fs/vfs/t_ro.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ro.c,v 1.5 2011/02/22 21:23:19 yamt Exp $ */
+/* $NetBSD: t_ro.c,v 1.6 2017/01/13 21:30:40 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
#include <rump/rump.h>
#include "../common/h_fsmacros.h"
-#include "../../h_macros.h"
+#include "h_macros.h"
#define AFILE "testfile"
#define ADIR "testdir"
diff --git a/contrib/netbsd-tests/fs/vfs/t_rwtoro.c b/contrib/netbsd-tests/fs/vfs/t_rwtoro.c
new file mode 100644
index 0000000..ca8af07
--- /dev/null
+++ b/contrib/netbsd-tests/fs/vfs/t_rwtoro.c
@@ -0,0 +1,233 @@
+/* $NetBSD: t_rwtoro.c,v 1.1 2017/01/27 10:45:11 hannken Exp $ */
+
+/*-
+ * Copyright (c) 2017 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.
+ */
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/statvfs.h>
+
+#include <atf-c.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <rump/rump_syscalls.h>
+#include <rump/rump.h>
+
+#include <miscfs/nullfs/null.h>
+#include <fs/tmpfs/tmpfs_args.h>
+
+#include "../common/h_fsmacros.h"
+#include "../../h_macros.h"
+
+static const char *unsupported = "fs does not support r/o remount";
+static char file_path[MAXPATHLEN];
+static int file_fd;
+
+/*
+ * Remount the filesystem read-only and test errno.
+ * Skip filesystems that don't implement read-write -> read-only.
+ */
+static void
+remount_ro(const atf_tc_t *tc, const char *mp, int expected_errno)
+{
+ int error;
+ union {
+ struct tmpfs_args tmpfs;
+ char data[4095];
+ } mount_args;
+ int mount_args_length;
+ struct statvfs sbuf;
+
+ if (FSTYPE_ZFS(tc))
+ atf_tc_skip("%s", unsupported);
+
+ /* Prepare mount arguments. */
+ RL(rump_sys_statvfs1(mp, &sbuf, ST_WAIT));
+ mount_args_length = sizeof(mount_args);
+ memset(&mount_args, 0, mount_args_length);
+ if (FSTYPE_TMPFS(tc))
+ mount_args.tmpfs.ta_version = TMPFS_ARGS_VERSION;
+ mount_args_length = rump_sys_mount(sbuf.f_fstypename, mp, MNT_GETARGS,
+ &mount_args, mount_args_length);
+ ATF_CHECK(mount_args_length >= 0);
+
+ /* Remount and test result. */
+ error = rump_sys_mount(sbuf.f_fstypename, mp, MNT_UPDATE | MNT_RDONLY,
+ &mount_args, mount_args_length);
+ if (errno == EOPNOTSUPP)
+ atf_tc_skip("%s", unsupported);
+ if (expected_errno == 0)
+ ATF_CHECK(error == 0);
+ else
+ ATF_CHECK_ERRNO(expected_errno, error == -1);
+}
+
+static void
+open_file_ro(const char *prefix)
+{
+
+ snprintf(file_path, sizeof(file_path), "%s/file", prefix);
+ RL(file_fd = rump_sys_open(file_path, O_CREAT | O_RDWR, 0777));
+ RL(rump_sys_close(file_fd));
+ RL(file_fd = rump_sys_open(file_path, O_RDONLY));
+}
+
+static void
+open_file_ro_unlink(const char *prefix)
+{
+
+ snprintf(file_path, sizeof(file_path), "%s/file", prefix);
+ RL(file_fd = rump_sys_open(file_path, O_CREAT | O_RDWR, 0777));
+ RL(rump_sys_close(file_fd));
+ RL(file_fd = rump_sys_open(file_path, O_RDONLY));
+ RL(rump_sys_unlink(file_path));
+}
+
+static void
+open_file_rw(const char *prefix)
+{
+
+ snprintf(file_path, sizeof(file_path), "%s/file", prefix);
+ RL(file_fd = rump_sys_open(file_path, O_CREAT | O_RDWR, 0777));
+}
+
+static void
+close_file(const char *unused)
+{
+
+ RL(rump_sys_close(file_fd));
+}
+
+static void
+basic_test(const atf_tc_t *tc, const char *mp, int expected_errno,
+ bool use_layer, void (*pre)(const char *), void (*post)(const char *))
+{
+ const char *null_mount = "/nullm";
+ struct null_args nargs;
+
+ if (use_layer) {
+ RL(rump_sys_mkdir(null_mount, 0777));
+ memset(&nargs, 0, sizeof(nargs));
+ nargs.nulla_target = __UNCONST(mp);;
+ RL(rump_sys_mount(MOUNT_NULL, null_mount, 0,
+ &nargs, sizeof(nargs)));
+ }
+ if (pre)
+ (*pre)(use_layer ? null_mount : mp);
+ remount_ro(tc, mp, expected_errno);
+ if (post)
+ (*post)(use_layer ? null_mount : mp);
+ if (use_layer)
+ RL(rump_sys_unmount(null_mount, 0));
+}
+
+static void
+noneopen(const atf_tc_t *tc, const char *mp)
+{
+
+ basic_test(tc, mp, 0, false, NULL, NULL);
+}
+
+static void
+readopen(const atf_tc_t *tc, const char *mp)
+{
+
+ basic_test(tc, mp, 0, false, open_file_ro, close_file);
+}
+
+static void
+writeopen(const atf_tc_t *tc, const char *mp)
+{
+
+ basic_test(tc, mp, EBUSY, false, open_file_rw, close_file);
+}
+
+static void
+read_unlinked(const atf_tc_t *tc, const char *mp)
+{
+
+ basic_test(tc, mp, EBUSY, false, open_file_ro_unlink, close_file);
+}
+
+static void
+layer_noneopen(const atf_tc_t *tc, const char *mp)
+{
+
+ basic_test(tc, mp, 0, true, NULL, NULL);
+}
+
+static void
+layer_readopen(const atf_tc_t *tc, const char *mp)
+{
+
+ basic_test(tc, mp, 0, true, open_file_ro, close_file);
+}
+
+static void
+layer_writeopen(const atf_tc_t *tc, const char *mp)
+{
+
+ basic_test(tc, mp, EBUSY, true, open_file_rw, close_file);
+}
+
+static void
+layer_read_unlinked(const atf_tc_t *tc, const char *mp)
+{
+
+ basic_test(tc, mp, EBUSY, true, open_file_ro_unlink, close_file);
+}
+
+ATF_TC_FSAPPLY(noneopen, "remount r/o with no file open");
+ATF_TC_FSAPPLY(readopen, "remount r/o with file open for reading");
+ATF_TC_FSAPPLY(writeopen, "remount r/o with file open for writing");
+ATF_TC_FSAPPLY(read_unlinked,
+ "remount r/o with unlinked file open for reading");
+ATF_TC_FSAPPLY(layer_noneopen, "remount r/o with no file open on layer");
+ATF_TC_FSAPPLY(layer_readopen,
+ "remount r/o with file open for reading on layer");
+ATF_TC_FSAPPLY(layer_writeopen,
+ "remount r/o with file open for writing on layer");
+ATF_TC_FSAPPLY(layer_read_unlinked,
+ "remount r/o with unlinked file open for reading on layer");
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_FSAPPLY(noneopen);
+ ATF_TP_FSAPPLY(readopen);
+ ATF_TP_FSAPPLY(writeopen);
+ ATF_TP_FSAPPLY(read_unlinked);
+ ATF_TP_FSAPPLY(layer_noneopen);
+ ATF_TP_FSAPPLY(layer_readopen);
+ ATF_TP_FSAPPLY(layer_writeopen);
+ ATF_TP_FSAPPLY(layer_read_unlinked);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/fs/vfs/t_union.c b/contrib/netbsd-tests/fs/vfs/t_union.c
index bdcef93..5da1ea1 100644
--- a/contrib/netbsd-tests/fs/vfs/t_union.c
+++ b/contrib/netbsd-tests/fs/vfs/t_union.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_union.c,v 1.8 2011/08/07 06:01:51 hannken Exp $ */
+/* $NetBSD: t_union.c,v 1.9 2017/01/13 21:30:40 christos Exp $ */
#include <sys/types.h>
#include <sys/mount.h>
@@ -17,7 +17,7 @@
#include <miscfs/union/union.h>
-#include "../../h_macros.h"
+#include "h_macros.h"
#include "../common/h_fsmacros.h"
#define MSTR "magic bus"
diff --git a/contrib/netbsd-tests/fs/vfs/t_unpriv.c b/contrib/netbsd-tests/fs/vfs/t_unpriv.c
index 6da771b4..6536c21 100644
--- a/contrib/netbsd-tests/fs/vfs/t_unpriv.c
+++ b/contrib/netbsd-tests/fs/vfs/t_unpriv.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_unpriv.c,v 1.12 2015/04/09 19:51:13 riastradh Exp $ */
+/* $NetBSD: t_unpriv.c,v 1.13 2017/01/13 21:30:40 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include <rump/rump.h>
#include "../common/h_fsmacros.h"
-#include "../../h_macros.h"
+#include "h_macros.h"
#define USES_OWNER \
if (FSTYPE_MSDOS(tc)) \
diff --git a/contrib/netbsd-tests/fs/vfs/t_vfsops.c b/contrib/netbsd-tests/fs/vfs/t_vfsops.c
index 1bcee89..bbed9f9 100644
--- a/contrib/netbsd-tests/fs/vfs/t_vfsops.c
+++ b/contrib/netbsd-tests/fs/vfs/t_vfsops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_vfsops.c,v 1.11 2011/04/04 19:16:58 hannken Exp $ */
+/* $NetBSD: t_vfsops.c,v 1.12 2017/01/13 21:30:40 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
#include <rump/rump.h>
#include "../common/h_fsmacros.h"
-#include "../../h_macros.h"
+#include "h_macros.h"
static void
tmount(const atf_tc_t *tc, const char *path)
diff --git a/contrib/netbsd-tests/fs/vfs/t_vnops.c b/contrib/netbsd-tests/fs/vfs/t_vnops.c
index 978fadb..7da53c8 100644
--- a/contrib/netbsd-tests/fs/vfs/t_vnops.c
+++ b/contrib/netbsd-tests/fs/vfs/t_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_vnops.c,v 1.58 2016/08/29 02:31:46 kre Exp $ */
+/* $NetBSD: t_vnops.c,v 1.59 2017/01/13 21:30:40 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
#include <rump/rump.h>
#include "../common/h_fsmacros.h"
-#include "../../h_macros.h"
+#include "h_macros.h"
#define TESTFILE "afile"
OpenPOWER on IntegriCloud