Add write_file () syscall, CE implement redirections, libarena arena_realloc ()
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m14s

This commit is contained in:
2026-03-01 12:04:21 +01:00
parent abd85744cc
commit a5d5e7d6a4
9 changed files with 220 additions and 44 deletions

View File

@@ -483,6 +483,38 @@ DEFINE_SYSCALL (sys_create_file) {
return SYSRESULT (ret);
}
/* int write_file (char* path, size_t off, uint8_t* buffer, size_t size) */
DEFINE_SYSCALL (sys_write_file) {
uintptr_t uvaddr_path = a1;
size_t off = (size_t)a2;
uintptr_t uvaddr_buffer = a3;
size_t size = (size_t)a4;
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
uintptr_t out_paddr;
spin_lock (&proc->procgroup->lock);
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
spin_unlock (&proc->procgroup->lock);
if (out_paddr == 0)
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
uint8_t* buffer = sys_get_user_buffer (proc, uvaddr_buffer, size);
if (buffer == NULL)
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
spin_lock (&proc->lock);
int ret = vfs_write_file (proc, proc->cwv, path, buffer, off, size);
spin_unlock (&proc->lock);
return SYSRESULT (ret);
}
/* int get_exec_pid (void) */
DEFINE_SYSCALL (sys_get_exec_pid) { return SYSRESULT (proc->exec_pid); }
@@ -510,6 +542,7 @@ static syscall_handler_func_t handler_table[] = {
[SYS_GET_EXEC_PID] = &sys_get_exec_pid,
[SYS_READ_DIR_ENTRY] = &sys_read_dir_entry,
[SYS_CREATE_FILE] = &sys_create_file,
[SYS_WRITE_FILE] = &sys_write_file,
};
syscall_handler_func_t syscall_find_handler (int syscall_num) {