I don't think we're ever going to support different threads of a process
running with different emulations, so move p_emul and p_emuldata to
struct process. This uses the p__pgid kinfo_proc hack to allow p_emul
to remain as a macro so I don't have to rewrite half the kernel.
Index: bin/ps/print.c
===================================================================
RCS file: /home/tedu/cvs/src/bin/ps/print.c,v
retrieving revision 1.48
diff -u -p -r1.48 print.c
--- bin/ps/print.c 10 Apr 2011 03:20:58 -0000 1.48
+++ bin/ps/print.c 8 Jul 2011 05:31:06 -0000
@@ -683,5 +683,5 @@ emulname(const struct kinfo_proc *kp, VA
v = ve->var;
- (void)printf("%-*s", (int)v->width, kp->p_emul);
+ (void)printf("%-*s", (int)v->width, kp->p__emul);
}
Index: sys/compat/linux/linux_exec.c
===================================================================
RCS file: /home/tedu/cvs/src/sys/compat/linux/linux_exec.c,v
retrieving revision 1.34
diff -u -p -r1.34 linux_exec.c
--- sys/compat/linux/linux_exec.c 20 Apr 2011 19:14:34 -0000 1.34
+++ sys/compat/linux/linux_exec.c 8 Jul 2011 05:21:56 -0000
@@ -198,7 +198,7 @@ void
linux_e_proc_fork(struct proc *p, struct proc *parent)
{
struct linux_emuldata *emul;
- struct linux_emuldata *p_emul;
+ struct linux_emuldata *pp_emul;
/* Allocate new emuldata for the new process. */
p->p_emuldata = NULL;
@@ -207,11 +207,11 @@ linux_e_proc_fork(struct proc *p, struct
linux_e_proc_init(p, parent->p_vmspace);
emul = p->p_emuldata;
- p_emul = parent->p_emuldata;
+ pp_emul = parent->p_emuldata;
- emul->my_set_tid = p_emul->child_set_tid;
- emul->my_clear_tid = p_emul->child_clear_tid;
- emul->my_tls_base = p_emul->child_tls_base;
+ emul->my_set_tid = pp_emul->child_set_tid;
+ emul->my_clear_tid = pp_emul->child_clear_tid;
+ emul->my_tls_base = pp_emul->child_tls_base;
}
static void *
Index: sys/sys/proc.h
===================================================================
RCS file: /home/tedu/cvs/src/sys/sys/proc.h,v
retrieving revision 1.141
diff -u -p -r1.141 proc.h
--- sys/sys/proc.h 7 Jul 2011 18:00:33 -0000 1.141
+++ sys/sys/proc.h 8 Jul 2011 05:19:47 -0000
@@ -155,12 +155,16 @@ struct process {
struct klist ps_klist; /* knotes attached to this process */
int ps_flags; /* PS_* flags. */
+ void *ps_emuldata; /* Per-process emulation data, or */
+ /* NULL. Malloc type M_EMULDATA */
+
/* End area that is zeroed on creation. */
#define ps_endzero ps_startcopy
/* The following fields are all copied upon creation in process_new. */
#define ps_startcopy ps_limit
+ struct emul *ps_emul; /* Emulation information */
struct plimit *ps_limit; /* Process limits. */
struct pgrp *ps_pgrp; /* Pointer to process group. */
u_int ps_rtableid; /* Process routing table/domain. */
@@ -266,8 +270,7 @@ struct proc {
struct vnode *p_textvp; /* Vnode of executable. */
- void *p_emuldata; /* Per-process emulation data, or */
- /* NULL. Malloc type M_EMULDATA */
+#define p_emuldata p_p->ps_emuldata
sigset_t p_sigdivert; /* Signals to be diverted to thread. */
struct sigaltstack p_sigstk; /* sp & on stack state variable */
@@ -284,7 +287,7 @@ struct proc {
u_char p_usrpri; /* User-priority based on p_cpu and ps_nice. */
char p_comm[MAXCOMLEN+1];
- struct emul *p_emul; /* Emulation information */
+#define p_emul p_p->ps_emul
vaddr_t p_sigcode; /* user pointer to the signal code. */
/* End area that is copied on creation. */
Index: sys/sys/sysctl.h
===================================================================
RCS file: /home/tedu/cvs/src/sys/sys/sysctl.h,v
retrieving revision 1.115
diff -u -p -r1.115 sysctl.h
--- sys/sys/sysctl.h 5 Jul 2011 04:48:02 -0000 1.115
+++ sys/sys/sysctl.h 8 Jul 2011 05:23:46 -0000
@@ -437,7 +437,7 @@ struct kinfo_proc {
u_int64_t p_realflag; /* INT: P_* flags (not including LWPs).
*/
u_int32_t p_svuid; /* UID_T: saved user id */
u_int32_t p_svgid; /* GID_T: saved group id */
- char p_emul[KI_EMULNAMELEN]; /* syscall emulation name */
+ char p__emul[KI_EMULNAMELEN]; /* syscall emulation name */
u_int64_t p_rlim_rss_cur; /* RLIM_T: soft limit for rss */
u_int64_t p_cpuid; /* LONG: CPU id */
u_int64_t p_vm_map_size; /* VSIZE_T: virtual size */
@@ -529,8 +529,8 @@ do {
\
(kp)->p_acflag = (p)->p_acflag; \
\
/* XXX depends on p_emul being an array and not a pointer */ \
- copy_str((kp)->p_emul, (char *)(p)->p_emul + \
- offsetof(struct emul, e_name), sizeof((kp)->p_emul)); \
+ copy_str((kp)->p__emul, (char *)(p)->p_emul + \
+ offsetof(struct emul, e_name), sizeof((kp)->p__emul)); \
copy_str((kp)->p_comm, (p)->p_comm, sizeof((kp)->p_comm)); \
copy_str((kp)->p_login, (sess)->s_login, \
MIN(sizeof((kp)->p_login) - 1, sizeof((sess)->s_login))); \