1 1.4 christos /* $NetBSD: t_snapshot.c,v 1.4 2017/01/13 21:30:40 christos Exp $ */ 2 1.1 pooka 3 1.1 pooka #include <sys/types.h> 4 1.1 pooka #include <sys/mount.h> 5 1.1 pooka 6 1.1 pooka #include <rump/rump.h> 7 1.1 pooka #include <rump/rump_syscalls.h> 8 1.1 pooka 9 1.1 pooka #include <fs/tmpfs/tmpfs_args.h> 10 1.1 pooka #include <msdosfs/msdosfsmount.h> 11 1.1 pooka 12 1.1 pooka #include <atf-c.h> 13 1.1 pooka #include <err.h> 14 1.1 pooka #include <fcntl.h> 15 1.1 pooka #include <stdio.h> 16 1.1 pooka #include <stdlib.h> 17 1.1 pooka #include <string.h> 18 1.1 pooka #include <unistd.h> 19 1.1 pooka 20 1.4 christos #include "h_macros.h" 21 1.1 pooka 22 1.1 pooka #define IMGNAME "msdosfs.img" 23 1.1 pooka #define NEWFS "newfs_msdos -C 5M " IMGNAME 24 1.2 hannken #define FSCK "fsck_msdos -fn" 25 1.1 pooka #define BAKNAME "/stor/snap" 26 1.1 pooka 27 1.1 pooka static void 28 1.1 pooka mount_diskfs(const char *fspec, const char *path) 29 1.1 pooka { 30 1.1 pooka struct msdosfs_args margs; 31 1.1 pooka 32 1.1 pooka memset(&margs, 0, sizeof(margs)); 33 1.1 pooka margs.fspec = __UNCONST(fspec); 34 1.1 pooka margs.version = MSDOSFSMNT_VERSION; 35 1.1 pooka 36 1.1 pooka if (rump_sys_mount(MOUNT_MSDOS, path, 0, &margs, sizeof(margs)) == -1) 37 1.1 pooka err(1, "mount msdosfs %s", path); 38 1.1 pooka } 39 1.1 pooka 40 1.1 pooka static void 41 1.1 pooka begin(void) 42 1.1 pooka { 43 1.3 martin struct tmpfs_args targs = { .ta_version = TMPFS_ARGS_VERSION, }; 44 1.1 pooka 45 1.1 pooka if (rump_sys_mkdir("/stor", 0777) == -1) 46 1.1 pooka atf_tc_fail_errno("mkdir /stor"); 47 1.1 pooka if (rump_sys_mount(MOUNT_TMPFS, "/stor", 0, &targs,sizeof(targs)) == -1) 48 1.1 pooka atf_tc_fail_errno("mount storage"); 49 1.1 pooka } 50 1.1 pooka 51 1.1 pooka #include "../common/snapshot.c" 52