Module Name: src
Committed By: pooka
Date: Fri Apr 25 18:25:38 UTC 2014
Modified Files:
src/sys/rump/librump/rumpkern: Makefile.rumpkern rump.c
Added Files:
src/sys/rump/librump/rumpkern: accessors.c
Log Message:
gardenize rump.c: move data structure helper routines to accessors.c
To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/sys/rump/librump/rumpkern/Makefile.rumpkern
cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/rumpkern/accessors.c
cvs rdiff -u -r1.300 -r1.301 src/sys/rump/librump/rumpkern/rump.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/librump/rumpkern/Makefile.rumpkern
diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.144 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.145
--- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.144 Fri Apr 25 13:10:42 2014
+++ src/sys/rump/librump/rumpkern/Makefile.rumpkern Fri Apr 25 18:25:38 2014
@@ -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 @@ LIB= rump
#
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
Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.300 src/sys/rump/librump/rumpkern/rump.c:1.301
--- src/sys/rump/librump/rumpkern/rump.c:1.300 Fri Apr 25 18:13:59 2014
+++ src/sys/rump/librump/rumpkern/rump.c Fri Apr 25 18:25:38 2014
@@ -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 @@ cpu_reboot(int howto, char *bootstr)
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];
Added files:
Index: src/sys/rump/librump/rumpkern/accessors.c
diff -u /dev/null src/sys/rump/librump/rumpkern/accessors.c:1.1
--- /dev/null Fri Apr 25 18:25:38 2014
+++ src/sys/rump/librump/rumpkern/accessors.c Fri Apr 25 18:25:38 2014
@@ -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);
+}