xref: /netbsd-src/usr.sbin/puffs/rump_ext2fs/rump_ext2fs.c (revision ef38ca99339fd7802cb3a1b04a47b6d73d0e69cf)
1*ef38ca99Spooka /*	$NetBSD: rump_ext2fs.c,v 1.9 2010/01/12 18:43:37 pooka Exp $	*/
2bdf6e0b0Spooka 
3bdf6e0b0Spooka /*
4d559e459Spooka  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
5bdf6e0b0Spooka  *
6bdf6e0b0Spooka  * Redistribution and use in source and binary forms, with or without
7bdf6e0b0Spooka  * modification, are permitted provided that the following conditions
8bdf6e0b0Spooka  * are met:
9bdf6e0b0Spooka  * 1. Redistributions of source code must retain the above copyright
10bdf6e0b0Spooka  *    notice, this list of conditions and the following disclaimer.
11bdf6e0b0Spooka  * 2. Redistributions in binary form must reproduce the above copyright
12bdf6e0b0Spooka  *    notice, this list of conditions and the following disclaimer in the
13bdf6e0b0Spooka  *    documentation and/or other materials provided with the distribution.
14bdf6e0b0Spooka  *
15bdf6e0b0Spooka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16bdf6e0b0Spooka  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17bdf6e0b0Spooka  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18bdf6e0b0Spooka  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19bdf6e0b0Spooka  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20bdf6e0b0Spooka  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21bdf6e0b0Spooka  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22bdf6e0b0Spooka  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23bdf6e0b0Spooka  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24bdf6e0b0Spooka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25bdf6e0b0Spooka  * SUCH DAMAGE.
26bdf6e0b0Spooka  */
27bdf6e0b0Spooka 
28bdf6e0b0Spooka #include <sys/types.h>
29bdf6e0b0Spooka #include <sys/mount.h>
30bdf6e0b0Spooka 
31bdf6e0b0Spooka #include <ufs/ufs/ufsmount.h>
32bdf6e0b0Spooka 
33bdf6e0b0Spooka #include <err.h>
34bdf6e0b0Spooka #include <puffs.h>
35bdf6e0b0Spooka #include <stdlib.h>
36bdf6e0b0Spooka #include <unistd.h>
37bdf6e0b0Spooka 
38bdf6e0b0Spooka #include <rump/p2k.h>
39d07d1f30Spooka #include <rump/ukfs.h>
40bdf6e0b0Spooka 
4199fed726Spooka #include "mount_ext2fs.h"
42bdf6e0b0Spooka 
43bdf6e0b0Spooka int
main(int argc,char * argv[])44bdf6e0b0Spooka main(int argc, char *argv[])
45bdf6e0b0Spooka {
46bdf6e0b0Spooka 	struct ufs_args args;
47a1c46739Spooka 	char canon_dev[UKFS_DEVICE_MAXPATHLEN], canon_dir[MAXPATHLEN];
48a1c46739Spooka 	struct ukfs_part *part;
49a1c46739Spooka 	int mntflags;
5099fed726Spooka 	int rv;
51bdf6e0b0Spooka 
52bdf6e0b0Spooka 	setprogname(argv[0]);
53*ef38ca99Spooka 	puffs_unmountonsignal(SIGINT, true);
54*ef38ca99Spooka 	puffs_unmountonsignal(SIGTERM, true);
55d07d1f30Spooka 
56a1c46739Spooka 	UKFS_DEVICE_ARGVPROBE(&part);
5799fed726Spooka 	mount_ext2fs_parseargs(argc, argv, &args, &mntflags,
5899fed726Spooka 	    canon_dev, canon_dir);
59d07d1f30Spooka 	rv = p2k_run_diskfs(MOUNT_EXT2FS, canon_dev, part, canon_dir, mntflags,
6099fed726Spooka 		&args, sizeof(args), 0);
610446aae7Spooka 	ukfs_part_release(part);
62bdf6e0b0Spooka 	if (rv)
63bdf6e0b0Spooka 		err(1, "mount");
64bdf6e0b0Spooka 
65bdf6e0b0Spooka 	return 0;
66bdf6e0b0Spooka }
67