minor fixes for safecopy & safemap tests
[minix.git] / lib / libexec / libexec.h
blob69da9cb298bfe275bc8d2fc7729b67fd387dd63f
1 #ifndef _LIBEXEC_H_
2 #define _LIBEXEC_H_ 1
4 #include <sys/exec_elf.h>
6 struct exec_info;
8 typedef int (*libexec_loadfunc_t)(struct exec_info *execi,
9 off_t offset, off_t vaddr, size_t len);
11 typedef int (*libexec_clearfunc_t)(struct exec_info *execi,
12 off_t vaddr, size_t len);
14 typedef int (*libexec_allocfunc_t)(struct exec_info *execi,
15 off_t vaddr, size_t len);
17 typedef int (*libexec_procclearfunc_t)(struct exec_info *execi);
19 struct exec_info {
20 /* Filled in by libexec caller */
21 endpoint_t proc_e; /* Process endpoint */
22 char *hdr; /* Header or full image */
23 size_t hdr_len; /* Size of hdr */
24 vir_bytes frame_len; /* Stack size */
25 char progname[PROC_NAME_LEN]; /* Program name */
26 uid_t new_uid; /* Process UID after exec */
27 gid_t new_gid; /* Process GID after exec */
28 int allow_setuid; /* Allow set{u,g}id execution? */
29 vir_bytes stack_size; /* Desired stack size */
30 vir_bytes load_offset; /* Desired load offset */
32 /* Callback pointers for use by libexec */
33 libexec_loadfunc_t copymem; /* Copy callback */
34 libexec_clearfunc_t clearmem; /* Clear callback */
35 libexec_allocfunc_t allocmem_prealloc; /* Alloc callback */
36 libexec_allocfunc_t allocmem_ondemand; /* Alloc callback */
37 libexec_procclearfunc_t clearproc; /* Clear process callback */
38 void *opaque; /* Callback data */
40 /* Filled in by libexec load function */
41 vir_bytes load_base; /* Where executable is loaded */
42 vir_bytes pc; /* Entry point of exec file */
43 vir_bytes stack_high; /* High stack addr */
46 int elf_has_interpreter(char *exec_hdr, int hdr_len, char *interp, int maxsz);
47 int elf_phdr(char *exec_hdr, int hdr_len, vir_bytes *phdr);
49 void libexec_patch_ptr(char stack[ARG_MAX], vir_bytes base);
50 int libexec_pm_newexec(endpoint_t proc_e, struct exec_info *execi);
52 typedef int (*libexec_exec_loadfunc_t)(struct exec_info *execi);
53 int libexec_load_elf(struct exec_info *execi);
55 int libexec_copy_memcpy(struct exec_info *execi, off_t offset, off_t vaddr, size_t len);
56 int libexec_clear_memset(struct exec_info *execi, off_t vaddr, size_t len);
57 int libexec_alloc_mmap_prealloc(struct exec_info *execi, off_t vaddr, size_t len);
58 int libexec_alloc_mmap_ondemand(struct exec_info *execi, off_t vaddr, size_t len);
59 int libexec_clearproc_vm_procctl(struct exec_info *execi);
60 int libexec_clear_sys_memset(struct exec_info *execi, off_t vaddr, size_t len);
62 #endif /* !_LIBEXEC_H_ */