make minix lwip make explicit use of 'int'
[minix3.git] / kernel / system / do_exec.c
blob74370544b6d916286a2e97dd3b5c2d70a9b17ca2
1 /* The kernel call implemented in this file:
2 * m_type: SYS_EXEC
4 * The parameters for this kernel call are:
5 * m1_i1: PR_ENDPT (process that did exec call)
6 * m1_p1: PR_STACK_PTR (new stack pointer)
7 * m1_p2: PR_NAME_PTR (pointer to program name)
8 * m1_p3: PR_IP_PTR (new instruction pointer)
9 */
10 #include "kernel/system.h"
11 #include <string.h>
12 #include <minix/endpoint.h>
14 #if USE_EXEC
16 /*===========================================================================*
17 * do_exec *
18 *===========================================================================*/
19 int do_exec(struct proc * caller, message * m_ptr)
21 /* Handle sys_exec(). A process has done a successful EXEC. Patch it up. */
22 register struct proc *rp;
23 int proc_nr;
24 char name[PROC_NAME_LEN];
26 if(!isokendpt(m_ptr->PR_ENDPT, &proc_nr))
27 return EINVAL;
29 rp = proc_addr(proc_nr);
31 if(rp->p_misc_flags & MF_DELIVERMSG) {
32 rp->p_misc_flags &= ~MF_DELIVERMSG;
35 /* Save command name for debugging, ps(1) output, etc. */
36 if(data_copy(caller->p_endpoint, (vir_bytes) m_ptr->PR_NAME_PTR,
37 KERNEL, (vir_bytes) name,
38 (phys_bytes) sizeof(name) - 1) != OK)
39 strncpy(name, "<unset>", PROC_NAME_LEN);
41 name[sizeof(name)-1] = '\0';
43 /* Set process state. */
44 arch_proc_init(rp, (u32_t) m_ptr->PR_IP_PTR, (u32_t) m_ptr->PR_STACK_PTR, name);
46 /* No reply to EXEC call */
47 RTS_UNSET(rp, RTS_RECEIVING);
49 /* Mark fpu_regs contents as not significant, so fpu
50 * will be initialized, when it's used next time. */
51 rp->p_misc_flags &= ~MF_FPU_INITIALIZED;
52 /* force reloading FPU if the current process is the owner */
53 release_fpu(rp);
54 return(OK);
56 #endif /* USE_EXEC */