t_pr.c revision 1.3 1 /* $NetBSD: t_pr.c,v 1.3 2010/07/03 08:18:30 jmmv Exp $ */
2
3 #include <sys/types.h>
4 #include <sys/mount.h>
5
6 #include <atf-c.h>
7 #include <err.h>
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <stdio.h>
11 #include <unistd.h>
12 #include <string.h>
13 #include <stdlib.h>
14
15 #include <rump/rump.h>
16 #include <rump/rump_syscalls.h>
17
18 #include <miscfs/union/union.h>
19 #include <ufs/ufs/ufsmount.h>
20
21 #include "../../h_macros.h"
22
23 ATF_TC(multilayer);
24 ATF_TC_HEAD(multilayer, tc)
25 {
26 atf_tc_set_md_var(tc, "descr", "mount_union -b twice");
27 atf_tc_set_md_var(tc, "use.fs", "true");
28 }
29
30 #define IMG1 "atf1.img"
31 #define DEV1 "/dev/fs1"
32 #define newfs_base "newfs -F -s 10000 "
33
34 ATF_TC_BODY(multilayer, tc)
35 {
36 struct ufs_args args;
37 struct union_args unionargs;
38
39 if (system(newfs_base IMG1) == -1)
40 atf_tc_fail_errno("create img1");
41
42 rump_init();
43 rump_pub_etfs_register(DEV1, IMG1, RUMP_ETFS_BLK);
44
45 memset(&args, 0, sizeof(args));
46 args.fspec = __UNCONST(DEV1);
47 if (rump_sys_mount(MOUNT_FFS, "/", 0, &args, sizeof(args)) == -1)
48 atf_tc_fail_errno("could not mount root");
49
50 if (rump_sys_mkdir("/Tunion", 0777) == -1)
51 atf_tc_fail_errno("mkdir mp1");
52 if (rump_sys_mkdir("/Tunion2", 0777) == -1)
53 atf_tc_fail_errno("mkdir mp2");
54 if (rump_sys_mkdir("/Tunion2/A", 0777) == -1)
55 atf_tc_fail_errno("mkdir A");
56 if (rump_sys_mkdir("/Tunion2/B", 0777) == -1)
57 atf_tc_fail_errno("mkdir B");
58
59 unionargs.target = __UNCONST("/Tunion2/A");
60 unionargs.mntflags = UNMNT_BELOW;
61
62 if (rump_sys_mount(MOUNT_UNION, "/Tunion", 0,
63 &unionargs, sizeof(unionargs)) == -1)
64 atf_tc_fail_errno("union mount");
65
66 unionargs.target = __UNCONST("/Tunion2/B");
67 unionargs.mntflags = UNMNT_BELOW;
68
69 /* BADABOOM */
70 /* atf_tc_expect_signal(-1, "PR kern/23986"); */
71 rump_sys_mount(MOUNT_UNION, "/Tunion", 0,&unionargs,sizeof(unionargs));
72 }
73
74 ATF_TP_ADD_TCS(tp)
75 {
76 ATF_TP_ADD_TC(tp, multilayer);
77
78 return atf_no_error();
79 }
80