diff options
| author | pooka <pooka@NetBSD.org> | 2008-11-19 14:10:48 +0000 |
|---|---|---|
| committer | pooka <pooka@NetBSD.org> | 2008-11-19 14:10:48 +0000 |
| commit | e10fef6cd2415f9ceb847aa0dd710a0dcf410b8a (patch) | |
| tree | c45f98bddbc2be945651f058a3ee5e71690a5e13 /sys | |
| parent | c5f4f0e1da65756a40c570437d8091b86eadcdab (diff) | |
Split vfs out of rumpkern into rumpvfs. Non-fs rumps no longer
include the file system code. File system rumps explicitly need
to include rumpvfs from now on.
Diffstat (limited to 'sys')
20 files changed, 865 insertions, 660 deletions
diff --git a/sys/kern/vnode_if.sh b/sys/kern/vnode_if.sh index 9ccba4f631b..d2a9b604f8d 100644 --- a/sys/kern/vnode_if.sh +++ b/sys/kern/vnode_if.sh @@ -29,7 +29,7 @@ copyright="\ * SUCH DAMAGE. */ " -SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.50 2008/11/17 08:46:03 pooka Exp $' +SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.51 2008/11/19 14:10:49 pooka Exp $' # Script to produce VFS front-end sugar. # @@ -48,7 +48,7 @@ SRC_ID=`head -1 $src | sed -e 's/.*\$\(.*\)\$.*/\1/'` # Names of the created files. out_c=vnode_if.c -out_rumpc=../rump/librump/rumpkern/rumpvnode_if.c +out_rumpc=../rump/librump/rumpvfs/rumpvnode_if.c out_h=../sys/vnode_if.h out_rumph=../rump/include/rump/rumpvnode_if.h diff --git a/sys/rump/README.dirs b/sys/rump/README.dirs index c73805dea2b..e5f8914909b 100644 --- a/sys/rump/README.dirs +++ b/sys/rump/README.dirs @@ -1,14 +1,15 @@ - $NetBSD: README.dirs,v 1.6 2008/11/18 13:08:34 pooka Exp $ + $NetBSD: README.dirs,v 1.7 2008/11/19 14:10:49 pooka Exp $ Runnable Userspace Meta Programs Quick rundown of the current directory structure: sys/rump/librump - kernel runtime emulation - /rumpkern - portion compiled with -D_KERNEL, uses kernel headers + /rumpkern - kernel core, e.g. syscall, interrupt and lock support /rumpnet - networking support and sockets layer /rumpuser - userspace namespace support for previous, *NO* -D_KERNEL provides e.g. malloc() and some syscalls + /rumpvfs - file system support sys/rump/include /machine - headers meant to be used for rump compilation when the MD diff --git a/sys/rump/fs/rumptest/Makefile b/sys/rump/fs/rumptest/Makefile index e9c629461bd..f6c87a67add 100644 --- a/sys/rump/fs/rumptest/Makefile +++ b/sys/rump/fs/rumptest/Makefile @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.2 2008/07/29 14:00:01 pooka Exp $ +# $NetBSD: Makefile,v 1.3 2008/11/19 14:10:49 pooka Exp $ # PROG= rumptest NOMAN= woman -LDADD= ${RUMPFSLDADD} -lrump -lrumpuser -lpthread +LDADD= ${RUMPFSLDADD} -lrumpvfs -lrumpnet -lrump -lrumpuser -lpthread LDFLAGS+=-Wl,--wrap=malloc .include "${.CURDIR}/../Makefile.rumpfs" diff --git a/sys/rump/include/rump/rump.h b/sys/rump/include/rump/rump.h index 9078615b4d0..818b7771c7f 100644 --- a/sys/rump/include/rump/rump.h +++ b/sys/rump/include/rump/rump.h @@ -1,4 +1,4 @@ -/* $NetBSD: rump.h,v 1.2 2008/11/17 13:24:14 pooka Exp $ */ +/* $NetBSD: rump.h,v 1.3 2008/11/19 14:10:49 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -136,6 +136,8 @@ void rump_clear_curlwp(void); void rump_rcvp_set(struct vnode *, struct vnode *); struct vnode *rump_cdir_get(void); +void rump_intr_enter(void); +void rump_intr_exit(void); int rump_splfoo(void); void rump_splx(int); diff --git a/sys/rump/librump/Makefile b/sys/rump/librump/Makefile index 060fa29c222..e58d14ab95b 100644 --- a/sys/rump/librump/Makefile +++ b/sys/rump/librump/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.3 2008/11/17 10:21:44 pooka Exp $ +# $NetBSD: Makefile,v 1.4 2008/11/19 14:10:49 pooka Exp $ # -SUBDIR= rumpuser rumpkern rumpnet +SUBDIR= rumpkern rumpnet rumpuser rumpvfs .include <bsd.subdir.mk> diff --git a/sys/rump/librump/rumpkern/Makefile.rumpkern b/sys/rump/librump/rumpkern/Makefile.rumpkern index 38a6d0a6e69..f3ac5b27cf1 100644 --- a/sys/rump/librump/rumpkern/Makefile.rumpkern +++ b/sys/rump/librump/rumpkern/Makefile.rumpkern @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpkern,v 1.19 2008/11/18 11:36:58 pooka Exp $ +# $NetBSD: Makefile.rumpkern,v 1.20 2008/11/19 14:10:49 pooka Exp $ # .include "${RUMPTOP}/Makefile.rump" @@ -14,10 +14,15 @@ LDFLAGS+= -Wl,--wrap=malloc # # Source modules, first the ones specifically implemented for librump. # -SRCS= rump.c emul.c intr.c genfs_io.c locks.c ltsleep.c percpu.c \ - pool.c sleepq.c specfs.c vfs.c vm.c +SRCS= rump.c emul.c intr.c locks.c ltsleep.c percpu.c pool.c sleepq.c vm.c + # stubs -SRCS+= fstrans_stub.c misc_stub.c pmap_stub.c vfsops_stub.c +# +SRCS+= misc_stub.c pmap_stub.c + +# autogenerated +# +SRCS+= rump_syscalls.c # # Rest are from the std kernel sources. @@ -28,21 +33,14 @@ SRCS+= kern_auth.c kern_descrip.c kern_malloc_stdtype.c kern_module.c \ kern_uidinfo.c param.c sys_descrip.c sys_generic.c # sys/kern subr (misc) -SRCS+= subr_bufq.c subr_callback.c subr_hash.c subr_iostat.c \ +SRCS+= subr_callback.c subr_hash.c subr_iostat.c \ subr_kobj.c subr_once.c subr_prf2.c subr_specificdata.c \ subr_time.c subr_workqueue.c -# sys/kern vfs -SRCS+= vfs_bio.c vfs_cache.c vfs_cwd.c vfs_dirhash.c vfs_getcwd.c \ - vfs_hooks.c vfs_init.c vfs_lookup.c vfs_subr.c vfs_syscalls.c \ - vfs_vnops.c vfs_wapbl.c vnode_if.c - -# sys/miscfs -SRCS+= genfs_vfsops.c genfs_vnops.c sync_subr.c - -# sys/kern bufq -SRCS+= subr_bufq.c bufq_disksort.c bufq_fcfs.c bufq_priocscan.c \ - bufq_readprio.c +# the funny bit. this doesn't really belong here, but helps with the +# needs of kern_descrip.c. And since it's a fully dynamic interface, +# it doesn't pull in other gunk. +SRCS+= vnode_if.c # sys/dev SRCS+= clock_subr.c @@ -50,8 +48,6 @@ SRCS+= clock_subr.c # src/lib/libkern SRCS+= __assert.c scanc.c skpc.c -SRCS+= rumpvnode_if.c rump_syscalls.c - # uncomment these lines if you want to use the real kmem code #CPPFLAGS+= -DRUMP_USE_REAL_KMEM #SRCS+= subr_kmem.c subr_vmem.c @@ -66,7 +62,7 @@ SHLIB_MAJOR= 0 SHLIB_MINOR= 0 CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern/opt -DMAXUSERS=32 -CPPFLAGS+= -I${RUMPTOP}/librump/rumpnet +CPPFLAGS+= -I${RUMPTOP}/librump/rumpnet -I${RUMPTOP}/librump/rumpvfs CFLAGS+= -Wno-pointer-sign .include <bsd.lib.mk> diff --git a/sys/rump/librump/rumpkern/rump.c b/sys/rump/librump/rumpkern/rump.c index 2507c55b0b9..f36c3fde75e 100644 --- a/sys/rump/librump/rumpkern/rump.c +++ b/sys/rump/librump/rumpkern/rump.c @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.74 2008/11/18 12:39:35 pooka Exp $ */ +/* $NetBSD: rump.c,v 1.75 2008/11/19 14:10:49 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -29,6 +29,7 @@ #include <sys/param.h> #include <sys/atomic.h> +#include <sys/buf.h> #include <sys/callout.h> #include <sys/cpu.h> #include <sys/filedesc.h> @@ -36,28 +37,21 @@ #include <sys/kauth.h> #include <sys/kmem.h> #include <sys/module.h> -#include <sys/mount.h> -#include <sys/namei.h> #include <sys/once.h> #include <sys/percpu.h> #include <sys/queue.h> #include <sys/resourcevar.h> #include <sys/select.h> #include <sys/uidinfo.h> -#include <sys/vnode.h> -#include <sys/vfs_syscalls.h> -#include <sys/wapbl.h> #include <sys/sysctl.h> -#include <miscfs/specfs/specdev.h> - #include <rump/rumpuser.h> #include "rump_private.h" #include "rump_net_private.h" +#include "rump_vfs_private.h" struct proc proc0; -struct cwdinfo rump_cwdi; struct pstats rump_stats; struct plimit rump_limits; struct cpu_info rump_cpu; @@ -76,13 +70,6 @@ int rump_threads = 0; int rump_threads = 1; #endif -struct fakeblk { - char path[MAXPATHLEN]; - LIST_ENTRY(fakeblk) entries; -}; - -static LIST_HEAD(, fakeblk) fakeblks = LIST_HEAD_INITIALIZER(fakeblks); - static void rump_aiodone_worker(struct work *wk, void *dummy) { @@ -95,13 +82,27 @@ rump_aiodone_worker(struct work *wk, void *dummy) static int rump_inited; static struct emul emul_rump; -void __rump_net_unavailable(void); -void __rump_net_unavailable() {} -__weak_alias(rump_net_init,__rump_net_unavailable); +void __rump_unavailable(void); +void __rump_unavailable() {} +__weak_alias(rump_net_init,__rump_unavailable); +__weak_alias(rump_vfs_init,__rump_unavailable); + +static void +pvfsinit_nop(struct proc *p) +{ -void __rump_vfs_unavailable(void); -void __rump_vfs_unavailable() {} -__weak_alias(rump_vfs_init,__rump_vfs_unavailable); + return; +} + +static void +pvfsrele_nop(struct proc *p) +{ + + return; +} + +rump_proc_vfs_init_fn rump_proc_vfs_init = pvfsinit_nop; +rump_proc_vfs_release_fn rump_proc_vfs_release = pvfsrele_nop; int _rump_init(int rump_version) @@ -144,13 +145,9 @@ _rump_init(int rump_version) kauth_init(); rump_susercred = rump_cred_create(0, 0, 0, NULL); - cache_cpu_init(&rump_cpu); - rw_init(&rump_cwdi.cwdi_lock); - l = &lwp0; p = &proc0; p->p_stats = &rump_stats; - p->p_cwdi = &rump_cwdi; p->p_limit = &rump_limits; p->p_pid = 0; p->p_fd = &rump_filedesc0; @@ -165,11 +162,7 @@ _rump_init(int rump_version) rump_limits.pl_rlimit[RLIMIT_NOFILE].rlim_cur = RLIM_INFINITY; rump_limits.pl_rlimit[RLIMIT_SBSIZE].rlim_cur = RLIM_INFINITY; - syncdelay = 0; - dovfsusermount = 1; - rumpuser_thrinit(); - rumpuser_bioinit(rump_biodone); callout_startup(); callout_init_cpu(&rump_cpu); @@ -180,14 +173,11 @@ _rump_init(int rump_version) fd_sys_init(); module_init(); sysctl_init(); - vfsinit(); - bufinit(); - wapbl_init(); softint_init(&rump_cpu); - rumpvfs_init(); - if (rump_net_init != __rump_net_unavailable) - rump_net_init(); + /* these do nothing if not present */ + rump_vfs_init(); + rump_net_init(); /* aieeeedondest */ if (rump_threads) { @@ -202,336 +192,10 @@ _rump_init(int rump_version) sigemptyset(&sigcantmask); lwp0.l_fd = proc0.p_fd = fd_init(&rump_filedesc0); - rump_cwdi.cwdi_cdir = rootvnode; return 0; } -struct mount * -rump_mnt_init(struct vfsops *vfsops, int mntflags) -{ - struct mount *mp; - - mp = kmem_zalloc(sizeof(struct mount), KM_SLEEP); - - mp->mnt_op = vfsops; - mp->mnt_flag = mntflags; - TAILQ_INIT(&mp->mnt_vnodelist); - rw_init(&mp->mnt_unmounting); - mutex_init(&mp->mnt_updating, MUTEX_DEFAULT, IPL_NONE); - mutex_init(&mp->mnt_renamelock, MUTEX_DEFAULT, IPL_NONE); - mp->mnt_refcnt = 1; - - mount_initspecific(mp); - - return mp; -} - -int -rump_mnt_mount(struct mount *mp, const char *path, void *data, size_t *dlen) -{ - struct vnode *rvp; - int rv; - - rv = VFS_MOUNT(mp, path, data, dlen); - if (rv) - return rv; - - (void) VFS_STATVFS(mp, &mp->mnt_stat); - rv = VFS_START(mp, 0); - if (rv) - VFS_UNMOUNT(mp, MNT_FORCE); - - /* - * XXX: set a root for lwp0. This is strictly not correct, - * but makes things works for single fs case without having - * to manually call rump_rcvp_set(). - */ - VFS_ROOT(mp, &rvp); - rump_rcvp_set(rvp, rvp); - vput(rvp); - - return rv; -} - -void -rump_mnt_destroy(struct mount *mp) -{ - - mount_finispecific(mp); - kmem_free(mp, sizeof(*mp)); -} - -struct componentname * -rump_makecn(u_long nameiop, u_long flags, const char *name, size_t namelen, - kauth_cred_t creds, struct lwp *l) -{ - struct componentname *cnp; - const char *cp = NULL; - - cnp = kmem_zalloc(sizeof(struct componentname), KM_SLEEP); - - cnp->cn_nameiop = nameiop; - cnp->cn_flags = flags | HASBUF; - - cnp->cn_pnbuf = PNBUF_GET(); - strcpy(cnp->cn_pnbuf, name); - cnp->cn_nameptr = cnp->cn_pnbuf; - cnp->cn_namelen = namelen; - cnp->cn_hash = namei_hash(name, &cp); - - cnp->cn_cred = creds; - - return cnp; -} - -void -rump_freecn(struct componentname *cnp, int flags) -{ - - if (flags & RUMPCN_FREECRED) - rump_cred_destroy(cnp->cn_cred); - - if ((flags & RUMPCN_HASNTBUF) == 0) { - if (cnp->cn_flags & SAVENAME) { - if (flags & RUMPCN_ISLOOKUP ||cnp->cn_flags & SAVESTART) - PNBUF_PUT(cnp->cn_pnbuf); - } else { - PNBUF_PUT(cnp->cn_pnbuf); - } - } - kmem_free(cnp, sizeof(*cnp)); -} - -/* hey baby, what's your namei? */ -int -rump_namei(uint32_t op, uint32_t flags, const char *namep, - struct vnode **dvpp, struct vnode **vpp, struct componentname **cnpp) -{ - struct nameidata nd; - int rv; - - NDINIT(&nd, op, flags, UIO_SYSSPACE, namep); - rv = namei(&nd); - if (rv) - return rv; - - if (dvpp) { - KASSERT(flags & LOCKPARENT); - *dvpp = nd.ni_dvp; - } else { - KASSERT((flags & LOCKPARENT) == 0); - } - - if (vpp) { - *vpp = nd.ni_vp; - } else { - if (nd.ni_vp) { - if (flags & LOCKLEAF) - vput(nd.ni_vp); - else - vrele(nd.ni_vp); - } - } - - if (cnpp) { - struct componentname *cnp; - - cnp = kmem_alloc(sizeof(*cnp), KM_SLEEP); - memcpy(cnp, &nd.ni_cnd, sizeof(*cnp)); - *cnpp = cnp; - } else if (nd.ni_cnd.cn_flags & HASBUF) { - panic("%s: pathbuf mismatch", __func__); - } - - return rv; -} - -static struct fakeblk * -_rump_fakeblk_find(const char *path) -{ - char buf[MAXPATHLEN]; - struct fakeblk *fblk; - int error; - - if (rumpuser_realpath(path, buf, &error) == NULL) - return NULL; - - LIST_FOREACH(fblk, &fakeblks, entries) - if (strcmp(fblk->path, buf) == 0) - return fblk; - - return NULL; -} - -int -rump_fakeblk_register(const char *path) -{ - char buf[MAXPATHLEN]; - struct fakeblk *fblk; - int error; - - if (_rump_fakeblk_find(path)) - return EEXIST; - - if (rumpuser_realpath(path, buf, &error) == NULL) - return error; - - fblk = kmem_alloc(sizeof(struct fakeblk), KM_NOSLEEP); - if (fblk == NULL) - return ENOMEM; - - strlcpy(fblk->path, buf, MAXPATHLEN); - LIST_INSERT_HEAD(&fakeblks, fblk, entries); - - return 0; -} - -int -rump_fakeblk_find(const char *path) -{ - - return _rump_fakeblk_find(path) != NULL; -} - -void -rump_fakeblk_deregister(const char *path) -{ - struct fakeblk *fblk; - - fblk = _rump_fakeblk_find(path); - if (fblk == NULL) - return; - - LIST_REMOVE(fblk, entries); - kmem_free(fblk, sizeof(*fblk)); -} - -void -rump_getvninfo(struct vnode *vp, enum vtype *vtype, voff_t *vsize, dev_t *vdev) -{ - - *vtype = vp->v_type; - *vsize = vp->v_size; - if (vp->v_specnode) - *vdev = vp->v_rdev; - else - *vdev = 0; -} - -struct vfsops * -rump_vfslist_iterate(struct vfsops *ops) -{ - - if (ops == NULL) - return LIST_FIRST(&vfs_list); - else - return LIST_NEXT(ops, vfs_list); -} - -struct vfsops * -rump_vfs_getopsbyname(const char *name) -{ - - return vfs_getopsbyname(name); -} - -struct vattr* -rump_vattr_init() -{ - struct vattr *vap; - - vap = kmem_alloc(sizeof(struct vattr), KM_SLEEP); - vattr_null(vap); - - return vap; -} - -void -rump_vattr_settype(struct vattr *vap, enum vtype vt) -{ - - vap->va_type = vt; -} - -void -rump_vattr_setmode(struct vattr *vap, mode_t mode) -{ - - vap->va_mode = mode; -} - -void -rump_vattr_setrdev(struct vattr *vap, dev_t dev) -{ - - vap->va_rdev = dev; -} - -void -rump_vattr_free(struct vattr *vap) -{ - - kmem_free(vap, sizeof(*vap)); -} - -void -rump_vp_incref(struct vnode *vp) -{ - - mutex_enter(&vp->v_interlock); - ++vp->v_usecount; - mutex_exit(&vp->v_interlock); -} - -int -rump_vp_getref(struct vnode *vp) -{ - - return vp->v_usecount; -} - -void -rump_vp_decref(struct vnode *vp) -{ - - mutex_enter(&vp->v_interlock); - --vp->v_usecount; - mutex_exit(&vp->v_interlock); -} - -/* - * Really really recycle with a cherry on top. We should be - * extra-sure we can do this. For example with p2k there is - * no problem, since puffs in the kernel takes care of refcounting - * for us. - */ -void -rump_vp_recycle_nokidding(struct vnode *vp) -{ - - mutex_enter(&vp->v_interlock); - vp->v_usecount = 1; - /* - * XXX: NFS holds a reference to the root vnode, so don't clean - * it out. This is very wrong, but fixing it properly would - * take too much effort for now - */ - if (vp->v_tag == VT_NFS && vp->v_vflag & VV_ROOT) { - mutex_exit(&vp->v_interlock); - return; - } - vclean(vp, DOCLOSE); - vrelel(vp, 0); -} - -void -rump_vp_rele(struct vnode *vp) -{ - - vrele(vp); -} - struct uio * rump_uio_setup(void *buf, size_t bufsize, off_t offset, enum rump_uiorw rw) { @@ -590,92 +254,6 @@ rump_uio_free(struct uio *uio) return resid; } -void -rump_vp_interlock(struct vnode *vp) -{ - - mutex_enter(&vp->v_interlock); -} - -int -rump_vfs_unmount(struct mount *mp, int mntflags) -{ - - return VFS_UNMOUNT(mp, mntflags); -} - -int -rump_vfs_root(struct mount *mp, struct vnode **vpp, int lock) -{ - int rv; - - rv = VFS_ROOT(mp, vpp); - if (rv) - return rv; - - if (!lock) - VOP_UNLOCK(*vpp, 0); - - return 0; -} - -int -rump_vfs_statvfs(struct mount *mp, struct statvfs *sbp) -{ - - return VFS_STATVFS(mp, sbp); -} - -int -rump_vfs_sync(struct mount *mp, int wait, kauth_cred_t cred) -{ - - return VFS_SYNC(mp, wait ? MNT_WAIT : MNT_NOWAIT, cred); -} - -int -rump_vfs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp) -{ - - return VFS_FHTOVP(mp, fid, vpp); -} - -int -rump_vfs_vptofh(struct vnode *vp, struct fid *fid, size_t *fidsize) -{ - - return VFS_VPTOFH(vp, fid, fidsize); -} - -/*ARGSUSED*/ -void -rump_vfs_syncwait(struct mount *mp) -{ - int n; - - n = buf_syncwait(); - if (n) - printf("syncwait: unsynced buffers: %d\n", n); -} - -int -rump_vfs_load(struct modinfo **mi) -{ - - if (!module_compatible((*mi)->mi_version, __NetBSD_Version__)) - return EPROGMISMATCH; - - return (*mi)->mi_modcmd(MODULE_CMD_INIT, NULL); -} - -void -rump_bioops_sync() -{ - - if (bioopsp) - bioopsp->io_sync(NULL); -} - struct lwp * rump_setup_curlwp(pid_t pid, lwpid_t lid, int set) { @@ -685,8 +263,7 @@ rump_setup_curlwp(pid_t pid, lwpid_t lid, int set) l = kmem_zalloc(sizeof(struct lwp), KM_SLEEP); if (pid != 0) { p = kmem_zalloc(sizeof(struct proc), KM_SLEEP); - p->p_cwdi = cwdinit(); - + rump_proc_vfs_init(p); p->p_stats = &rump_stats; p->p_limit = &rump_limits; p->p_pid = pid; @@ -717,7 +294,7 @@ rump_clear_curlwp() l = rumpuser_get_curlwp(); if (l->l_proc->p_pid != 0) { fd_free(); - cwdfree(l->l_proc->p_cwdi); + rump_proc_vfs_release(l->l_proc); rump_cred_destroy(l->l_cred); kmem_free(l->l_proc, sizeof(*l->l_proc)); } @@ -749,7 +326,7 @@ rump_splfoo() return 0; } -static void +void rump_intr_enter(void) { @@ -757,7 +334,7 @@ rump_intr_enter(void) rumpuser_rw_enter(&rumpspl, 1); } -static void +void rump_intr_exit(void) { @@ -775,20 +352,6 @@ rump_splx(int dummy) } } -void -rump_biodone(void *arg, size_t count, int error) -{ - struct buf *bp = arg; - - bp->b_resid = bp->b_bcount - count; - KASSERT(bp->b_resid >= 0); - bp->b_error = error; - - rump_intr_enter(); - biodone(bp); - rump_intr_exit(); -} - kauth_cred_t rump_cred_create(uid_t uid, gid_t gid, size_t ngroups, gid_t *groups) { diff --git a/sys/rump/librump/rumpkern/rump_private.h b/sys/rump/librump/rumpkern/rump_private.h index d082e7ab738..db6e6cb353e 100644 --- a/sys/rump/librump/rumpkern/rump_private.h +++ b/sys/rump/librump/rumpkern/rump_private.h @@ -1,4 +1,4 @@ -/* $NetBSD: rump_private.h,v 1.14 2008/11/18 12:39:35 pooka Exp $ */ +/* $NetBSD: rump_private.h,v 1.15 2008/11/19 14:10:49 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -35,6 +35,7 @@ #include <sys/disklabel.h> #include <sys/mount.h> +#include <sys/proc.h> #include <sys/vnode.h> #include <uvm/uvm.h> @@ -73,15 +74,11 @@ extern int rump_threads; void abort(void) __dead; -void rump_putnode(struct vnode *); -int rump_recyclenode(struct vnode *); - struct ubc_window; int rump_ubc_magic_uiomove(void *, size_t, struct uio *, int *, struct ubc_window *); void rumpvm_init(void); -void rumpvfs_init(void); void rump_sleepers_init(void); struct vm_page *rumpvm_makepage(struct uvm_object *, voff_t); @@ -92,4 +89,9 @@ lwpid_t rump_nextlid(void); void rump_biodone(void *, size_t, int); +typedef void (*rump_proc_vfs_init_fn)(struct proc *); +typedef void (*rump_proc_vfs_release_fn)(struct proc *); +rump_proc_vfs_init_fn rump_proc_vfs_init; +rump_proc_vfs_release_fn rump_proc_vfs_release; + #endif /* _SYS_RUMP_PRIVATE_H_ */ diff --git a/sys/rump/librump/rumpkern/vm.c b/sys/rump/librump/rumpkern/vm.c index 3acab315fe1..b732afc2285 100644 --- a/sys/rump/librump/rumpkern/vm.c +++ b/sys/rump/librump/rumpkern/vm.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm.c,v 1.41 2008/10/15 13:04:26 pooka Exp $ */ +/* $NetBSD: vm.c,v 1.42 2008/11/19 14:10:49 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -56,7 +56,6 @@ #include <uvm/uvm.h> #include <uvm/uvm_prot.h> -#include <uvm/uvm_readahead.h> #include "rump_private.h" @@ -65,17 +64,10 @@ (((((len) + PAGE_MASK) & ~(PAGE_MASK)) >> PAGE_SHIFT) \ + (((off & PAGE_MASK) + (len & PAGE_MASK)) > PAGE_SIZE)) -static int vn_get(struct uvm_object *, voff_t, struct vm_page **, - int *, int, vm_prot_t, int, int); -static int vn_put(struct uvm_object *, voff_t, voff_t, int); static int ao_get(struct uvm_object *, voff_t, struct vm_page **, int *, int, vm_prot_t, int, int); static int ao_put(struct uvm_object *, voff_t, voff_t, int); -const struct uvm_pagerops uvm_vnodeops = { - .pgo_get = vn_get, - .pgo_put = vn_put, -}; const struct uvm_pagerops aobj_pager = { .pgo_get = ao_get, .pgo_put = ao_put, @@ -169,29 +161,6 @@ rumpvm_flushva() } /* - * vnode pager - */ - -static int -vn_get(struct uvm_object *uobj, voff_t off, struct vm_page **pgs, - int *npages, int centeridx, vm_prot_t access_type, - int advice, int flags) -{ - struct vnode *vp = (struct vnode *)uobj; - - return VOP_GETPAGES(vp, off, pgs, npages, centeridx, access_type, - advice, flags); -} - -static int -vn_put(struct uvm_object *uobj, voff_t offlo, voff_t offhi, int flags) -{ - struct vnode *vp = (struct vnode *)uobj; - - return VOP_PUTPAGES(vp, offlo, offhi, flags); -} - -/* * Anon object stuff */ @@ -526,28 +495,6 @@ uvm_estimatepageable(int *active, int *inactive) } void -uvm_aio_biodone1(struct buf *bp) -{ - - panic("%s: unimplemented", __func__); -} - -void -uvm_aio_biodone(struct buf *bp) -{ - - uvm_aio_aiodone(bp); -} - -void -uvm_aio_aiodone(struct buf *bp) -{ - - if (((bp->b_flags | bp->b_cflags) & (B_READ | BC_NOCACHE)) == 0 && bioopsp) - bioopsp->io_pageiodone(bp); -} - -void uvm_vnp_setsize(struct vnode *vp, voff_t newsize) { @@ -602,28 +549,6 @@ uvm_vnp_zerorange(struct vnode *vp, off_t off, size_t len) return; } -struct uvm_ractx * -uvm_ra_allocctx() -{ - - return NULL; -} - -void -uvm_ra_freectx(struct uvm_ractx *ra) -{ - - return; -} - -bool -uvn_clean_p(struct uvm_object *uobj) -{ - struct vnode *vp = (void *)uobj; - - return (vp->v_iflag & VI_ONWORKLST) == 0; -} - struct vm_map_kernel * vm_map_to_kernel(struct vm_map *map) { diff --git a/sys/rump/librump/rumpvfs/Makefile b/sys/rump/librump/rumpvfs/Makefile new file mode 100644 index 00000000000..0a4fed79601 --- /dev/null +++ b/sys/rump/librump/rumpvfs/Makefile @@ -0,0 +1,5 @@ +# $NetBSD: Makefile,v 1.1 2008/11/19 14:10:49 pooka Exp $ +# + +RUMPTOP=${.CURDIR}/../.. +.include "${RUMPTOP}/librump/rumpvfs/Makefile.rumpvfs" diff --git a/sys/rump/librump/rumpvfs/Makefile.rumpvfs b/sys/rump/librump/rumpvfs/Makefile.rumpvfs new file mode 100644 index 00000000000..f0435bc3232 --- /dev/null +++ b/sys/rump/librump/rumpvfs/Makefile.rumpvfs @@ -0,0 +1,42 @@ +# $NetBSD: Makefile.rumpvfs,v 1.1 2008/11/19 14:10:49 pooka Exp $ +# + +.include "${RUMPTOP}/Makefile.rump" + +LIB= rumpvfs + +.PATH: ${RUMPTOP}/librump/rumpvfs \ + ${RUMPTOP}/../kern ${RUMPTOP}/../lib/libkern \ + ${RUMPTOP}/../miscfs/genfs ${RUMPTOP}/../miscfs/syncfs + +# +# Source modules, first the ones specifically implemented for librump. +# +SRCS= genfs_io.c rump_vfs.c rumpfs.c specfs.c vm_vfs.c + +SRCS+= fstrans_stub.c vfsops_stub.c + +# sys/kern vfs +SRCS+= vfs_bio.c vfs_cache.c vfs_cwd.c vfs_dirhash.c vfs_getcwd.c \ + vfs_hooks.c vfs_init.c vfs_lookup.c vfs_subr.c vfs_syscalls.c \ + vfs_vnops.c vfs_wapbl.c + +# sys/miscfs +SRCS+= genfs_vfsops.c genfs_vnops.c sync_subr.c + +# sys/kern bufq +SRCS+= subr_bufq.c bufq_disksort.c bufq_fcfs.c bufq_priocscan.c \ + bufq_readprio.c + +SRCS+= rumpvnode_if.c + +# no shlib_version because this is automatically in sync with lib/librump +SHLIB_MAJOR= 0 +SHLIB_MINOR= 0 + +CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern/opt -DMAXUSERS=32 +CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern +CFLAGS+= -Wno-pointer-sign + +.include <bsd.lib.mk> +.include <bsd.klinks.mk> diff --git a/sys/rump/librump/rumpkern/fstrans_stub.c b/sys/rump/librump/rumpvfs/fstrans_stub.c index b38eead6f77..c2dfa1ea3db 100644 --- a/sys/rump/librump/rumpkern/fstrans_stub.c +++ b/sys/rump/librump/rumpvfs/fstrans_stub.c @@ -1,4 +1,4 @@ -/* $NetBSD: fstrans_stub.c,v 1.6 2008/07/21 10:51:03 pooka Exp $ */ +/* $NetBSD: fstrans_stub.c,v 1.1 2008/11/19 14:10:49 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. diff --git a/sys/rump/librump/rumpkern/genfs_io.c b/sys/rump/librump/rumpvfs/genfs_io.c index 1b61b7c1f7b..3db1524cec0 100644 --- a/sys/rump/librump/rumpkern/genfs_io.c +++ b/sys/rump/librump/rumpvfs/genfs_io.c @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.16 2008/11/16 18:37:28 pooka Exp $ */ +/* $NetBSD: genfs_io.c,v 1.1 2008/11/19 14:10:49 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. diff --git a/sys/rump/librump/rumpvfs/rump_vfs.c b/sys/rump/librump/rumpvfs/rump_vfs.c new file mode 100644 index 00000000000..4f8b4819fd1 --- /dev/null +++ b/sys/rump/librump/rumpvfs/rump_vfs.c @@ -0,0 +1,552 @@ +/* $NetBSD: rump_vfs.c,v 1.1 2008/11/19 14:10:49 pooka Exp $ */ + +/* + * Copyright (c) 2008 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by the + * Finnish Cultural Foundation. + * + * 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 AUTHOR ``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 AUTHOR 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/param.h> +#include <sys/buf.h> +#include <sys/filedesc.h> +#include <sys/module.h> +#include <sys/namei.h> +#include <sys/queue.h> +#include <sys/vfs_syscalls.h> +#include <sys/vnode.h> +#include <sys/wapbl.h> + +#include <miscfs/specfs/specdev.h> + +#include <rump/rump.h> +#include <rump/rumpuser.h> + +#include "rump_private.h" +#include "rump_vfs_private.h" + +struct fakeblk { + char path[MAXPATHLEN]; + LIST_ENTRY(fakeblk) entries; +}; +static LIST_HEAD(, fakeblk) fakeblks = LIST_HEAD_INITIALIZER(fakeblks); + +static struct cwdinfo rump_cwdi; + +static void +pvfs_init(struct proc *p) +{ + + p->p_cwdi = cwdinit(); +} + +static void +pvfs_rele(struct proc *p) +{ + + cwdfree(p->p_cwdi); +} + +void +rump_vfs_init() +{ + + syncdelay = 0; + dovfsusermount = 1; + + cache_cpu_init(&rump_cpu); + vfsinit(); + bufinit(); + wapbl_init(); + cwd_sys_init(); + rumpuser_bioinit(rump_biodone); + rumpfs_init(); + + rump_proc_vfs_init = pvfs_init; + rump_proc_vfs_release = pvfs_rele; + + rw_init(&rump_cwdi.cwdi_lock); + rump_cwdi.cwdi_cdir = rootvnode; + proc0.p_cwdi = &rump_cwdi; +} + +struct mount * +rump_mnt_init(struct vfsops *vfsops, int mntflags) +{ + struct mount *mp; + + mp = kmem_zalloc(sizeof(struct mount), KM_SLEEP); + + mp->mnt_op = vfsops; + mp->mnt_flag = mntflags; + TAILQ_INIT(&mp->mnt_vnodelist); + rw_init(&mp->mnt_unmounting); + mutex_init(&mp->mnt_updating, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&mp->mnt_renamelock, MUTEX_DEFAULT, IPL_NONE); + mp->mnt_refcnt = 1; + + mount_initspecific(mp); + + return mp; +} + +int +rump_mnt_mount(struct mount *mp, const char *path, void *data, size_t *dlen) +{ + struct vnode *rvp; + int rv; + + rv = VFS_MOUNT(mp, path, data, dlen); + if (rv) + return rv; + + (void) VFS_STATVFS(mp, &mp->mnt_stat); + rv = VFS_START(mp, 0); + if (rv) + VFS_UNMOUNT(mp, MNT_FORCE); + + /* + * XXX: set a root for lwp0. This is strictly not correct, + * but makes things works for single fs case without having + * to manually call rump_rcvp_set(). + */ + VFS_ROOT(mp, &rvp); + rump_rcvp_set(rvp, rvp); + vput(rvp); + + return rv; +} + +void +rump_mnt_destroy(struct mount *mp) +{ + + mount_finispecific(mp); + kmem_free(mp, sizeof(*mp)); +} + +struct componentname * +rump_makecn(u_long nameiop, u_long flags, const char *name, size_t namelen, + kauth_cred_t creds, struct lwp *l) +{ + struct componentname *cnp; + const char *cp = NULL; + + cnp = kmem_zalloc(sizeof(struct componentname), KM_SLEEP); + + cnp->cn_nameiop = nameiop; + cnp->cn_flags = flags | HASBUF; + + cnp->cn_pnbuf = PNBUF_GET(); + strcpy(cnp->cn_pnbuf, name); + cnp->cn_nameptr = cnp->cn_pnbuf; + cnp->cn_namelen = namelen; + cnp->cn_hash = namei_hash(name, &cp); + + cnp->cn_cred = creds; + + return cnp; +} + +void +rump_freecn(struct componentname *cnp, int flags) +{ + + if (flags & RUMPCN_FREECRED) + rump_cred_destroy(cnp->cn_cred); + + if ((flags & RUMPCN_HASNTBUF) == 0) { + if (cnp->cn_flags & SAVENAME) { + if (flags & RUMPCN_ISLOOKUP ||cnp->cn_flags & SAVESTART) + PNBUF_PUT(cnp->cn_pnbuf); + } else { + PNBUF_PUT(cnp->cn_pnbuf); + } + } + kmem_free(cnp, sizeof(*cnp)); +} + +/* hey baby, what's your namei? */ +int +rump_namei(uint32_t op, uint32_t flags, const char *namep, + struct vnode **dvpp, struct vnode **vpp, struct componentname **cnpp) +{ + struct nameidata nd; + int rv; + + NDINIT(&nd, op, flags, UIO_SYSSPACE, namep); + rv = namei(&nd); + if (rv) + return rv; + + if (dvpp) { + KASSERT(flags & LOCKPARENT); + *dvpp = nd.ni_dvp; + } else { + KASSERT((flags & LOCKPARENT) == 0); + } + + if (vpp) { + *vpp = nd.ni_vp; + } else { + if (nd.ni_vp) { + if (flags & LOCKLEAF) + vput(nd.ni_vp); + else + vrele(nd.ni_vp); + } + } + + if (cnpp) { + struct componentname *cnp; + + cnp = kmem_alloc(sizeof(*cnp), KM_SLEEP); + memcpy(cnp, &nd.ni_cnd, sizeof(*cnp)); + *cnpp = cnp; + } else if (nd.ni_cnd.cn_flags & HASBUF) { + panic("%s: pathbuf mismatch", __func__); + } + + return rv; +} + +static struct fakeblk * +_rump_fakeblk_find(const char *path) +{ + char buf[MAXPATHLEN]; + struct fakeblk *fblk; + int error; + + if (rumpuser_realpath(path, buf, &error) == NULL) + return NULL; + + LIST_FOREACH(fblk, &fakeblks, entries) + if (strcmp(fblk->path, buf) == 0) + return fblk; + + return NULL; +} + +int +rump_fakeblk_register(const char *path) +{ + char buf[MAXPATHLEN]; + struct fakeblk *fblk; + int error; + + if (_rump_fakeblk_find(path)) + return EEXIST; + + if (rumpuser_realpath(path, buf, &error) == NULL) + return error; + + fblk = kmem_alloc(sizeof(struct fakeblk), KM_NOSLEEP); + if (fblk == NULL) + return ENOMEM; + + strlcpy(fblk->path, buf, MAXPATHLEN); + LIST_INSERT_HEAD(&fakeblks, fblk, entries); + + return 0; +} + +int +rump_fakeblk_find(const char *path) +{ + + return _rump_fakeblk_find(path) != NULL; +} + +void +rump_fakeblk_deregister(const char *path) +{ + struct fakeblk *fblk; + + fblk = _rump_fakeblk_find(path); + if (fblk == NULL) + return; + + LIST_REMOVE(fblk, entries); + kmem_free(fblk, sizeof(*fblk)); +} + +void +rump_getvninfo(struct vnode *vp, enum vtype *vtype, voff_t *vsize, dev_t *vdev) +{ + + *vtype = vp->v_type; + *vsize = vp->v_size; + if (vp->v_specnode) + *vdev = vp->v_rdev; + else + *vdev = 0; +} + +struct vfsops * +rump_vfslist_iterate(struct vfsops *ops) +{ + + if (ops == NULL) + return LIST_FIRST(&vfs_list); + else + return LIST_NEXT(ops, vfs_list); +} + +struct vfsops * +rump_vfs_getopsbyname(const char *name) +{ + + return vfs_getopsbyname(name); +} + +struct vattr* +rump_vattr_init() +{ + struct vattr *vap; + + vap = kmem_alloc(sizeof(struct vattr), KM_SLEEP); + vattr_null(vap); + + return vap; +} + +void +rump_vattr_settype(struct vattr *vap, enum vtype vt) +{ + + vap->va_type = vt; +} + +void +rump_vattr_setmode(struct vattr *vap, mode_t mode) +{ + + vap->va_mode = mode; +} + +void +rump_vattr_setrdev(struct vattr *vap, dev_t dev) +{ + + vap->va_rdev = dev; +} + +void +rump_vattr_free(struct vattr *vap) +{ + + kmem_free(vap, sizeof(*vap)); +} + +void +rump_vp_incref(struct vnode *vp) +{ + + mutex_enter(&vp->v_interlock); + ++vp->v_usecount; + mutex_exit(&vp->v_interlock); +} + +int +rump_vp_getref(struct vnode *vp) +{ + + return vp->v_usecount; +} + +void +rump_vp_decref(struct vnode *vp) +{ + + mutex_enter(&vp->v_interlock); + --vp->v_usecount; + mutex_exit(&vp->v_interlock); +} + +/* + * Really really recycle with a cherry on top. We should be + * extra-sure we can do this. For example with p2k there is + * no problem, since puffs in the kernel takes care of refcounting + * for us. + */ +void +rump_vp_recycle_nokidding(struct vnode *vp) +{ + + mutex_enter(&vp->v_interlock); + vp->v_usecount = 1; + /* + * XXX: NFS holds a reference to the root vnode, so don't clean + * it out. This is very wrong, but fixing it properly would + * take too much effort for now + */ + if (vp->v_tag == VT_NFS && vp->v_vflag & VV_ROOT) { + mutex_exit(&vp->v_interlock); + return; + } + vclean(vp, DOCLOSE); + vrelel(vp, 0); +} + +void +rump_vp_rele(struct vnode *vp) +{ + + vrele(vp); +} + +void +rump_vp_interlock(struct vnode *vp) +{ + + mutex_enter(&vp->v_interlock); +} + +int +rump_vfs_unmount(struct mount *mp, int mntflags) +{ + + return VFS_UNMOUNT(mp, mntflags); +} + +int +rump_vfs_root(struct mount *mp, struct vnode **vpp, int lock) +{ + int rv; + + rv = VFS_ROOT(mp, vpp); + if (rv) + return rv; + + if (!lock) + VOP_UNLOCK(*vpp, 0); + + return 0; +} + +int +rump_vfs_statvfs(struct mount *mp, struct statvfs *sbp) +{ + + return VFS_STATVFS(mp, sbp); +} + +int +rump_vfs_sync(struct mount *mp, int wait, kauth_cred_t cred) +{ + + return VFS_SYNC(mp, wait ? MNT_WAIT : MNT_NOWAIT, cred); +} + +int +rump_vfs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp) +{ + + return VFS_FHTOVP(mp, fid, vpp); +} + +int +rump_vfs_vptofh(struct vnode *vp, struct fid *fid, size_t *fidsize) +{ + + return VFS_VPTOFH(vp, fid, fidsize); +} + +/*ARGSUSED*/ +void +rump_vfs_syncwait(struct mount *mp) +{ + int n; + + n = buf_syncwait(); + if (n) + printf("syncwait: unsynced buffers: %d\n", n); +} + +int +rump_vfs_load(struct modinfo **mi) +{ + + if (!module_compatible((*mi)->mi_version, __NetBSD_Version__)) + return EPROGMISMATCH; + + return (*mi)->mi_modcmd(MODULE_CMD_INIT, NULL); +} + +void +rump_bioops_sync() +{ + + if (bioopsp) + bioopsp->io_sync(NULL); +} + +void +rump_biodone(void *arg, size_t count, int error) +{ + struct buf *bp = arg; + + bp->b_resid = bp->b_bcount - count; + KASSERT(bp->b_resid >= 0); + bp->b_error = error; + + rump_intr_enter(); + biodone(bp); + rump_intr_exit(); +} + +void +rump_rcvp_set(struct vnode *rvp, struct vnode *cvp) +{ + struct lwp *l = curlwp; + struct cwdinfo *cwdi = l->l_proc->p_cwdi; + + KASSERT(cvp); + + rw_enter(&cwdi->cwdi_lock, RW_WRITER); + if (cwdi->cwdi_rdir) + vrele(cwdi->cwdi_rdir); + if (rvp) + vref(rvp); + cwdi->cwdi_rdir = rvp; + + vrele(cwdi->cwdi_cdir); + vref(cvp); + cwdi->cwdi_cdir = cvp; + rw_exit(&cwdi->cwdi_lock); +} + +struct vnode * +rump_cdir_get() +{ + struct vnode *vp; + struct cwdinfo *cwdi = curlwp->l_proc->p_cwdi; + + rw_enter(&cwdi->cwdi_lock, RW_READER); + vp = cwdi->cwdi_cdir; + rw_exit(&cwdi->cwdi_lock); + vref(vp); + + return vp; +} diff --git a/sys/rump/librump/rumpvfs/rump_vfs_private.h b/sys/rump/librump/rumpvfs/rump_vfs_private.h new file mode 100644 index 00000000000..9947640d4ea --- /dev/null +++ b/sys/rump/librump/rumpvfs/rump_vfs_private.h @@ -0,0 +1,34 @@ +/* $NetBSD: rump_vfs_private.h,v 1.1 2008/11/19 14:10:49 pooka Exp $ */ + +/* + * Copyright (c) 2008 Antti Kantee. 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 AUTHOR ``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 AUTHOR 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. + */ + +#ifndef _SYS_RUMP_VFS_PRIVATE_H_ +#define _SYS_RUMP_VFS_PRIVATE_H_ + +void rump_vfs_init(void); +void rumpfs_init(void); + +#endif /* _SYS_RUMP_VFS_PRIVATE_H_ */ diff --git a/sys/rump/librump/rumpkern/vfs.c b/sys/rump/librump/rumpvfs/rumpfs.c index 874160a79e4..65b83bacb35 100644 --- a/sys/rump/librump/rumpkern/vfs.c +++ b/sys/rump/librump/rumpvfs/rumpfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs.c,v 1.39 2008/07/29 13:17:47 pooka Exp $ */ +/* $NetBSD: rumpfs.c,v 1.1 2008/11/19 14:10:49 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -48,6 +48,7 @@ #include <rump/rumpuser.h> #include "rump_private.h" +#include "rump_vfs_private.h" static int rump_vop_lookup(void *); @@ -90,33 +91,6 @@ const struct vnodeopv_desc * const rump_opv_descs[] = { NULL }; -vnode_t *specfs_hash[SPECHSZ]; -int (*mountroot)(void); - -int -vfs_stdextattrctl(struct mount *mp, int cmt, struct vnode *vp, - int attrnamespace, const char *attrname) -{ - - if (vp != NULL) - VOP_UNLOCK(vp, 0); - return EOPNOTSUPP; -} - -int -vfs_allocate_syncvnode(struct mount *mp) -{ - - panic("%s: unimplemented", __func__); -} - -void -vfs_deallocate_syncvnode(struct mount *mp) -{ - - panic("%s: unimplemented", __func__); -} - struct mount mnt_dummy; static struct vnode * @@ -216,59 +190,10 @@ rump_vop_lookup(void *v) return 0; } -int -lf_advlock(struct vop_advlock_args *ap, struct lockf **head, off_t size) -{ - - panic("%s: unimplemented", __func__); -} - void -fifo_printinfo(struct vnode *vp) -{ - - return; -} - -void -rumpvfs_init() +rumpfs_init() { vfs_opv_init(rump_opv_descs); rootvnode = rump_makevnode("/", 0, VDIR, -1); } - -void -rump_rcvp_set(struct vnode *rvp, struct vnode *cvp) -{ - struct lwp *l = curlwp; - struct cwdinfo *cwdi = l->l_proc->p_cwdi; - - KASSERT(cvp); - - rw_enter(&cwdi->cwdi_lock, RW_WRITER); - if (cwdi->cwdi_rdir) - vrele(cwdi->cwdi_rdir); - if (rvp) - vref(rvp); - cwdi->cwdi_rdir = rvp; - - vrele(cwdi->cwdi_cdir); - vref(cvp); - cwdi->cwdi_cdir = cvp; - rw_exit(&cwdi->cwdi_lock); -} - -struct vnode * -rump_cdir_get() -{ - struct vnode *vp; - struct cwdinfo *cwdi = curlwp->l_proc->p_cwdi; - - rw_enter(&cwdi->cwdi_lock, RW_READER); - vp = cwdi->cwdi_cdir; - rw_exit(&cwdi->cwdi_lock); - vref(vp); - - return vp; -} diff --git a/sys/rump/librump/rumpkern/rumpvnode_if.c b/sys/rump/librump/rumpvfs/rumpvnode_if.c index b5152c99300..7a131e77e1a 100644 --- a/sys/rump/librump/rumpkern/rumpvnode_if.c +++ b/sys/rump/librump/rumpvfs/rumpvnode_if.c @@ -1,4 +1,4 @@ -/* $NetBSD: rumpvnode_if.c,v 1.2 2008/11/17 08:59:33 pooka Exp $ */ +/* $NetBSD: rumpvnode_if.c,v 1.1 2008/11/19 14:10:49 pooka Exp $ */ /* * Warning: DO NOT EDIT! This file is automatically generated! @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rumpvnode_if.c,v 1.2 2008/11/17 08:59:33 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rumpvnode_if.c,v 1.1 2008/11/19 14:10:49 pooka Exp $"); #include "opt_vnode_lockdebug.h" diff --git a/sys/rump/librump/rumpkern/specfs.c b/sys/rump/librump/rumpvfs/specfs.c index 7743fce6e70..e712bd998d0 100644 --- a/sys/rump/librump/rumpkern/specfs.c +++ b/sys/rump/librump/rumpvfs/specfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: specfs.c,v 1.29 2008/11/18 12:39:35 pooka Exp $ */ +/* $NetBSD: specfs.c,v 1.1 2008/11/19 14:10:49 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -75,6 +75,8 @@ const struct vnodeopv_entry_desc rumpspec_vnodeop_entries[] = { const struct vnodeopv_desc spec_vnodeop_opv_desc = { &spec_vnodeop_p, rumpspec_vnodeop_entries }; +vnode_t *specfs_hash[SPECHSZ]; + static int rump_specopen(void *v) { diff --git a/sys/rump/librump/rumpkern/vfsops_stub.c b/sys/rump/librump/rumpvfs/vfsops_stub.c index 74f3943ec4d..630c8fb4def 100644 --- a/sys/rump/librump/rumpkern/vfsops_stub.c +++ b/sys/rump/librump/rumpvfs/vfsops_stub.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfsops_stub.c,v 1.7 2008/09/30 21:47:33 pooka Exp $ */ +/* $NetBSD: vfsops_stub.c,v 1.1 2008/11/19 14:10:49 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -29,10 +29,15 @@ #include <sys/param.h> #include <sys/errno.h> +#include <sys/lockf.h> #include <sys/systm.h> +#include <sys/vnode.h> #include <miscfs/specfs/specdev.h> #include <miscfs/fifofs/fifo.h> +#include <miscfs/syncfs/syncfs.h> + +int (*mountroot)(void); #define VFSSTUB(name) \ int name(void *arg) {panic("%s: unimplemented vfs stub", __func__);} @@ -71,3 +76,41 @@ VFSSTUB(fifo_pathconf) VFSSTUB(fifo_bmap) VFSSTUB(fifo_read) VFSSTUB(fifo_write) + +int +vfs_allocate_syncvnode(struct mount *mp) +{ + + panic("%s: unimplemented", __func__); +} + +void +vfs_deallocate_syncvnode(struct mount *mp) +{ + + panic("%s: unimplemented", __func__); +} + +int +lf_advlock(struct vop_advlock_args *ap, struct lockf **head, off_t size) +{ + + panic("%s: unimplemented", __func__); +} + +void +fifo_printinfo(struct vnode *vp) +{ + + return; +} + +int +vfs_stdextattrctl(struct mount *mp, int cmt, struct vnode *vp, + int attrnamespace, const char *attrname) +{ + + if (vp != NULL) + VOP_UNLOCK(vp, 0); + return EOPNOTSUPP; +} diff --git a/sys/rump/librump/rumpvfs/vm_vfs.c b/sys/rump/librump/rumpvfs/vm_vfs.c new file mode 100644 index 00000000000..a8f1daf342a --- /dev/null +++ b/sys/rump/librump/rumpvfs/vm_vfs.c @@ -0,0 +1,113 @@ +/* $NetBSD: vm_vfs.c,v 1.1 2008/11/19 14:10:49 pooka Exp $ */ + +/* + * Copyright (c) 2008 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by the + * Finnish Cultural Foundation. + * + * 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 AUTHOR ``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 AUTHOR 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/param.h> + +#include <sys/buf.h> +#include <sys/vnode.h> + +#include <uvm/uvm.h> +#include <uvm/uvm_readahead.h> + +static int vn_get(struct uvm_object *, voff_t, struct vm_page **, + int *, int, vm_prot_t, int, int); +static int vn_put(struct uvm_object *, voff_t, voff_t, int); + +const struct uvm_pagerops uvm_vnodeops = { + .pgo_get = vn_get, + .pgo_put = vn_put, +}; + +/* + * vnode pager + */ + +static int +vn_get(struct uvm_object *uobj, voff_t off, struct vm_page **pgs, + int *npages, int centeridx, vm_prot_t access_type, + int advice, int flags) +{ + struct vnode *vp = (struct vnode *)uobj; + + return VOP_GETPAGES(vp, off, pgs, npages, centeridx, access_type, + advice, flags); +} + +static int +vn_put(struct uvm_object *uobj, voff_t offlo, voff_t offhi, int flags) +{ + struct vnode *vp = (struct vnode *)uobj; + + return VOP_PUTPAGES(vp, offlo, offhi, flags); +} + +void +uvm_aio_biodone1(struct buf *bp) +{ + + panic("%s: unimplemented", __func__); +} + +void +uvm_aio_biodone(struct buf *bp) +{ + + uvm_aio_aiodone(bp); +} + +void +uvm_aio_aiodone(struct buf *bp) +{ + + if (((bp->b_flags|bp->b_cflags) & (B_READ|BC_NOCACHE)) == 0 && bioopsp) + bioopsp->io_pageiodone(bp); +} + +struct uvm_ractx * +uvm_ra_allocctx() +{ + + return NULL; +} + +void +uvm_ra_freectx(struct uvm_ractx *ra) +{ + + return; +} + +bool +uvn_clean_p(struct uvm_object *uobj) +{ + struct vnode *vp = (void *)uobj; + + return (vp->v_iflag & VI_ONWORKLST) == 0; +} |
