xref: /minix3/tests/fs/lfs/t_pr.c (revision 11be35a165022172ed3cea20f2b5df0307540b0e)
1*11be35a1SLionel Sambuc /*	$NetBSD: t_pr.c,v 1.6 2011/02/22 18:41:05 pooka Exp $	*/
2*11be35a1SLionel Sambuc 
3*11be35a1SLionel Sambuc #include <sys/types.h>
4*11be35a1SLionel Sambuc #include <sys/mount.h>
5*11be35a1SLionel Sambuc 
6*11be35a1SLionel Sambuc #include <atf-c.h>
7*11be35a1SLionel Sambuc #include <errno.h>
8*11be35a1SLionel Sambuc #include <fcntl.h>
9*11be35a1SLionel Sambuc #include <limits.h>
10*11be35a1SLionel Sambuc #include <stdio.h>
11*11be35a1SLionel Sambuc #include <stdlib.h>
12*11be35a1SLionel Sambuc #include <unistd.h>
13*11be35a1SLionel Sambuc #include <string.h>
14*11be35a1SLionel Sambuc 
15*11be35a1SLionel Sambuc #include <rump/rump.h>
16*11be35a1SLionel Sambuc #include <rump/rump_syscalls.h>
17*11be35a1SLionel Sambuc 
18*11be35a1SLionel Sambuc #include <ufs/ufs/ufsmount.h>
19*11be35a1SLionel Sambuc 
20*11be35a1SLionel Sambuc #include "../../h_macros.h"
21*11be35a1SLionel Sambuc 
22*11be35a1SLionel Sambuc ATF_TC(mknod);
ATF_TC_HEAD(mknod,tc)23*11be35a1SLionel Sambuc ATF_TC_HEAD(mknod, tc)
24*11be35a1SLionel Sambuc {
25*11be35a1SLionel Sambuc 
26*11be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "mknod(2) hangs on LFS (PR kern/43503)");
27*11be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "timeout", "20");
28*11be35a1SLionel Sambuc }
29*11be35a1SLionel Sambuc 
30*11be35a1SLionel Sambuc #define IMGNAME "disk.img"
31*11be35a1SLionel Sambuc #define FAKEBLK "/dev/blk"
ATF_TC_BODY(mknod,tc)32*11be35a1SLionel Sambuc ATF_TC_BODY(mknod, tc)
33*11be35a1SLionel Sambuc {
34*11be35a1SLionel Sambuc 	struct ufs_args args;
35*11be35a1SLionel Sambuc 
36*11be35a1SLionel Sambuc 	/* hmm, maybe i should fix newfs_lfs instead? */
37*11be35a1SLionel Sambuc 	if (system("newfs_lfs -D -F -s 10000 ./" IMGNAME) == -1)
38*11be35a1SLionel Sambuc 		atf_tc_fail_errno("newfs failed");
39*11be35a1SLionel Sambuc 
40*11be35a1SLionel Sambuc 	memset(&args, 0, sizeof(args));
41*11be35a1SLionel Sambuc 	args.fspec = __UNCONST(FAKEBLK);
42*11be35a1SLionel Sambuc 
43*11be35a1SLionel Sambuc 	rump_init();
44*11be35a1SLionel Sambuc 	if (rump_sys_mkdir("/mp", 0777) == -1)
45*11be35a1SLionel Sambuc 		atf_tc_fail_errno("cannot create mountpoint");
46*11be35a1SLionel Sambuc 	rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK);
47*11be35a1SLionel Sambuc 	if (rump_sys_mount(MOUNT_LFS, "/mp", 0, &args, sizeof(args)) == -1)
48*11be35a1SLionel Sambuc 		atf_tc_fail_errno("rump_sys_mount failed");
49*11be35a1SLionel Sambuc 
50*11be35a1SLionel Sambuc 	//atf_tc_expect_timeout("PR kern/43503");
51*11be35a1SLionel Sambuc 	if (rump_sys_mknod("/mp/node", S_IFCHR | 0777, 0) == -1)
52*11be35a1SLionel Sambuc 		atf_tc_fail_errno("mknod failed");
53*11be35a1SLionel Sambuc }
54*11be35a1SLionel Sambuc 
ATF_TP_ADD_TCS(tp)55*11be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
56*11be35a1SLionel Sambuc {
57*11be35a1SLionel Sambuc 
58*11be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, mknod);
59*11be35a1SLionel Sambuc 	return 0;
60*11be35a1SLionel Sambuc }
61