1*11be35a1SLionel Sambuc /* $NetBSD: t_ptyfs.c,v 1.1 2010/06/11 23:52:38 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 <err.h>
8*11be35a1SLionel Sambuc #include <errno.h>
9*11be35a1SLionel Sambuc #include <fcntl.h>
10*11be35a1SLionel Sambuc #include <stdio.h>
11*11be35a1SLionel Sambuc #include <unistd.h>
12*11be35a1SLionel Sambuc #include <string.h>
13*11be35a1SLionel Sambuc #include <stdlib.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 <fs/ptyfs/ptyfs.h>
19*11be35a1SLionel Sambuc
20*11be35a1SLionel Sambuc #include "../../h_macros.h"
21*11be35a1SLionel Sambuc
22*11be35a1SLionel Sambuc static void
mountptyfs(const char * mp,int flags)23*11be35a1SLionel Sambuc mountptyfs(const char *mp, int flags)
24*11be35a1SLionel Sambuc {
25*11be35a1SLionel Sambuc struct ptyfs_args args;
26*11be35a1SLionel Sambuc
27*11be35a1SLionel Sambuc if (rump_sys_mkdir("/mp", 0777) == -1) {
28*11be35a1SLionel Sambuc if (errno != EEXIST)
29*11be35a1SLionel Sambuc atf_tc_fail_errno("mp1");
30*11be35a1SLionel Sambuc }
31*11be35a1SLionel Sambuc memset(&args, 0, sizeof(args));
32*11be35a1SLionel Sambuc args.version = PTYFS_ARGSVERSION;
33*11be35a1SLionel Sambuc args.mode = 0777;
34*11be35a1SLionel Sambuc if (rump_sys_mount(MOUNT_PTYFS, mp, flags, &args, sizeof(args)) == -1)
35*11be35a1SLionel Sambuc atf_tc_fail_errno("could not mount ptyfs");
36*11be35a1SLionel Sambuc }
37*11be35a1SLionel Sambuc
38*11be35a1SLionel Sambuc ATF_TC(basic);
ATF_TC_HEAD(basic,tc)39*11be35a1SLionel Sambuc ATF_TC_HEAD(basic, tc)
40*11be35a1SLionel Sambuc {
41*11be35a1SLionel Sambuc atf_tc_set_md_var(tc, "descr", "mount ptyfs");
42*11be35a1SLionel Sambuc }
43*11be35a1SLionel Sambuc
ATF_TC_BODY(basic,tc)44*11be35a1SLionel Sambuc ATF_TC_BODY(basic, tc)
45*11be35a1SLionel Sambuc {
46*11be35a1SLionel Sambuc
47*11be35a1SLionel Sambuc rump_init();
48*11be35a1SLionel Sambuc
49*11be35a1SLionel Sambuc mountptyfs("/mp", 0);
50*11be35a1SLionel Sambuc if (rump_sys_unmount("/mp", 0) == -1)
51*11be35a1SLionel Sambuc atf_tc_fail_errno("unmount failed");
52*11be35a1SLionel Sambuc
53*11be35a1SLionel Sambuc /* done */
54*11be35a1SLionel Sambuc }
55*11be35a1SLionel Sambuc
ATF_TP_ADD_TCS(tp)56*11be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
57*11be35a1SLionel Sambuc {
58*11be35a1SLionel Sambuc
59*11be35a1SLionel Sambuc ATF_TP_ADD_TC(tp, basic);
60*11be35a1SLionel Sambuc
61*11be35a1SLionel Sambuc return atf_no_error();
62*11be35a1SLionel Sambuc }
63