From: Lionel Sambuc Date: Mon, 26 May 2014 09:42:00 +0000 (+0200) Subject: Message type for SYS_FORK X-Git-Tag: v3.3.0~212 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/invmod.png?a=commitdiff_plain;h=cc0c1fbd75a032864d5d65c001f39f12c35d75fc;p=minix.git Message type for SYS_FORK Change-Id: Ibcf4fdfec51129b2be3d667ec07aea0f42e3fd89 --- diff --git a/include/minix/com.h b/include/minix/com.h index 3516d0be4..13c27237a 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -359,8 +359,6 @@ #define PR_NAME_PTR m1_p2 /* tells where program name is for dmp */ #define PR_IP_PTR m1_p3 /* initial value for ip after exec */ #define PR_PS_STR_PTR m1_p4 /* pointer to ps_strings, expected by __start */ -#define PR_FORK_FLAGS m1_i3 /* optional flags for fork operation */ -#define PR_FORK_MSGADDR m1_p1 /* reply message address of forked child */ /* Constants for exec. FIXME: these do not belong here. */ #define PMEF_AUXVECTORS 20 diff --git a/include/minix/ipc.h b/include/minix/ipc.h index f11364aeb..62fa2174b 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -719,6 +719,23 @@ typedef struct { } mess_lsys_krn_sys_copy; _ASSERT_MSG_SIZE(mess_lsys_krn_sys_copy); +typedef struct { + endpoint_t endpt; + endpoint_t slot; + uint32_t flags; + + uint8_t padding[44]; +} mess_lsys_krn_sys_fork; +_ASSERT_MSG_SIZE(mess_lsys_krn_sys_fork); + +typedef struct { + endpoint_t endpt; + vir_bytes msgaddr; + + uint8_t padding[48]; +} mess_krn_lsys_sys_fork; +_ASSERT_MSG_SIZE(mess_krn_lsys_sys_fork); + typedef struct { int request; endpoint_t endpt; @@ -1582,6 +1599,7 @@ typedef struct { mess_sigcalls m_sigcalls; mess_krn_lsys_schedule m_krn_lsys_schedule; + mess_krn_lsys_sys_fork m_krn_lsys_sys_fork; mess_krn_lsys_sys_getwhoami m_krn_lsys_sys_getwhoami; mess_krn_lsys_sys_irqctl m_krn_lsys_sys_irqctl; mess_krn_lsys_sys_times m_krn_lsys_sys_times; @@ -1666,6 +1684,7 @@ typedef struct { mess_lsys_krn_schedule m_lsys_krn_schedule; mess_lsys_krn_sys_abort m_lsys_krn_sys_abort; mess_lsys_krn_sys_copy m_lsys_krn_sys_copy; + mess_lsys_krn_sys_fork m_lsys_krn_sys_fork; mess_lsys_krn_sys_getinfo m_lsys_krn_sys_getinfo; mess_lsys_krn_sys_getmcontext m_lsys_krn_sys_getmcontext; mess_lsys_krn_sys_iopenable m_lsys_krn_sys_iopenable; diff --git a/kernel/system/do_fork.c b/kernel/system/do_fork.c index 49a9424cd..3873a2a2c 100644 --- a/kernel/system/do_fork.c +++ b/kernel/system/do_fork.c @@ -2,10 +2,11 @@ * m_type: SYS_FORK * * The parameters for this kernel call are: - * m1_i1: PR_ENDPT (parent, process that forked) - * m1_i2: PR_SLOT (child's process table slot) - * m1_p1: PR_MEM_PTR (new memory map for the child) - * m1_i3: PR_FORK_FLAGS (fork flags) + * m_lsys_krn_sys_fork.endpt (parent, process that forked) + * m_lsys_krn_sys_fork.slot (child's process table slot) + * m_lsys_krn_sys_fork.flags (fork flags) + * m_krn_lsys_sys_fork.endpt (endpoint of the child) + * m_krn_lsys_sys_fork.msgaddr (new memory map for the child) */ #include "kernel/system.h" @@ -24,7 +25,10 @@ *===========================================================================*/ int do_fork(struct proc * caller, message * m_ptr) { -/* Handle sys_fork(). PR_ENDPT has forked. The child is PR_SLOT. */ +/* Handle sys_fork(). + * m_lsys_krn_sys_fork.endpt has forked. + * The child is m_lsys_krn_sys_fork.slot. + */ #if defined(__i386__) char *old_fpu_save_area_p; #endif @@ -34,11 +38,11 @@ int do_fork(struct proc * caller, message * m_ptr) int p_proc; int namelen; - if(!isokendpt(m_ptr->PR_ENDPT, &p_proc)) + if(!isokendpt(m_ptr->m_lsys_krn_sys_fork.endpt, &p_proc)) return EINVAL; rpp = proc_addr(p_proc); - rpc = proc_addr(m_ptr->PR_SLOT); + rpc = proc_addr(m_ptr->m_lsys_krn_sys_fork.slot); if (isemptyp(rpp) || ! isemptyp(rpc)) return(EINVAL); assert(!(rpp->p_misc_flags & MF_DELIVERMSG)); @@ -64,7 +68,7 @@ int do_fork(struct proc * caller, message * m_ptr) #endif if(++gen >= _ENDPOINT_MAX_GENERATION) /* increase generation */ gen = 1; /* generation number wraparound */ - rpc->p_nr = m_ptr->PR_SLOT; /* this was obliterated by copy */ + rpc->p_nr = m_ptr->m_lsys_krn_sys_fork.slot; /* this was obliterated by copy */ rpc->p_endpoint = _ENDPOINT(gen, rpc->p_nr); /* new endpoint of slot */ rpc->p_reg.retreg = 0; /* child sees pid = 0 to know it is child */ @@ -102,11 +106,11 @@ int do_fork(struct proc * caller, message * m_ptr) } /* Calculate endpoint identifier, so caller knows what it is. */ - m_ptr->PR_ENDPT = rpc->p_endpoint; - m_ptr->PR_FORK_MSGADDR = (char *) rpp->p_delivermsg_vir; + m_ptr->m_krn_lsys_sys_fork.endpt = rpc->p_endpoint; + m_ptr->m_krn_lsys_sys_fork.msgaddr = rpp->p_delivermsg_vir; /* Don't schedule process in VM mode until it has a new pagetable. */ - if(m_ptr->PR_FORK_FLAGS & PFF_VMINHIBIT) { + if(m_ptr->m_lsys_krn_sys_fork.flags & PFF_VMINHIBIT) { RTS_SET(rpc, RTS_VMINHIBIT); } @@ -128,4 +132,3 @@ int do_fork(struct proc * caller, message * m_ptr) } #endif /* USE_FORK */ - diff --git a/lib/libsys/sys_fork.c b/lib/libsys/sys_fork.c index 811e2301d..4eab41fa9 100644 --- a/lib/libsys/sys_fork.c +++ b/lib/libsys/sys_fork.c @@ -12,11 +12,11 @@ vir_bytes *msgaddr; message m; int r; - m.PR_ENDPT = parent; - m.PR_SLOT = child; - m.PR_FORK_FLAGS = flags; + m.m_lsys_krn_sys_fork.endpt = parent; + m.m_lsys_krn_sys_fork.slot = child; + m.m_lsys_krn_sys_fork.flags = flags; r = _kernel_call(SYS_FORK, &m); - *child_endpoint = m.PR_ENDPT; - *msgaddr = (vir_bytes) m.PR_FORK_MSGADDR; + *child_endpoint = m.m_krn_lsys_sys_fork.endpt; + *msgaddr = m.m_krn_lsys_sys_fork.msgaddr; return r; }