Module Name: src
Committed By: pooka
Date: Thu Aug 6 00:51:55 UTC 2009
Modified Files:
src/libexec/lfs_cleanerd: Makefile coalesce.c fdfs.c lfs_cleanerd.c
src/sbin/fsck_lfs: Makefile lfs.c vnode.c
src/sbin/newfs_lfs: Makefile
Added Files:
src/libexec/lfs_cleanerd: Makefile.inc
src/sbin/fsck_lfs: kernelops.c kernelops.h
Log Message:
Define syscalls of lfs userspace tools (cleaner, mainly) through
a struct called kernelops, which contains standard system calls
for the normal case and rump system calls for the rump case.
Make it possible to run the lfs cleaner in a library fashion (taking
the quick route with the implementation).
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/libexec/lfs_cleanerd/Makefile
cvs rdiff -u -r0 -r1.1 src/libexec/lfs_cleanerd/Makefile.inc
cvs rdiff -u -r1.17 -r1.18 src/libexec/lfs_cleanerd/coalesce.c
cvs rdiff -u -r1.6 -r1.7 src/libexec/lfs_cleanerd/fdfs.c
cvs rdiff -u -r1.20 -r1.21 src/libexec/lfs_cleanerd/lfs_cleanerd.c
cvs rdiff -u -r1.16 -r1.17 src/sbin/fsck_lfs/Makefile
cvs rdiff -u -r0 -r1.1 src/sbin/fsck_lfs/kernelops.c \
src/sbin/fsck_lfs/kernelops.h
cvs rdiff -u -r1.30 -r1.31 src/sbin/fsck_lfs/lfs.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/fsck_lfs/vnode.c
cvs rdiff -u -r1.8 -r1.9 src/sbin/newfs_lfs/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/libexec/lfs_cleanerd/Makefile
diff -u src/libexec/lfs_cleanerd/Makefile:1.14 src/libexec/lfs_cleanerd/Makefile:1.15
--- src/libexec/lfs_cleanerd/Makefile:1.14 Sun Jun 21 20:20:50 2009
+++ src/libexec/lfs_cleanerd/Makefile Thu Aug 6 00:51:55 2009
@@ -1,24 +1,10 @@
-# $NetBSD: Makefile,v 1.14 2009/06/21 20:20:50 christos Exp $
+# $NetBSD: Makefile,v 1.15 2009/08/06 00:51:55 pooka Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
-WARNS?=3 # XXX: too many sign-compare issues
-
-.include <bsd.own.mk>
+.include "Makefile.inc"
PROG= lfs_cleanerd
-SRCS= lfs_cleanerd.c fdfs.c coalesce.c cleansrv.c
-SRCS+= lfs_cksum.c
-SRCS+= bufcache.c vnode.c lfs.c # segwrite.c
MAN= lfs_cleanerd.8
-.PATH: ${NETBSDSRCDIR}/sys/ufs/lfs ${NETBSDSRCDIR}/sbin/fsck_lfs
-
-FSCK_LFS= ${NETBSDSRCDIR}/sbin/fsck_lfs
-DPADD= ${LIBUTIL}
-LDADD= -lutil
-CPPFLAGS+=-I${FSCK_LFS} "-Dmutex_enter(x)=" "-Dmutex_exit(x)=" # -DUSE_CLIENT_SERVER
-CPPFLAGS+="-DKASSERT(x)="
-#CPPFLAGS+=-DREPAIR_ZERO_FINFO
-#CPPFLAGS+=-DTEST_PATTERN
BINDIR= /libexec
.if (${MKDYNAMICROOT} == "no")
Index: src/libexec/lfs_cleanerd/coalesce.c
diff -u src/libexec/lfs_cleanerd/coalesce.c:1.17 src/libexec/lfs_cleanerd/coalesce.c:1.18
--- src/libexec/lfs_cleanerd/coalesce.c:1.17 Mon Mar 16 00:08:10 2009
+++ src/libexec/lfs_cleanerd/coalesce.c Thu Aug 6 00:51:55 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: coalesce.c,v 1.17 2009/03/16 00:08:10 lukem Exp $ */
+/* $NetBSD: coalesce.c,v 1.18 2009/08/06 00:51:55 pooka Exp $ */
/*-
* Copyright (c) 2002, 2005 The NetBSD Foundation, Inc.
@@ -56,6 +56,7 @@
#include "bufcache.h"
#include "vnode.h"
#include "cleaner.h"
+#include "kernelops.h"
extern int debug, do_mmap;
@@ -197,7 +198,7 @@
}
lim.blkiov = bip;
lim.blkcnt = nb;
- if (fcntl(fs->clfs_ifilefd, LFCNBMAPV, &lim) < 0) {
+ if (kops.ko_fcntl(fs->clfs_ifilefd, LFCNBMAPV, &lim) < 0) {
syslog(LOG_WARNING, "%s: coalesce: LFCNBMAPV: %m",
fs->lfs_fsmnt);
retval = COALESCE_BADBMAPV;
@@ -277,7 +278,7 @@
goto out;
}
- if (pread(fs->clfs_devfd, bip[i].bi_bp, bip[i].bi_size,
+ if (kops.ko_pread(fs->clfs_devfd, bip[i].bi_bp, bip[i].bi_size,
fsbtob(fs, bip[i].bi_daddr)) < 0) {
retval = COALESCE_EIO;
goto out;
@@ -300,12 +301,13 @@
brelse(bp, B_INVAL);
if (cip.clean < 4) /* XXX magic number 4 */
- fcntl(fs->clfs_ifilefd, LFCNSEGWAIT, NULL);
+ kops.ko_fcntl(fs->clfs_ifilefd,
+ LFCNSEGWAIT, NULL);
} while(cip.clean < 4);
lim.blkiov = tbip;
lim.blkcnt = (tbip + bps < bip + nb ? bps : nb % bps);
- if (fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim) < 0) {
+ if (kops.ko_fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim) < 0) {
retval = COALESCE_BADMARKV;
goto out;
}
Index: src/libexec/lfs_cleanerd/fdfs.c
diff -u src/libexec/lfs_cleanerd/fdfs.c:1.6 src/libexec/lfs_cleanerd/fdfs.c:1.7
--- src/libexec/lfs_cleanerd/fdfs.c:1.6 Mon Apr 28 20:23:04 2008
+++ src/libexec/lfs_cleanerd/fdfs.c Thu Aug 6 00:51:55 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: fdfs.c,v 1.6 2008/04/28 20:23:04 martin Exp $ */
+/* $NetBSD: fdfs.c,v 1.7 2009/08/06 00:51:55 pooka Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -52,6 +52,7 @@
#include "vnode.h"
#include "bufcache.h"
#include "fdfs.h"
+#include "kernelops.h"
/*
* Return a "vnode" interface to a given file descriptor.
@@ -202,7 +203,7 @@
fs->fd_bufp[fs->fd_bufi].start = start;
fs->fd_bufp[fs->fd_bufi].end = start + fs->fd_ssize / fs->fd_bsize;
- if ((r = pread(fs->fd_fd, fs->fd_bufp[fs->fd_bufi].buf,
+ if ((r = kops.ko_pread(fs->fd_fd, fs->fd_bufp[fs->fd_bufi].buf,
(size_t)fs->fd_ssize, start * fs->fd_bsize)) < 0) {
syslog(LOG_ERR, "preload to segment buffer %d", fs->fd_bufi);
return r;
@@ -250,12 +251,12 @@
bp->b_flags |= (B_DONTFREE | B_DONE);
return 0;
}
- count = pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
+ count = kops.ko_pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
bp->b_blkno * fs->fd_bsize);
if (count == bp->b_bcount)
bp->b_flags |= B_DONE;
} else {
- count = pwrite(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
+ count = kops.ko_pwrite(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
bp->b_blkno * fs->fd_bsize);
if (count == 0) {
perror("pwrite");
Index: src/libexec/lfs_cleanerd/lfs_cleanerd.c
diff -u src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.20 src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.21
--- src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.20 Thu Aug 6 00:23:08 2009
+++ src/libexec/lfs_cleanerd/lfs_cleanerd.c Thu Aug 6 00:51:55 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.20 2009/08/06 00:23:08 pooka Exp $ */
+/* $NetBSD: lfs_cleanerd.c,v 1.21 2009/08/06 00:51:55 pooka Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -57,6 +57,8 @@
#include "lfs_user.h"
#include "fdfs.h"
#include "cleaner.h"
+#include "kernelops.h"
+#include "mount_lfs.h"
/*
* Global variables.
@@ -134,8 +136,8 @@
char fsname[MNAMELEN];
strncpy(fsname, (char *)fs->lfs_fsmnt, MNAMELEN);
- close(fs->clfs_ifilefd);
- close(fs->clfs_devfd);
+ kops.ko_close(fs->clfs_ifilefd);
+ kops.ko_close(fs->clfs_devfd);
fd_reclaim(fs->clfs_devvp);
fd_reclaim(fs->lfs_ivnode);
free(fs->clfs_dev);
@@ -157,7 +159,7 @@
int i;
fs->clfs_dev = fsname;
- if ((fs->clfs_devfd = open(fs->clfs_dev, O_RDWR)) < 0) {
+ if ((fs->clfs_devfd = kops.ko_open(fs->clfs_dev, O_RDWR)) < 0) {
syslog(LOG_ERR, "couldn't open device %s read/write",
fs->clfs_dev);
return -1;
@@ -207,7 +209,7 @@
* XXX this is ugly. Is there a way to discover the raw device
* XXX for a given mount point?
*/
- if (statvfs(fsname, &sf) < 0)
+ if (kops.ko_statvfs(fsname, &sf, ST_WAIT) < 0)
return -1;
fs->clfs_dev = malloc(strlen(sf.f_mntfromname) + 2);
if (fs->clfs_dev == NULL) {
@@ -215,24 +217,24 @@
return -1;
}
sprintf(fs->clfs_dev, "/dev/r%s", sf.f_mntfromname + 5);
- if ((fs->clfs_devfd = open(fs->clfs_dev, O_RDONLY)) < 0) {
+ if ((fs->clfs_devfd = kops.ko_open(fs->clfs_dev, O_RDONLY, 0)) < 0) {
syslog(LOG_ERR, "couldn't open device %s for reading",
fs->clfs_dev);
return -1;
}
/* Find the Ifile and open it */
- if ((rootfd = open(fsname, O_RDONLY)) < 0)
+ if ((rootfd = kops.ko_open(fsname, O_RDONLY, 0)) < 0)
return -2;
- if (fcntl(rootfd, LFCNIFILEFH, &fs->clfs_ifilefh) < 0)
+ if (kops.ko_fcntl(rootfd, LFCNIFILEFH, &fs->clfs_ifilefh) < 0)
return -3;
- if ((fs->clfs_ifilefd = fhopen(&fs->clfs_ifilefh,
+ if ((fs->clfs_ifilefd = kops.ko_fhopen(&fs->clfs_ifilefh,
sizeof(fs->clfs_ifilefh), O_RDONLY)) < 0)
return -4;
- close(rootfd);
+ kops.ko_close(rootfd);
/* Load in the superblock */
- if (pread(fs->clfs_devfd, &(fs->lfs_dlfs), sizeof(struct dlfs),
+ if (kops.ko_pread(fs->clfs_devfd, &(fs->lfs_dlfs), sizeof(struct dlfs),
LFS_LABELPAD) < 0)
return -1;
@@ -798,7 +800,7 @@
/* Use bmapv to locate the blocks */
lim.blkiov = bip;
lim.blkcnt = *bic;
- if ((r = fcntl(fs->clfs_ifilefd, LFCNBMAPV, &lim)) < 0) {
+ if ((r = kops.ko_fcntl(fs->clfs_ifilefd, LFCNBMAPV, &lim)) < 0) {
syslog(LOG_WARNING, "%s: bmapv returned %d (%m)",
fs->lfs_fsmnt, r);
return;
@@ -859,7 +861,7 @@
*/
lim.blkiov = bip;
lim.blkcnt = bic;
- if ((r = fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim)) < 0) {
+ if ((r = kops.ko_fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim)) < 0) {
syslog(LOG_WARNING, "%s: markv returned %d (%m) "
"for seg %d", fs->lfs_fsmnt, r, sn);
return r;
@@ -868,7 +870,7 @@
/*
* Finally call invalidate to invalidate the segment.
*/
- if ((r = fcntl(fs->clfs_ifilefd, LFCNINVAL, &sn)) < 0) {
+ if ((r = kops.ko_fcntl(fs->clfs_ifilefd, LFCNINVAL, &sn)) < 0) {
syslog(LOG_WARNING, "%s: inval returned %d (%m) "
"for seg %d", fs->lfs_fsmnt, r, sn);
return r;
@@ -1129,7 +1131,7 @@
}
#endif /* TEST_PATTERN */
dlog("sending blocks %d-%d", mc, mc + lim.blkcnt - 1);
- if ((r = fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim)) < 0) {
+ if ((r = kops.ko_fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim))<0) {
syslog(LOG_WARNING, "%s: markv returned %d (%m)",
fs->lfs_fsmnt, r);
if (errno != EAGAIN && errno != ESHUTDOWN) {
@@ -1158,7 +1160,7 @@
/*
* Finally call reclaim to prompt cleaning of the segments.
*/
- fcntl(fs->clfs_ifilefd, LFCNRECLAIM, NULL);
+ kops.ko_fcntl(fs->clfs_ifilefd, LFCNRECLAIM, NULL);
fd_release_all(fs->clfs_devvp);
return 0;
@@ -1309,12 +1311,21 @@
"[-n nsegs] [-r report_freq] [-t timeout] fs_name ...");
}
+#ifndef LFS_CLEANER_AS_LIB
/*
* Main.
*/
int
main(int argc, char **argv)
{
+
+ return lfs_cleaner_main(argc, argv);
+}
+#endif
+
+int
+lfs_cleaner_main(int argc, char **argv)
+{
int i, opt, error, r, loopcount, nodetach;
struct timeval tv;
CLEANERINFO ci;
@@ -1538,7 +1549,7 @@
} while(cleaned_one);
tv.tv_sec = segwait_timeout;
tv.tv_usec = 0;
- error = fcntl(fsp[0]->clfs_ifilefd, LFCNSEGWAITALL, &tv);
+ error = kops.ko_fcntl(fsp[0]->clfs_ifilefd,LFCNSEGWAITALL,&tv);
if (error)
err(1, "LFCNSEGWAITALL");
}
Index: src/sbin/fsck_lfs/Makefile
diff -u src/sbin/fsck_lfs/Makefile:1.16 src/sbin/fsck_lfs/Makefile:1.17
--- src/sbin/fsck_lfs/Makefile:1.16 Sat Apr 11 07:58:12 2009
+++ src/sbin/fsck_lfs/Makefile Thu Aug 6 00:51:55 2009
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.16 2009/04/11 07:58:12 lukem Exp $
+# $NetBSD: Makefile,v 1.17 2009/08/06 00:51:55 pooka Exp $
# @(#)Makefile 8.1 (Berkeley) 6/5/93
WARNS?= 3 # XXX: sign-compare issues
@@ -10,6 +10,7 @@
SRCS= bufcache.c dir.c fsutil.c inode.c lfs.c lfs_cksum.c lfs_itimes.c main.c
SRCS+= pass0.c pass1.c pass2.c pass3.c pass4.c pass5.c pass6.c
SRCS+= segwrite.c setup.c utilities.c vars.c vnode.c
+SRCS+= kernelops.c
FSCK= ${NETBSDSRCDIR}/sbin/fsck
.PATH: ${NETBSDSRCDIR}/sys/ufs/lfs ${FSCK}
CPPFLAGS+=-I${.CURDIR} -I${FSCK} -DIN_FSCK_LFS "-Dmutex_enter(x)=" "-Dmutex_exit(x)="
Index: src/sbin/fsck_lfs/lfs.c
diff -u src/sbin/fsck_lfs/lfs.c:1.30 src/sbin/fsck_lfs/lfs.c:1.31
--- src/sbin/fsck_lfs/lfs.c:1.30 Sun Feb 22 20:28:05 2009
+++ src/sbin/fsck_lfs/lfs.c Thu Aug 6 00:51:55 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.30 2009/02/22 20:28:05 ad Exp $ */
+/* $NetBSD: lfs.c,v 1.31 2009/08/06 00:51:55 pooka Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -90,6 +90,7 @@
#include "vnode.h"
#include "lfs_user.h"
#include "segwrite.h"
+#include "kernelops.h"
#define panic call_panic
@@ -117,12 +118,12 @@
int count;
if (bp->b_flags & B_READ) {
- count = pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
+ count = kops.ko_pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
dbtob(bp->b_blkno));
if (count == bp->b_bcount)
bp->b_flags |= B_DONE;
} else {
- count = pwrite(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
+ count = kops.ko_pwrite(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
dbtob(bp->b_blkno));
if (count == 0) {
perror("pwrite");
Index: src/sbin/fsck_lfs/vnode.c
diff -u src/sbin/fsck_lfs/vnode.c:1.9 src/sbin/fsck_lfs/vnode.c:1.10
--- src/sbin/fsck_lfs/vnode.c:1.9 Mon Apr 28 20:23:08 2008
+++ src/sbin/fsck_lfs/vnode.c Thu Aug 6 00:51:55 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode.c,v 1.9 2008/04/28 20:23:08 martin Exp $ */
+/* $NetBSD: vnode.c,v 1.10 2009/08/06 00:51:55 pooka Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -53,6 +53,7 @@
#include "bufcache.h"
#include "vnode.h"
+#include "kernelops.h"
struct uvnodelst vnodelist;
struct uvnodelst getvnodelist[VNODE_HASH_MAX];
@@ -73,10 +74,10 @@
raw_vop_strategy(struct ubuf * bp)
{
if (bp->b_flags & B_READ) {
- return pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
+ return kops.ko_pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
dbtob(bp->b_blkno));
} else {
- return pwrite(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
+ return kops.ko_pwrite(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
dbtob(bp->b_blkno));
}
}
Index: src/sbin/newfs_lfs/Makefile
diff -u src/sbin/newfs_lfs/Makefile:1.8 src/sbin/newfs_lfs/Makefile:1.9
--- src/sbin/newfs_lfs/Makefile:1.8 Fri Jun 5 21:52:31 2009
+++ src/sbin/newfs_lfs/Makefile Thu Aug 6 00:51:55 2009
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8 2009/06/05 21:52:31 haad Exp $
+# $NetBSD: Makefile,v 1.9 2009/08/06 00:51:55 pooka Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
WARNS?= 3 # XXX: sign-compare issues
@@ -8,6 +8,7 @@
PROG= newfs_lfs
SRCS= dkcksum.c make_lfs.c lfs_cksum.c misc.c newfs.c
SRCS+= bufcache.c vnode.c lfs.c segwrite.c lfs_itimes.c partutil.c
+SRCS+= kernelops.c
MAN= newfs_lfs.8
DISKLABEL= ${NETBSDSRCDIR}/sbin/disklabel
Added files:
Index: src/libexec/lfs_cleanerd/Makefile.inc
diff -u /dev/null src/libexec/lfs_cleanerd/Makefile.inc:1.1
--- /dev/null Thu Aug 6 00:51:55 2009
+++ src/libexec/lfs_cleanerd/Makefile.inc Thu Aug 6 00:51:55 2009
@@ -0,0 +1,21 @@
+# $NetBSD: Makefile.inc,v 1.1 2009/08/06 00:51:55 pooka Exp $
+# @(#)Makefile 8.1 (Berkeley) 6/18/93
+
+WARNS?=3 # XXX: too many sign-compare issues
+
+.include <bsd.own.mk>
+
+SRCS= lfs_cleanerd.c fdfs.c coalesce.c cleansrv.c
+SRCS+= lfs_cksum.c
+SRCS+= bufcache.c vnode.c lfs.c kernelops.c # segwrite.c
+.PATH: ${NETBSDSRCDIR}/sys/ufs/lfs ${NETBSDSRCDIR}/sbin/fsck_lfs \
+ ${NETBSDSRCDIR}/libexec/lfs_cleanerd
+
+FSCK_LFS= ${NETBSDSRCDIR}/sbin/fsck_lfs
+DPADD= ${LIBUTIL}
+LDADD= -lutil
+CPPFLAGS+=-I${FSCK_LFS} -I${NETBSDSRCDIR}/sbin/mount_lfs # -DUSE_CLIENT_SERVER
+CPPFLAGS+="-Dmutex_enter(x)=" "-Dmutex_exit(x)="
+CPPFLAGS+="-DKASSERT(x)="
+#CPPFLAGS+=-DREPAIR_ZERO_FINFO
+#CPPFLAGS+=-DTEST_PATTERN
Index: src/sbin/fsck_lfs/kernelops.c
diff -u /dev/null src/sbin/fsck_lfs/kernelops.c:1.1
--- /dev/null Thu Aug 6 00:51:55 2009
+++ src/sbin/fsck_lfs/kernelops.c Thu Aug 6 00:51:55 2009
@@ -0,0 +1,80 @@
+/* $NetBSD: kernelops.c,v 1.1 2009/08/06 00:51:55 pooka Exp $ */
+
+/*
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: kernelops.c,v 1.1 2009/08/06 00:51:55 pooka Exp $");
+#endif /* !lint */
+
+/*
+ * Select operations vector for kernel communication -- either regular
+ * system calls or rump system calls. The latter are use when the
+ * cleaner is run as part of rump_lfs.
+ *
+ * The selection is controlled by an ifdef for now, since I see no
+ * value in making it dynamic.
+ */
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <sys/statvfs.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "kernelops.h"
+
+#ifdef USE_RUMP
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+struct kernelops kops = {
+ .ko_open = rump_sys_open,
+ .ko_fcntl = rump_sys_fcntl,
+ .ko_statvfs = rump_sys_statvfs1,
+ .ko_fhopen = rump_sys_fhopen,
+ .ko_close = rump_sys_close,
+
+ .ko_pread = rump_sys_pread,
+ .ko_pwrite = rump_sys_pwrite,
+};
+
+#else
+
+struct kernelops kops = {
+ .ko_open = (void *)open, /* XXX: fix rump_syscalls */
+ .ko_fcntl = (void *)fcntl,
+ .ko_statvfs = statvfs1,
+ .ko_fhopen = fhopen,
+ .ko_close = close,
+
+ .ko_pread = pread,
+ .ko_pwrite = pwrite,
+};
+#endif
Index: src/sbin/fsck_lfs/kernelops.h
diff -u /dev/null src/sbin/fsck_lfs/kernelops.h:1.1
--- /dev/null Thu Aug 6 00:51:55 2009
+++ src/sbin/fsck_lfs/kernelops.h Thu Aug 6 00:51:55 2009
@@ -0,0 +1,22 @@
+#ifndef _LFS_KERNEL_OPS_H_
+#define _LFS_KERNEL_OPS_H_
+
+#include <sys/types.h>
+#include <sys/statvfs.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+
+struct kernelops {
+ int (*ko_open)(const char *, int, mode_t);
+ int (*ko_statvfs)(const char *, struct statvfs *, int);
+ int (*ko_fcntl)(int, int, void *);
+ int (*ko_fhopen)(const void *, size_t, int);
+ int (*ko_close)(int);
+
+ ssize_t (*ko_pread)(int, void *, size_t, off_t);
+ ssize_t (*ko_pwrite)(int, const void *, size_t, off_t);
+};
+extern struct kernelops kops;
+
+#endif /* _LFS_KERNEL_OPS_H_ */