This was added 2024-09-27. It isn't going to be straightforward. It should be fairly similar to getrlimit, with the additional requirement that it needs to get the current guest file/data/stack usage.
If I compile and run the exe at the end of this page https://reviews.freebsd.org/D46747?id=143605 then I get cpu (0): 0 fsize (1): -1 data (2): 4096 stack (3): 131072 core (4): -1 rss (5): 2547712 memlock (6): 0 nproc (7): 6 nofile (8): 3 sbsize (9): 0 vmem (10): 14397440 npts (11): 0 swap (12): 17977 kqueues (13): 0 umtx (14): 0 pipebuf (15): 0 data and stack look like the most complicated ones The kernel code is case RLIMIT_DATA: if (vm == NULL) error = ENXIO; else *res = vm->vm_dsize * PAGE_SIZE; break; case RLIMIT_STACK: if (vm == NULL) error = ENXIO; else *res = vm->vm_ssize * PAGE_SIZE; break;
commit 0b6c1515d158745e97ad206bf1cd3caceb8ed4dd Author: Paul Floyd <pjfloyd@wanadoo.fr> Date: Sun Nov 3 10:17:17 2024 +0100 Bug 495488 - Add FreeBSD getrlimitusage syscall wrapper