Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpkern gardenize rump.c: move data struct...



details:   https://anonhg.NetBSD.org/src/rev/6c716a9d882e
branches:  trunk
changeset: 328954:6c716a9d882e
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Apr 25 18:25:38 2014 +0000

description:
gardenize rump.c: move data structure helper routines to accessors.c

diffstat:

 sys/rump/librump/rumpkern/Makefile.rumpkern |    5 +-
 sys/rump/librump/rumpkern/accessors.c       |  128 ++++++++++++++++++++++++++++
 sys/rump/librump/rumpkern/rump.c            |   90 +-------------------
 3 files changed, 133 insertions(+), 90 deletions(-)

diffs (262 lines):

diff -r bb579ec033ea -r 6c716a9d882e sys/rump/librump/rumpkern/Makefile.rumpkern
--- a/sys/rump/librump/rumpkern/Makefile.rumpkern       Fri Apr 25 18:13:59 2014 +0000
+++ b/sys/rump/librump/rumpkern/Makefile.rumpkern       Fri Apr 25 18:25:38 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.rumpkern,v 1.144 2014/04/25 13:10:42 pooka Exp $
+#      $NetBSD: Makefile.rumpkern,v 1.145 2014/04/25 18:25:38 pooka Exp $
 #
 
 .include "${RUMPTOP}/Makefile.rump"
@@ -24,7 +24,8 @@
 # 
 SRCS+= rump.c rumpcopy.c cons.c emul.c etfs_wrap.c intr.c      \
        lwproc.c klock.c kobj_rename.c ltsleep.c scheduler.c    \
-       signals.c sleepq.c threads.c vm.c hyperentropy.c
+       signals.c sleepq.c threads.c vm.c hyperentropy.c        \
+       accessors.c
 
 # autogenerated into the correct namespace
 RUMPOBJ_NORENAME= rump_syscalls.o rump_syscalls.pico rump_syscalls.po
diff -r bb579ec033ea -r 6c716a9d882e sys/rump/librump/rumpkern/accessors.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/rumpkern/accessors.c     Fri Apr 25 18:25:38 2014 +0000
@@ -0,0 +1,128 @@
+/*     $NetBSD: accessors.c,v 1.1 2014/04/25 18:25:38 pooka Exp $      */
+
+/*
+ * Copyright (c) 2007-2011 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.
+ */
+
+/*
+ * This file contains various data structure accessor routines.
+ * They are meant to help clients that make calls into the depths
+ * of the kernel (e.g. at vfs layer) bypassing the syscall layer.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: accessors.c,v 1.1 2014/04/25 18:25:38 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/kauth.h>
+#include <sys/kmem.h>
+#include <sys/uio.h>
+
+#include "rump_private.h"
+
+struct uio *
+rump_uio_setup(void *buf, size_t bufsize, off_t offset, enum rump_uiorw rw)
+{
+       struct uio *uio;
+       enum uio_rw uiorw;
+
+       switch (rw) {
+       case RUMPUIO_READ:
+               uiorw = UIO_READ;
+               break;
+       case RUMPUIO_WRITE:
+               uiorw = UIO_WRITE;
+               break;
+       default:
+               panic("%s: invalid rw %d", __func__, rw);
+       }
+
+       uio = kmem_alloc(sizeof(struct uio), KM_SLEEP);
+       uio->uio_iov = kmem_alloc(sizeof(struct iovec), KM_SLEEP);
+
+       uio->uio_iov->iov_base = buf;
+       uio->uio_iov->iov_len = bufsize;
+
+       uio->uio_iovcnt = 1;
+       uio->uio_offset = offset;
+       uio->uio_resid = bufsize;
+       uio->uio_rw = uiorw;
+       UIO_SETUP_SYSSPACE(uio);
+
+       return uio;
+}
+
+size_t
+rump_uio_getresid(struct uio *uio)
+{
+
+       return uio->uio_resid;
+}
+
+off_t
+rump_uio_getoff(struct uio *uio)
+{
+
+       return uio->uio_offset;
+}
+
+size_t
+rump_uio_free(struct uio *uio)
+{
+       size_t resid;
+
+       resid = uio->uio_resid;
+       kmem_free(uio->uio_iov, sizeof(*uio->uio_iov));
+       kmem_free(uio, sizeof(*uio));
+
+       return resid;
+}
+
+kauth_cred_t
+rump_cred_create(uid_t uid, gid_t gid, size_t ngroups, gid_t *groups)
+{
+       kauth_cred_t cred;
+       int rv;
+
+       cred = kauth_cred_alloc();
+       kauth_cred_setuid(cred, uid);
+       kauth_cred_seteuid(cred, uid);
+       kauth_cred_setsvuid(cred, uid);
+       kauth_cred_setgid(cred, gid);
+       kauth_cred_setgid(cred, gid);
+       kauth_cred_setegid(cred, gid);
+       kauth_cred_setsvgid(cred, gid);
+       rv = kauth_cred_setgroups(cred, groups, ngroups, 0, UIO_SYSSPACE);
+       /* oh this is silly.  and by "this" I mean kauth_cred_setgroups() */
+       assert(rv == 0);
+
+       return cred;
+}
+
+void
+rump_cred_put(kauth_cred_t cred)
+{
+
+       kauth_cred_free(cred);
+}
diff -r bb579ec033ea -r 6c716a9d882e sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Fri Apr 25 18:13:59 2014 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Fri Apr 25 18:25:38 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.c,v 1.300 2014/04/25 18:13:59 pooka Exp $ */
+/*     $NetBSD: rump.c,v 1.301 2014/04/25 18:25:38 pooka Exp $ */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.300 2014/04/25 18:13:59 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.301 2014/04/25 18:25:38 pooka Exp $");
 
 #include <sys/systm.h>
 #define ELFSIZE ARCH_ELFSIZE
