Module Name:    src
Committed By:   pooka
Date:           Thu Jul 29 14:15:47 UTC 2010

Modified Files:
        src/tests/fs/common: Makefile
Added Files:
        src/tests/fs/common: fstest_ext2fs.c fstest_ffs.c fstest_lfs.c
            fstest_msdosfs.c fstest_nfs.c fstest_puffs.c fstest_sysvbfs.c
            fstest_tmpfs.c
Removed Files:
        src/tests/fs/common: ext2fs.c ffs.c lfs.c msdosfs.c nfs.c puffs.c
            sysvbfs.c tmpfs.c

Log Message:
Rename xfs.c to fstest_xfs.c to avoid collisions with other
source files with the name xfs.c

ok njoly


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/fs/common/Makefile
cvs rdiff -u -r1.5 -r0 src/tests/fs/common/ext2fs.c src/tests/fs/common/ffs.c \
    src/tests/fs/common/msdosfs.c src/tests/fs/common/sysvbfs.c \
    src/tests/fs/common/tmpfs.c
cvs rdiff -u -r0 -r1.1 src/tests/fs/common/fstest_ext2fs.c \
    src/tests/fs/common/fstest_ffs.c src/tests/fs/common/fstest_lfs.c \
    src/tests/fs/common/fstest_msdosfs.c src/tests/fs/common/fstest_nfs.c \
    src/tests/fs/common/fstest_puffs.c src/tests/fs/common/fstest_sysvbfs.c \
    src/tests/fs/common/fstest_tmpfs.c
cvs rdiff -u -r1.7 -r0 src/tests/fs/common/lfs.c
cvs rdiff -u -r1.2 -r0 src/tests/fs/common/nfs.c
cvs rdiff -u -r1.4 -r0 src/tests/fs/common/puffs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/fs/common/Makefile
diff -u src/tests/fs/common/Makefile:1.2 src/tests/fs/common/Makefile:1.3
--- src/tests/fs/common/Makefile:1.2	Mon Jul 26 16:15:49 2010
+++ src/tests/fs/common/Makefile	Thu Jul 29 14:15:46 2010
@@ -1,10 +1,11 @@
-#	$NetBSD: Makefile,v 1.2 2010/07/26 16:15:49 pooka Exp $
+#	$NetBSD: Makefile,v 1.3 2010/07/29 14:15:46 pooka Exp $
 #
 
 .include <bsd.own.mk>
 
 LIB=	vfstest
-SRCS=	ext2fs.c ffs.c lfs.c msdosfs.c nfs.c puffs.c sysvbfs.c tmpfs.c
+SRCS=	fstest_ext2fs.c fstest_ffs.c fstest_lfs.c fstest_msdosfs.c	\
+	fstest_nfs.c fstest_puffs.c fstest_sysvbfs.c fstest_tmpfs.c
 
 WARNS=	3
 

Added files:

