Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump There is a use case where preserving the parent's f...
details: https://anonhg.NetBSD.org/src/rev/35aadbfbbc55
branches: trunk
changeset: 760314:35aadbfbbc55
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Jan 02 12:52:25 2011 +0000
description:
There is a use case where preserving the parent's fd table is
relevant, so to accommodate that change rump_lwproc_newproc() to
rump_lwproc_rfork(). The new interface has the rfork() fd table
semantics. The equivalent of rump_lwproc_newproc() is
rump_lwproc_rfork(RUMP_RFCFDG).
diffstat:
sys/rump/include/rump/rump.h | 6 +++++-
sys/rump/include/rump/rumpuser.h | 4 ++--
sys/rump/librump/rumpkern/lwproc.c | 30 +++++++++++++++++++++---------
sys/rump/librump/rumpkern/rump.c | 12 ++++++------
sys/rump/librump/rumpkern/rumpkern.ifspec | 4 ++--
5 files changed, 36 insertions(+), 20 deletions(-)
diffs (187 lines):
diff -r 0afaca3290f6 -r 35aadbfbbc55 sys/rump/include/rump/rump.h
--- a/sys/rump/include/rump/rump.h Sun Jan 02 12:48:21 2011 +0000
+++ b/sys/rump/include/rump/rump.h Sun Jan 02 12:52:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.h,v 1.49 2010/11/30 14:23:24 pooka Exp $ */
+/* $NetBSD: rump.h,v 1.50 2011/01/02 12:52:25 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -73,6 +73,10 @@
RUMP_SIGMODEL_RECORD
};
+/* flags to rump_lwproc_rfork */
+#define RUMP_RFFDG 0x01
+#define RUMP_RFCFDG 0x02
+
/* rumpvfs */
#define RUMPCN_FREECRED 0x02
#define RUMP_ETFS_SIZE_ENDOFF ((uint64_t)-1)
diff -r 0afaca3290f6 -r 35aadbfbbc55 sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h Sun Jan 02 12:48:21 2011 +0000
+++ b/sys/rump/include/rump/rumpuser.h Sun Jan 02 12:52:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.h,v 1.60 2010/12/30 15:47:30 pooka Exp $ */
+/* $NetBSD: rumpuser.h,v 1.61 2011/01/02 12:52:25 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -214,7 +214,7 @@
void (*spop_lwproc_switch)(struct lwp *);
void (*spop_lwproc_release)(void);
- int (*spop_lwproc_newproc)(void *);
+ int (*spop_lwproc_rfork)(void *, int);
int (*spop_lwproc_newlwp)(pid_t);
struct lwp * (*spop_lwproc_curlwp)(void);
int (*spop_syscall)(int, void *, register_t *);
diff -r 0afaca3290f6 -r 35aadbfbbc55 sys/rump/librump/rumpkern/lwproc.c
--- a/sys/rump/librump/rumpkern/lwproc.c Sun Jan 02 12:48:21 2011 +0000
+++ b/sys/rump/librump/rumpkern/lwproc.c Sun Jan 02 12:52:25 2011 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: lwproc.c,v 1.6 2010/11/22 20:42:19 pooka Exp $ */
+/* $NetBSD: lwproc.c,v 1.7 2011/01/02 12:52:25 pooka Exp $ */
/*
- * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
+ * Copyright (c) 2010, 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
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.6 2010/11/22 20:42:19 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.7 2011/01/02 12:52:25 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -94,7 +94,7 @@
* Switch to the new lwp and return a pointer to it.
*/
static struct proc *
-lwproc_newproc(struct proc *parent)
+lwproc_newproc(struct proc *parent, int flags)
{
uid_t uid = kauth_cred_getuid(parent->p_cred);
struct proc *p;
@@ -113,10 +113,18 @@
p->p_stats = pstatscopy(parent->p_stats);
- /* not based on parent */
p->p_vmspace = vmspace_kernel();
p->p_emul = &emul_netbsd;
- p->p_fd = fd_init(NULL);
+
+ if ((flags & RUMP_RFCFDG) == 0)
+ KASSERT(parent == curproc);
+ if (flags & RUMP_RFFDG)
+ p->p_fd = fd_copy();
+ else if (flags & RUMP_RFCFDG)
+ p->p_fd = fd_init(NULL);
+ else
+ fd_share(p);
+
lim_addref(parent->p_limit);
p->p_limit = parent->p_limit;
@@ -234,7 +242,7 @@
bool newproc = false;
if (p == NULL) {
- p = lwproc_newproc(&proc0);
+ p = lwproc_newproc(&proc0, 0);
newproc = true;
}
@@ -268,12 +276,16 @@
}
int
-rump_lwproc_newproc(void)
+rump_lwproc_rfork(int flags)
{
struct proc *p;
struct lwp *l;
- p = lwproc_newproc(curproc);
+ if (flags & ~(RUMP_RFFDG|RUMP_RFCFDG) ||
+ (~flags & (RUMP_RFFDG|RUMP_RFCFDG)) == 0)
+ return EINVAL;
+
+ p = lwproc_newproc(curproc, flags);
l = kmem_zalloc(sizeof(*l), KM_SLEEP);
mutex_enter(p->p_lock);
lwproc_makelwp(p, l, true, true);
diff -r 0afaca3290f6 -r 35aadbfbbc55 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c Sun Jan 02 12:48:21 2011 +0000
+++ b/sys/rump/librump/rumpkern/rump.c Sun Jan 02 12:52:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.213 2010/12/30 16:46:32 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.214 2011/01/02 12:52:25 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.213 2010/12/30 16:46:32 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.214 2011/01/02 12:52:25 pooka Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@@ -99,7 +99,7 @@
#endif
static int rump_proxy_syscall(int, void *, register_t *);
-static int rump_proxy_newproc(void *);
+static int rump_proxy_rfork(void *, int);
static char rump_msgbuf[16*1024]; /* 16k should be enough for std rump needs */
@@ -199,7 +199,7 @@
.spop_unschedule = rump_unschedule,
.spop_lwproc_switch = rump_lwproc_switch,
.spop_lwproc_release = rump_lwproc_releaselwp,
- .spop_lwproc_newproc = rump_proxy_newproc,
+ .spop_lwproc_rfork = rump_proxy_rfork,
.spop_lwproc_newlwp = rump_lwproc_newlwp,
.spop_lwproc_curlwp = rump_lwproc_curlwp,
.spop_syscall = rump_proxy_syscall,
@@ -704,12 +704,12 @@
}
static int
-rump_proxy_newproc(void *priv)
+rump_proxy_rfork(void *priv, int flags)
{
struct vmspace *newspace;
int error;
- if ((error = rump_lwproc_newproc()) != 0)
+ if ((error = rump_lwproc_rfork(flags)) != 0)
return error;
/*
diff -r 0afaca3290f6 -r 35aadbfbbc55 sys/rump/librump/rumpkern/rumpkern.ifspec
--- a/sys/rump/librump/rumpkern/rumpkern.ifspec Sun Jan 02 12:48:21 2011 +0000
+++ b/sys/rump/librump/rumpkern/rumpkern.ifspec Sun Jan 02 12:52:25 2011 +0000
@@ -1,4 +1,4 @@
-; $NetBSD: rumpkern.ifspec,v 1.9 2010/11/21 17:34:11 pooka Exp $
+; $NetBSD: rumpkern.ifspec,v 1.10 2011/01/02 12:52:25 pooka Exp $
NAME|kern
PUBHDR|include/rump/rumpkern_if_pub.h
@@ -23,7 +23,7 @@
void |cred_put |struct kauth_cred *
; lwp and proc creation / switching interfaces
-int |lwproc_newproc |void
+int |lwproc_rfork |int
int |lwproc_newlwp |pid_t
void |lwproc_switch |struct lwp *
void |lwproc_releaselwp |void
Home |
Main Index |
Thread Index |
Old Index