Module Name: src
Committed By: pooka
Date: Thu Aug 6 01:00:04 UTC 2009
Modified Files:
src/usr.sbin/puffs/rump_lfs: Makefile rump_lfs.c
Log Message:
run lfs cleaner
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/puffs/rump_lfs/Makefile \
src/usr.sbin/puffs/rump_lfs/rump_lfs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/puffs/rump_lfs/Makefile
diff -u src/usr.sbin/puffs/rump_lfs/Makefile:1.5 src/usr.sbin/puffs/rump_lfs/Makefile:1.6
--- src/usr.sbin/puffs/rump_lfs/Makefile:1.5 Tue Jul 21 00:37:25 2009
+++ src/usr.sbin/puffs/rump_lfs/Makefile Thu Aug 6 01:00:04 2009
@@ -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>
@@ -8,4 +8,10 @@
ISRUMP= # don't deny it
+CPPFLAGS+= -DUSE_RUMP -DLFS_CLEANER_AS_LIB
+
+.include "../../../libexec/lfs_cleanerd/Makefile.inc"
+
+DBG=-g
+
.include <bsd.prog.mk>
Index: src/usr.sbin/puffs/rump_lfs/rump_lfs.c
diff -u src/usr.sbin/puffs/rump_lfs/rump_lfs.c:1.5 src/usr.sbin/puffs/rump_lfs/rump_lfs.c:1.6
--- src/usr.sbin/puffs/rump_lfs/rump_lfs.c:1.5 Tue Jul 21 00:40:44 2009
+++ src/usr.sbin/puffs/rump_lfs/rump_lfs.c Thu Aug 6 01:00:04 2009
@@ -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)