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