From 18c141daf82533938c0e70e9d00e91cbeb479148 Mon Sep 17 00:00:00 2001 From: pooka Date: Thu, 19 Mar 2009 09:14:37 +0000 Subject: [PATCH] Make it possible to mount a file system through the mount() system call in addition to the old rump_mnt_mount(). Some issues remain (but require more deeprooted changes): * it is possible to mount only to / * unmount needs MNT_FORCE due to the new fs being root and having a bonus reference * cwdi is not set (since there is no concept of a process) --- sys/rump/librump/rumpkern/rump.c | 6 +- sys/rump/librump/rumpvfs/Makefile.rumpvfs | 7 +- sys/rump/librump/rumpvfs/rumpfs.c | 82 ++++++++++++++++++----- sys/rump/librump/rumpvfs/vfsops_stub.c | 18 +---- 4 files changed, 76 insertions(+), 37 deletions(-) diff --git a/sys/rump/librump/rumpkern/rump.c b/sys/rump/librump/rumpkern/rump.c index 5dab32664419..92114d7eff0b 100644 --- a/sys/rump/librump/rumpkern/rump.c +++ b/sys/rump/librump/rumpkern/rump.c @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.98 2009/03/18 18:00:38 pooka Exp $ */ +/* $NetBSD: rump.c,v 1.99 2009/03/19 09:14:37 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.98 2009/03/18 18:00:38 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.99 2009/03/19 09:14:37 pooka Exp $"); #include #include @@ -189,7 +189,7 @@ rump__init(int rump_version) l->l_cred = rump_cred_suserget(); l->l_proc = p; l->l_lid = 1; - LIST_INSERT_HEAD(&allproc, p, p_list); + LIST_INIT(&allproc); proc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE); rump_limits.pl_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; diff --git a/sys/rump/librump/rumpvfs/Makefile.rumpvfs b/sys/rump/librump/rumpvfs/Makefile.rumpvfs index 0554420d19f5..26c2d823bc39 100644 --- a/sys/rump/librump/rumpvfs/Makefile.rumpvfs +++ b/sys/rump/librump/rumpvfs/Makefile.rumpvfs @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpvfs,v 1.5 2009/01/13 11:37:16 pooka Exp $ +# $NetBSD: Makefile.rumpvfs,v 1.6 2009/03/19 09:14:37 pooka Exp $ # .include "${RUMPTOP}/Makefile.rump" @@ -22,8 +22,11 @@ SRCS+= vfs_bio.c vfs_cache.c vfs_cwd.c vfs_dirhash.c vfs_getcwd.c \ vfs_hooks.c vfs_init.c vfs_lockf.c vfs_lookup.c vfs_subr.c \ vfs_syscalls.c vfs_vnops.c vfs_wapbl.c vfs_xattr.c +# sys/miscfs/syncfs +SRCS+= sync_subr.c sync_vnops.c + # sys/miscfs -SRCS+= genfs_vfsops.c genfs_vnops.c sync_subr.c spec_vnops.c +SRCS+= genfs_vfsops.c genfs_vnops.c spec_vnops.c # sys/kern bufq SRCS+= subr_bufq.c bufq_disksort.c bufq_fcfs.c bufq_priocscan.c \ diff --git a/sys/rump/librump/rumpvfs/rumpfs.c b/sys/rump/librump/rumpvfs/rumpfs.c index 2c0036a69011..99374f6f3bc0 100644 --- a/sys/rump/librump/rumpvfs/rumpfs.c +++ b/sys/rump/librump/rumpvfs/rumpfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: rumpfs.c,v 1.8 2009/03/18 10:22:45 cegger Exp $ */ +/* $NetBSD: rumpfs.c,v 1.9 2009/03/19 09:14:37 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.8 2009/03/18 10:22:45 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.9 2009/03/19 09:14:37 pooka Exp $"); #include #include @@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.8 2009/03/18 10:22:45 cegger Exp $"); #include #include -#include #include #include @@ -54,6 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.8 2009/03/18 10:22:45 cegger Exp $"); #include "rump_vfs_private.h" static int rump_vop_lookup(void *); +static int rump_vop_getattr(void *); +static int rump_vop_success(void *); int (**dead_vnodeop_p)(void *); const struct vnodeopv_entry_desc dead_vnodeop_entries[] = { @@ -63,14 +64,6 @@ const struct vnodeopv_entry_desc dead_vnodeop_entries[] = { const struct vnodeopv_desc dead_vnodeop_opv_desc = { &dead_vnodeop_p, dead_vnodeop_entries }; -int (**sync_vnodeop_p)(void *); -const struct vnodeopv_entry_desc sync_vnodeop_entries[] = { - { &vop_default_desc, vn_default_error }, - { NULL, NULL } -}; -const struct vnodeopv_desc sync_vnodeop_opv_desc = - { &sync_vnodeop_p, sync_vnodeop_entries }; - int (**fifo_vnodeop_p)(void *); const struct vnodeopv_entry_desc fifo_vnodeop_entries[] = { { &vop_default_desc, vn_default_error }, @@ -83,6 +76,9 @@ int (**rump_vnodeop_p)(void *); const struct vnodeopv_entry_desc rump_vnodeop_entries[] = { { &vop_default_desc, vn_default_error }, { &vop_lookup_desc, rump_vop_lookup }, + { &vop_getattr_desc, rump_vop_getattr }, + { &vop_putpages_desc, rump_vop_success }, + { &vop_fsync_desc, rump_vop_success }, { &vop_lock_desc, genfs_lock }, { &vop_unlock_desc, genfs_unlock }, { NULL, NULL } @@ -94,7 +90,40 @@ const struct vnodeopv_desc * const rump_opv_descs[] = { NULL }; -static struct mount mnt_dummy; +static struct mount rump_mnt; +static int lastino = 1; + +static struct vattr * +makevattr(enum vtype vt) +{ + struct vattr *va; + struct timespec ts; + + nanotime(&ts); + + va = kmem_alloc(sizeof(*va), KM_SLEEP); + va->va_type = vt; + va->va_mode = 0755; + va->va_nlink = 2; + va->va_uid = 0; + va->va_gid = 0; + va->va_fsid = + va->va_fileid = atomic_inc_uint_nv(&lastino); + va->va_size = 512; + va->va_blocksize = 512; + va->va_atime = ts; + va->va_mtime = ts; + va->va_ctime = ts; + va->va_birthtime = ts; + va->va_gen = 0; + va->va_flags = 0; + va->va_rdev = -1; + va->va_bytes = 512; + va->va_filerev = 0; + va->va_vaflags = 0; + + return va; +} static int rump_makevnode(const char *path, size_t size, enum vtype vt, struct vnode **vpp) @@ -105,9 +134,8 @@ rump_makevnode(const char *path, size_t size, enum vtype vt, struct vnode **vpp) vp = kmem_alloc(sizeof(struct vnode), KM_SLEEP); vp->v_size = vp->v_writesize = size; vp->v_type = vt; - if (vp->v_type != VBLK) - if (rump_fakeblk_find(path)) - vp->v_type = VBLK; + if (vp->v_type == VREG) + vp->v_type = VBLK; if (vp->v_type != VBLK && vp->v_type != VDIR) panic("rump_makevnode: only VBLK/VDIR vnodes supported"); @@ -123,9 +151,11 @@ rump_makevnode(const char *path, size_t size, enum vtype vt, struct vnode **vpp) } else { vp->v_op = rump_vnodeop_p; } - vp->v_mount = &mnt_dummy; + vp->v_tag = VT_RUMP; + vp->v_mount = &rump_mnt; vp->v_vnlock = &vp->v_lock; vp->v_usecount = 1; + vp->v_data = makevattr(vp->v_type); mutex_init(&vp->v_interlock, MUTEX_DEFAULT, IPL_NONE); memset(&vp->v_lock, 0, sizeof(vp->v_lock)); rw_init(&vp->v_lock.vl_lock); @@ -190,6 +220,26 @@ rump_vop_lookup(void *v) return 0; } +static int +rump_vop_getattr(void *v) +{ + struct vop_getattr_args /* { + struct vnode *a_vp; + struct vattr *a_vap; + kauth_cred_t a_cred; + } */ *ap = v; + + memcpy(ap->a_vap, ap->a_vp->v_data, sizeof(struct vattr)); + return 0; +} + +static int +rump_vop_success(void *v) +{ + + return 0; +} + void rumpfs_init(void) { diff --git a/sys/rump/librump/rumpvfs/vfsops_stub.c b/sys/rump/librump/rumpvfs/vfsops_stub.c index a3660c6d9996..3b93ecbaa621 100644 --- a/sys/rump/librump/rumpvfs/vfsops_stub.c +++ b/sys/rump/librump/rumpvfs/vfsops_stub.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfsops_stub.c,v 1.6 2009/01/13 11:37:16 pooka Exp $ */ +/* $NetBSD: vfsops_stub.c,v 1.7 2009/03/19 09:14:37 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfsops_stub.c,v 1.6 2009/01/13 11:37:16 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfsops_stub.c,v 1.7 2009/03/19 09:14:37 pooka Exp $"); #include #include @@ -57,20 +57,6 @@ 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__); -} - void fifo_printinfo(struct vnode *vp) {