1 /* $NetBSD: rump_lfs.c,v 1.13 2009/12/03 14:27:16 pooka Exp $ */
4 * Copyright (c) 2008 Antti Kantee. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/types.h>
29 #include <sys/mount.h>
31 #include <ufs/ufs/ufsmount.h>
39 #include <rump/rump.h>
41 #include <rump/ukfs.h>
43 #include "mount_lfs.h"
48 const char *the_argv
[7];
50 the_argv
[0] = "megamaid";
51 the_argv
[1] = "-D"; /* don't fork() & detach */
54 lfs_cleaner_main(3, __UNCONST(the_argv
));
60 main(int argc
, char *argv
[])
63 char canon_dev
[UKFS_DEVICE_MAXPATHLEN
], canon_dir
[MAXPATHLEN
];
64 char rawdev
[MAXPATHLEN
];
65 struct p2k_mount
*p2m
;
66 pthread_t cleanerthread
;
67 struct ukfs_part
*part
;
73 UKFS_DEVICE_ARGVPROBE(&part
);
74 if (part
!= ukfs_part_none
) {
75 errx(1, "lfs does not currently support embedded partitions");
77 mount_lfs_parseargs(argc
, argv
, &args
, &mntflags
, canon_dev
, canon_dir
);
83 * XXX: this particular piece inspired by the cleaner code.
84 * obviously FIXXXME along with the cleaner.
86 sprintf(rawdev
, "/dev/r%s", canon_dev
+5);
87 rump_pub_etfs_register(rawdev
, canon_dev
, RUMP_ETFS_CHR
);
90 * We basically have two choices:
91 * 1) run the cleaner in another process and do rump ipc syscalls
92 * 2) run it off a thread in this process and do rump syscalls
97 #ifdef CLEANER_TESTING
98 ukfs_mount(MOUNT_LFS
, canon_dev
, canon_dir
, mntflags
,
102 if (p2k_setup_diskfs(p2m
, MOUNT_LFS
, canon_dev
, part
, canon_dir
,
103 mntflags
, &args
, sizeof(args
)) == -1)
105 ukfs_part_release(part
);
107 #ifndef CLEANER_TESTING
108 if ((mntflags
& MNT_RDONLY
) == 0) {
109 if (pthread_create(&cleanerthread
, NULL
,
110 cleaner
, canon_dir
) == -1)
111 err(1, "cannot start cleaner");
115 rv
= p2k_mainloop(p2m
);
117 err(1, "fs service");