1272343Sngie/*	$NetBSD: t_snapshot.c,v 1.3 2014/06/10 13:15:18 martin Exp $	*/
2272343Sngie
3272343Sngie#include <sys/types.h>
4272343Sngie#include <sys/mount.h>
5272343Sngie
6272343Sngie#include <rump/rump.h>
7272343Sngie#include <rump/rump_syscalls.h>
8272343Sngie
9272343Sngie#include <fs/tmpfs/tmpfs_args.h>
10272343Sngie#include <msdosfs/msdosfsmount.h>
11272343Sngie
12272343Sngie#include <atf-c.h>
13272343Sngie#include <err.h>
14272343Sngie#include <fcntl.h>
15272343Sngie#include <stdio.h>
16272343Sngie#include <stdlib.h>
17272343Sngie#include <string.h>
18272343Sngie#include <unistd.h>
19272343Sngie
20272343Sngie#include "../../h_macros.h"
21272343Sngie
22272343Sngie#define IMGNAME "msdosfs.img"
23272343Sngie#define NEWFS "newfs_msdos -C 5M " IMGNAME
24272343Sngie#define FSCK "fsck_msdos -fn"
25272343Sngie#define BAKNAME "/stor/snap"
26272343Sngie
27272343Sngiestatic void
28272343Sngiemount_diskfs(const char *fspec, const char *path)
29272343Sngie{
30272343Sngie	struct msdosfs_args margs;
31272343Sngie
32272343Sngie	memset(&margs, 0, sizeof(margs));
33272343Sngie	margs.fspec = __UNCONST(fspec);
34272343Sngie	margs.version = MSDOSFSMNT_VERSION;
35272343Sngie
36272343Sngie	if (rump_sys_mount(MOUNT_MSDOS, path, 0, &margs, sizeof(margs)) == -1)
37272343Sngie		err(1, "mount msdosfs %s", path);
38272343Sngie}
39272343Sngie
40272343Sngiestatic void
41272343Sngiebegin(void)
42272343Sngie{
43272343Sngie	struct tmpfs_args targs = { .ta_version = TMPFS_ARGS_VERSION, };
44272343Sngie
45272343Sngie	if (rump_sys_mkdir("/stor", 0777) == -1)
46272343Sngie		atf_tc_fail_errno("mkdir /stor");
47272343Sngie	if (rump_sys_mount(MOUNT_TMPFS, "/stor", 0, &targs,sizeof(targs)) == -1)
48272343Sngie		atf_tc_fail_errno("mount storage");
49272343Sngie}
50272343Sngie
51272343Sngie#include "../common/snapshot.c"
52