t_vnops.c revision 1.5 1 1.5 njoly /* $NetBSD: t_vnops.c,v 1.5 2010/07/26 13:37:48 njoly Exp $ */
2 1.1 pooka
3 1.1 pooka /*-
4 1.1 pooka * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 1.1 pooka * All rights reserved.
6 1.1 pooka *
7 1.1 pooka * Redistribution and use in source and binary forms, with or without
8 1.1 pooka * modification, are permitted provided that the following conditions
9 1.1 pooka * are met:
10 1.1 pooka * 1. Redistributions of source code must retain the above copyright
11 1.1 pooka * notice, this list of conditions and the following disclaimer.
12 1.1 pooka * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 pooka * notice, this list of conditions and the following disclaimer in the
14 1.1 pooka * documentation and/or other materials provided with the distribution.
15 1.1 pooka *
16 1.1 pooka * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1 pooka * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 pooka * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 pooka * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1 pooka * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1 pooka * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1 pooka * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 pooka * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1 pooka * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1 pooka * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 pooka * POSSIBILITY OF SUCH DAMAGE.
27 1.1 pooka */
28 1.1 pooka
29 1.1 pooka #include <sys/stat.h>
30 1.1 pooka #include <sys/statvfs.h>
31 1.1 pooka
32 1.1 pooka #include <atf-c.h>
33 1.1 pooka #include <fcntl.h>
34 1.1 pooka #include <libgen.h>
35 1.5 njoly #include <stdlib.h>
36 1.1 pooka #include <unistd.h>
37 1.1 pooka
38 1.1 pooka #include <rump/rump_syscalls.h>
39 1.1 pooka #include <rump/rump.h>
40 1.1 pooka
41 1.1 pooka #include "../common/h_fsmacros.h"
42 1.1 pooka #include "../../h_macros.h"
43 1.1 pooka
44 1.1 pooka #define USES_DIRS \
45 1.1 pooka if (FSTYPE_SYSVBFS(tc)) atf_tc_skip("dirs not supported by file system")
46 1.1 pooka
47 1.2 pooka static char *
48 1.2 pooka md(char *buf, const char *base, const char *tail)
49 1.2 pooka {
50 1.2 pooka
51 1.2 pooka sprintf(buf, "%s/%s", base, tail);
52 1.2 pooka return buf;
53 1.2 pooka }
54 1.2 pooka
55 1.1 pooka static void
56 1.1 pooka lookup_simple(const atf_tc_t *tc, const char *mountpath)
57 1.1 pooka {
58 1.1 pooka char pb[MAXPATHLEN], final[MAXPATHLEN];
59 1.1 pooka struct stat sb1, sb2;
60 1.1 pooka
61 1.1 pooka strcpy(final, mountpath);
62 1.1 pooka sprintf(pb, "%s/../%s", mountpath, basename(final));
63 1.1 pooka if (rump_sys_stat(pb, &sb1) == -1)
64 1.1 pooka atf_tc_fail_errno("stat 1");
65 1.1 pooka
66 1.1 pooka sprintf(pb, "%s/./../%s", mountpath, basename(final));
67 1.1 pooka if (rump_sys_stat(pb, &sb2) == -1)
68 1.1 pooka atf_tc_fail_errno("stat 2");
69 1.1 pooka
70 1.1 pooka ATF_REQUIRE(memcmp(&sb1, &sb2, sizeof(sb1)) == 0);
71 1.1 pooka }
72 1.1 pooka
73 1.1 pooka static void
74 1.1 pooka lookup_complex(const atf_tc_t *tc, const char *mountpath)
75 1.1 pooka {
76 1.1 pooka char pb[MAXPATHLEN];
77 1.1 pooka struct stat sb1, sb2;
78 1.1 pooka
79 1.1 pooka USES_DIRS;
80 1.1 pooka
81 1.1 pooka sprintf(pb, "%s/dir", mountpath);
82 1.1 pooka if (rump_sys_mkdir(pb, 0777) == -1)
83 1.1 pooka atf_tc_fail_errno("mkdir");
84 1.1 pooka if (rump_sys_stat(pb, &sb1) == -1)
85 1.1 pooka atf_tc_fail_errno("stat 1");
86 1.1 pooka
87 1.1 pooka sprintf(pb, "%s/./dir/../././dir/.", mountpath);
88 1.1 pooka if (rump_sys_stat(pb, &sb2) == -1)
89 1.1 pooka atf_tc_fail_errno("stat 2");
90 1.1 pooka
91 1.1 pooka ATF_REQUIRE(memcmp(&sb1, &sb2, sizeof(sb1)) == 0);
92 1.1 pooka }
93 1.1 pooka
94 1.1 pooka static void
95 1.1 pooka dir_simple(const atf_tc_t *tc, const char *mountpath)
96 1.1 pooka {
97 1.1 pooka char pb[MAXPATHLEN];
98 1.1 pooka struct stat sb;
99 1.1 pooka
100 1.1 pooka USES_DIRS;
101 1.1 pooka
102 1.1 pooka /* check we can create directories */
103 1.1 pooka sprintf(pb, "%s/dir", mountpath);
104 1.1 pooka if (rump_sys_mkdir(pb, 0777) == -1)
105 1.1 pooka atf_tc_fail_errno("mkdir");
106 1.1 pooka if (rump_sys_stat(pb, &sb) == -1)
107 1.1 pooka atf_tc_fail_errno("stat new directory");
108 1.1 pooka
109 1.1 pooka /* check we can remove then and that it makes them unreachable */
110 1.1 pooka if (rump_sys_rmdir(pb) == -1)
111 1.1 pooka atf_tc_fail_errno("rmdir");
112 1.1 pooka if (rump_sys_stat(pb, &sb) != -1 || errno != ENOENT)
113 1.1 pooka atf_tc_fail("ENOENT expected from stat");
114 1.1 pooka }
115 1.1 pooka
116 1.1 pooka static void
117 1.1 pooka dir_notempty(const atf_tc_t *tc, const char *mountpath)
118 1.1 pooka {
119 1.1 pooka char pb[MAXPATHLEN], pb2[MAXPATHLEN];
120 1.1 pooka int fd, rv;
121 1.1 pooka
122 1.1 pooka USES_DIRS;
123 1.1 pooka
124 1.1 pooka /* check we can create directories */
125 1.1 pooka sprintf(pb, "%s/dir", mountpath);
126 1.1 pooka if (rump_sys_mkdir(pb, 0777) == -1)
127 1.1 pooka atf_tc_fail_errno("mkdir");
128 1.1 pooka
129 1.1 pooka sprintf(pb2, "%s/dir/file", mountpath);
130 1.1 pooka fd = rump_sys_open(pb2, O_RDWR | O_CREAT, 0777);
131 1.1 pooka if (fd == -1)
132 1.1 pooka atf_tc_fail_errno("create file");
133 1.1 pooka rump_sys_close(fd);
134 1.1 pooka
135 1.1 pooka rv = rump_sys_rmdir(pb);
136 1.1 pooka if (rv != -1 || errno != ENOTEMPTY)
137 1.1 pooka atf_tc_fail("non-empty directory removed succesfully");
138 1.1 pooka
139 1.1 pooka if (rump_sys_unlink(pb2) == -1)
140 1.1 pooka atf_tc_fail_errno("cannot remove dir/file");
141 1.1 pooka
142 1.1 pooka if (rump_sys_rmdir(pb) == -1)
143 1.1 pooka atf_tc_fail_errno("remove directory");
144 1.1 pooka }
145 1.1 pooka
146 1.2 pooka static void
147 1.2 pooka checkfile(const char *path, struct stat *refp)
148 1.2 pooka {
149 1.2 pooka char buf[MAXPATHLEN];
150 1.2 pooka struct stat sb;
151 1.2 pooka static int n = 1;
152 1.2 pooka
153 1.2 pooka md(buf, path, "file");
154 1.2 pooka if (rump_sys_stat(buf, &sb) == -1)
155 1.2 pooka atf_tc_fail_errno("cannot stat file %d (%s)", n, buf);
156 1.2 pooka if (memcmp(&sb, refp, sizeof(sb)) != 0)
157 1.2 pooka atf_tc_fail("stat mismatch %d", n);
158 1.2 pooka n++;
159 1.2 pooka }
160 1.2 pooka
161 1.2 pooka static void
162 1.2 pooka rename_dir(const atf_tc_t *tc, const char *mp)
163 1.2 pooka {
164 1.2 pooka char pb1[MAXPATHLEN], pb2[MAXPATHLEN], pb3[MAXPATHLEN];
165 1.2 pooka struct stat ref;
166 1.2 pooka
167 1.3 pooka if (FSTYPE_MSDOS(tc))
168 1.3 pooka atf_tc_skip("test fails in some setups, reason unknown");
169 1.3 pooka
170 1.2 pooka USES_DIRS;
171 1.2 pooka
172 1.2 pooka md(pb1, mp, "dir1");
173 1.2 pooka if (rump_sys_mkdir(pb1, 0777) == -1)
174 1.2 pooka atf_tc_fail_errno("mkdir 1");
175 1.2 pooka
176 1.2 pooka md(pb2, mp, "dir2");
177 1.2 pooka if (rump_sys_mkdir(pb2, 0777) == -1)
178 1.2 pooka atf_tc_fail_errno("mkdir 2");
179 1.2 pooka md(pb2, mp, "dir2/subdir");
180 1.2 pooka if (rump_sys_mkdir(pb2, 0777) == -1)
181 1.2 pooka atf_tc_fail_errno("mkdir 3");
182 1.2 pooka
183 1.2 pooka md(pb3, mp, "dir1/file");
184 1.2 pooka if (rump_sys_mknod(pb3, S_IFREG | 0777, -1) == -1)
185 1.2 pooka atf_tc_fail_errno("create file");
186 1.2 pooka if (rump_sys_stat(pb3, &ref) == -1)
187 1.2 pooka atf_tc_fail_errno("stat of file");
188 1.2 pooka
189 1.2 pooka /*
190 1.2 pooka * First try ops which should succeed.
191 1.2 pooka */
192 1.2 pooka
193 1.2 pooka /* rename within directory */
194 1.2 pooka md(pb3, mp, "dir3");
195 1.2 pooka if (rump_sys_rename(pb1, pb3) == -1)
196 1.2 pooka atf_tc_fail_errno("rename 1");
197 1.2 pooka checkfile(pb3, &ref);
198 1.2 pooka
199 1.2 pooka /* rename directory onto itself (two ways, should fail) */
200 1.2 pooka md(pb1, mp, "dir3/.");
201 1.2 pooka if (rump_sys_rename(pb1, pb3) != -1 || errno != EINVAL)
202 1.2 pooka atf_tc_fail_errno("rename 2");
203 1.2 pooka if (rump_sys_rename(pb3, pb1) != -1 || errno != EISDIR)
204 1.2 pooka atf_tc_fail_errno("rename 3");
205 1.2 pooka
206 1.2 pooka checkfile(pb3, &ref);
207 1.2 pooka
208 1.2 pooka /* rename father of directory into directory */
209 1.2 pooka md(pb1, mp, "dir2/dir");
210 1.2 pooka md(pb2, mp, "dir2");
211 1.2 pooka if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL)
212 1.2 pooka atf_tc_fail_errno("rename 4");
213 1.2 pooka
214 1.2 pooka /* same for grandfather */
215 1.2 pooka md(pb1, mp, "dir2/subdir/dir2");
216 1.2 pooka if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL)
217 1.2 pooka atf_tc_fail("rename 5");
218 1.2 pooka
219 1.2 pooka checkfile(pb3, &ref);
220 1.2 pooka
221 1.2 pooka /* rename directory over a non-empty directory */
222 1.2 pooka if (rump_sys_rename(pb2, pb3) != -1 || errno != ENOTEMPTY)
223 1.2 pooka atf_tc_fail("rename 6");
224 1.2 pooka
225 1.2 pooka /* cross-directory rename */
226 1.2 pooka md(pb1, mp, "dir3");
227 1.2 pooka md(pb2, mp, "dir2/somedir");
228 1.2 pooka if (rump_sys_rename(pb1, pb2) == -1)
229 1.2 pooka atf_tc_fail_errno("rename 7");
230 1.2 pooka checkfile(pb2, &ref);
231 1.2 pooka
232 1.2 pooka /* move to parent directory */
233 1.2 pooka md(pb1, mp, "dir2/somedir/../../dir3");
234 1.2 pooka if (rump_sys_rename(pb2, pb1) == -1)
235 1.2 pooka atf_tc_fail_errno("rename 8");
236 1.2 pooka md(pb1, mp, "dir2/../dir3");
237 1.2 pooka checkfile(pb1, &ref);
238 1.2 pooka
239 1.2 pooka /* finally, atomic cross-directory rename */
240 1.2 pooka md(pb3, mp, "dir2/subdir");
241 1.2 pooka if (rump_sys_rename(pb1, pb3) == -1)
242 1.2 pooka atf_tc_fail_errno("rename 9");
243 1.2 pooka checkfile(pb3, &ref);
244 1.2 pooka }
245 1.2 pooka
246 1.2 pooka static void
247 1.2 pooka rename_dotdot(const atf_tc_t *tc, const char *mp)
248 1.2 pooka {
249 1.2 pooka
250 1.2 pooka USES_DIRS;
251 1.2 pooka
252 1.2 pooka if (rump_sys_chdir(mp) == -1)
253 1.2 pooka atf_tc_fail_errno("chdir mountpoint");
254 1.2 pooka
255 1.2 pooka if (rump_sys_mkdir("dir1", 0777) == -1)
256 1.2 pooka atf_tc_fail_errno("mkdir 1");
257 1.2 pooka if (rump_sys_mkdir("dir2", 0777) == -1)
258 1.2 pooka atf_tc_fail_errno("mkdir 2");
259 1.2 pooka
260 1.2 pooka /* msdosfs fails both at least currently */
261 1.2 pooka if (FSTYPE_MSDOS(tc)) {
262 1.2 pooka atf_tc_expect_fail("PR kern/43616");
263 1.2 pooka }
264 1.2 pooka if (rump_sys_rename("dir1", "dir1/..") != -1 || errno != EINVAL)
265 1.2 pooka atf_tc_fail_errno("self-dotdot to");
266 1.2 pooka
267 1.2 pooka if (rump_sys_rename("dir1/..", "sometarget") != -1 || errno != EINVAL)
268 1.2 pooka atf_tc_fail_errno("self-dotdot from");
269 1.2 pooka atf_tc_expect_pass();
270 1.2 pooka
271 1.2 pooka if (FSTYPE_TMPFS(tc)) {
272 1.2 pooka atf_tc_expect_fail("PR kern/43617");
273 1.2 pooka }
274 1.2 pooka if (rump_sys_rename("dir1", "dir2/..") != -1 || errno != EINVAL)
275 1.2 pooka atf_tc_fail("other-dotdot");
276 1.2 pooka
277 1.2 pooka rump_sys_chdir("/");
278 1.2 pooka }
279 1.2 pooka
280 1.2 pooka static void
281 1.2 pooka rename_reg_nodir(const atf_tc_t *tc, const char *mp)
282 1.2 pooka {
283 1.2 pooka bool haslinks;
284 1.2 pooka struct stat sb;
285 1.2 pooka ino_t f1ino, f2ino;
286 1.2 pooka
287 1.3 pooka if (FSTYPE_MSDOS(tc))
288 1.3 pooka atf_tc_skip("test fails in some setups, reason unknown");
289 1.3 pooka
290 1.2 pooka if (rump_sys_chdir(mp) == -1)
291 1.2 pooka atf_tc_fail_errno("chdir mountpoint");
292 1.2 pooka
293 1.2 pooka if (FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc))
294 1.2 pooka haslinks = false;
295 1.2 pooka else
296 1.2 pooka haslinks = true;
297 1.2 pooka
298 1.2 pooka if (rump_sys_mknod("file1", S_IFREG | 0777, -1) == -1)
299 1.2 pooka atf_tc_fail_errno("create file");
300 1.2 pooka if (rump_sys_mknod("file2", S_IFREG | 0777, -1) == -1)
301 1.2 pooka atf_tc_fail_errno("create file");
302 1.2 pooka
303 1.2 pooka if (rump_sys_stat("file1", &sb) == -1)
304 1.2 pooka atf_tc_fail_errno("stat");
305 1.2 pooka f1ino = sb.st_ino;
306 1.2 pooka
307 1.2 pooka if (haslinks) {
308 1.2 pooka if (rump_sys_link("file1", "file_link") == -1)
309 1.2 pooka atf_tc_fail_errno("link");
310 1.2 pooka if (rump_sys_stat("file_link", &sb) == -1)
311 1.2 pooka atf_tc_fail_errno("stat");
312 1.2 pooka ATF_REQUIRE_EQ(sb.st_ino, f1ino);
313 1.2 pooka ATF_REQUIRE_EQ(sb.st_nlink, 2);
314 1.2 pooka }
315 1.2 pooka
316 1.2 pooka if (rump_sys_stat("file2", &sb) == -1)
317 1.2 pooka atf_tc_fail_errno("stat");
318 1.2 pooka f2ino = sb.st_ino;
319 1.2 pooka
320 1.2 pooka if (rump_sys_rename("file1", "file3") == -1)
321 1.2 pooka atf_tc_fail_errno("rename 1");
322 1.2 pooka if (rump_sys_stat("file3", &sb) == -1)
323 1.2 pooka atf_tc_fail_errno("stat 1");
324 1.2 pooka if (haslinks) {
325 1.2 pooka ATF_REQUIRE_EQ(sb.st_ino, f1ino);
326 1.2 pooka }
327 1.2 pooka if (rump_sys_stat("file1", &sb) != -1 || errno != ENOENT)
328 1.2 pooka atf_tc_fail_errno("source 1");
329 1.2 pooka
330 1.2 pooka if (rump_sys_rename("file3", "file2") == -1)
331 1.2 pooka atf_tc_fail_errno("rename 2");
332 1.2 pooka if (rump_sys_stat("file2", &sb) == -1)
333 1.2 pooka atf_tc_fail_errno("stat 2");
334 1.2 pooka if (haslinks) {
335 1.2 pooka ATF_REQUIRE_EQ(sb.st_ino, f1ino);
336 1.2 pooka }
337 1.2 pooka
338 1.2 pooka if (rump_sys_stat("file3", &sb) != -1 || errno != ENOENT)
339 1.2 pooka atf_tc_fail_errno("source 2");
340 1.2 pooka
341 1.2 pooka if (haslinks) {
342 1.2 pooka if (rump_sys_rename("file2", "file_link") == -1)
343 1.2 pooka atf_tc_fail_errno("rename hardlink");
344 1.2 pooka if (rump_sys_stat("file2", &sb) != -1 || errno != ENOENT)
345 1.2 pooka atf_tc_fail_errno("source 3");
346 1.2 pooka if (rump_sys_stat("file_link", &sb) == -1)
347 1.2 pooka atf_tc_fail_errno("stat 2");
348 1.2 pooka ATF_REQUIRE_EQ(sb.st_ino, f1ino);
349 1.2 pooka ATF_REQUIRE_EQ(sb.st_nlink, 1);
350 1.2 pooka }
351 1.2 pooka
352 1.2 pooka rump_sys_chdir("/");
353 1.2 pooka }
354 1.2 pooka
355 1.5 njoly static void
356 1.5 njoly create_nametoolong(const atf_tc_t *tc, const char *mp)
357 1.5 njoly {
358 1.5 njoly char *name;
359 1.5 njoly int fd;
360 1.5 njoly long val;
361 1.5 njoly size_t len;
362 1.5 njoly
363 1.5 njoly if (rump_sys_chdir(mp) == -1)
364 1.5 njoly atf_tc_fail_errno("chdir mountpoint");
365 1.5 njoly
366 1.5 njoly val = rump_sys_pathconf(".", _PC_NAME_MAX);
367 1.5 njoly if (val == -1)
368 1.5 njoly atf_tc_fail_errno("pathconf");
369 1.5 njoly
370 1.5 njoly len = val + 1;
371 1.5 njoly name = malloc(len+1);
372 1.5 njoly if (name == NULL)
373 1.5 njoly atf_tc_fail_errno("malloc");
374 1.5 njoly
375 1.5 njoly memset(name, 'a', len);
376 1.5 njoly *(name+len) = '\0';
377 1.5 njoly
378 1.5 njoly val = rump_sys_pathconf(".", _PC_NO_TRUNC);
379 1.5 njoly if (val == -1)
380 1.5 njoly atf_tc_fail_errno("pathconf");
381 1.5 njoly
382 1.5 njoly if (FSTYPE_MSDOS(tc))
383 1.5 njoly atf_tc_expect_fail("PR kern/43670");
384 1.5 njoly fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666);
385 1.5 njoly if (val != 0 && (fd != -1 || errno != ENAMETOOLONG))
386 1.5 njoly atf_tc_fail_errno("open");
387 1.5 njoly
388 1.5 njoly if (val == 0 && rump_sys_close(fd) == -1)
389 1.5 njoly atf_tc_fail_errno("close");
390 1.5 njoly if (val == 0 && rump_sys_unlink(name) == -1)
391 1.5 njoly atf_tc_fail_errno("unlink");
392 1.5 njoly
393 1.5 njoly free(name);
394 1.5 njoly
395 1.5 njoly rump_sys_chdir("/");
396 1.5 njoly }
397 1.5 njoly
398 1.5 njoly static void
399 1.5 njoly rename_nametoolong(const atf_tc_t *tc, const char *mp)
400 1.5 njoly {
401 1.5 njoly char *name;
402 1.5 njoly int res, fd;
403 1.5 njoly long val;
404 1.5 njoly size_t len;
405 1.5 njoly
406 1.5 njoly if (rump_sys_chdir(mp) == -1)
407 1.5 njoly atf_tc_fail_errno("chdir mountpoint");
408 1.5 njoly
409 1.5 njoly val = rump_sys_pathconf(".", _PC_NAME_MAX);
410 1.5 njoly if (val == -1)
411 1.5 njoly atf_tc_fail_errno("pathconf");
412 1.5 njoly
413 1.5 njoly len = val + 1;
414 1.5 njoly name = malloc(len+1);
415 1.5 njoly if (name == NULL)
416 1.5 njoly atf_tc_fail_errno("malloc");
417 1.5 njoly
418 1.5 njoly memset(name, 'a', len);
419 1.5 njoly *(name+len) = '\0';
420 1.5 njoly
421 1.5 njoly fd = rump_sys_open("dummy", O_RDWR|O_CREAT, 0666);
422 1.5 njoly if (fd == -1)
423 1.5 njoly atf_tc_fail_errno("open");
424 1.5 njoly if (rump_sys_close(fd) == -1)
425 1.5 njoly atf_tc_fail_errno("close");
426 1.5 njoly
427 1.5 njoly val = rump_sys_pathconf(".", _PC_NO_TRUNC);
428 1.5 njoly if (val == -1)
429 1.5 njoly atf_tc_fail_errno("pathconf");
430 1.5 njoly
431 1.5 njoly if (FSTYPE_MSDOS(tc))
432 1.5 njoly atf_tc_expect_fail("PR kern/43670");
433 1.5 njoly res = rump_sys_rename("dummy", name);
434 1.5 njoly if (val != 0 && (res != -1 || errno != ENAMETOOLONG))
435 1.5 njoly atf_tc_fail_errno("rename");
436 1.5 njoly
437 1.5 njoly if (val == 0 && rump_sys_unlink(name) == -1)
438 1.5 njoly atf_tc_fail_errno("unlink");
439 1.5 njoly
440 1.5 njoly free(name);
441 1.5 njoly
442 1.5 njoly rump_sys_chdir("/");
443 1.5 njoly }
444 1.5 njoly
445 1.1 pooka ATF_TC_FSAPPLY(lookup_simple, "simple lookup (./.. on root)");
446 1.1 pooka ATF_TC_FSAPPLY(lookup_complex, "lookup of non-dot entries");
447 1.1 pooka ATF_TC_FSAPPLY(dir_simple, "mkdir/rmdir");
448 1.1 pooka ATF_TC_FSAPPLY(dir_notempty, "non-empty directories cannot be removed");
449 1.2 pooka ATF_TC_FSAPPLY(rename_dir, "exercise various directory renaming ops");
450 1.2 pooka ATF_TC_FSAPPLY(rename_dotdot, "rename dir ..");
451 1.2 pooka ATF_TC_FSAPPLY(rename_reg_nodir, "rename regular files, no subdirectories");
452 1.5 njoly ATF_TC_FSAPPLY(create_nametoolong, "create file with name too long");
453 1.5 njoly ATF_TC_FSAPPLY(rename_nametoolong, "rename to file with name too long");
454 1.1 pooka
455 1.1 pooka ATF_TP_ADD_TCS(tp)
456 1.1 pooka {
457 1.1 pooka
458 1.1 pooka ATF_TP_FSAPPLY(lookup_simple);
459 1.1 pooka ATF_TP_FSAPPLY(lookup_complex);
460 1.1 pooka ATF_TP_FSAPPLY(dir_simple);
461 1.1 pooka ATF_TP_FSAPPLY(dir_notempty);
462 1.2 pooka ATF_TP_FSAPPLY(rename_dir);
463 1.2 pooka ATF_TP_FSAPPLY(rename_dotdot);
464 1.2 pooka ATF_TP_FSAPPLY(rename_reg_nodir);
465 1.5 njoly ATF_TP_FSAPPLY(create_nametoolong);
466 1.5 njoly ATF_TP_FSAPPLY(rename_nametoolong);
467 1.1 pooka
468 1.1 pooka return atf_no_error();
469 1.1 pooka }
470