Maxime Villard <max%M00nBSD.net@localhost> writes:
> Well, looking at the code, it seems to me that _kvm_open() should be
> changed to keep /dev/ksyms open, the same way it keeps /dev/kmem open.
Agreed. This works fine for me, with and without /dev/ksyms present:
Index: lib/libkvm/kvm.c
===================================================================
RCS file: /cvsroot/src/lib/libkvm/kvm.c,v
retrieving revision 1.102
diff -u -u -r1.102 kvm.c
--- lib/libkvm/kvm.c 29 Mar 2016 06:51:40 -0000 1.102
+++ lib/libkvm/kvm.c 18 Jan 2018 12:41:56 -0000
@@ -322,15 +322,6 @@
strlcpy(kd->kernelname, uf, sizeof(kd->kernelname));
} else {
strlcpy(kd->kernelname, _PATH_KSYMS, sizeof(kd->kernelname));
- /*
- * We're here because /dev/ksyms was opened
- * successfully. However, we don't want to keep it
- * open, so we close it now. Later, we will open
- * it again, since it will be the only case where
- * kd->nlfd is negative.
- */
- close(kd->nlfd);
- kd->nlfd = -1;
}
if ((kd->pmfd = open(mf, flag | O_CLOEXEC, 0)) < 0) {
@@ -769,33 +760,16 @@
int
kvm_nlist(kvm_t *kd, struct nlist *nl)
{
- int rv, nlfd;
-
- /*
- * kd->nlfd might be negative when we get here, and in that
- * case that means that we're using /dev/ksyms.
- * So open it again, just for the time we retrieve the list.
- */
- if (kd->nlfd < 0) {
- nlfd = open(_PATH_KSYMS, O_RDONLY | O_CLOEXEC, 0);
- if (nlfd < 0) {
- _kvm_err(kd, 0, "failed to open %s", _PATH_KSYMS);
- return (nlfd);
- }
- } else
- nlfd = kd->nlfd;
+ int rv;
/*
* Call the nlist(3) routines to retrieve the given namelist.
*/
- rv = __fdnlist(nlfd, nl);
+ rv = __fdnlist(kd->nlfd, nl);
if (rv == -1)
_kvm_err(kd, 0, "bad namelist");
- if (kd->nlfd < 0)
- close(nlfd);
-
return (rv);
}
-tih
--
Most people who graduate with CS degrees don't understand the significance
of Lisp. Lisp is the most important idea in computer science. --Alan Kay
Attachment:
signature.asc
Description: PGP signature