From nobody Mon Nov 01 00:46:00 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7456F1829957; Mon, 1 Nov 2021 00:46:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjDqF0p72z4dBC; Mon, 1 Nov 2021 00:46:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B7F4A27D1A; Mon, 1 Nov 2021 00:46:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A10k0Kf005188; Mon, 1 Nov 2021 00:46:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A10k0KU005187; Mon, 1 Nov 2021 00:46:00 GMT (envelope-from git) Date: Mon, 1 Nov 2021 00:46:00 GMT Message-Id: <202111010046.1A10k0KU005187@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: cfccf3baca5c - stable/13 - libutil: add kinfo_getswapvmobject(3) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cfccf3baca5c26feb9fb4b72a980ea85d3f4f810 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=cfccf3baca5c26feb9fb4b72a980ea85d3f4f810 commit cfccf3baca5c26feb9fb4b72a980ea85d3f4f810 Author: Konstantin Belousov AuthorDate: 2021-10-26 08:40:10 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-01 00:44:51 +0000 libutil: add kinfo_getswapvmobject(3) (cherry picked from commit f2069331e5821f4c2b65d82af2809946a34158d2) --- lib/libutil/kinfo_getvmobject.c | 20 ++++++++++++++++---- lib/libutil/libutil.h | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/libutil/kinfo_getvmobject.c b/lib/libutil/kinfo_getvmobject.c index de55650a518b..4bf666fd7f3b 100644 --- a/lib/libutil/kinfo_getvmobject.c +++ b/lib/libutil/kinfo_getvmobject.c @@ -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 @@ unpack: *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")); +} diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h index bb96b2caa502..17c44de0fce7 100644 --- a/lib/libutil/libutil.h +++ b/lib/libutil/libutil.h @@ -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 *