xref: /minix3/tests/fs/vfs/t_vnops.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: t_vnops.c,v 1.49 2015/04/09 19:47:05 riastradh Exp $	*/
211be35a1SLionel Sambuc 
311be35a1SLionel Sambuc /*-
411be35a1SLionel Sambuc  * Copyright (c) 2010 The NetBSD Foundation, Inc.
511be35a1SLionel Sambuc  * All rights reserved.
611be35a1SLionel Sambuc  *
711be35a1SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
811be35a1SLionel Sambuc  * modification, are permitted provided that the following conditions
911be35a1SLionel Sambuc  * are met:
1011be35a1SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
1111be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
1211be35a1SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
1311be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
1411be35a1SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
1511be35a1SLionel Sambuc  *
1611be35a1SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1711be35a1SLionel Sambuc  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1811be35a1SLionel Sambuc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1911be35a1SLionel Sambuc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2011be35a1SLionel Sambuc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2111be35a1SLionel Sambuc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2211be35a1SLionel Sambuc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2311be35a1SLionel Sambuc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2411be35a1SLionel Sambuc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2511be35a1SLionel Sambuc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2611be35a1SLionel Sambuc  * POSSIBILITY OF SUCH DAMAGE.
2711be35a1SLionel Sambuc  */
2811be35a1SLionel Sambuc 
2911be35a1SLionel Sambuc #include <sys/stat.h>
3011be35a1SLionel Sambuc #include <sys/statvfs.h>
3111be35a1SLionel Sambuc 
3211be35a1SLionel Sambuc #include <assert.h>
3311be35a1SLionel Sambuc #include <atf-c.h>
3411be35a1SLionel Sambuc #include <fcntl.h>
3511be35a1SLionel Sambuc #include <libgen.h>
3611be35a1SLionel Sambuc #include <stdlib.h>
3711be35a1SLionel Sambuc #include <string.h>
3811be35a1SLionel Sambuc #include <unistd.h>
3911be35a1SLionel Sambuc 
4011be35a1SLionel Sambuc #include <rump/rump_syscalls.h>
4111be35a1SLionel Sambuc #include <rump/rump.h>
4211be35a1SLionel Sambuc 
4311be35a1SLionel Sambuc #include "../common/h_fsmacros.h"
4411be35a1SLionel Sambuc #include "../../h_macros.h"
4511be35a1SLionel Sambuc 
4611be35a1SLionel Sambuc #define TESTFILE "afile"
4711be35a1SLionel Sambuc 
4811be35a1SLionel Sambuc #define USES_DIRS					\
4911be35a1SLionel Sambuc     if (FSTYPE_SYSVBFS(tc))				\
5011be35a1SLionel Sambuc 	atf_tc_skip("directories not supported by file system")
5111be35a1SLionel Sambuc 
5211be35a1SLionel Sambuc #define USES_SYMLINKS					\
5311be35a1SLionel Sambuc     if (FSTYPE_SYSVBFS(tc) || FSTYPE_MSDOS(tc))		\
5411be35a1SLionel Sambuc 	atf_tc_skip("symlinks not supported by file system")
5511be35a1SLionel Sambuc 
5611be35a1SLionel Sambuc static char *
md(char * buf,const char * base,const char * tail)5711be35a1SLionel Sambuc md(char *buf, const char *base, const char *tail)
5811be35a1SLionel Sambuc {
5911be35a1SLionel Sambuc 
6011be35a1SLionel Sambuc 	sprintf(buf, "%s/%s", base, tail);
6111be35a1SLionel Sambuc 	return buf;
6211be35a1SLionel Sambuc }
6311be35a1SLionel Sambuc 
6411be35a1SLionel Sambuc static void
lookup_simple(const atf_tc_t * tc,const char * mountpath)6511be35a1SLionel Sambuc lookup_simple(const atf_tc_t *tc, const char *mountpath)
6611be35a1SLionel Sambuc {
6711be35a1SLionel Sambuc 	char pb[MAXPATHLEN], final[MAXPATHLEN];
6811be35a1SLionel Sambuc 	struct stat sb1, sb2;
6911be35a1SLionel Sambuc 
7011be35a1SLionel Sambuc 	strcpy(final, mountpath);
7111be35a1SLionel Sambuc 	sprintf(pb, "%s/../%s", mountpath, basename(final));
7211be35a1SLionel Sambuc 	if (rump_sys_stat(pb, &sb1) == -1)
7311be35a1SLionel Sambuc 		atf_tc_fail_errno("stat 1");
7411be35a1SLionel Sambuc 
7511be35a1SLionel Sambuc 	sprintf(pb, "%s/./../%s", mountpath, basename(final));
7611be35a1SLionel Sambuc 	if (rump_sys_stat(pb, &sb2) == -1)
7711be35a1SLionel Sambuc 		atf_tc_fail_errno("stat 2");
7811be35a1SLionel Sambuc 
7911be35a1SLionel Sambuc 	ATF_REQUIRE(memcmp(&sb1, &sb2, sizeof(sb1)) == 0);
8011be35a1SLionel Sambuc }
8111be35a1SLionel Sambuc 
8211be35a1SLionel Sambuc static void
lookup_complex(const atf_tc_t * tc,const char * mountpath)8311be35a1SLionel Sambuc lookup_complex(const atf_tc_t *tc, const char *mountpath)
8411be35a1SLionel Sambuc {
8511be35a1SLionel Sambuc 	char pb[MAXPATHLEN];
8611be35a1SLionel Sambuc 	struct stat sb1, sb2;
8711be35a1SLionel Sambuc 
8811be35a1SLionel Sambuc 	USES_DIRS;
8911be35a1SLionel Sambuc 
90*0a6a1f1dSLionel Sambuc 	if (FSTYPE_UDF(tc))
91*0a6a1f1dSLionel Sambuc 		atf_tc_expect_fail("PR kern/49033");
92*0a6a1f1dSLionel Sambuc 
9311be35a1SLionel Sambuc 	sprintf(pb, "%s/dir", mountpath);
9411be35a1SLionel Sambuc 	if (rump_sys_mkdir(pb, 0777) == -1)
9511be35a1SLionel Sambuc 		atf_tc_fail_errno("mkdir");
9611be35a1SLionel Sambuc 	if (rump_sys_stat(pb, &sb1) == -1)
9711be35a1SLionel Sambuc 		atf_tc_fail_errno("stat 1");
9811be35a1SLionel Sambuc 
9911be35a1SLionel Sambuc 	sprintf(pb, "%s/./dir/../././dir/.", mountpath);
10011be35a1SLionel Sambuc 	if (rump_sys_stat(pb, &sb2) == -1)
10111be35a1SLionel Sambuc 		atf_tc_fail_errno("stat 2");
10211be35a1SLionel Sambuc 
103*0a6a1f1dSLionel Sambuc 	if (memcmp(&sb1, &sb2, sizeof(sb1)) != 0) {
104*0a6a1f1dSLionel Sambuc 		printf("what\tsb1\t\tsb2\n");
105*0a6a1f1dSLionel Sambuc 
106*0a6a1f1dSLionel Sambuc #define FIELD(FN)	\
107*0a6a1f1dSLionel Sambuc 		printf(#FN "\t%lld\t%lld\n", \
108*0a6a1f1dSLionel Sambuc 		(long long)sb1.FN, (long long)sb2.FN)
109*0a6a1f1dSLionel Sambuc #define TIME(FN)	\
110*0a6a1f1dSLionel Sambuc 		printf(#FN "\t%lld.%ld\t%lld.%ld\n", \
111*0a6a1f1dSLionel Sambuc 		(long long)sb1.FN.tv_sec, sb1.FN.tv_nsec, \
112*0a6a1f1dSLionel Sambuc 		(long long)sb2.FN.tv_sec, sb2.FN.tv_nsec)
113*0a6a1f1dSLionel Sambuc 
114*0a6a1f1dSLionel Sambuc 		FIELD(st_dev);
115*0a6a1f1dSLionel Sambuc 		FIELD(st_mode);
116*0a6a1f1dSLionel Sambuc 		FIELD(st_ino);
117*0a6a1f1dSLionel Sambuc 		FIELD(st_nlink);
118*0a6a1f1dSLionel Sambuc 		FIELD(st_uid);
119*0a6a1f1dSLionel Sambuc 		FIELD(st_gid);
120*0a6a1f1dSLionel Sambuc 		FIELD(st_rdev);
121*0a6a1f1dSLionel Sambuc 		TIME(st_atimespec);
122*0a6a1f1dSLionel Sambuc 		TIME(st_mtimespec);
123*0a6a1f1dSLionel Sambuc 		TIME(st_ctimespec);
124*0a6a1f1dSLionel Sambuc 		TIME(st_birthtimespec);
125*0a6a1f1dSLionel Sambuc 		FIELD(st_size);
126*0a6a1f1dSLionel Sambuc 		FIELD(st_blocks);
127*0a6a1f1dSLionel Sambuc 		FIELD(st_flags);
128*0a6a1f1dSLionel Sambuc 		FIELD(st_gen);
129*0a6a1f1dSLionel Sambuc 
130*0a6a1f1dSLionel Sambuc #undef FIELD
131*0a6a1f1dSLionel Sambuc #undef TIME
132*0a6a1f1dSLionel Sambuc 
133*0a6a1f1dSLionel Sambuc 		atf_tc_fail("stat results differ, see ouput for more details");
134*0a6a1f1dSLionel Sambuc 	}
135*0a6a1f1dSLionel Sambuc 	if (FSTYPE_UDF(tc))
136*0a6a1f1dSLionel Sambuc 		atf_tc_fail("random failure of PR kern/49033 "
137*0a6a1f1dSLionel Sambuc 			    "did not happen this time");
13811be35a1SLionel Sambuc }
13911be35a1SLionel Sambuc 
14011be35a1SLionel Sambuc static void
dir_simple(const atf_tc_t * tc,const char * mountpath)14111be35a1SLionel Sambuc dir_simple(const atf_tc_t *tc, const char *mountpath)
14211be35a1SLionel Sambuc {
14311be35a1SLionel Sambuc 	char pb[MAXPATHLEN];
14411be35a1SLionel Sambuc 	struct stat sb;
14511be35a1SLionel Sambuc 
14611be35a1SLionel Sambuc 	USES_DIRS;
14711be35a1SLionel Sambuc 
14811be35a1SLionel Sambuc 	/* check we can create directories */
14911be35a1SLionel Sambuc 	sprintf(pb, "%s/dir", mountpath);
15011be35a1SLionel Sambuc 	if (rump_sys_mkdir(pb, 0777) == -1)
15111be35a1SLionel Sambuc 		atf_tc_fail_errno("mkdir");
15211be35a1SLionel Sambuc 	if (rump_sys_stat(pb, &sb) == -1)
15311be35a1SLionel Sambuc 		atf_tc_fail_errno("stat new directory");
15411be35a1SLionel Sambuc 
15511be35a1SLionel Sambuc 	/* check we can remove then and that it makes them unreachable */
15611be35a1SLionel Sambuc 	if (rump_sys_rmdir(pb) == -1)
15711be35a1SLionel Sambuc 		atf_tc_fail_errno("rmdir");
15811be35a1SLionel Sambuc 	if (rump_sys_stat(pb, &sb) != -1 || errno != ENOENT)
15911be35a1SLionel Sambuc 		atf_tc_fail("ENOENT expected from stat");
16011be35a1SLionel Sambuc }
16111be35a1SLionel Sambuc 
16211be35a1SLionel Sambuc static void
dir_notempty(const atf_tc_t * tc,const char * mountpath)16311be35a1SLionel Sambuc dir_notempty(const atf_tc_t *tc, const char *mountpath)
16411be35a1SLionel Sambuc {
16511be35a1SLionel Sambuc 	char pb[MAXPATHLEN], pb2[MAXPATHLEN];
16611be35a1SLionel Sambuc 	int fd, rv;
16711be35a1SLionel Sambuc 
16811be35a1SLionel Sambuc 	USES_DIRS;
16911be35a1SLionel Sambuc 
17011be35a1SLionel Sambuc 	/* check we can create directories */
17111be35a1SLionel Sambuc 	sprintf(pb, "%s/dir", mountpath);
17211be35a1SLionel Sambuc 	if (rump_sys_mkdir(pb, 0777) == -1)
17311be35a1SLionel Sambuc 		atf_tc_fail_errno("mkdir");
17411be35a1SLionel Sambuc 
17511be35a1SLionel Sambuc 	sprintf(pb2, "%s/dir/file", mountpath);
17611be35a1SLionel Sambuc 	fd = rump_sys_open(pb2, O_RDWR | O_CREAT, 0777);
17711be35a1SLionel Sambuc 	if (fd == -1)
17811be35a1SLionel Sambuc 		atf_tc_fail_errno("create file");
17911be35a1SLionel Sambuc 	rump_sys_close(fd);
18011be35a1SLionel Sambuc 
18111be35a1SLionel Sambuc 	rv = rump_sys_rmdir(pb);
18211be35a1SLionel Sambuc 	if (rv != -1 || errno != ENOTEMPTY)
18311be35a1SLionel Sambuc 		atf_tc_fail("non-empty directory removed succesfully");
18411be35a1SLionel Sambuc 
18511be35a1SLionel Sambuc 	if (rump_sys_unlink(pb2) == -1)
18611be35a1SLionel Sambuc 		atf_tc_fail_errno("cannot remove dir/file");
18711be35a1SLionel Sambuc 
18811be35a1SLionel Sambuc 	if (rump_sys_rmdir(pb) == -1)
18911be35a1SLionel Sambuc 		atf_tc_fail_errno("remove directory");
19011be35a1SLionel Sambuc }
19111be35a1SLionel Sambuc 
19211be35a1SLionel Sambuc static void
dir_rmdirdotdot(const atf_tc_t * tc,const char * mp)19311be35a1SLionel Sambuc dir_rmdirdotdot(const atf_tc_t *tc, const char *mp)
19411be35a1SLionel Sambuc {
19511be35a1SLionel Sambuc 	char pb[MAXPATHLEN];
19611be35a1SLionel Sambuc 	int xerrno;
19711be35a1SLionel Sambuc 
19811be35a1SLionel Sambuc 	USES_DIRS;
19911be35a1SLionel Sambuc 
20011be35a1SLionel Sambuc 	FSTEST_ENTER();
20111be35a1SLionel Sambuc 	RL(rump_sys_mkdir("test", 0777));
20211be35a1SLionel Sambuc 	RL(rump_sys_chdir("test"));
20311be35a1SLionel Sambuc 
20411be35a1SLionel Sambuc 	RL(rump_sys_mkdir("subtest", 0777));
20511be35a1SLionel Sambuc 	RL(rump_sys_chdir("subtest"));
20611be35a1SLionel Sambuc 
20711be35a1SLionel Sambuc 	md(pb, mp, "test/subtest");
20811be35a1SLionel Sambuc 	RL(rump_sys_rmdir(pb));
20911be35a1SLionel Sambuc 	md(pb, mp, "test");
21011be35a1SLionel Sambuc 	RL(rump_sys_rmdir(pb));
21111be35a1SLionel Sambuc 
21211be35a1SLionel Sambuc 	if (FSTYPE_NFS(tc))
21311be35a1SLionel Sambuc 		xerrno = ESTALE;
21411be35a1SLionel Sambuc 	else
21511be35a1SLionel Sambuc 		xerrno = ENOENT;
21611be35a1SLionel Sambuc 	ATF_REQUIRE_ERRNO(xerrno, rump_sys_chdir("..") == -1);
21711be35a1SLionel Sambuc 	FSTEST_EXIT();
21811be35a1SLionel Sambuc }
21911be35a1SLionel Sambuc 
22011be35a1SLionel Sambuc static void
checkfile(const char * path,struct stat * refp)22111be35a1SLionel Sambuc checkfile(const char *path, struct stat *refp)
22211be35a1SLionel Sambuc {
22311be35a1SLionel Sambuc 	char buf[MAXPATHLEN];
22411be35a1SLionel Sambuc 	struct stat sb;
22511be35a1SLionel Sambuc 	static int n = 1;
22611be35a1SLionel Sambuc 
22711be35a1SLionel Sambuc 	md(buf, path, "file");
22811be35a1SLionel Sambuc 	if (rump_sys_stat(buf, &sb) == -1)
22911be35a1SLionel Sambuc 		atf_tc_fail_errno("cannot stat file %d (%s)", n, buf);
23011be35a1SLionel Sambuc 	if (memcmp(&sb, refp, sizeof(sb)) != 0)
23111be35a1SLionel Sambuc 		atf_tc_fail("stat mismatch %d", n);
23211be35a1SLionel Sambuc 	n++;
23311be35a1SLionel Sambuc }
23411be35a1SLionel Sambuc 
23511be35a1SLionel Sambuc static void
rename_dir(const atf_tc_t * tc,const char * mp)23611be35a1SLionel Sambuc rename_dir(const atf_tc_t *tc, const char *mp)
23711be35a1SLionel Sambuc {
23811be35a1SLionel Sambuc 	char pb1[MAXPATHLEN], pb2[MAXPATHLEN], pb3[MAXPATHLEN];
23911be35a1SLionel Sambuc 	struct stat ref, sb;
24011be35a1SLionel Sambuc 
24111be35a1SLionel Sambuc 	if (FSTYPE_RUMPFS(tc))
24211be35a1SLionel Sambuc 		atf_tc_skip("rename not supported by file system");
24311be35a1SLionel Sambuc 
24411be35a1SLionel Sambuc 	USES_DIRS;
24511be35a1SLionel Sambuc 
24611be35a1SLionel Sambuc 	md(pb1, mp, "dir1");
24711be35a1SLionel Sambuc 	if (rump_sys_mkdir(pb1, 0777) == -1)
24811be35a1SLionel Sambuc 		atf_tc_fail_errno("mkdir 1");
24911be35a1SLionel Sambuc 
25011be35a1SLionel Sambuc 	md(pb2, mp, "dir2");
25111be35a1SLionel Sambuc 	if (rump_sys_mkdir(pb2, 0777) == -1)
25211be35a1SLionel Sambuc 		atf_tc_fail_errno("mkdir 2");
25311be35a1SLionel Sambuc 	md(pb2, mp, "dir2/subdir");
25411be35a1SLionel Sambuc 	if (rump_sys_mkdir(pb2, 0777) == -1)
25511be35a1SLionel Sambuc 		atf_tc_fail_errno("mkdir 3");
25611be35a1SLionel Sambuc 
25711be35a1SLionel Sambuc 	md(pb3, mp, "dir1/file");
25811be35a1SLionel Sambuc 	if (rump_sys_mknod(pb3, S_IFREG | 0777, -1) == -1)
25911be35a1SLionel Sambuc 		atf_tc_fail_errno("create file");
26011be35a1SLionel Sambuc 	if (rump_sys_stat(pb3, &ref) == -1)
26111be35a1SLionel Sambuc 		atf_tc_fail_errno("stat of file");
26211be35a1SLionel Sambuc 
26311be35a1SLionel Sambuc 	/*
26411be35a1SLionel Sambuc 	 * First try ops which should succeed.
26511be35a1SLionel Sambuc 	 */
26611be35a1SLionel Sambuc 
26711be35a1SLionel Sambuc 	/* rename within directory */
26811be35a1SLionel Sambuc 	md(pb3, mp, "dir3");
26911be35a1SLionel Sambuc 	if (rump_sys_rename(pb1, pb3) == -1)
27011be35a1SLionel Sambuc 		atf_tc_fail_errno("rename 1");
27111be35a1SLionel Sambuc 	checkfile(pb3, &ref);
27211be35a1SLionel Sambuc 
27311be35a1SLionel Sambuc 	/* rename directory onto itself (two ways, should fail) */
27411be35a1SLionel Sambuc 	md(pb1, mp, "dir3/.");
27511be35a1SLionel Sambuc 	if (rump_sys_rename(pb1, pb3) != -1 || errno != EINVAL)
27611be35a1SLionel Sambuc 		atf_tc_fail_errno("rename 2");
27711be35a1SLionel Sambuc 	if (rump_sys_rename(pb3, pb1) != -1 || errno != EISDIR)
27811be35a1SLionel Sambuc 		atf_tc_fail_errno("rename 3");
27911be35a1SLionel Sambuc 
28011be35a1SLionel Sambuc 	checkfile(pb3, &ref);
28111be35a1SLionel Sambuc 
28211be35a1SLionel Sambuc 	/* rename father of directory into directory */
28311be35a1SLionel Sambuc 	md(pb1, mp, "dir2/dir");
28411be35a1SLionel Sambuc 	md(pb2, mp, "dir2");
28511be35a1SLionel Sambuc 	if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL)
28611be35a1SLionel Sambuc 		atf_tc_fail_errno("rename 4");
28711be35a1SLionel Sambuc 
28811be35a1SLionel Sambuc 	/* same for grandfather */
28911be35a1SLionel Sambuc 	md(pb1, mp, "dir2/subdir/dir2");
29011be35a1SLionel Sambuc 	if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL)
29111be35a1SLionel Sambuc 		atf_tc_fail("rename 5");
29211be35a1SLionel Sambuc 
29311be35a1SLionel Sambuc 	checkfile(pb3, &ref);
29411be35a1SLionel Sambuc 
29511be35a1SLionel Sambuc 	/* rename directory over a non-empty directory */
29611be35a1SLionel Sambuc 	if (rump_sys_rename(pb2, pb3) != -1 || errno != ENOTEMPTY)
29711be35a1SLionel Sambuc 		atf_tc_fail("rename 6");
29811be35a1SLionel Sambuc 
29911be35a1SLionel Sambuc 	/* cross-directory rename */
30011be35a1SLionel Sambuc 	md(pb1, mp, "dir3");
30111be35a1SLionel Sambuc 	md(pb2, mp, "dir2/somedir");
30211be35a1SLionel Sambuc 	if (rump_sys_rename(pb1, pb2) == -1)
30311be35a1SLionel Sambuc 		atf_tc_fail_errno("rename 7");
30411be35a1SLionel Sambuc 	checkfile(pb2, &ref);
30511be35a1SLionel Sambuc 
30611be35a1SLionel Sambuc 	/* move to parent directory */
30711be35a1SLionel Sambuc 	md(pb1, mp, "dir2/somedir/../../dir3");
30811be35a1SLionel Sambuc 	if (rump_sys_rename(pb2, pb1) == -1)
30911be35a1SLionel Sambuc 		atf_tc_fail_errno("rename 8");
31011be35a1SLionel Sambuc 	md(pb1, mp, "dir2/../dir3");
31111be35a1SLionel Sambuc 	checkfile(pb1, &ref);
31211be35a1SLionel Sambuc 
31311be35a1SLionel Sambuc 	/* atomic cross-directory rename */
31411be35a1SLionel Sambuc 	md(pb3, mp, "dir2/subdir");
31511be35a1SLionel Sambuc 	if (rump_sys_rename(pb1, pb3) == -1)
31611be35a1SLionel Sambuc 		atf_tc_fail_errno("rename 9");
31711be35a1SLionel Sambuc 	checkfile(pb3, &ref);
31811be35a1SLionel Sambuc 
31911be35a1SLionel Sambuc 	/* rename directory over an empty directory */
32011be35a1SLionel Sambuc 	md(pb1, mp, "parent");
32111be35a1SLionel Sambuc 	md(pb2, mp, "parent/dir1");
32211be35a1SLionel Sambuc 	md(pb3, mp, "parent/dir2");
32311be35a1SLionel Sambuc 	RL(rump_sys_mkdir(pb1, 0777));
32411be35a1SLionel Sambuc 	RL(rump_sys_mkdir(pb2, 0777));
32511be35a1SLionel Sambuc 	RL(rump_sys_mkdir(pb3, 0777));
32611be35a1SLionel Sambuc 	RL(rump_sys_rename(pb2, pb3));
32711be35a1SLionel Sambuc 
32811be35a1SLionel Sambuc 	RL(rump_sys_stat(pb1, &sb));
32911be35a1SLionel Sambuc 	if (! FSTYPE_MSDOS(tc))
33011be35a1SLionel Sambuc 		ATF_CHECK_EQ(sb.st_nlink, 3);
33111be35a1SLionel Sambuc 	RL(rump_sys_rmdir(pb3));
33211be35a1SLionel Sambuc 	RL(rump_sys_rmdir(pb1));
33311be35a1SLionel Sambuc }
33411be35a1SLionel Sambuc 
33511be35a1SLionel Sambuc static void
rename_dotdot(const atf_tc_t * tc,const char * mp)33611be35a1SLionel Sambuc rename_dotdot(const atf_tc_t *tc, const char *mp)
33711be35a1SLionel Sambuc {
33811be35a1SLionel Sambuc 
33911be35a1SLionel Sambuc 	if (FSTYPE_RUMPFS(tc))
34011be35a1SLionel Sambuc 		atf_tc_skip("rename not supported by file system");
34111be35a1SLionel Sambuc 
34211be35a1SLionel Sambuc 	USES_DIRS;
34311be35a1SLionel Sambuc 
34411be35a1SLionel Sambuc 	if (rump_sys_chdir(mp) == -1)
34511be35a1SLionel Sambuc 		atf_tc_fail_errno("chdir mountpoint");
34611be35a1SLionel Sambuc 
34711be35a1SLionel Sambuc 	if (rump_sys_mkdir("dir1", 0777) == -1)
34811be35a1SLionel Sambuc 		atf_tc_fail_errno("mkdir 1");
34911be35a1SLionel Sambuc 	if (rump_sys_mkdir("dir2", 0777) == -1)
35011be35a1SLionel Sambuc 		atf_tc_fail_errno("mkdir 2");
35111be35a1SLionel Sambuc 
35211be35a1SLionel Sambuc 	if (rump_sys_rename("dir1", "dir1/..") != -1 || errno != EINVAL)
35311be35a1SLionel Sambuc 		atf_tc_fail_errno("self-dotdot to");
35411be35a1SLionel Sambuc 
35511be35a1SLionel Sambuc 	if (rump_sys_rename("dir1/..", "sometarget") != -1 || errno != EINVAL)
35611be35a1SLionel Sambuc 		atf_tc_fail_errno("self-dotdot from");
35711be35a1SLionel Sambuc 
35811be35a1SLionel Sambuc 	if (rump_sys_rename("dir1", "dir2/..") != -1 || errno != EINVAL)
35911be35a1SLionel Sambuc 		atf_tc_fail("other-dotdot");
36011be35a1SLionel Sambuc 
36111be35a1SLionel Sambuc 	rump_sys_chdir("/");
36211be35a1SLionel Sambuc }
36311be35a1SLionel Sambuc 
36411be35a1SLionel Sambuc static void
rename_reg_nodir(const atf_tc_t * tc,const char * mp)36511be35a1SLionel Sambuc rename_reg_nodir(const atf_tc_t *tc, const char *mp)
36611be35a1SLionel Sambuc {
36711be35a1SLionel Sambuc 	bool haslinks;
36811be35a1SLionel Sambuc 	struct stat sb;
36984d9c625SLionel Sambuc 	ino_t f1ino;
37011be35a1SLionel Sambuc 
37111be35a1SLionel Sambuc 	if (FSTYPE_RUMPFS(tc))
37211be35a1SLionel Sambuc 		atf_tc_skip("rename not supported by file system");
37311be35a1SLionel Sambuc 
37411be35a1SLionel Sambuc 	if (rump_sys_chdir(mp) == -1)
37511be35a1SLionel Sambuc 		atf_tc_fail_errno("chdir mountpoint");
37611be35a1SLionel Sambuc 
37711be35a1SLionel Sambuc 	if (FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc))
37811be35a1SLionel Sambuc 		haslinks = false;
37911be35a1SLionel Sambuc 	else
38011be35a1SLionel Sambuc 		haslinks = true;
38111be35a1SLionel Sambuc 
38211be35a1SLionel Sambuc 	if (rump_sys_mknod("file1", S_IFREG | 0777, -1) == -1)
38311be35a1SLionel Sambuc 		atf_tc_fail_errno("create file");
38411be35a1SLionel Sambuc 	if (rump_sys_mknod("file2", S_IFREG | 0777, -1) == -1)
38511be35a1SLionel Sambuc 		atf_tc_fail_errno("create file");
38611be35a1SLionel Sambuc 
38711be35a1SLionel Sambuc 	if (rump_sys_stat("file1", &sb) == -1)
38811be35a1SLionel Sambuc 		atf_tc_fail_errno("stat");
38911be35a1SLionel Sambuc 	f1ino = sb.st_ino;
39011be35a1SLionel Sambuc 
39111be35a1SLionel Sambuc 	if (haslinks) {
39211be35a1SLionel Sambuc 		if (rump_sys_link("file1", "file_link") == -1)
39311be35a1SLionel Sambuc 			atf_tc_fail_errno("link");
39411be35a1SLionel Sambuc 		if (rump_sys_stat("file_link", &sb) == -1)
39511be35a1SLionel Sambuc 			atf_tc_fail_errno("stat");
39611be35a1SLionel Sambuc 		ATF_REQUIRE_EQ(sb.st_ino, f1ino);
39711be35a1SLionel Sambuc 		ATF_REQUIRE_EQ(sb.st_nlink, 2);
39811be35a1SLionel Sambuc 	}
39911be35a1SLionel Sambuc 
40011be35a1SLionel Sambuc 	if (rump_sys_stat("file2", &sb) == -1)
40111be35a1SLionel Sambuc 		atf_tc_fail_errno("stat");
40211be35a1SLionel Sambuc 
40311be35a1SLionel Sambuc 	if (rump_sys_rename("file1", "file3") == -1)
40411be35a1SLionel Sambuc 		atf_tc_fail_errno("rename 1");
40511be35a1SLionel Sambuc 	if (rump_sys_stat("file3", &sb) == -1)
40611be35a1SLionel Sambuc 		atf_tc_fail_errno("stat 1");
40711be35a1SLionel Sambuc 	if (haslinks) {
40811be35a1SLionel Sambuc 		ATF_REQUIRE_EQ(sb.st_ino, f1ino);
40911be35a1SLionel Sambuc 	}
41011be35a1SLionel Sambuc 	if (rump_sys_stat("file1", &sb) != -1 || errno != ENOENT)
41111be35a1SLionel Sambuc 		atf_tc_fail_errno("source 1");
41211be35a1SLionel Sambuc 
41311be35a1SLionel Sambuc 	if (rump_sys_rename("file3", "file2") == -1)
41411be35a1SLionel Sambuc 		atf_tc_fail_errno("rename 2");
41511be35a1SLionel Sambuc 	if (rump_sys_stat("file2", &sb) == -1)
41611be35a1SLionel Sambuc 		atf_tc_fail_errno("stat 2");
41711be35a1SLionel Sambuc 	if (haslinks) {
41811be35a1SLionel Sambuc 		ATF_REQUIRE_EQ(sb.st_ino, f1ino);
41911be35a1SLionel Sambuc 	}
42011be35a1SLionel Sambuc 
42111be35a1SLionel Sambuc 	if (rump_sys_stat("file3", &sb) != -1 || errno != ENOENT)
42211be35a1SLionel Sambuc 		atf_tc_fail_errno("source 2");
42311be35a1SLionel Sambuc 
42411be35a1SLionel Sambuc 	if (haslinks) {
42511be35a1SLionel Sambuc 		if (rump_sys_rename("file2", "file_link") == -1)
42611be35a1SLionel Sambuc 			atf_tc_fail_errno("rename hardlink");
42711be35a1SLionel Sambuc 		if (rump_sys_stat("file2", &sb) != -1 || errno != ENOENT)
42811be35a1SLionel Sambuc 			atf_tc_fail_errno("source 3");
42911be35a1SLionel Sambuc 		if (rump_sys_stat("file_link", &sb) == -1)
43011be35a1SLionel Sambuc 			atf_tc_fail_errno("stat 2");
43111be35a1SLionel Sambuc 		ATF_REQUIRE_EQ(sb.st_ino, f1ino);
43211be35a1SLionel Sambuc 		ATF_REQUIRE_EQ(sb.st_nlink, 1);
43311be35a1SLionel Sambuc 	}
43411be35a1SLionel Sambuc 
43584d9c625SLionel Sambuc 	ATF_CHECK_ERRNO(EFAULT, rump_sys_rename("file2", NULL) == -1);
43684d9c625SLionel Sambuc 	ATF_CHECK_ERRNO(EFAULT, rump_sys_rename(NULL, "file2") == -1);
43784d9c625SLionel Sambuc 
43811be35a1SLionel Sambuc 	rump_sys_chdir("/");
43911be35a1SLionel Sambuc }
44011be35a1SLionel Sambuc 
44111be35a1SLionel Sambuc static void
create_nametoolong(const atf_tc_t * tc,const char * mp)44211be35a1SLionel Sambuc create_nametoolong(const atf_tc_t *tc, const char *mp)
44311be35a1SLionel Sambuc {
44411be35a1SLionel Sambuc 	char *name;
44511be35a1SLionel Sambuc 	int fd;
44611be35a1SLionel Sambuc 	long val;
44711be35a1SLionel Sambuc 	size_t len;
44811be35a1SLionel Sambuc 
44911be35a1SLionel Sambuc 	if (rump_sys_chdir(mp) == -1)
45011be35a1SLionel Sambuc 		atf_tc_fail_errno("chdir mountpoint");
45111be35a1SLionel Sambuc 
45211be35a1SLionel Sambuc 	val = rump_sys_pathconf(".", _PC_NAME_MAX);
45311be35a1SLionel Sambuc 	if (val == -1)
45411be35a1SLionel Sambuc 		atf_tc_fail_errno("pathconf");
45511be35a1SLionel Sambuc 
45611be35a1SLionel Sambuc 	len = val + 1;
45711be35a1SLionel Sambuc 	name = malloc(len+1);
45811be35a1SLionel Sambuc 	if (name == NULL)
45911be35a1SLionel Sambuc 		atf_tc_fail_errno("malloc");
46011be35a1SLionel Sambuc 
46111be35a1SLionel Sambuc 	memset(name, 'a', len);
46211be35a1SLionel Sambuc 	*(name+len) = '\0';
46311be35a1SLionel Sambuc 
46411be35a1SLionel Sambuc 	val = rump_sys_pathconf(".", _PC_NO_TRUNC);
46511be35a1SLionel Sambuc 	if (val == -1)
46611be35a1SLionel Sambuc 		atf_tc_fail_errno("pathconf");
46711be35a1SLionel Sambuc 
46811be35a1SLionel Sambuc 	fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666);
46911be35a1SLionel Sambuc 	if (val != 0 && (fd != -1 || errno != ENAMETOOLONG))
47011be35a1SLionel Sambuc 		atf_tc_fail_errno("open");
47111be35a1SLionel Sambuc 
47211be35a1SLionel Sambuc 	if (val == 0 && rump_sys_close(fd) == -1)
47311be35a1SLionel Sambuc 		atf_tc_fail_errno("close");
47411be35a1SLionel Sambuc 	if (val == 0 && rump_sys_unlink(name) == -1)
47511be35a1SLionel Sambuc 		atf_tc_fail_errno("unlink");
47611be35a1SLionel Sambuc 
47711be35a1SLionel Sambuc 	free(name);
47811be35a1SLionel Sambuc 
47911be35a1SLionel Sambuc 	rump_sys_chdir("/");
48011be35a1SLionel Sambuc }
48111be35a1SLionel Sambuc 
48211be35a1SLionel Sambuc static void
create_exist(const atf_tc_t * tc,const char * mp)48311be35a1SLionel Sambuc create_exist(const atf_tc_t *tc, const char *mp)
48411be35a1SLionel Sambuc {
48511be35a1SLionel Sambuc 	const char *name = "hoge";
48611be35a1SLionel Sambuc 	int fd;
48711be35a1SLionel Sambuc 
48811be35a1SLionel Sambuc 	RL(rump_sys_chdir(mp));
48911be35a1SLionel Sambuc 	RL(fd = rump_sys_open(name, O_RDWR|O_CREAT|O_EXCL, 0666));
49011be35a1SLionel Sambuc 	RL(rump_sys_close(fd));
49111be35a1SLionel Sambuc 	RL(rump_sys_unlink(name));
49211be35a1SLionel Sambuc 	RL(fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666));
49311be35a1SLionel Sambuc 	RL(rump_sys_close(fd));
49411be35a1SLionel Sambuc 	RL(fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666));
49511be35a1SLionel Sambuc 	RL(rump_sys_close(fd));
49611be35a1SLionel Sambuc 	ATF_REQUIRE_ERRNO(EEXIST,
49711be35a1SLionel Sambuc 	    (fd = rump_sys_open(name, O_RDWR|O_CREAT|O_EXCL, 0666)));
49811be35a1SLionel Sambuc 	RL(rump_sys_unlink(name));
49911be35a1SLionel Sambuc 	RL(rump_sys_chdir("/"));
50011be35a1SLionel Sambuc }
50111be35a1SLionel Sambuc 
50211be35a1SLionel Sambuc static void
rename_nametoolong(const atf_tc_t * tc,const char * mp)50311be35a1SLionel Sambuc rename_nametoolong(const atf_tc_t *tc, const char *mp)
50411be35a1SLionel Sambuc {
50511be35a1SLionel Sambuc 	char *name;
50611be35a1SLionel Sambuc 	int res, fd;
50711be35a1SLionel Sambuc 	long val;
50811be35a1SLionel Sambuc 	size_t len;
50911be35a1SLionel Sambuc 
51011be35a1SLionel Sambuc 	if (FSTYPE_RUMPFS(tc))
51111be35a1SLionel Sambuc 		atf_tc_skip("rename not supported by file system");
51211be35a1SLionel Sambuc 
51311be35a1SLionel Sambuc 	if (rump_sys_chdir(mp) == -1)
51411be35a1SLionel Sambuc 		atf_tc_fail_errno("chdir mountpoint");
51511be35a1SLionel Sambuc 
51611be35a1SLionel Sambuc 	val = rump_sys_pathconf(".", _PC_NAME_MAX);
51711be35a1SLionel Sambuc 	if (val == -1)
51811be35a1SLionel Sambuc 		atf_tc_fail_errno("pathconf");
51911be35a1SLionel Sambuc 
52011be35a1SLionel Sambuc 	len = val + 1;
52111be35a1SLionel Sambuc 	name = malloc(len+1);
52211be35a1SLionel Sambuc 	if (name == NULL)
52311be35a1SLionel Sambuc 		atf_tc_fail_errno("malloc");
52411be35a1SLionel Sambuc 
52511be35a1SLionel Sambuc 	memset(name, 'a', len);
52611be35a1SLionel Sambuc 	*(name+len) = '\0';
52711be35a1SLionel Sambuc 
52811be35a1SLionel Sambuc 	fd = rump_sys_open("dummy", O_RDWR|O_CREAT, 0666);
52911be35a1SLionel Sambuc 	if (fd == -1)
53011be35a1SLionel Sambuc 		atf_tc_fail_errno("open");
53111be35a1SLionel Sambuc 	if (rump_sys_close(fd) == -1)
53211be35a1SLionel Sambuc 		atf_tc_fail_errno("close");
53311be35a1SLionel Sambuc 
53411be35a1SLionel Sambuc 	val = rump_sys_pathconf(".", _PC_NO_TRUNC);
53511be35a1SLionel Sambuc 	if (val == -1)
53611be35a1SLionel Sambuc 		atf_tc_fail_errno("pathconf");
53711be35a1SLionel Sambuc 
53811be35a1SLionel Sambuc 	res = rump_sys_rename("dummy", name);
53911be35a1SLionel Sambuc 	if (val != 0 && (res != -1 || errno != ENAMETOOLONG))
54011be35a1SLionel Sambuc 		atf_tc_fail_errno("rename");
54111be35a1SLionel Sambuc 
54211be35a1SLionel Sambuc 	if (val == 0 && rump_sys_unlink(name) == -1)
54311be35a1SLionel Sambuc 		atf_tc_fail_errno("unlink");
54411be35a1SLionel Sambuc 
54511be35a1SLionel Sambuc 	free(name);
54611be35a1SLionel Sambuc 
54711be35a1SLionel Sambuc 	rump_sys_chdir("/");
54811be35a1SLionel Sambuc }
54911be35a1SLionel Sambuc 
550*0a6a1f1dSLionel Sambuc /*
551*0a6a1f1dSLionel Sambuc  * Test creating a symlink whose length is "len" bytes, not including
552*0a6a1f1dSLionel Sambuc  * the terminating NUL.
553*0a6a1f1dSLionel Sambuc  */
55411be35a1SLionel Sambuc static void
symlink_len(const atf_tc_t * tc,const char * mp,size_t len)555*0a6a1f1dSLionel Sambuc symlink_len(const atf_tc_t *tc, const char *mp, size_t len)
55611be35a1SLionel Sambuc {
557*0a6a1f1dSLionel Sambuc 	char *buf;
558*0a6a1f1dSLionel Sambuc 	int r;
55911be35a1SLionel Sambuc 
56011be35a1SLionel Sambuc 	USES_SYMLINKS;
56111be35a1SLionel Sambuc 
56211be35a1SLionel Sambuc 	RL(rump_sys_chdir(mp));
56311be35a1SLionel Sambuc 
564*0a6a1f1dSLionel Sambuc 	buf = malloc(len + 1);
565*0a6a1f1dSLionel Sambuc 	ATF_REQUIRE(buf);
566*0a6a1f1dSLionel Sambuc 	memset(buf, 'a', len);
567*0a6a1f1dSLionel Sambuc 	buf[len] = '\0';
568*0a6a1f1dSLionel Sambuc 	r = rump_sys_symlink(buf, "afile");
569*0a6a1f1dSLionel Sambuc 	if (r == -1) {
570*0a6a1f1dSLionel Sambuc 		ATF_REQUIRE_ERRNO(ENAMETOOLONG, r);
571*0a6a1f1dSLionel Sambuc 	} else {
572*0a6a1f1dSLionel Sambuc 		RL(rump_sys_unlink("afile"));
573*0a6a1f1dSLionel Sambuc 	}
574*0a6a1f1dSLionel Sambuc 	free(buf);
575*0a6a1f1dSLionel Sambuc 
57611be35a1SLionel Sambuc 	RL(rump_sys_chdir("/"));
57711be35a1SLionel Sambuc }
57811be35a1SLionel Sambuc 
57911be35a1SLionel Sambuc static void
symlink_zerolen(const atf_tc_t * tc,const char * mp)580*0a6a1f1dSLionel Sambuc symlink_zerolen(const atf_tc_t *tc, const char *mp)
581*0a6a1f1dSLionel Sambuc {
582*0a6a1f1dSLionel Sambuc 	symlink_len(tc, mp, 0);
583*0a6a1f1dSLionel Sambuc }
584*0a6a1f1dSLionel Sambuc 
585*0a6a1f1dSLionel Sambuc static void
symlink_long(const atf_tc_t * tc,const char * mp)586*0a6a1f1dSLionel Sambuc symlink_long(const atf_tc_t *tc, const char *mp)
587*0a6a1f1dSLionel Sambuc {
588*0a6a1f1dSLionel Sambuc 	/*
589*0a6a1f1dSLionel Sambuc 	 * Test lengths close to powers of two, as those are likely
590*0a6a1f1dSLionel Sambuc 	 * to be edge cases.
591*0a6a1f1dSLionel Sambuc 	 */
592*0a6a1f1dSLionel Sambuc 	size_t len;
593*0a6a1f1dSLionel Sambuc 	int fuzz;
594*0a6a1f1dSLionel Sambuc 	for (len = 2; len <= 65536; len *= 2) {
595*0a6a1f1dSLionel Sambuc 		for (fuzz = -1; fuzz <= 1; fuzz++) {
596*0a6a1f1dSLionel Sambuc 			symlink_len(tc, mp, len + fuzz);
597*0a6a1f1dSLionel Sambuc 		}
598*0a6a1f1dSLionel Sambuc 	}
599*0a6a1f1dSLionel Sambuc }
600*0a6a1f1dSLionel Sambuc 
601*0a6a1f1dSLionel Sambuc static void
symlink_root(const atf_tc_t * tc,const char * mp)60211be35a1SLionel Sambuc symlink_root(const atf_tc_t *tc, const char *mp)
60311be35a1SLionel Sambuc {
60411be35a1SLionel Sambuc 
60511be35a1SLionel Sambuc 	USES_SYMLINKS;
60611be35a1SLionel Sambuc 
60711be35a1SLionel Sambuc 	RL(rump_sys_chdir(mp));
60811be35a1SLionel Sambuc 	RL(rump_sys_symlink("/", "foo"));
60911be35a1SLionel Sambuc 	RL(rump_sys_chdir("foo"));
61011be35a1SLionel Sambuc }
61111be35a1SLionel Sambuc 
61211be35a1SLionel Sambuc static void
attrs(const atf_tc_t * tc,const char * mp)61311be35a1SLionel Sambuc attrs(const atf_tc_t *tc, const char *mp)
61411be35a1SLionel Sambuc {
61511be35a1SLionel Sambuc 	struct stat sb, sb2;
61611be35a1SLionel Sambuc 	struct timeval tv[2];
61711be35a1SLionel Sambuc 	int fd;
61811be35a1SLionel Sambuc 
61911be35a1SLionel Sambuc 	FSTEST_ENTER();
62011be35a1SLionel Sambuc 	RL(fd = rump_sys_open(TESTFILE, O_RDWR | O_CREAT, 0755));
62111be35a1SLionel Sambuc 	RL(rump_sys_close(fd));
62211be35a1SLionel Sambuc 	RL(rump_sys_stat(TESTFILE, &sb));
62311be35a1SLionel Sambuc 	if (!(FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc))) {
62411be35a1SLionel Sambuc 		RL(rump_sys_chown(TESTFILE, 1, 2));
62511be35a1SLionel Sambuc 		sb.st_uid = 1;
62611be35a1SLionel Sambuc 		sb.st_gid = 2;
62711be35a1SLionel Sambuc 		RL(rump_sys_chmod(TESTFILE, 0123));
62811be35a1SLionel Sambuc 		sb.st_mode = (sb.st_mode & ~ACCESSPERMS) | 0123;
62911be35a1SLionel Sambuc 	}
63011be35a1SLionel Sambuc 
63111be35a1SLionel Sambuc 	tv[0].tv_sec = 1000000000; /* need something >1980 for msdosfs */
63211be35a1SLionel Sambuc 	tv[0].tv_usec = 1;
63311be35a1SLionel Sambuc 	tv[1].tv_sec = 1000000002; /* need even seconds for msdosfs */
63411be35a1SLionel Sambuc 	tv[1].tv_usec = 3;
63511be35a1SLionel Sambuc 	RL(rump_sys_utimes(TESTFILE, tv));
63611be35a1SLionel Sambuc 	RL(rump_sys_utimes(TESTFILE, tv)); /* XXX: utimes & birthtime */
63711be35a1SLionel Sambuc 	sb.st_atimespec.tv_sec = 1000000000;
63811be35a1SLionel Sambuc 	sb.st_atimespec.tv_nsec = 1000;
63911be35a1SLionel Sambuc 	sb.st_mtimespec.tv_sec = 1000000002;
64011be35a1SLionel Sambuc 	sb.st_mtimespec.tv_nsec = 3000;
64111be35a1SLionel Sambuc 
64211be35a1SLionel Sambuc 	RL(rump_sys_stat(TESTFILE, &sb2));
64311be35a1SLionel Sambuc #define CHECK(a) ATF_REQUIRE_EQ(sb.a, sb2.a)
64411be35a1SLionel Sambuc 	if (!(FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc))) {
64511be35a1SLionel Sambuc 		CHECK(st_uid);
64611be35a1SLionel Sambuc 		CHECK(st_gid);
64711be35a1SLionel Sambuc 		CHECK(st_mode);
64811be35a1SLionel Sambuc 	}
64911be35a1SLionel Sambuc 	if (!FSTYPE_MSDOS(tc)) {
65011be35a1SLionel Sambuc 		/* msdosfs has only access date, not time */
65111be35a1SLionel Sambuc 		CHECK(st_atimespec.tv_sec);
65211be35a1SLionel Sambuc 	}
65311be35a1SLionel Sambuc 	CHECK(st_mtimespec.tv_sec);
65411be35a1SLionel Sambuc 	if (!(FSTYPE_EXT2FS(tc) || FSTYPE_MSDOS(tc) ||
65511be35a1SLionel Sambuc 	      FSTYPE_SYSVBFS(tc) || FSTYPE_V7FS(tc))) {
65611be35a1SLionel Sambuc 		CHECK(st_atimespec.tv_nsec);
65711be35a1SLionel Sambuc 		CHECK(st_mtimespec.tv_nsec);
65811be35a1SLionel Sambuc 	}
65911be35a1SLionel Sambuc #undef  CHECK
66011be35a1SLionel Sambuc 
66111be35a1SLionel Sambuc 	FSTEST_EXIT();
66211be35a1SLionel Sambuc }
66311be35a1SLionel Sambuc 
66411be35a1SLionel Sambuc static void
fcntl_lock(const atf_tc_t * tc,const char * mp)66511be35a1SLionel Sambuc fcntl_lock(const atf_tc_t *tc, const char *mp)
66611be35a1SLionel Sambuc {
66711be35a1SLionel Sambuc 	int fd, fd2;
66811be35a1SLionel Sambuc 	struct flock l;
66911be35a1SLionel Sambuc 	struct lwp *lwp1, *lwp2;
67011be35a1SLionel Sambuc 
67111be35a1SLionel Sambuc 	FSTEST_ENTER();
67211be35a1SLionel Sambuc 	l.l_pid = 0;
67311be35a1SLionel Sambuc 	l.l_start = l.l_len = 1024;
67411be35a1SLionel Sambuc 	l.l_type = F_RDLCK | F_WRLCK;
67511be35a1SLionel Sambuc 	l.l_whence = SEEK_END;
67611be35a1SLionel Sambuc 
67711be35a1SLionel Sambuc 	lwp1 = rump_pub_lwproc_curlwp();
67811be35a1SLionel Sambuc 	RL(fd = rump_sys_open(TESTFILE, O_RDWR | O_CREAT, 0755));
67911be35a1SLionel Sambuc 	RL(rump_sys_ftruncate(fd, 8192));
68011be35a1SLionel Sambuc 
68111be35a1SLionel Sambuc 	RL(rump_sys_fcntl(fd, F_SETLK, &l));
68211be35a1SLionel Sambuc 
68311be35a1SLionel Sambuc 	/* Next, we fork and try to lock the same area */
68411be35a1SLionel Sambuc 	RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
68511be35a1SLionel Sambuc 	lwp2 = rump_pub_lwproc_curlwp();
68611be35a1SLionel Sambuc 	RL(fd2 = rump_sys_open(TESTFILE, O_RDWR, 0));
68711be35a1SLionel Sambuc 	ATF_REQUIRE_ERRNO(EAGAIN, rump_sys_fcntl(fd2, F_SETLK, &l));
68811be35a1SLionel Sambuc 
68911be35a1SLionel Sambuc 	/* Switch back and unlock... */
69011be35a1SLionel Sambuc 	rump_pub_lwproc_switch(lwp1);
69111be35a1SLionel Sambuc 	l.l_type = F_UNLCK;
69211be35a1SLionel Sambuc 	RL(rump_sys_fcntl(fd, F_SETLK, &l));
69311be35a1SLionel Sambuc 
69411be35a1SLionel Sambuc 	/* ... and try to lock again */
69511be35a1SLionel Sambuc 	rump_pub_lwproc_switch(lwp2);
69611be35a1SLionel Sambuc 	l.l_type = F_RDLCK | F_WRLCK;
69711be35a1SLionel Sambuc 	RL(rump_sys_fcntl(fd2, F_SETLK, &l));
69811be35a1SLionel Sambuc 
69911be35a1SLionel Sambuc 	RL(rump_sys_close(fd2));
70011be35a1SLionel Sambuc 	rump_pub_lwproc_releaselwp();
70111be35a1SLionel Sambuc 
70211be35a1SLionel Sambuc 	RL(rump_sys_close(fd));
70311be35a1SLionel Sambuc 
70411be35a1SLionel Sambuc 	FSTEST_EXIT();
70511be35a1SLionel Sambuc }
70611be35a1SLionel Sambuc 
70711be35a1SLionel Sambuc static int
flock_compare(const void * p,const void * q)70811be35a1SLionel Sambuc flock_compare(const void *p, const void *q)
70911be35a1SLionel Sambuc {
71011be35a1SLionel Sambuc 	int a = ((const struct flock *)p)->l_start;
71111be35a1SLionel Sambuc 	int b = ((const struct flock *)q)->l_start;
71211be35a1SLionel Sambuc 	return a < b ? -1 : (a > b ? 1 : 0);
71311be35a1SLionel Sambuc }
71411be35a1SLionel Sambuc 
71511be35a1SLionel Sambuc /*
71611be35a1SLionel Sambuc  * Find all locks set by fcntl_getlock_pids test
71711be35a1SLionel Sambuc  * using GETLK for a range [start, start+end], and,
71811be35a1SLionel Sambuc  * if there is a blocking lock, recursively find
71911be35a1SLionel Sambuc  * all locks to the left (toward the beginning of
72011be35a1SLionel Sambuc  * a file) and to the right of the lock.
72111be35a1SLionel Sambuc  * The function also understands "until end of file"
72211be35a1SLionel Sambuc  * convention when len==0.
72311be35a1SLionel Sambuc  */
72411be35a1SLionel Sambuc static unsigned int
fcntl_getlocks(int fildes,off_t start,off_t len,struct flock * lock,struct flock * end)72511be35a1SLionel Sambuc fcntl_getlocks(int fildes, off_t start, off_t len,
72611be35a1SLionel Sambuc     struct flock *lock, struct flock *end)
72711be35a1SLionel Sambuc {
72811be35a1SLionel Sambuc 	unsigned int rv = 0;
72911be35a1SLionel Sambuc 	const struct flock l = { start, len, 0, F_RDLCK, SEEK_SET };
73011be35a1SLionel Sambuc 
73111be35a1SLionel Sambuc 	if (lock == end)
73211be35a1SLionel Sambuc 		return rv;
73311be35a1SLionel Sambuc 
73411be35a1SLionel Sambuc 	RL(rump_sys_fcntl(fildes, F_GETLK, &l));
73511be35a1SLionel Sambuc 
73611be35a1SLionel Sambuc 	if (l.l_type == F_UNLCK)
73711be35a1SLionel Sambuc 		return rv;
73811be35a1SLionel Sambuc 
73911be35a1SLionel Sambuc 	*lock++ = l;
74011be35a1SLionel Sambuc 	rv += 1;
74111be35a1SLionel Sambuc 
74211be35a1SLionel Sambuc 	ATF_REQUIRE(l.l_whence == SEEK_SET);
74311be35a1SLionel Sambuc 
74411be35a1SLionel Sambuc 	if (l.l_start > start) {
74511be35a1SLionel Sambuc 		unsigned int n =
74611be35a1SLionel Sambuc 		    fcntl_getlocks(fildes, start, l.l_start - start, lock, end);
74711be35a1SLionel Sambuc 		rv += n;
74811be35a1SLionel Sambuc 		lock += n;
74911be35a1SLionel Sambuc 		if (lock == end)
75011be35a1SLionel Sambuc 			return rv;
75111be35a1SLionel Sambuc 	}
75211be35a1SLionel Sambuc 
75311be35a1SLionel Sambuc 	if (l.l_len == 0) /* does l spans until the end? */
75411be35a1SLionel Sambuc 		return rv;
75511be35a1SLionel Sambuc 
75611be35a1SLionel Sambuc 	if (len == 0) /* are we looking for locks until the end? */ {
75711be35a1SLionel Sambuc 		rv += fcntl_getlocks(fildes, l.l_start + l.l_len, len, lock, end);
75811be35a1SLionel Sambuc 	} else if (l.l_start + l.l_len < start + len) {
75911be35a1SLionel Sambuc 		len -= l.l_start + l.l_len - start;
76011be35a1SLionel Sambuc 		rv += fcntl_getlocks(fildes, l.l_start + l.l_len, len, lock, end);
76111be35a1SLionel Sambuc 	}
76211be35a1SLionel Sambuc 
76311be35a1SLionel Sambuc 	return rv;
76411be35a1SLionel Sambuc }
76511be35a1SLionel Sambuc 
76611be35a1SLionel Sambuc static void
fcntl_getlock_pids(const atf_tc_t * tc,const char * mp)76711be35a1SLionel Sambuc fcntl_getlock_pids(const atf_tc_t *tc, const char *mp)
76811be35a1SLionel Sambuc {
76911be35a1SLionel Sambuc 	/* test non-overlaping ranges */
77011be35a1SLionel Sambuc 	struct flock expect[4];
77111be35a1SLionel Sambuc 	const struct flock lock[4] = {
77211be35a1SLionel Sambuc 		{ 0, 2, 0, F_WRLCK, SEEK_SET },
77311be35a1SLionel Sambuc 		{ 2, 1, 0, F_WRLCK, SEEK_SET },
77411be35a1SLionel Sambuc 		{ 7, 5, 0, F_WRLCK, SEEK_SET },
77511be35a1SLionel Sambuc 		{ 4, 3, 0, F_WRLCK, SEEK_SET },
77611be35a1SLionel Sambuc 	};
77711be35a1SLionel Sambuc 
77811be35a1SLionel Sambuc     /* Add extra element to make sure recursion does't stop at array end */
77911be35a1SLionel Sambuc 	struct flock result[5];
78011be35a1SLionel Sambuc 
78111be35a1SLionel Sambuc 	/* Add 5th process */
78211be35a1SLionel Sambuc 	int fd[5];
78311be35a1SLionel Sambuc 	pid_t pid[5];
78411be35a1SLionel Sambuc 	struct lwp *lwp[5];
78511be35a1SLionel Sambuc 
78611be35a1SLionel Sambuc 	unsigned int i, j;
78711be35a1SLionel Sambuc 	const off_t sz = 8192;
78811be35a1SLionel Sambuc 	int omode  = 0755;
78911be35a1SLionel Sambuc 	int oflags = O_RDWR | O_CREAT;
79011be35a1SLionel Sambuc 
79111be35a1SLionel Sambuc 	memcpy(expect, lock, sizeof(lock));
79211be35a1SLionel Sambuc 
79311be35a1SLionel Sambuc 	FSTEST_ENTER();
79411be35a1SLionel Sambuc 
79511be35a1SLionel Sambuc 	/*
79611be35a1SLionel Sambuc 	 * First, we create 4 processes and let each lock a range of the
79711be35a1SLionel Sambuc 	 * file.  Note that the third and fourth processes lock in
79811be35a1SLionel Sambuc 	 * "reverse" order, i.e. the greater pid locks a range before
79911be35a1SLionel Sambuc 	 * the lesser pid.
80011be35a1SLionel Sambuc 	 * Then, we create 5th process which doesn't lock anything.
80111be35a1SLionel Sambuc 	 */
80211be35a1SLionel Sambuc 	for (i = 0; i < __arraycount(lwp); i++) {
80311be35a1SLionel Sambuc 		RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
80411be35a1SLionel Sambuc 
80511be35a1SLionel Sambuc 		lwp[i] = rump_pub_lwproc_curlwp();
80611be35a1SLionel Sambuc 		pid[i] = rump_sys_getpid();
80711be35a1SLionel Sambuc 
80811be35a1SLionel Sambuc 		RL(fd[i] = rump_sys_open(TESTFILE, oflags, omode));
80911be35a1SLionel Sambuc 		oflags = O_RDWR;
81011be35a1SLionel Sambuc 		omode  = 0;
81111be35a1SLionel Sambuc 
81211be35a1SLionel Sambuc 		RL(rump_sys_ftruncate(fd[i], sz));
81311be35a1SLionel Sambuc 
81411be35a1SLionel Sambuc 		if (i < __arraycount(lock)) {
81511be35a1SLionel Sambuc 			RL(rump_sys_fcntl(fd[i], F_SETLK, &lock[i]));
81611be35a1SLionel Sambuc 			expect[i].l_pid = pid[i];
81711be35a1SLionel Sambuc 		}
81811be35a1SLionel Sambuc 	}
81911be35a1SLionel Sambuc 
82011be35a1SLionel Sambuc 	qsort(expect, __arraycount(expect), sizeof(expect[0]), &flock_compare);
82111be35a1SLionel Sambuc 
82211be35a1SLionel Sambuc 	/*
82311be35a1SLionel Sambuc 	 * In the context of each process, recursively find all locks
82411be35a1SLionel Sambuc 	 * that would block the current process. Processes 1-4 don't
82511be35a1SLionel Sambuc 	 * see their own lock, we insert it to simplify checks.
82611be35a1SLionel Sambuc 	 * Process 5 sees all 4 locks.
82711be35a1SLionel Sambuc 	 */
82811be35a1SLionel Sambuc 	for (i = 0; i < __arraycount(lwp); i++) {
82911be35a1SLionel Sambuc 		unsigned int nlocks;
83011be35a1SLionel Sambuc 
83111be35a1SLionel Sambuc 		rump_pub_lwproc_switch(lwp[i]);
83211be35a1SLionel Sambuc 
83311be35a1SLionel Sambuc 		memset(result, 0, sizeof(result));
83411be35a1SLionel Sambuc 		nlocks = fcntl_getlocks(fd[i], 0, sz,
83511be35a1SLionel Sambuc 		    result, result + __arraycount(result));
83611be35a1SLionel Sambuc 
83711be35a1SLionel Sambuc 		if (i < __arraycount(lock)) {
83811be35a1SLionel Sambuc 			ATF_REQUIRE(nlocks < __arraycount(result));
83911be35a1SLionel Sambuc 			result[nlocks] = lock[i];
84011be35a1SLionel Sambuc 			result[nlocks].l_pid = pid[i];
84111be35a1SLionel Sambuc 			nlocks++;
84211be35a1SLionel Sambuc 		}
84311be35a1SLionel Sambuc 
84411be35a1SLionel Sambuc 		ATF_CHECK_EQ(nlocks, __arraycount(expect));
84511be35a1SLionel Sambuc 
84611be35a1SLionel Sambuc 		qsort(result, nlocks, sizeof(result[0]), &flock_compare);
84711be35a1SLionel Sambuc 
84811be35a1SLionel Sambuc 		for (j = 0; j < nlocks; j++) {
84911be35a1SLionel Sambuc 			ATF_CHECK_EQ(result[j].l_start,  expect[j].l_start );
85011be35a1SLionel Sambuc 			ATF_CHECK_EQ(result[j].l_len,    expect[j].l_len   );
85111be35a1SLionel Sambuc 			ATF_CHECK_EQ(result[j].l_pid,    expect[j].l_pid   );
85211be35a1SLionel Sambuc 			ATF_CHECK_EQ(result[j].l_type,   expect[j].l_type  );
85311be35a1SLionel Sambuc 			ATF_CHECK_EQ(result[j].l_whence, expect[j].l_whence);
85411be35a1SLionel Sambuc 		}
85511be35a1SLionel Sambuc 	}
85611be35a1SLionel Sambuc 
85711be35a1SLionel Sambuc 	/*
85811be35a1SLionel Sambuc 	 * Release processes.  This also releases the fds and locks
85911be35a1SLionel Sambuc 	 * making fs unmount possible
86011be35a1SLionel Sambuc 	 */
86111be35a1SLionel Sambuc 	for (i = 0; i < __arraycount(lwp); i++) {
86211be35a1SLionel Sambuc 		rump_pub_lwproc_switch(lwp[i]);
86311be35a1SLionel Sambuc 		rump_pub_lwproc_releaselwp();
86411be35a1SLionel Sambuc 	}
86511be35a1SLionel Sambuc 
86611be35a1SLionel Sambuc 	FSTEST_EXIT();
86711be35a1SLionel Sambuc }
86811be35a1SLionel Sambuc 
86911be35a1SLionel Sambuc static void
access_simple(const atf_tc_t * tc,const char * mp)87011be35a1SLionel Sambuc access_simple(const atf_tc_t *tc, const char *mp)
87111be35a1SLionel Sambuc {
87211be35a1SLionel Sambuc 	int fd;
87311be35a1SLionel Sambuc 	int tmode;
87411be35a1SLionel Sambuc 
87511be35a1SLionel Sambuc 	FSTEST_ENTER();
87611be35a1SLionel Sambuc 	RL(fd = rump_sys_open("tfile", O_CREAT | O_RDWR, 0777));
87711be35a1SLionel Sambuc 	RL(rump_sys_close(fd));
87811be35a1SLionel Sambuc 
87911be35a1SLionel Sambuc #define ALLACC (F_OK | X_OK | W_OK | R_OK)
88011be35a1SLionel Sambuc 	if (FSTYPE_SYSVBFS(tc) || FSTYPE_MSDOS(tc))
88111be35a1SLionel Sambuc 		tmode = F_OK;
88211be35a1SLionel Sambuc 	else
88311be35a1SLionel Sambuc 		tmode = ALLACC;
88411be35a1SLionel Sambuc 
88511be35a1SLionel Sambuc 	RL(rump_sys_access("tfile", tmode));
88611be35a1SLionel Sambuc 
88711be35a1SLionel Sambuc 	/* PR kern/44648 */
88811be35a1SLionel Sambuc 	ATF_REQUIRE_ERRNO(EINVAL, rump_sys_access("tfile", ALLACC+1) == -1);
88911be35a1SLionel Sambuc #undef ALLACC
89011be35a1SLionel Sambuc 	FSTEST_EXIT();
89111be35a1SLionel Sambuc }
89211be35a1SLionel Sambuc 
89311be35a1SLionel Sambuc static void
read_directory(const atf_tc_t * tc,const char * mp)89411be35a1SLionel Sambuc read_directory(const atf_tc_t *tc, const char *mp)
89511be35a1SLionel Sambuc {
89611be35a1SLionel Sambuc 	char buf[1024];
89711be35a1SLionel Sambuc 	int fd, res;
89811be35a1SLionel Sambuc 	ssize_t size;
89911be35a1SLionel Sambuc 
90011be35a1SLionel Sambuc 	FSTEST_ENTER();
90111be35a1SLionel Sambuc 	fd = rump_sys_open(".", O_DIRECTORY | O_RDONLY, 0777);
90211be35a1SLionel Sambuc 	ATF_REQUIRE(fd != -1);
90311be35a1SLionel Sambuc 
90411be35a1SLionel Sambuc 	size = rump_sys_pread(fd, buf, sizeof(buf), 0);
90511be35a1SLionel Sambuc 	ATF_CHECK(size != -1 || errno == EISDIR);
90611be35a1SLionel Sambuc 	size = rump_sys_read(fd, buf, sizeof(buf));
90711be35a1SLionel Sambuc 	ATF_CHECK(size != -1 || errno == EISDIR);
90811be35a1SLionel Sambuc 
90911be35a1SLionel Sambuc 	res = rump_sys_close(fd);
91011be35a1SLionel Sambuc 	ATF_REQUIRE(res != -1);
91111be35a1SLionel Sambuc 	FSTEST_EXIT();
91211be35a1SLionel Sambuc }
91311be35a1SLionel Sambuc 
914*0a6a1f1dSLionel Sambuc static void
lstat_symlink(const atf_tc_t * tc,const char * mp)915*0a6a1f1dSLionel Sambuc lstat_symlink(const atf_tc_t *tc, const char *mp)
916*0a6a1f1dSLionel Sambuc {
917*0a6a1f1dSLionel Sambuc 	const char *src, *dst;
918*0a6a1f1dSLionel Sambuc 	int res;
919*0a6a1f1dSLionel Sambuc 	struct stat st;
920*0a6a1f1dSLionel Sambuc 
921*0a6a1f1dSLionel Sambuc 	USES_SYMLINKS;
922*0a6a1f1dSLionel Sambuc 
923*0a6a1f1dSLionel Sambuc 	FSTEST_ENTER();
924*0a6a1f1dSLionel Sambuc 
925*0a6a1f1dSLionel Sambuc 	src = "source";
926*0a6a1f1dSLionel Sambuc 	dst = "destination";
927*0a6a1f1dSLionel Sambuc 
928*0a6a1f1dSLionel Sambuc 	res = rump_sys_symlink(src, dst);
929*0a6a1f1dSLionel Sambuc 	ATF_REQUIRE(res != -1);
930*0a6a1f1dSLionel Sambuc 	res = rump_sys_lstat(dst, &st);
931*0a6a1f1dSLionel Sambuc 	ATF_REQUIRE(res != -1);
932*0a6a1f1dSLionel Sambuc 
933*0a6a1f1dSLionel Sambuc 	ATF_CHECK(S_ISLNK(st.st_mode) != 0);
934*0a6a1f1dSLionel Sambuc 	ATF_CHECK(st.st_size == (off_t)strlen(src));
935*0a6a1f1dSLionel Sambuc 
936*0a6a1f1dSLionel Sambuc 	FSTEST_EXIT();
937*0a6a1f1dSLionel Sambuc }
938*0a6a1f1dSLionel Sambuc 
93911be35a1SLionel Sambuc ATF_TC_FSAPPLY(lookup_simple, "simple lookup (./.. on root)");
94011be35a1SLionel Sambuc ATF_TC_FSAPPLY(lookup_complex, "lookup of non-dot entries");
94111be35a1SLionel Sambuc ATF_TC_FSAPPLY(dir_simple, "mkdir/rmdir");
94211be35a1SLionel Sambuc ATF_TC_FSAPPLY(dir_notempty, "non-empty directories cannot be removed");
94311be35a1SLionel Sambuc ATF_TC_FSAPPLY(dir_rmdirdotdot, "remove .. and try to cd out (PR kern/44657)");
94411be35a1SLionel Sambuc ATF_TC_FSAPPLY(rename_dir, "exercise various directory renaming ops "
94511be35a1SLionel Sambuc "(PR kern/44288)");
94611be35a1SLionel Sambuc ATF_TC_FSAPPLY(rename_dotdot, "rename dir .. (PR kern/43617)");
94711be35a1SLionel Sambuc ATF_TC_FSAPPLY(rename_reg_nodir, "rename regular files, no subdirectories");
94811be35a1SLionel Sambuc ATF_TC_FSAPPLY(create_nametoolong, "create file with name too long");
94911be35a1SLionel Sambuc ATF_TC_FSAPPLY(create_exist, "create with O_EXCL");
95011be35a1SLionel Sambuc ATF_TC_FSAPPLY(rename_nametoolong, "rename to file with name too long");
951*0a6a1f1dSLionel Sambuc ATF_TC_FSAPPLY(symlink_zerolen, "symlink with target of length 0");
952*0a6a1f1dSLionel Sambuc ATF_TC_FSAPPLY(symlink_long, "symlink with target of length > 0");
95311be35a1SLionel Sambuc ATF_TC_FSAPPLY(symlink_root, "symlink to root directory");
95411be35a1SLionel Sambuc ATF_TC_FSAPPLY(attrs, "check setting attributes works");
95511be35a1SLionel Sambuc ATF_TC_FSAPPLY(fcntl_lock, "check fcntl F_SETLK");
95611be35a1SLionel Sambuc ATF_TC_FSAPPLY(fcntl_getlock_pids,"fcntl F_GETLK w/ many procs, PR kern/44494");
95711be35a1SLionel Sambuc ATF_TC_FSAPPLY(access_simple, "access(2)");
95811be35a1SLionel Sambuc ATF_TC_FSAPPLY(read_directory, "read(2) on directories");
959*0a6a1f1dSLionel Sambuc ATF_TC_FSAPPLY(lstat_symlink, "lstat(2) values for symbolic links");
96011be35a1SLionel Sambuc 
ATF_TP_ADD_TCS(tp)96111be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
96211be35a1SLionel Sambuc {
96311be35a1SLionel Sambuc 
96411be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(lookup_simple);
96511be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(lookup_complex);
96611be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(dir_simple);
96711be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(dir_notempty);
96811be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(dir_rmdirdotdot);
96911be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(rename_dir);
97011be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(rename_dotdot);
97111be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(rename_reg_nodir);
97211be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(create_nametoolong);
97311be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(create_exist);
97411be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(rename_nametoolong);
97511be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(symlink_zerolen);
976*0a6a1f1dSLionel Sambuc 	ATF_TP_FSAPPLY(symlink_long);
97711be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(symlink_root);
97811be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(attrs);
97911be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(fcntl_lock);
98011be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(fcntl_getlock_pids);
98111be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(access_simple);
98211be35a1SLionel Sambuc 	ATF_TP_FSAPPLY(read_directory);
983*0a6a1f1dSLionel Sambuc 	ATF_TP_FSAPPLY(lstat_symlink);
98411be35a1SLionel Sambuc 
98511be35a1SLionel Sambuc 	return atf_no_error();
98611be35a1SLionel Sambuc }
987