xref: /netbsd/tests/fs/msdosfs/t_snapshot.c (revision 77102b8e)
1*77102b8eSchristos /*	$NetBSD: t_snapshot.c,v 1.4 2017/01/13 21:30:40 christos Exp $	*/
233304497Spooka 
333304497Spooka #include <sys/types.h>
433304497Spooka #include <sys/mount.h>
533304497Spooka 
633304497Spooka #include <rump/rump.h>
733304497Spooka #include <rump/rump_syscalls.h>
833304497Spooka 
933304497Spooka #include <fs/tmpfs/tmpfs_args.h>
1033304497Spooka #include <msdosfs/msdosfsmount.h>
1133304497Spooka 
1233304497Spooka #include <atf-c.h>
1333304497Spooka #include <err.h>
1433304497Spooka #include <fcntl.h>
1533304497Spooka #include <stdio.h>
1633304497Spooka #include <stdlib.h>
1733304497Spooka #include <string.h>
1833304497Spooka #include <unistd.h>
1933304497Spooka 
20*77102b8eSchristos #include "h_macros.h"
2133304497Spooka 
2233304497Spooka #define IMGNAME "msdosfs.img"
2333304497Spooka #define NEWFS "newfs_msdos -C 5M " IMGNAME
246e032d76Shannken #define FSCK "fsck_msdos -fn"
2533304497Spooka #define BAKNAME "/stor/snap"
2633304497Spooka 
2733304497Spooka static void
mount_diskfs(const char * fspec,const char * path)2833304497Spooka mount_diskfs(const char *fspec, const char *path)
2933304497Spooka {
3033304497Spooka 	struct msdosfs_args margs;
3133304497Spooka 
3233304497Spooka 	memset(&margs, 0, sizeof(margs));
3333304497Spooka 	margs.fspec = __UNCONST(fspec);
3433304497Spooka 	margs.version = MSDOSFSMNT_VERSION;
3533304497Spooka 
3633304497Spooka 	if (rump_sys_mount(MOUNT_MSDOS, path, 0, &margs, sizeof(margs)) == -1)
3733304497Spooka 		err(1, "mount msdosfs %s", path);
3833304497Spooka }
3933304497Spooka 
4033304497Spooka static void
begin(void)4133304497Spooka begin(void)
4233304497Spooka {
432a0a755fSmartin 	struct tmpfs_args targs = { .ta_version = TMPFS_ARGS_VERSION, };
4433304497Spooka 
4533304497Spooka 	if (rump_sys_mkdir("/stor", 0777) == -1)
4633304497Spooka 		atf_tc_fail_errno("mkdir /stor");
4733304497Spooka 	if (rump_sys_mount(MOUNT_TMPFS, "/stor", 0, &targs,sizeof(targs)) == -1)
4833304497Spooka 		atf_tc_fail_errno("mount storage");
4933304497Spooka }
5033304497Spooka 
5133304497Spooka #include "../common/snapshot.c"
52