Home | History | Annotate | Line # | Download | only in union
t_pr.c revision 1.3
      1  1.3   jmmv /*	$NetBSD: t_pr.c,v 1.3 2010/07/03 08:18:30 jmmv 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 }
     29  1.1  pooka 
     30  1.1  pooka #define IMG1 "atf1.img"
     31  1.1  pooka #define DEV1 "/dev/fs1"
     32  1.1  pooka #define newfs_base "newfs -F -s 10000 "
     33  1.1  pooka 
     34  1.1  pooka ATF_TC_BODY(multilayer, tc)
     35  1.1  pooka {
     36  1.1  pooka 	struct ufs_args args;
     37  1.1  pooka 	struct union_args unionargs;
     38  1.1  pooka 
     39  1.1  pooka 	if (system(newfs_base IMG1) == -1)
     40  1.1  pooka 		atf_tc_fail_errno("create img1");
     41  1.1  pooka 
     42  1.1  pooka 	rump_init();
     43  1.1  pooka         rump_pub_etfs_register(DEV1, IMG1, RUMP_ETFS_BLK);
     44  1.1  pooka 
     45  1.1  pooka 	memset(&args, 0, sizeof(args));
     46  1.1  pooka 	args.fspec = __UNCONST(DEV1);
     47  1.1  pooka 	if (rump_sys_mount(MOUNT_FFS, "/", 0, &args, sizeof(args)) == -1)
     48  1.1  pooka 		atf_tc_fail_errno("could not mount root");
     49  1.1  pooka 
     50  1.1  pooka 	if (rump_sys_mkdir("/Tunion", 0777) == -1)
     51  1.1  pooka 		atf_tc_fail_errno("mkdir mp1");
     52  1.1  pooka 	if (rump_sys_mkdir("/Tunion2", 0777) == -1)
     53  1.1  pooka 		atf_tc_fail_errno("mkdir mp2");
     54  1.1  pooka 	if (rump_sys_mkdir("/Tunion2/A", 0777) == -1)
     55  1.1  pooka 		atf_tc_fail_errno("mkdir A");
     56  1.1  pooka 	if (rump_sys_mkdir("/Tunion2/B", 0777) == -1)
     57  1.1  pooka 		atf_tc_fail_errno("mkdir B");
     58  1.1  pooka 
     59  1.1  pooka 	unionargs.target = __UNCONST("/Tunion2/A");
     60  1.1  pooka 	unionargs.mntflags = UNMNT_BELOW;
     61  1.1  pooka 
     62  1.1  pooka 	if (rump_sys_mount(MOUNT_UNION, "/Tunion", 0,
     63  1.1  pooka 	    &unionargs, sizeof(unionargs)) == -1)
     64  1.1  pooka 		atf_tc_fail_errno("union mount");
     65  1.1  pooka 
     66  1.1  pooka 	unionargs.target = __UNCONST("/Tunion2/B");
     67  1.1  pooka 	unionargs.mntflags = UNMNT_BELOW;
     68  1.1  pooka 
     69  1.1  pooka 	/* BADABOOM */
     70  1.3   jmmv 	/* atf_tc_expect_signal(-1, "PR kern/23986"); */
     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