Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libkvm Keep /dev/ksyms open in _kvm_open(). This way /de...
details: https://anonhg.NetBSD.org/src/rev/191592a49793
branches: trunk
changeset: 359347:191592a49793
user: maxv <maxv%NetBSD.org@localhost>
date: Wed Feb 07 14:03:18 2018 +0000
description:
Keep /dev/ksyms open in _kvm_open(). This way /dev/ksyms can be put into
$g_kmem without breaking the tools that need kmem+ksyms.
Discussed on tech-kern@ three weeks ago. The original issue was reported
by maya@, the patch was written by Tom Ivar Helbekkmo, ok christos@.
diffstat:
lib/libkvm/kvm.c | 34 ++++------------------------------
1 files changed, 4 insertions(+), 30 deletions(-)
diffs (70 lines):
diff -r 166fc55f2690 -r 191592a49793 lib/libkvm/kvm.c
--- a/lib/libkvm/kvm.c Wed Feb 07 13:22:41 2018 +0000
+++ b/lib/libkvm/kvm.c Wed Feb 07 14:03:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm.c,v 1.102 2016/03/29 06:51:40 mrg Exp $ */
+/* $NetBSD: kvm.c,v 1.103 2018/02/07 14:03:18 maxv Exp $ */
/*-
* Copyright (c) 1989, 1992, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94";
#else
-__RCSID("$NetBSD: kvm.c,v 1.102 2016/03/29 06:51:40 mrg Exp $");
+__RCSID("$NetBSD: kvm.c,v 1.103 2018/02/07 14:03:18 maxv Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -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);
}
Home |
Main Index |
Thread Index |
Old Index