11.2Schristos/* $NetBSD: t_ptyfs.c,v 1.2 2017/01/13 21:30:40 christos Exp $ */ 21.1Spooka 31.1Spooka#include <sys/types.h> 41.1Spooka#include <sys/mount.h> 51.1Spooka 61.1Spooka#include <atf-c.h> 71.1Spooka#include <err.h> 81.1Spooka#include <errno.h> 91.1Spooka#include <fcntl.h> 101.1Spooka#include <stdio.h> 111.1Spooka#include <unistd.h> 121.1Spooka#include <string.h> 131.1Spooka#include <stdlib.h> 141.1Spooka 151.1Spooka#include <rump/rump.h> 161.1Spooka#include <rump/rump_syscalls.h> 171.1Spooka 181.1Spooka#include <fs/ptyfs/ptyfs.h> 191.1Spooka 201.2Schristos#include "h_macros.h" 211.1Spooka 221.1Spookastatic void 231.1Spookamountptyfs(const char *mp, int flags) 241.1Spooka{ 251.1Spooka struct ptyfs_args args; 261.1Spooka 271.1Spooka if (rump_sys_mkdir("/mp", 0777) == -1) { 281.1Spooka if (errno != EEXIST) 291.1Spooka atf_tc_fail_errno("mp1"); 301.1Spooka } 311.1Spooka memset(&args, 0, sizeof(args)); 321.1Spooka args.version = PTYFS_ARGSVERSION; 331.1Spooka args.mode = 0777; 341.1Spooka if (rump_sys_mount(MOUNT_PTYFS, mp, flags, &args, sizeof(args)) == -1) 351.1Spooka atf_tc_fail_errno("could not mount ptyfs"); 361.1Spooka} 371.1Spooka 381.1SpookaATF_TC(basic); 391.1SpookaATF_TC_HEAD(basic, tc) 401.1Spooka{ 411.1Spooka atf_tc_set_md_var(tc, "descr", "mount ptyfs"); 421.1Spooka} 431.1Spooka 441.1SpookaATF_TC_BODY(basic, tc) 451.1Spooka{ 461.1Spooka 471.1Spooka rump_init(); 481.1Spooka 491.1Spooka mountptyfs("/mp", 0); 501.1Spooka if (rump_sys_unmount("/mp", 0) == -1) 511.1Spooka atf_tc_fail_errno("unmount failed"); 521.1Spooka 531.1Spooka /* done */ 541.1Spooka} 551.1Spooka 561.1SpookaATF_TP_ADD_TCS(tp) 571.1Spooka{ 581.1Spooka 591.1Spooka ATF_TP_ADD_TC(tp, basic); 601.1Spooka 611.1Spooka return atf_no_error(); 621.1Spooka} 63