1 /* execve() - basic program execution call */
10 #include <minix/param.h>
11 #include <sys/exec_elf.h>
14 int execve(const char *path
, char * const *argv
, char * const *envp
)
17 size_t frame_size
= 0; /* Size of the new initial stack. */
18 int argc
= 0; /* Argument count. */
19 int envc
= 0; /* Environment count */
20 char overflow
= 0; /* No overflow yet. */
22 struct ps_strings
*psp
;
23 int vsp
= 0; /* (virtual) Stack pointer in new address space. */
25 minix_stack_params(path
, argv
, envp
, &frame_size
, &overflow
,
28 /* The party is off if there is an overflow. */
34 /* Allocate space for the stack frame. */
35 if ((frame
= (char *) sbrk(frame_size
)) == (char *) -1) {
40 minix_stack_fill(path
, argc
, argv
, envc
, envp
, frame_size
, frame
,
43 /* Clear unused message fields */
44 memset(&m
, 0, sizeof(m
));
46 /* We can finally make the system call. */
47 m
.m_lc_pm_exec
.name
= (vir_bytes
)path
;
48 m
.m_lc_pm_exec
.namelen
= strlen(path
) + 1;
49 m
.m_lc_pm_exec
.frame
= (vir_bytes
)frame
;
50 m
.m_lc_pm_exec
.framelen
= frame_size
;
51 m
.m_lc_pm_exec
.ps_str
= (vir_bytes
)(vsp
+ ((char *)psp
- frame
));
53 (void) _syscall(PM_PROC_NR
, PM_EXEC
, &m
);
55 /* Failure, return the memory used for the frame and exit. */
56 (void) sbrk(-frame_size
);