xref: /netbsd-src/usr.sbin/puffs/rump_lfs/rump_lfs.c (revision cac8e449158efc7261bebc8657cbb0125a2cfdde)
1 /*	$NetBSD: rump_lfs.c,v 1.1 2008/07/29 13:17:48 pooka Exp $	*/
2 
3 /*
4  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
5  *
6  * Development of this software was supported by Google Summer of Code.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #include <sys/types.h>
31 #include <sys/mount.h>
32 
33 #include <ufs/ufs/ufsmount.h>
34 
35 #include <err.h>
36 #include <puffs.h>
37 #include <stdlib.h>
38 #include <unistd.h>
39 
40 #include <rump/p2k.h>
41 
42 static void
43 usage(void)
44 {
45 
46 	errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
47 }
48 
49 int
50 main(int argc, char *argv[])
51 {
52 	struct ufs_args args;
53 	mntoptparse_t mp;
54 	int mntflags, pflags;
55 	int rv, ch;
56 
57 	setprogname(argv[0]);
58 
59 	mntflags = pflags = 0;
60 	while ((ch = getopt(argc, argv, "o:")) != -1) {
61 		switch (ch) {
62 		case 'o':
63 			mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
64 			if (mp == NULL)
65 				err(1, "getmntops");
66 			freemntopts(mp);
67 			break;
68 		default:
69 			usage();
70 			/* NOTREACHED */
71 		}
72 	}
73 	argc -= optind;
74 	argv += optind;
75 	if (argc != 2)
76 		usage();
77 
78 	memset(&args, 0, sizeof(args));
79 	args.fspec = argv[0];
80 
81 	rv = p2k_run_fs(MOUNT_LFS, argv[0], argv[1], mntflags,
82 	    &args, sizeof(args), pflags);
83 	if (rv)
84 		err(1, "mount");
85 
86 	return 0;
87 }
88