Expand PMF_FN_* macros.
[netbsd-mini2440.git] / tests / fs / tmpfs / t_renamerace.c
blob65476b43a90c6d4b773a49d85b5b416c0694211a
1 /* $NetBSD: t_renamerace.c,v 1.5 2009/04/14 10:19:39 pooka Exp $ */
3 /*
4 * Modified for rump and atf from a program supplied
5 * by Nicolas Joly in kern/40948
6 */
8 #include <sys/types.h>
9 #include <sys/mount.h>
11 #include <atf-c.h>
12 #include <errno.h>
13 #include <fcntl.h>
14 #include <pthread.h>
15 #include <stdio.h>
16 #include <unistd.h>
17 #include <string.h>
19 #include <rump/rump.h>
20 #include <rump/rump_syscalls.h>
22 #include <fs/tmpfs/tmpfs_args.h>
24 #include "../../h_macros.h"
26 ATF_TC(renamerace);
27 ATF_TC_HEAD(renamerace, tc)
29 atf_tc_set_md_var(tc, "descr", "rename(2) race against files "
30 "unlinked mid-operation, kern/41128");
33 static void *
34 w1(void *arg)
36 int fd;
38 for (;;) {
39 fd = rump_sys_open("/rename.test1",
40 O_WRONLY|O_CREAT|O_TRUNC, 0666);
41 rump_sys_unlink("/rename.test1");
42 rump_sys_close(fd);
44 return NULL;
47 static void *
48 w2(void *arg)
51 for (;;) {
52 rump_sys_rename("/rename.test1", "/rename.test2");
54 return NULL;
57 ATF_TC_BODY(renamerace, tc)
59 struct tmpfs_args args;
60 pthread_t pt1, pt2;
62 memset(&args, 0, sizeof(args));
63 args.ta_version = TMPFS_ARGS_VERSION;
64 args.ta_root_mode = 0777;
66 rump_init();
67 if (rump_sys_mount(MOUNT_TMPFS, "/", 0, &args, sizeof(args)) == -1)
68 atf_tc_fail_errno("could not mount tmpfs");
70 pthread_create(&pt1, NULL, w1, NULL);
71 pthread_create(&pt2, NULL, w2, NULL);
73 sleep(10);
76 ATF_TP_ADD_TCS(tp)
78 ATF_TP_ADD_TC(tp, renamerace);
79 return 0; /*XXX?*/