| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: t_vnops.c,v 1.61 2021/09/16 21:29:42 andvar Exp $ */ | | 1 | /* $NetBSD: t_vnops.c,v 1.62 2022/02/01 18:27:24 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -165,26 +165,65 @@ dir_simple(const atf_tc_t *tc, const cha | | | @@ -165,26 +165,65 @@ dir_simple(const atf_tc_t *tc, const cha |
165 | if (rump_sys_mkdir(pb, 0777) == -1) | | 165 | if (rump_sys_mkdir(pb, 0777) == -1) |
166 | atf_tc_fail_errno("mkdir"); | | 166 | atf_tc_fail_errno("mkdir"); |
167 | if (rump_sys_stat(pb, &sb) == -1) | | 167 | if (rump_sys_stat(pb, &sb) == -1) |
168 | atf_tc_fail_errno("stat new directory"); | | 168 | atf_tc_fail_errno("stat new directory"); |
169 | | | 169 | |
170 | /* check we can remove then and that it makes them unreachable */ | | 170 | /* check we can remove then and that it makes them unreachable */ |
171 | if (rump_sys_rmdir(pb) == -1) | | 171 | if (rump_sys_rmdir(pb) == -1) |
172 | atf_tc_fail_errno("rmdir"); | | 172 | atf_tc_fail_errno("rmdir"); |
173 | if (rump_sys_stat(pb, &sb) != -1 || errno != ENOENT) | | 173 | if (rump_sys_stat(pb, &sb) != -1 || errno != ENOENT) |
174 | atf_tc_fail("ENOENT expected from stat"); | | 174 | atf_tc_fail("ENOENT expected from stat"); |
175 | } | | 175 | } |
176 | | | 176 | |
177 | static void | | 177 | static void |
| | | 178 | do_dir_slash(const atf_tc_t *tc, const char *mountpath, const char *addend) |
| | | 179 | { |
| | | 180 | char plain[MAXPATHLEN], with_slash[MAXPATHLEN]; |
| | | 181 | struct stat sb; |
| | | 182 | |
| | | 183 | USES_DIRS; |
| | | 184 | |
| | | 185 | /* check we can create directories with one or more / appended */ |
| | | 186 | snprintf(plain, sizeof(plain), "%s/dir%s", mountpath, addend); |
| | | 187 | snprintf(with_slash, sizeof(with_slash), "%s/dir/", mountpath); |
| | | 188 | if (rump_sys_mkdir(with_slash, 0777) == -1) |
| | | 189 | atf_tc_fail_errno("mkdir"); |
| | | 190 | if (rump_sys_stat(plain, &sb) == -1) |
| | | 191 | atf_tc_fail_errno("stat new directory"); |
| | | 192 | if (rump_sys_rmdir(plain) == -1) |
| | | 193 | atf_tc_fail_errno("rmdir"); |
| | | 194 | if (rump_sys_stat(with_slash, &sb) != -1 || errno != ENOENT) |
| | | 195 | atf_tc_fail("ENOENT expected from stat"); |
| | | 196 | } |
| | | 197 | |
| | | 198 | static void |
| | | 199 | dir_slash(const atf_tc_t *tc, const char *mountpath) |
| | | 200 | { |
| | | 201 | do_dir_slash(tc, mountpath, "/"); |
| | | 202 | } |
| | | 203 | |
| | | 204 | static void |
| | | 205 | dir_2slash(const atf_tc_t *tc, const char *mountpath) |
| | | 206 | { |
| | | 207 | do_dir_slash(tc, mountpath, "//"); |
| | | 208 | } |
| | | 209 | |
| | | 210 | static void |
| | | 211 | dir_3slash(const atf_tc_t *tc, const char *mountpath) |
| | | 212 | { |
| | | 213 | do_dir_slash(tc, mountpath, "///"); |
| | | 214 | } |
| | | 215 | |
| | | 216 | static void |
178 | dir_notempty(const atf_tc_t *tc, const char *mountpath) | | 217 | dir_notempty(const atf_tc_t *tc, const char *mountpath) |
179 | { | | 218 | { |
180 | char pb[MAXPATHLEN], pb2[MAXPATHLEN]; | | 219 | char pb[MAXPATHLEN], pb2[MAXPATHLEN]; |
181 | int fd, rv; | | 220 | int fd, rv; |
182 | | | 221 | |
183 | USES_DIRS; | | 222 | USES_DIRS; |
184 | | | 223 | |
185 | /* check we can create directories */ | | 224 | /* check we can create directories */ |
186 | snprintf(pb, sizeof(pb), "%s/dir", mountpath); | | 225 | snprintf(pb, sizeof(pb), "%s/dir", mountpath); |
187 | if (rump_sys_mkdir(pb, 0777) == -1) | | 226 | if (rump_sys_mkdir(pb, 0777) == -1) |
188 | atf_tc_fail_errno("mkdir"); | | 227 | atf_tc_fail_errno("mkdir"); |
189 | | | 228 | |
190 | snprintf(pb2, sizeof(pb2), "%s/dir/file", mountpath); | | 229 | snprintf(pb2, sizeof(pb2), "%s/dir/file", mountpath); |
| @@ -1016,26 +1055,29 @@ lstat_symlink(const atf_tc_t *tc, const | | | @@ -1016,26 +1055,29 @@ lstat_symlink(const atf_tc_t *tc, const |
1016 | ATF_REQUIRE(res != -1); | | 1055 | ATF_REQUIRE(res != -1); |
1017 | res = rump_sys_lstat(dst, &st); | | 1056 | res = rump_sys_lstat(dst, &st); |
1018 | ATF_REQUIRE(res != -1); | | 1057 | ATF_REQUIRE(res != -1); |
1019 | | | 1058 | |
1020 | ATF_CHECK(S_ISLNK(st.st_mode) != 0); | | 1059 | ATF_CHECK(S_ISLNK(st.st_mode) != 0); |
1021 | ATF_CHECK(st.st_size == (off_t)strlen(src)); | | 1060 | ATF_CHECK(st.st_size == (off_t)strlen(src)); |
1022 | | | 1061 | |
1023 | FSTEST_EXIT(); | | 1062 | FSTEST_EXIT(); |
1024 | } | | 1063 | } |
1025 | | | 1064 | |
1026 | ATF_TC_FSAPPLY(lookup_simple, "simple lookup (./.. on root)"); | | 1065 | ATF_TC_FSAPPLY(lookup_simple, "simple lookup (./.. on root)"); |
1027 | ATF_TC_FSAPPLY(lookup_complex, "lookup of non-dot entries"); | | 1066 | ATF_TC_FSAPPLY(lookup_complex, "lookup of non-dot entries"); |
1028 | ATF_TC_FSAPPLY(dir_simple, "mkdir/rmdir"); | | 1067 | ATF_TC_FSAPPLY(dir_simple, "mkdir/rmdir"); |
| | | 1068 | ATF_TC_FSAPPLY(dir_slash, "mkdir with appended slash"); |
| | | 1069 | ATF_TC_FSAPPLY(dir_2slash, "mkdir with two slashes appended"); |
| | | 1070 | ATF_TC_FSAPPLY(dir_3slash, "mkdir with three slashes appended"); |
1029 | ATF_TC_FSAPPLY(dir_notempty, "non-empty directories cannot be removed"); | | 1071 | ATF_TC_FSAPPLY(dir_notempty, "non-empty directories cannot be removed"); |
1030 | ATF_TC_FSAPPLY(dir_rmdirdotdot, "remove .. and try to cd out (PR kern/44657)"); | | 1072 | ATF_TC_FSAPPLY(dir_rmdirdotdot, "remove .. and try to cd out (PR kern/44657)"); |
1031 | ATF_TC_FSAPPLY(rename_dir, "exercise various directory renaming ops " | | 1073 | ATF_TC_FSAPPLY(rename_dir, "exercise various directory renaming ops " |
1032 | "(PR kern/44288)"); | | 1074 | "(PR kern/44288)"); |
1033 | ATF_TC_FSAPPLY(rename_dotdot, "rename dir .. (PR kern/43617)"); | | 1075 | ATF_TC_FSAPPLY(rename_dotdot, "rename dir .. (PR kern/43617)"); |
1034 | ATF_TC_FSAPPLY(rename_reg_nodir, "rename regular files, no subdirectories"); | | 1076 | ATF_TC_FSAPPLY(rename_reg_nodir, "rename regular files, no subdirectories"); |
1035 | ATF_TC_FSAPPLY(create_nametoolong, "create file with name too long"); | | 1077 | ATF_TC_FSAPPLY(create_nametoolong, "create file with name too long"); |
1036 | ATF_TC_FSAPPLY(create_exist, "create with O_EXCL"); | | 1078 | ATF_TC_FSAPPLY(create_exist, "create with O_EXCL"); |
1037 | ATF_TC_FSAPPLY(rename_nametoolong, "rename to file with name too long"); | | 1079 | ATF_TC_FSAPPLY(rename_nametoolong, "rename to file with name too long"); |
1038 | ATF_TC_FSAPPLY(symlink_zerolen, "symlink with target of length 0"); | | 1080 | ATF_TC_FSAPPLY(symlink_zerolen, "symlink with target of length 0"); |
1039 | ATF_TC_FSAPPLY(symlink_long, "symlink with target of length > 0"); | | 1081 | ATF_TC_FSAPPLY(symlink_long, "symlink with target of length > 0"); |
1040 | ATF_TC_FSAPPLY(symlink_root, "symlink to root directory"); | | 1082 | ATF_TC_FSAPPLY(symlink_root, "symlink to root directory"); |
1041 | ATF_TC_FSAPPLY(attrs, "check setting attributes works"); | | 1083 | ATF_TC_FSAPPLY(attrs, "check setting attributes works"); |
| @@ -1048,26 +1090,29 @@ ATF_TC_FSAPPLY(lstat_symlink, "lstat(2) | | | @@ -1048,26 +1090,29 @@ ATF_TC_FSAPPLY(lstat_symlink, "lstat(2) |
1048 | #undef FSTEST_IMGSIZE | | 1090 | #undef FSTEST_IMGSIZE |
1049 | #define FSTEST_IMGSIZE (1024*1024*64) | | 1091 | #define FSTEST_IMGSIZE (1024*1024*64) |
1050 | ATF_TC_FSAPPLY(create_many, "create many directory entries"); | | 1092 | ATF_TC_FSAPPLY(create_many, "create many directory entries"); |
1051 | ATF_TC_FSAPPLY(create_nonalphanum, "non-alphanumeric filenames"); | | 1093 | ATF_TC_FSAPPLY(create_nonalphanum, "non-alphanumeric filenames"); |
1052 | | | 1094 | |
1053 | ATF_TP_ADD_TCS(tp) | | 1095 | ATF_TP_ADD_TCS(tp) |
1054 | { | | 1096 | { |
1055 | | | 1097 | |
1056 | ATF_TP_FSAPPLY(lookup_simple); | | 1098 | ATF_TP_FSAPPLY(lookup_simple); |
1057 | ATF_TP_FSAPPLY(lookup_complex); | | 1099 | ATF_TP_FSAPPLY(lookup_complex); |
1058 | ATF_TP_FSAPPLY(dir_simple); | | 1100 | ATF_TP_FSAPPLY(dir_simple); |
1059 | ATF_TP_FSAPPLY(dir_notempty); | | 1101 | ATF_TP_FSAPPLY(dir_notempty); |
1060 | ATF_TP_FSAPPLY(dir_rmdirdotdot); | | 1102 | ATF_TP_FSAPPLY(dir_rmdirdotdot); |
| | | 1103 | ATF_TP_FSAPPLY(dir_slash); |
| | | 1104 | ATF_TP_FSAPPLY(dir_2slash); |
| | | 1105 | ATF_TP_FSAPPLY(dir_3slash); |
1061 | ATF_TP_FSAPPLY(rename_dir); | | 1106 | ATF_TP_FSAPPLY(rename_dir); |
1062 | ATF_TP_FSAPPLY(rename_dotdot); | | 1107 | ATF_TP_FSAPPLY(rename_dotdot); |
1063 | ATF_TP_FSAPPLY(rename_reg_nodir); | | 1108 | ATF_TP_FSAPPLY(rename_reg_nodir); |
1064 | ATF_TP_FSAPPLY(create_many); | | 1109 | ATF_TP_FSAPPLY(create_many); |
1065 | ATF_TP_FSAPPLY(create_nonalphanum); | | 1110 | ATF_TP_FSAPPLY(create_nonalphanum); |
1066 | ATF_TP_FSAPPLY(create_nametoolong); | | 1111 | ATF_TP_FSAPPLY(create_nametoolong); |
1067 | ATF_TP_FSAPPLY(create_exist); | | 1112 | ATF_TP_FSAPPLY(create_exist); |
1068 | ATF_TP_FSAPPLY(rename_nametoolong); | | 1113 | ATF_TP_FSAPPLY(rename_nametoolong); |
1069 | ATF_TP_FSAPPLY(symlink_zerolen); | | 1114 | ATF_TP_FSAPPLY(symlink_zerolen); |
1070 | ATF_TP_FSAPPLY(symlink_long); | | 1115 | ATF_TP_FSAPPLY(symlink_long); |
1071 | ATF_TP_FSAPPLY(symlink_root); | | 1116 | ATF_TP_FSAPPLY(symlink_root); |
1072 | ATF_TP_FSAPPLY(attrs); | | 1117 | ATF_TP_FSAPPLY(attrs); |
1073 | ATF_TP_FSAPPLY(fcntl_lock); | | 1118 | ATF_TP_FSAPPLY(fcntl_lock); |