1*0a6a1f1dSLionel Sambuc /* $NetBSD: t_snapshot.c,v 1.3 2014/06/10 13:15:18 martin Exp $ */
211be35a1SLionel Sambuc
311be35a1SLionel Sambuc #include <sys/types.h>
411be35a1SLionel Sambuc #include <sys/mount.h>
511be35a1SLionel Sambuc
611be35a1SLionel Sambuc #include <rump/rump.h>
711be35a1SLionel Sambuc #include <rump/rump_syscalls.h>
811be35a1SLionel Sambuc
911be35a1SLionel Sambuc #include <fs/tmpfs/tmpfs_args.h>
1011be35a1SLionel Sambuc #include <msdosfs/msdosfsmount.h>
1111be35a1SLionel Sambuc
1211be35a1SLionel Sambuc #include <atf-c.h>
1311be35a1SLionel Sambuc #include <err.h>
1411be35a1SLionel Sambuc #include <fcntl.h>
1511be35a1SLionel Sambuc #include <stdio.h>
1611be35a1SLionel Sambuc #include <stdlib.h>
1711be35a1SLionel Sambuc #include <string.h>
1811be35a1SLionel Sambuc #include <unistd.h>
1911be35a1SLionel Sambuc
2011be35a1SLionel Sambuc #include "../../h_macros.h"
2111be35a1SLionel Sambuc
2211be35a1SLionel Sambuc #define IMGNAME "msdosfs.img"
2311be35a1SLionel Sambuc #define NEWFS "newfs_msdos -C 5M " IMGNAME
2411be35a1SLionel Sambuc #define FSCK "fsck_msdos -fn"
2511be35a1SLionel Sambuc #define BAKNAME "/stor/snap"
2611be35a1SLionel Sambuc
2711be35a1SLionel Sambuc static void
mount_diskfs(const char * fspec,const char * path)2811be35a1SLionel Sambuc mount_diskfs(const char *fspec, const char *path)
2911be35a1SLionel Sambuc {
3011be35a1SLionel Sambuc struct msdosfs_args margs;
3111be35a1SLionel Sambuc
3211be35a1SLionel Sambuc memset(&margs, 0, sizeof(margs));
3311be35a1SLionel Sambuc margs.fspec = __UNCONST(fspec);
3411be35a1SLionel Sambuc margs.version = MSDOSFSMNT_VERSION;
3511be35a1SLionel Sambuc
3611be35a1SLionel Sambuc if (rump_sys_mount(MOUNT_MSDOS, path, 0, &margs, sizeof(margs)) == -1)
3711be35a1SLionel Sambuc err(1, "mount msdosfs %s", path);
3811be35a1SLionel Sambuc }
3911be35a1SLionel Sambuc
4011be35a1SLionel Sambuc static void
begin(void)4111be35a1SLionel Sambuc begin(void)
4211be35a1SLionel Sambuc {
43*0a6a1f1dSLionel Sambuc struct tmpfs_args targs = { .ta_version = TMPFS_ARGS_VERSION, };
4411be35a1SLionel Sambuc
4511be35a1SLionel Sambuc if (rump_sys_mkdir("/stor", 0777) == -1)
4611be35a1SLionel Sambuc atf_tc_fail_errno("mkdir /stor");
4711be35a1SLionel Sambuc if (rump_sys_mount(MOUNT_TMPFS, "/stor", 0, &targs,sizeof(targs)) == -1)
4811be35a1SLionel Sambuc atf_tc_fail_errno("mount storage");
4911be35a1SLionel Sambuc }
5011be35a1SLionel Sambuc
5111be35a1SLionel Sambuc #include "../common/snapshot.c"
52