[kernel] Add the handle_close syscallnnAdd a generic handle_close syscall and use it in j6::channel when failing to open

This commit is contained in:
2024-04-24 15:48:00 -07:00
parent ed38e989b1
commit 182d3b0a6a
3 changed files with 16 additions and 2 deletions

View File

@@ -44,6 +44,11 @@ interface syscalls [syscall] {
param mask uint32 # The capability bitmask
}
# Close the handle to an object
function handle_close {
param hnd ref object [handle] # The handle to close
}
# Block waiting on a futex
function futex_wait [static] {
param address uint32* # Address of the futex value

View File

@@ -32,4 +32,13 @@ handle_clone(j6_handle_t orig, j6_handle_t *clone, uint32_t mask)
return j6_status_ok;
}
j6_status_t
handle_close(j6_handle_t hnd)
{
process &p = process::current();
p.remove_handle(hnd);
return j6_status_ok;
}
} // namespace syscalls

View File

@@ -79,7 +79,7 @@ channel::create(size_t tx_size, size_t rx_size)
uintptr_t rx_addr = create_channel_vma(rx_vma, rx_size);
if (!rx_addr) {
j6_vma_unmap(tx_vma, 0);
// TODO: Close TX handle
j6_handle_close(tx_vma);
return nullptr;
}
@@ -109,7 +109,7 @@ channel::open(const channel_def &def)
result = j6_vma_map(def.rx, 0, &rx_addr, 0);
if (result != j6_status_ok) {
j6_vma_unmap(def.tx, 0);
// TODO: Close TX handle
j6_handle_close(def.tx);
syslog(j6::logs::ipc, j6::log_level::error, "Failed to map channel VMA. Error: %lx", result);
return nullptr;
}