@@ -585,92 +585,6 @@
        rumpuser_exit(ruhow);
 }
 
-struct uio *
-rump_uio_setup(void *buf, size_t bufsize, off_t offset, enum rump_uiorw rw)
-{
-       struct uio *uio;
-       enum uio_rw uiorw;
-
-       switch (rw) {
-       case RUMPUIO_READ:
-               uiorw = UIO_READ;
-               break;
-       case RUMPUIO_WRITE:
-               uiorw = UIO_WRITE;
-               break;
-       default:
-               panic("%s: invalid rw %d", __func__, rw);
-       }
-
-       uio = kmem_alloc(sizeof(struct uio), KM_SLEEP);
-       uio->uio_iov = kmem_alloc(sizeof(struct iovec), KM_SLEEP);
-
-       uio->uio_iov->iov_base = buf;
-       uio->uio_iov->iov_len = bufsize;
-
-       uio->uio_iovcnt = 1;
-       uio->uio_offset = offset;
-       uio->uio_resid = bufsize;
-       uio->uio_rw = uiorw;
-       UIO_SETUP_SYSSPACE(uio);
-
-       return uio;
-}
-
-size_t
-rump_uio_getresid(struct uio *uio)
-{
-
-       return uio->uio_resid;
-}
-
-off_t
-rump_uio_getoff(struct uio *uio)
-{
-
-       return uio->uio_offset;
-}
-
-size_t
-rump_uio_free(struct uio *uio)
-{
-       size_t resid;
-
-       resid = uio->uio_resid;
-       kmem_free(uio->uio_iov, sizeof(*uio->uio_iov));
-       kmem_free(uio, sizeof(*uio));
-
-       return resid;
-}
-
-kauth_cred_t
-rump_cred_create(uid_t uid, gid_t gid, size_t ngroups, gid_t *groups)
-{
-       kauth_cred_t cred;
-       int rv;
-
-       cred = kauth_cred_alloc();
-       kauth_cred_setuid(cred, uid);
-       kauth_cred_seteuid(cred, uid);
-       kauth_cred_setsvuid(cred, uid);
-       kauth_cred_setgid(cred, gid);
-       kauth_cred_setgid(cred, gid);
-       kauth_cred_setegid(cred, gid);
-       kauth_cred_setsvgid(cred, gid);
-       rv = kauth_cred_setgroups(cred, groups, ngroups, 0, UIO_SYSSPACE);
-       /* oh this is silly.  and by "this" I mean kauth_cred_setgroups() */
-       assert(rv == 0);
-
-       return cred;
-}
-
-void
-rump_cred_put(kauth_cred_t cred)
-{
-
-       kauth_cred_free(cred);
-}
-
 static int compcounter[RUMP_COMPONENT_MAX];
 static int compinited[RUMP_COMPONENT_MAX];
 



Home | Main Index | Thread Index | Old Index