Index: src/tests/fs/common/fstest_ext2fs.c
diff -u /dev/null src/tests/fs/common/fstest_ext2fs.c:1.1
--- /dev/null	Thu Jul 29 14:15:47 2010
+++ src/tests/fs/common/fstest_ext2fs.c	Thu Jul 29 14:15:46 2010
@@ -0,0 +1,139 @@
+/*	$NetBSD: fstest_ext2fs.c,v 1.1 2010/07/29 14:15:46 pooka Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nicolas Joly.
+ *
+ * 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/mount.h>
+#include <sys/stat.h>
+
+#include <atf-c.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <ufs/ufs/ufsmount.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "h_fsmacros.h"
+
+struct ext2fstestargs {
+        struct ufs_args ta_uargs;
+        char ta_devpath[MAXPATHLEN];
+        char ta_imgpath[MAXPATHLEN];
+};
+
+int
+ext2fs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image,
+    off_t size)
+{
+	char cmd[1024];
+	int res;
+	static unsigned int num = 0;
+	struct ext2fstestargs *args;
+
+	size /= 512;
+	snprintf(cmd, 1024, "newfs_ext2fs -F -s %"PRId64" %s >/dev/null",
+	    size, image);
+	res = system(cmd);
+	if (res != 0)
+		return res;
+
+	res = rump_init();
+	if (res != 0)
+		return res;
+
+	args = calloc(1, sizeof(*args));
+	if (args == NULL)
+		return -1;
+
+	snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.ext2fs", num);
+	snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image);
+	args->ta_uargs.fspec = args->ta_devpath;
+
+	res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK);
+	if (res != 0) {
+		free(args);
+		return res;
+	}
+
+	*buf = args;
+	num++;
+
+	return res;
+}
+
+int
+ext2fs_fstest_delfs(const atf_tc_t *tc, void *buf)
+{
+	int res;
+	struct ext2fstestargs *args = buf;
+
+	res = rump_pub_etfs_remove(args->ta_devpath);
+	if (res != 0)
+		return res;
+
+	res = unlink(args->ta_imgpath);
+	if (res != 0)
+		return res;
+
+	free(args);
+
+	return 0;
+}
+
+int
+ext2fs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags)
+{
+	int res;
+	struct ext2fstestargs *args = buf;
+
+	res = rump_sys_mkdir(path, 0777);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_mount(MOUNT_EXT2FS, path, flags, &args->ta_uargs,
+	    sizeof(args->ta_uargs));
+	return res;
+}
+
+int
+ext2fs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags)
+{
+	int res;
+
+	res = rump_sys_unmount(path, flags);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_rmdir(path);
+	return res;
+}
Index: src/tests/fs/common/fstest_ffs.c
diff -u /dev/null src/tests/fs/common/fstest_ffs.c:1.1
--- /dev/null	Thu Jul 29 14:15:47 2010
+++ src/tests/fs/common/fstest_ffs.c	Thu Jul 29 14:15:46 2010
@@ -0,0 +1,137 @@
+/*	$NetBSD: fstest_ffs.c,v 1.1 2010/07/29 14:15:46 pooka Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nicolas Joly.
+ *
+ * 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/mount.h>
+#include <sys/stat.h>
+
+#include <atf-c.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <ufs/ufs/ufsmount.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "h_fsmacros.h"
+
+struct ffstestargs {
+        struct ufs_args ta_uargs;
+        char ta_devpath[MAXPATHLEN];
+        char ta_imgpath[MAXPATHLEN];
+};
+
+int
+ffs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, off_t size)
+{
+	char cmd[1024];
+	int res;
+	static unsigned int num = 0;
+	struct ffstestargs *args;
+
+	size /= 512;
+	snprintf(cmd, 1024, "newfs -F -s %"PRId64" %s >/dev/null", size, image);
+	res = system(cmd);
+	if (res != 0)
+		return res;
+
+	res = rump_init();
+	if (res != 0)
+		return res;
+
+	args = calloc(1, sizeof(*args));
+	if (args == NULL)
+		return -1;
+
+	snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.ffs", num);
+	snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image);
+	args->ta_uargs.fspec = args->ta_devpath;
+
+	res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK);
+	if (res != 0) {
+		free(args);
+		return res;
+	}
+
+	*buf = args;
+	num++;
+
+	return 0;
+}
+
+int
+ffs_fstest_delfs(const atf_tc_t *tc, void *buf)
+{
+	int res;
+	struct ffstestargs *args = buf;
+
+	res = rump_pub_etfs_remove(args->ta_devpath);
+	if (res != 0)
+		return res;
+
+	res = unlink(args->ta_imgpath);
+	if (res != 0)
+		return res;
+
+	free(args);
+
+	return 0;
+}
+
+int
+ffs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags)
+{
+	int res;
+	struct ffstestargs *args = buf;
+
+	res = rump_sys_mkdir(path, 0777);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_mount(MOUNT_FFS, path, flags, &args->ta_uargs,
+	    sizeof(args->ta_uargs));
+	return res;
+}
+
+int
+ffs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags)
+{
+	int res;
+
+	res = rump_sys_unmount(path, flags);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_rmdir(path);
+	return res;
+}
Index: src/tests/fs/common/fstest_lfs.c
diff -u /dev/null src/tests/fs/common/fstest_lfs.c:1.1
--- /dev/null	Thu Jul 29 14:15:47 2010
+++ src/tests/fs/common/fstest_lfs.c	Thu Jul 29 14:15:46 2010
@@ -0,0 +1,140 @@
+/*	$NetBSD: fstest_lfs.c,v 1.1 2010/07/29 14:15:46 pooka Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nicolas Joly.
+ *
+ * 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/mount.h>
+#include <sys/stat.h>
+
+#include <atf-c.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <ufs/ufs/ufsmount.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "h_fsmacros.h"
+
+struct lfstestargs {
+        struct ufs_args ta_uargs;
+        char ta_devpath[MAXPATHLEN];
+        char ta_imgpath[MAXPATHLEN];
+};
+
+int
+lfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, off_t size)
+{
+	char cmd[1024];
+	int res;
+	static unsigned int num = 0;
+	struct lfstestargs *args;
+
+	size /= 512;
+	snprintf(cmd, 1024, "newfs_lfs -D -F -s %"PRId64" ./%s >/dev/null",
+	    size, image);
+	res = system(cmd);
+	if (res != 0)
+		return res;
+
+	res = rump_init();
+	if (res != 0)
+		return res;
+
+	args = calloc(1, sizeof(*args));
+	if (args == NULL)
+		return -1;
+
+	snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.lfs", num);
+	snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image);
+	args->ta_uargs.fspec = args->ta_devpath;
+
+	res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK);
+	if (res != 0) {
+		free(args);
+		return res;
+	}
+
+	*buf = args;
+	num++;
+
+	return 0;
+}
+
+int
+lfs_fstest_delfs(const atf_tc_t *tc, void *buf)
+{
+	int res;
+	struct lfstestargs *args = buf;
+
+	res = rump_pub_etfs_remove(args->ta_devpath);
+	if (res != 0)
+		return res;
+
+	res = unlink(args->ta_imgpath);
+	if (res != 0)
+		return res;
+
+	free(args);
+
+	return 0;
+}
+
+int
+lfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags)
+{
+	int res;
+	struct lfstestargs *args = buf;
+
+	/* XXX: should start cleanerd */
+
+	res = rump_sys_mkdir(path, 0777);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_mount(MOUNT_LFS, path, flags, &args->ta_uargs,
+	    sizeof(args->ta_uargs));
+	return res;
+}
+
+int
+lfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags)
+{
+	int res;
+
+	res = rump_sys_unmount(path, flags);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_rmdir(path);
+	return res;
+}
Index: src/tests/fs/common/fstest_msdosfs.c
diff -u /dev/null src/tests/fs/common/fstest_msdosfs.c:1.1
--- /dev/null	Thu Jul 29 14:15:47 2010
+++ src/tests/fs/common/fstest_msdosfs.c	Thu Jul 29 14:15:46 2010
@@ -0,0 +1,139 @@
+/*	$NetBSD: fstest_msdosfs.c,v 1.1 2010/07/29 14:15:46 pooka Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nicolas Joly.
+ *
+ * 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/mount.h>
+#include <sys/stat.h>
+
+#include <atf-c.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <msdosfs/msdosfsmount.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "h_fsmacros.h"
+
+struct msdosfstestargs {
+        struct msdosfs_args ta_uargs;
+        char ta_devpath[MAXPATHLEN];
+        char ta_imgpath[MAXPATHLEN];
+};
+
+int
+msdosfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image,
+    off_t size)
+{
+	char cmd[1024];
+	int res;
+	static unsigned int num = 0;
+	struct msdosfstestargs *args;
+
+	size /= 512; size -= (size % 63);
+	snprintf(cmd, 1024, "newfs_msdos -C %"PRId64"s %s >/dev/null",
+	    size, image);
+	res = system(cmd);
+	if (res != 0)
+		return res;
+
+	res = rump_init();
+	if (res != 0)
+		return res;
+
+	args = calloc(1, sizeof(*args));
+	if (args == NULL)
+		return -1;
+
+        snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.msdosfs", num);
+        snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image);
+        args->ta_uargs.fspec = args->ta_devpath;
+
+	res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK);
+	if (res != 0) {
+		free(args);
+		return res;
+	}
+
+	*buf = args;
+	num++;
+
+	return 0;
+}
+
+int
+msdosfs_fstest_delfs(const atf_tc_t *tc, void *buf)
+{
+	int res;
+	struct msdosfstestargs *args = buf;
+
+	res = rump_pub_etfs_remove(args->ta_devpath);
+	if (res != 0)
+		return res;
+
+	res = unlink(args->ta_imgpath);
+	if (res != 0)
+		return res;
+
+	free(args);
+
+	return 0;
+}
+
+int
+msdosfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags)
+{
+	int res;
+	struct msdosfstestargs *args = buf;
+
+	res = rump_sys_mkdir(path, 0777);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_mount(MOUNT_MSDOS, path, flags, &args->ta_uargs,
+	    sizeof(args->ta_uargs));
+	return res;
+}
+
+int
+msdosfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags)
+{
+	int res;
+
+	res = rump_sys_unmount(path, flags);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_rmdir(path);
+	return res;
+}
Index: src/tests/fs/common/fstest_nfs.c
diff -u /dev/null src/tests/fs/common/fstest_nfs.c:1.1
--- /dev/null	Thu Jul 29 14:15:47 2010
+++ src/tests/fs/common/fstest_nfs.c	Thu Jul 29 14:15:47 2010
@@ -0,0 +1,220 @@
+/*	$NetBSD: fstest_nfs.c,v 1.1 2010/07/29 14:15:47 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ *
+ * 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 AUTHOR ``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 AUTHOR 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/socket.h>
+#include <sys/statvfs.h>
+#include <sys/wait.h>
+
+#include <assert.h>
+#include <atf-c.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <pthread.h>
+#include <puffs.h>
+#include <puffsdump.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "h_fsmacros.h"
+#include "mount_nfs.h"
+#include "../../net/config/netconfig.c"
+
+#define SERVERADDR "10.3.2.1"
+#define CLIENTADDR "10.3.2.2"
+#define NETNETMASK "255.255.255.0"
+#define EXPORTPATH "/myexport"
+
+static void
+childfail(int status)
+{
+
+	atf_tc_fail("child died");
+}
+
+struct nfstestargs *theargs;
+
+/* fork rump nfsd, configure interface */
+int
+nfs_fstest_newfs(const atf_tc_t *tc, void **argp,
+	const char *image, off_t size)
+{
+	const char *srcdir;
+	char *nfsdargv[7];
+	char nfsdpath[MAXPATHLEN];
+	char ethername[MAXPATHLEN];
+	char imagepath[MAXPATHLEN];
+	char ifname[IFNAMSIZ];
+	char cwd[MAXPATHLEN];
+	struct nfstestargs *args;
+	pid_t childpid;
+	int pipes[2];
+	int devnull;
+
+	/*
+	 * First, we start the nfs service.
+	 */
+	srcdir = atf_tc_get_config_var(tc, "srcdir");
+	sprintf(nfsdpath, "%s/../nfs/nfsservice/rumpnfsd", srcdir);
+	sprintf(ethername, "/%s/%s.etherbus", getcwd(cwd, sizeof(cwd)), image);
+	sprintf(imagepath, "/%s/%s", cwd, image);
+
+	nfsdargv[0] = nfsdpath;
+	nfsdargv[1] = ethername;
+	nfsdargv[2] = __UNCONST(SERVERADDR);
+	nfsdargv[3] = __UNCONST(NETNETMASK);
+	nfsdargv[4] = __UNCONST(EXPORTPATH);
+	nfsdargv[5] = imagepath;
+	nfsdargv[6] = NULL;
+
+	signal(SIGCHLD, childfail);
+	if (pipe(pipes) == -1)
+		return errno;
+
+	switch ((childpid = fork())) {
+	case 0:
+		if (chdir(dirname(nfsdpath)) == -1)
+			err(1, "chdir");
+		close(pipes[0]);
+		if (dup2(pipes[1], 3) == -1)
+			err(1, "dup2");
+		if (execvp(nfsdargv[0], nfsdargv) == -1)
+			err(1, "execvp");
+	case -1:
+		return errno;
+	default:
+		close(pipes[1]);
+		break;	
+	}
+
+	/*
+	 * Ok, nfsd has been run.  The following sleep helps with the
+	 * theoretical problem that nfsd can't start fast enough to
+	 * process our mount request and we end up doing a timeout
+	 * before the mount.  This would take several seconds.  So
+	 * try to make sure nfsd is up&running already at this stage.
+	 */
+	if (read(pipes[0], &devnull, 4) == -1)
+		return errno;
+
+	/*
+	 * Configure our networking interface.
+	 */
+	rump_init();
+	netcfg_rump_makeshmif(ethername, ifname);
+	netcfg_rump_if(ifname, CLIENTADDR, NETNETMASK);
+
+	/*
+	 * That's it.  The rest is done in mount, since we don't have
+	 * the mountpath available here.
+	 */
+	args = malloc(sizeof(*args));
+	args->ta_childpid = childpid;
+	strcpy(args->ta_ethername, ethername);
+
+	*argp = args;
+	theargs = args;
+
+	return 0;
+}
+
+/* mount the file system */
+int
+nfs_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags)
+{
+	char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
+	const char *nfscliargs[] = {
+		"nfsclient",
+		SERVERADDR ":" EXPORTPATH,
+		path,
+		NULL,
+	};
+	struct nfs_args args;
+	int mntflags;
+
+	if (rump_sys_mkdir(path, 0777) == -1)
+		return errno;
+
+	/* XXX: atf does not reset values */
+	optind = 1;
+	opterr = 1;
+
+	mount_nfs_parseargs(__arraycount(nfscliargs)-1, __UNCONST(nfscliargs),
+	    &args, &mntflags, canon_dev, canon_dir);
+
+	/*
+	 * We use nfs parseargs here, since as a side effect it
+	 * takes care of the  RPC hulabaloo.
+	 */
+	if (rump_sys_mount(MOUNT_NFS, path, flags, &args, sizeof(args)) == -1) {
+		return errno;
+	}
+
+	return 0;
+}
+
+int
+nfs_fstest_delfs(const atf_tc_t *tc, void *arg)
+{
+	return 0;
+
+}
+
+int
+nfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags)
+{
+	struct nfstestargs *args = theargs;
+
+	if (rump_sys_unmount(path, flags) == -1) {
+		return errno;
+	}
+
+	/*
+	 * It's highly expected that the child will die next, so we
+	 * don't need that information anymore thank you very many.
+	 */
+	signal(SIGCHLD, SIG_IGN);
+
+	/*
+	 * Just KILL it.  Sending it SIGTERM first causes it to try
+	 * to send some unmount RPCs, leading to sticky situations.
+	 */
+	kill(args->ta_childpid, SIGKILL);
+
+	/* remove ethernet bus */
+	unlink(args->ta_ethername);
+
+	return 0;
+}
Index: src/tests/fs/common/fstest_puffs.c
diff -u /dev/null src/tests/fs/common/fstest_puffs.c:1.1
--- /dev/null	Thu Jul 29 14:15:47 2010
+++ src/tests/fs/common/fstest_puffs.c	Thu Jul 29 14:15:47 2010
@@ -0,0 +1,380 @@
+/*	$NetBSD: fstest_puffs.c,v 1.1 2010/07/29 14:15:47 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ *
+ * 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 AUTHOR ``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 AUTHOR 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/socket.h>
+#include <sys/statvfs.h>
+#include <sys/wait.h>
+
+#include <assert.h>
+#include <atf-c.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <puffs.h>
+#include <puffsdump.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "h_fsmacros.h"
+
+struct puffstestargs {
+	uint8_t			*pta_pargs;
+	size_t			pta_pargslen;
+
+	int			pta_pflags;
+	int			pta_servfd;
+	pid_t			pta_childpid;
+
+	char			pta_dev[MAXPATHLEN];
+	char			pta_dir[MAXPATHLEN];
+
+	int			pta_mntflags;
+};
+
+#define BUFSIZE (128*1024)
+#define DTFS_DUMP "-o","dump"
+
+struct thefds {
+	int rumpfd;
+	int servfd;
+};
+
+int vfs_toserv_ops[PUFFS_VFS_MAX];
+int vn_toserv_ops[PUFFS_VN_MAX];
+
+#ifdef PUFFSDUMP
+static void __unused
+dumpopcount(void)
+{
+	size_t i;
+
+	printf("VFS OPS:\n");
+	for (i = 0; i < MIN(puffsdump_vfsop_count, PUFFS_VFS_MAX); i++) {
+		printf("\t%s: %d\n",
+		    puffsdump_vfsop_revmap[i], vfs_toserv_ops[i]);
+	}
+
+	printf("VN OPS:\n");
+	for (i = 0; i < MIN(puffsdump_vnop_count, PUFFS_VN_MAX); i++) {
+		printf("\t%s: %d\n",
+		    puffsdump_vnop_revmap[i], vn_toserv_ops[i]);
+	}
+}
+#endif
+
+/*
+ * Threads which shovel data between comfd and /dev/puffs.
+ * (cannot use polling since fd's are in different namespaces)
+ */
+static void *
+readshovel(void *arg)
+{
+	struct putter_hdr *phdr;
+	struct puffs_req *preq;
+	struct thefds *fds = arg;
+	char buf[BUFSIZE];
+	int comfd, puffsfd;
+
+	comfd = fds->servfd;
+	puffsfd = fds->rumpfd;
+
+	phdr = (void *)buf;
+	preq = (void *)buf;
+
+	/* use static thread id */
+	rump_pub_lwp_alloc_and_switch(0, 10);
+
+	for (;;) {
+		ssize_t n;
+
+		n = rump_sys_read(puffsfd, buf, sizeof(*phdr));
+		if (n <= 0)
+			break;
+
+		assert(phdr->pth_framelen < BUFSIZE);
+		n = rump_sys_read(puffsfd, buf+sizeof(*phdr), 
+		    phdr->pth_framelen - sizeof(*phdr));
+		if (n <= 0)
+			break;
+
+		/* Analyze request */
+		if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS) {
+			assert(preq->preq_optype < PUFFS_VFS_MAX);
+			vfs_toserv_ops[preq->preq_optype]++;
+		} else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) {
+			assert(preq->preq_optype < PUFFS_VN_MAX);
+			vn_toserv_ops[preq->preq_optype]++;
+		}
+
+		n = phdr->pth_framelen;
+		if (write(comfd, buf, n) != n)
+			break;
+	}
+
+	return NULL;
+}
+
+static void *
+writeshovel(void *arg)
+{
+	struct thefds *fds = arg;
+	struct putter_hdr *phdr;
+	char buf[BUFSIZE];
+	size_t toread;
+	int comfd, puffsfd;
+
+	/* use static thread id */
+	rump_pub_lwp_alloc_and_switch(0, 11);
+
+	comfd = fds->servfd;
+	puffsfd = fds->rumpfd;
+
+	phdr = (struct putter_hdr *)buf;
+
+	for (;;) {
+		uint64_t off;
+		ssize_t n;
+
+		/*
+		 * Need to write everything to the "kernel" in one chunk,
+		 * so make sure we have it here.
+		 */
+		off = 0;
+		toread = sizeof(struct putter_hdr);
+		assert(toread < BUFSIZE);
+		do {
+			n = read(comfd, buf+off, toread);
+			if (n <= 0) {
+				break;
+			}
+			off += n;
+			if (off >= sizeof(struct putter_hdr))
+				toread = phdr->pth_framelen - off;
+			else
+				toread = off - sizeof(struct putter_hdr);
+		} while (toread);
+
+		n = rump_sys_write(puffsfd, buf, phdr->pth_framelen);
+		if ((size_t)n != phdr->pth_framelen)
+			break;
+	}
+
+	return NULL;
+}
+
+static void
+rumpshovels(int rumpfd, int servfd)
+{
+	struct thefds *fds;
+	pthread_t pt;
+	int rv;
+
+	if ((rv = rump_init()) == -1)
+		err(1, "rump_init");
+
+	fds = malloc(sizeof(*fds));
+	fds->rumpfd = rumpfd;
+	fds->servfd = servfd;
+	if (pthread_create(&pt, NULL, readshovel, fds) == -1)
+		err(1, "read shovel");
+	pthread_detach(pt);
+	if (pthread_create(&pt, NULL, writeshovel, fds) == -1)
+		err(1, "write shovel");
+	pthread_detach(pt);
+}
+
+static void
+childfail(int sign)
+{
+
+	atf_tc_fail("child died"); /* almost signal-safe */
+}
+
+/* XXX: we don't support size */
+int
+puffs_fstest_newfs(const atf_tc_t *tc, void **argp,
+	const char *image, off_t size)
+{
+	struct puffstestargs *args;
+	char dtfs_path[MAXPATHLEN];
+	char *dtfsargv[6];
+	pid_t childpid;
+	int *pflags;
+	char comfd[16];
+	int sv[2];
+	int mntflags;
+	size_t len;
+	ssize_t n;
+
+	*argp = NULL;
+
+	args = malloc(sizeof(*args));
+	if (args == NULL)
+		return errno;
+
+	pflags = &args->pta_pflags;
+
+	/* build dtfs exec path from atf test dir */
+	sprintf(dtfs_path, "%s/../puffs/h_dtfs/h_dtfs",
+	    atf_tc_get_config_var(tc, "srcdir"));
+	dtfsargv[0] = dtfs_path;
+	dtfsargv[1] = __UNCONST("-i");
+	dtfsargv[2] = __UNCONST("-s");
+	dtfsargv[3] = __UNCONST("dtfs");
+	dtfsargv[4] = __UNCONST("fictional");
+	dtfsargv[5] = NULL;
+
+	/* Create sucketpair for communication with the real file server */
+	if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) == -1)
+		return errno;
+
+	signal(SIGCHLD, childfail);
+
+	switch ((childpid = fork())) {
+	case 0:
+		close(sv[1]);
+		snprintf(comfd, sizeof(sv[0]), "%d", sv[0]);
+		if (setenv("PUFFS_COMFD", comfd, 1) == -1)
+			return errno;
+
+		if (execvp(dtfsargv[0], dtfsargv) == -1)
+			return errno;
+	case -1:
+		return errno;
+	default:
+		close(sv[0]);
+		break;
+	}
+
+	/* read args */
+	if ((n = read(sv[1], &len, sizeof(len))) != sizeof(len))
+		err(1, "mp 1 %zd", n);
+	if (len > MAXPATHLEN)
+		err(1, "mntpath > MAXPATHLEN");
+	if ((size_t)read(sv[1], args->pta_dir, len) != len)
+		err(1, "mp 2");
+	if (read(sv[1], &len, sizeof(len)) != sizeof(len))
+		err(1, "fn 1");
+	if (len > MAXPATHLEN)
+		err(1, "devpath > MAXPATHLEN");
+	if ((size_t)read(sv[1], args->pta_dev, len) != len)
+		err(1, "fn 2");
+	if (read(sv[1], &mntflags, sizeof(mntflags)) != sizeof(mntflags))
+		err(1, "mntflags");
+	if (read(sv[1], &args->pta_pargslen, sizeof(args->pta_pargslen)) != sizeof(args->pta_pargslen))
+		err(1, "puffstest_args len");
+	args->pta_pargs = malloc(args->pta_pargslen);
+	if (args->pta_pargs == NULL)
+		err(1, "malloc");
+	if (read(sv[1], args->pta_pargs, args->pta_pargslen) != (ssize_t)args->pta_pargslen)
+		err(1, "puffstest_args");
+	if (read(sv[1], pflags, sizeof(*pflags)) != sizeof(*pflags))
+		err(1, "pflags");
+
+	args->pta_childpid = childpid;
+	args->pta_servfd = sv[1];
+	strlcpy(args->pta_dev, image, sizeof(args->pta_dev));
+
+	*argp = args;
+
+	return 0;
+}
+
+int
+puffs_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags)
+{
+	struct puffstestargs *pargs = arg;
+	int fd;
+
+	rump_init();
+	fd = rump_sys_open("/dev/puffs", O_RDWR);
+	if (fd == -1)
+		return fd;
+
+#if 0
+	pa->pa_fd = fd;
+#else
+	assert(fd == 0); /* XXX: FIXME */
+#endif
+
+	if (rump_sys_mkdir(path, 0777) == -1)
+		return -1;
+
+	if (rump_sys_mount(MOUNT_PUFFS, path, flags,
+	    pargs->pta_pargs, pargs->pta_pargslen) == -1) {
+		/* apply "to kill a child" to avoid atf hang (kludge) */
+		kill(pargs->pta_childpid, SIGKILL);
+		return -1;
+	}
+
+	rumpshovels(fd, pargs->pta_servfd);
+
+	return 0;
+}
+
+int
+puffs_fstest_delfs(const atf_tc_t *tc, void *arg)
+{
+	struct puffstestargs *pargs = arg;
+	int status;
+
+	if (waitpid(pargs->pta_childpid, &status, WNOHANG) > 0)
+		return 0;
+	kill(pargs->pta_childpid, SIGTERM);
+	usleep(10);
+	if (waitpid(pargs->pta_childpid, &status, WNOHANG) > 0)
+		return 0;
+	kill(pargs->pta_childpid, SIGKILL);
+	usleep(500);
+	if (waitpid(pargs->pta_childpid, &status, 0) == -1)
+		return errno;
+	return 0;
+}
+
+int
+puffs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags)
+{
+	int rv;
+
+	/* ok, child might exit here */
+	signal(SIGCHLD, SIG_IGN);
+
+	rv = rump_sys_unmount(path, flags);
+	if (rv)	
+		return rv;
+
+	return rump_sys_rmdir(path);
+}
Index: src/tests/fs/common/fstest_sysvbfs.c
diff -u /dev/null src/tests/fs/common/fstest_sysvbfs.c:1.1
--- /dev/null	Thu Jul 29 14:15:47 2010
+++ src/tests/fs/common/fstest_sysvbfs.c	Thu Jul 29 14:15:47 2010
@@ -0,0 +1,139 @@
+/*	$NetBSD: fstest_sysvbfs.c,v 1.1 2010/07/29 14:15:47 pooka Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nicolas Joly.
+ *
+ * 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/mount.h>
+#include <sys/stat.h>
+
+#include <atf-c.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <ufs/ufs/ufsmount.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "h_fsmacros.h"
+
+struct sysvbfstestargs {
+        struct ufs_args ta_uargs;
+        char ta_devpath[MAXPATHLEN];
+        char ta_imgpath[MAXPATHLEN];
+};
+
+int
+sysvbfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image,
+    off_t size)
+{
+	char cmd[1024];
+	int res;
+	static unsigned int num = 0;
+	struct sysvbfstestargs *args;
+
+	size /= 512;
+	snprintf(cmd, 1024, "newfs_sysvbfs -F -s %"PRId64" %s >/dev/null",
+	    size, image);
+	res = system(cmd);
+	if (res != 0)
+		return res;
+
+	res = rump_init();
+	if (res != 0)
+		return res;
+
+        args = calloc(1, sizeof(*args));
+        if (args == NULL)
+                return -1;
+
+	snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.sysvbfs", num);
+	snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image);
+	args->ta_uargs.fspec = args->ta_devpath;
+
+	res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK);
+	if (res != 0) {
+		free(args);
+		return res;
+	}
+
+	*buf = args;
+	num++;
+
+	return 0;
+}
+
+int
+sysvbfs_fstest_delfs(const atf_tc_t *tc, void *buf)
+{
+	int res;
+	struct sysvbfstestargs *args = buf;
+
+	res = rump_pub_etfs_remove(args->ta_devpath);
+	if (res != 0)
+		return res;
+
+	res = unlink(args->ta_imgpath);
+	if (res != 0)
+		return res;
+
+	free(args);
+
+	return 0;
+}
+
+int
+sysvbfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags)
+{
+	int res;
+	struct sysvbfstestargs *args = buf;
+
+	res = rump_sys_mkdir(path, 0777);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_mount(MOUNT_SYSVBFS, path, flags, &args->ta_uargs,
+	    sizeof(args->ta_uargs));
+	return res;
+}
+
+int
+sysvbfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags)
+{
+	int res;
+
+	res = rump_sys_unmount(path, flags);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_rmdir(path);
+	return res;
+}
Index: src/tests/fs/common/fstest_tmpfs.c
diff -u /dev/null src/tests/fs/common/fstest_tmpfs.c:1.1
--- /dev/null	Thu Jul 29 14:15:47 2010
+++ src/tests/fs/common/fstest_tmpfs.c	Thu Jul 29 14:15:47 2010
@@ -0,0 +1,112 @@
+/*	$NetBSD: fstest_tmpfs.c,v 1.1 2010/07/29 14:15:47 pooka Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nicolas Joly.
+ *
+ * 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/mount.h>
+#include <sys/stat.h>
+
+#include <atf-c.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <fs/tmpfs/tmpfs_args.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "h_fsmacros.h"
+
+struct tmpfstestargs {
+        struct tmpfs_args ta_uargs;
+};
+
+int
+tmpfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image,
+    off_t size)
+{
+	int res;
+	struct tmpfstestargs *args;
+
+	res = rump_init();
+	if (res != 0)
+		return res;
+
+	args = calloc(1, sizeof(*args));
+	if (args == NULL)
+		return -1;
+
+	args->ta_uargs.ta_version = TMPFS_ARGS_VERSION;
+	args->ta_uargs.ta_root_mode = 0777;
+	args->ta_uargs.ta_size_max = size;
+
+	*buf = args;
+
+	return 0;
+}
+
+int
+tmpfs_fstest_delfs(const atf_tc_t *tc, void *buf)
+{
+	struct tmpfstestargs *args = buf;
+
+	free(args);
+
+	return 0;
+}
+
+int
+tmpfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags)
+{
+	int res;
+	struct tmpfstestargs *args = buf;
+
+	res = rump_sys_mkdir(path, 0777);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_mount(MOUNT_TMPFS, path, flags, &args->ta_uargs,
+	    sizeof(args->ta_uargs));
+	return res;
+}
+
+int
+tmpfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags)
+{
+	int res;
+
+	res = rump_sys_unmount(path, flags);
+	if (res == -1)
+		return res;
+
+	res = rump_sys_rmdir(path);
+	return res;
+}

Reply via email to