1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

libutil: add kinfo_getswapvmobject(3)

(cherry picked from commit f2069331e5)
This commit is contained in:
Konstantin Belousov 2021-10-26 11:40:10 +03:00
parent 9b392d0738
commit cfccf3baca
2 changed files with 18 additions and 4 deletions

View File

@ -36,8 +36,8 @@ __FBSDID("$FreeBSD$");
#include "libutil.h"
struct kinfo_vmobject *
kinfo_getvmobject(int *cntp)
static struct kinfo_vmobject *
kinfo_getvmobject_impl(int *cntp, const char *vmobjsysctl)
{
char *buf, *bp, *ep;
struct kinfo_vmobject *kvo, *list, *kp;
@ -46,14 +46,14 @@ kinfo_getvmobject(int *cntp)
buf = NULL;
for (i = 0; i < 3; i++) {
if (sysctlbyname("vm.objects", NULL, &len, NULL, 0) < 0) {
if (sysctlbyname(vmobjsysctl, NULL, &len, NULL, 0) < 0) {
free(buf);
return (NULL);
}
buf = reallocf(buf, len);
if (buf == NULL)
return (NULL);
if (sysctlbyname("vm.objects", buf, &len, NULL, 0) == 0)
if (sysctlbyname(vmobjsysctl, buf, &len, NULL, 0) == 0)
goto unpack;
if (errno != ENOMEM) {
free(buf);
@ -94,3 +94,15 @@ kinfo_getvmobject(int *cntp)
*cntp = cnt;
return (list);
}
struct kinfo_vmobject *
kinfo_getvmobject(int *cntp)
{
return (kinfo_getvmobject_impl(cntp, "vm.objects"));
}
struct kinfo_vmobject *
kinfo_getswapvmobject(int *cntp)
{
return (kinfo_getvmobject_impl(cntp, "vm.swap_objects"));
}

View File

@ -109,6 +109,8 @@ struct kinfo_vmentry *
kinfo_getvmmap(pid_t _pid, int *_cntp);
struct kinfo_vmobject *
kinfo_getvmobject(int *_cntp);
struct kinfo_vmobject *
kinfo_getswapvmobject(int *_cntp);
struct kinfo_proc *
kinfo_getallproc(int *_cntp);
struct kinfo_proc *