[kernel] Allow passing 0 to vma_resize to query the current size

Passing a size of 0 in to vma_resize will now not attempt to alter the VMA size, but will
still put the size into the passed-in pointer. Using this allows querying the size of a
VMA without changing it.
This commit is contained in:
Justin C. Miller
2024-02-18 17:27:07 -08:00
parent 55a485ee67
commit f51f519c31
3 changed files with 8 additions and 4 deletions

View File

@@ -32,6 +32,6 @@ object vma : object {
} }
method resize [cap:resize] { method resize [cap:resize] {
param size size [inout] param size size [inout] # New size for the VMA, or 0 to query the current size without changing
} }
} }

View File

@@ -22,8 +22,8 @@ enum class vm_flags : uint32_t
#define VM_FLAG(name, v) name = v, #define VM_FLAG(name, v) name = v,
#include <j6/tables/vm_flags.inc> #include <j6/tables/vm_flags.inc>
#undef VM_FLAG #undef VM_FLAG
driver_mask = 0x000fffff, ///< flags allowed via syscall for drivers driver_mask = 0x00ff'ffff, ///< flags allowed via syscall for drivers
user_mask = 0x0000ffff, ///< flags allowed via syscall for non-drivers user_mask = 0x000f'ffff, ///< flags allowed via syscall for non-drivers
}; };
is_bitfield(vm_flags); is_bitfield(vm_flags);

View File

@@ -56,7 +56,11 @@ vma_unmap(vm_area *self, process *proc)
j6_status_t j6_status_t
vma_resize(vm_area *self, size_t *size) vma_resize(vm_area *self, size_t *size)
{ {
*size = self->resize(*size); if (!*size) {
*size = self->size();
} else {
*size = self->resize(*size);
}
return j6_status_ok; return j6_status_ok;
} }