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