rump_ffs.c revision 1.1
11.1Spooka/*	$NetBSD: rump_ffs.c,v 1.1 2008/07/29 13:17:47 pooka Exp $	*/
21.1Spooka
31.1Spooka/*
41.1Spooka * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
51.1Spooka *
61.1Spooka * Development of this software was supported by Google Summer of Code.
71.1Spooka *
81.1Spooka * Redistribution and use in source and binary forms, with or without
91.1Spooka * modification, are permitted provided that the following conditions
101.1Spooka * are met:
111.1Spooka * 1. Redistributions of source code must retain the above copyright
121.1Spooka *    notice, this list of conditions and the following disclaimer.
131.1Spooka * 2. Redistributions in binary form must reproduce the above copyright
141.1Spooka *    notice, this list of conditions and the following disclaimer in the
151.1Spooka *    documentation and/or other materials provided with the distribution.
161.1Spooka *
171.1Spooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
181.1Spooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
191.1Spooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
201.1Spooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
211.1Spooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221.1Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
231.1Spooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241.1Spooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251.1Spooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261.1Spooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271.1Spooka * SUCH DAMAGE.
281.1Spooka */
291.1Spooka
301.1Spooka#include <sys/types.h>
311.1Spooka#include <sys/mount.h>
321.1Spooka
331.1Spooka#include <ufs/ufs/ufsmount.h>
341.1Spooka
351.1Spooka#include <err.h>
361.1Spooka#include <puffs.h>
371.1Spooka#include <stdlib.h>
381.1Spooka#include <unistd.h>
391.1Spooka
401.1Spooka#include <rump/p2k.h>
411.1Spooka
421.1Spooka/* XXX: figure out a proper way to share code/integrate with mount_ffs */
431.1Spookastatic const struct mntopt ffsmopts[] = {
441.1Spooka	MOPT_STDOPTS,
451.1Spooka	MOPT_ASYNC,
461.1Spooka	MOPT_SYNC,
471.1Spooka	MOPT_UPDATE,
481.1Spooka	MOPT_RELOAD,
491.1Spooka	MOPT_NOATIME,
501.1Spooka	MOPT_NODEVMTIME,
511.1Spooka	MOPT_FORCE,
521.1Spooka	MOPT_SOFTDEP,
531.1Spooka	MOPT_GETARGS,
541.1Spooka	MOPT_NULL,
551.1Spooka};
561.1Spooka
571.1Spookastatic void
581.1Spookausage(void)
591.1Spooka{
601.1Spooka
611.1Spooka	errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
621.1Spooka}
631.1Spooka
641.1Spookaint
651.1Spookamain(int argc, char *argv[])
661.1Spooka{
671.1Spooka	struct ufs_args args;
681.1Spooka	mntoptparse_t mp;
691.1Spooka	int mntflags, pflags;
701.1Spooka	int rv, ch;
711.1Spooka
721.1Spooka	setprogname(argv[0]);
731.1Spooka	getmnt_silent = 1;
741.1Spooka
751.1Spooka	mntflags = pflags = 0;
761.1Spooka	while ((ch = getopt(argc, argv, "o:")) != -1) {
771.1Spooka		switch (ch) {
781.1Spooka		case 'o':
791.1Spooka			mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
801.1Spooka			if (mp == NULL) {
811.1Spooka				mp = getmntopts(optarg, ffsmopts, &mntflags, 0);
821.1Spooka				if (mp == NULL)
831.1Spooka					err(1, "getmntops");
841.1Spooka			}
851.1Spooka			freemntopts(mp);
861.1Spooka			break;
871.1Spooka		default:
881.1Spooka			usage();
891.1Spooka			/* NOTREACHED */
901.1Spooka		}
911.1Spooka	}
921.1Spooka	argc -= optind;
931.1Spooka	argv += optind;
941.1Spooka	if (argc != 2)
951.1Spooka		usage();
961.1Spooka
971.1Spooka	memset(&args, 0, sizeof(args));
981.1Spooka	args.fspec = argv[0];
991.1Spooka
1001.1Spooka	rv = p2k_run_fs(MOUNT_FFS, argv[0], argv[1], mntflags,
1011.1Spooka	    &args, sizeof(args), pflags);
1021.1Spooka	if (rv)
1031.1Spooka		err(1, "mount");
1041.1Spooka
1051.1Spooka	return 0;
1061.1Spooka}
107