@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.5 2009/07/21 00:37:25 pooka Exp $
+# $NetBSD: Makefile,v 1.6 2009/08/06 01:00:04 pooka Exp $
#
.include <bsd.own.mk>
@@ -7,5 +7,11 @@
DONOTLINKLIBS= # FFS and LFS loaded dynamically
ISRUMP= # don't deny it
+
+CPPFLAGS+= -DUSE_RUMP -DLFS_CLEANER_AS_LIB
+
+.include "../../../libexec/lfs_cleanerd/Makefile.inc"
+
+DBG=-g
.include <bsd.prog.mk>
@@ -1,4 +1,4 @@
-/* $NetBSD: rump_lfs.c,v 1.5 2009/07/21 00:40:44 pooka Exp $ */
+/* $NetBSD: rump_lfs.c,v 1.6 2009/08/06 01:00:04 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -31,20 +31,38 @@
#include <ufs/ufs/ufsmount.h>
#include <err.h>
-#include <puffs.h>
+#include <pthread.h>
+#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <rump/rump.h>
#include <rump/p2k.h>
#include <rump/ukfs.h>
#include "mount_lfs.h"
+static void *
+cleaner(void *arg)
+{
+ const char *the_argv[7];
+
+ the_argv[0] = "megamaid";
+ the_argv[1] = "-D"; /* don't fork() & detach */
+ the_argv[2] = arg;
+
+ sleep(1); /* XXXtehsuck: wait until mount is complete is other thread */
+ lfs_cleaner_main(3, __UNCONST(the_argv));
+
+ return NULL;
+}
+
int
main(int argc, char *argv[])
{
struct ufs_args args;
- char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
+ char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN], rawdev[MAXPATHLEN];
+ pthread_t cleanerthread;
int mntflags;
int rv;
@@ -61,6 +79,34 @@
err(1, "modload lfs");
mount_lfs_parseargs(argc, argv, &args, &mntflags, canon_dev, canon_dir);
+
+ /*
+ * XXX: this particular piece inspired by the cleaner code.
+ * obviously FIXXXME along with the cleaner.
+ */
+ sprintf(rawdev, "/dev/r%s", canon_dev+5);
+ rump_etfs_register(rawdev, canon_dev, RUMP_ETFS_CHR);
+
+ /*
+ * We basically have two choices:
+ * 1) run the cleaner in another process and do rump ipc syscalls
+ * 2) run it off a thread in this process and do rump syscalls
+ * as function calls.
+ *
+ * opt for "2" for now
+ */
+#ifndef CLEANER_TESTING
+ if ((mntflags & MNT_RDONLY) == 0) {
+ if (pthread_create(&cleanerthread, NULL,
+ cleaner, canon_dir) == -1)
+ err(1, "cannot start cleaner");
+ }
+#else
+ ukfs_mount(MOUNT_LFS, canon_dev, canon_dir, mntflags,
+ &args, sizeof(args));
+ cleaner(canon_dir);
+#endif
+
rv = p2k_run_fs(MOUNT_LFS, canon_dev, canon_dir, mntflags,
&args, sizeof(args), 0);
if (rv)