34 pr_warn(
"failed to read elf header");
40 const char **argv_copy =
NULL;
41 const char **envp_copy =
NULL;
42 const char *path_copy =
strdup(path);
48 argv_copy = krealloc(argv_copy, (
argc + 1) *
sizeof(
char *));
54 argv_copy = kmalloc(
sizeof(
char *) * 2);
55 argv_copy[0] =
strdup(path);
63 while (envp && envp[envc])
66 envp_copy = krealloc(envp_copy, (envc + 1) *
sizeof(
char *));
67 envp_copy[envc - 1] =
strdup(envp[envc - 1]);
72 envp_copy = kmalloc(
sizeof(
char *) * 1);
77 envp_copy[envc] =
NULL;
131 .invocation = path_copy,
138 for (
int i = 0; i <
argc; i++)
141 for (
int i = 0; i < envc; i++)
148 pr_emerg(
"failed to fill process, execve failed");
#define MOS_UNREACHABLE()
#define MOS_STACK_PAGES_USER
#define MOS_PROCESS_MAX_OPEN_FILES
#define MOS_ADDR_USER_STACK
vmap_t * cow_allocate_zeroed_pages(mm_context_t *handle, size_t npages, ptr_t vaddr, valloc_flags hints, vm_flags flags)
Allocate zero-on-demand pages at a specific address.
__nodiscard bool elf_read_and_verify_executable(file_t *file, elf_header_t *header)
__nodiscard bool elf_do_fill_process(process_t *proc, file_t *file, elf_header_t elf, elf_startup_info_t *info)
long process_do_execveat(process_t *process, fd_t dirfd, const char *path, const char *const argv[], const char *const envp[], int flags)
MOSAPI void stack_init(downwards_stack_t *stack, void *mem_region_bottom, size_t size)
long signal_send_to_thread(thread_t *target, signal_t signal)
Send a signal to a thread.
MOSAPI char * strdup(const char *src)
#define list_foreach(t, v, h)
Iterate over a list.
void vmap_finalise_init(vmap_t *vmap, vmap_content_t content, vmap_type_t type)
Finalize the initialization of a vmap object.
void vmap_destroy(vmap_t *vmap)
Destroy a vmap object, and unmmap the region.
@ VALLOC_DEFAULT
Default allocation flags.
file_t * vfs_openat(int fd, const char *path, open_flags flags)
Open a file at a given path.
__nodiscard bool io_valid(const io_t *io)
io_t * io_unref(io_t *io)
#define pr_emerg(fmt,...)
void process_exit(process_t *process, u8 exit_code, signal_t signal)
bool process_detach_fd(process_t *process, fd_t fd)
#define memzero(ptr, size)
#define spinlock_acquire(lock)
#define spinlock_release(lock)
spinlock_t mm_lock
protects [pgd] and the [mmaps] list (the list itself, not the vmap_t objects)
sigaction_t handlers[SIGNAL_MAX_N]
signal handlers
process_signal_info_t signal_info
signal handling info
fd_type files[MOS_PROCESS_MAX_OPEN_FILES]
thread_mode mode
user-mode thread or kernel-mode
downwards_stack_t u_stack
user-mode stack
spinlock_t state_lock
protects the thread state
void thread_destroy(thread_t *thread)
bool thread_wait_for_tid(tid_t tid)