summaryrefslogtreecommitdiff
path: root/lib/libkvm
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-01-21 22:18:01 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-01-21 22:18:01 +0000
commit344d1fb456e115c821a26586a85d9e3f058aff7a (patch)
treea77feb9cc9770c05a8cba002402f82734e8347b7 /lib/libkvm
parentebcf515942389f0e738f6323c8b553ceabee63f1 (diff)
All operation on live kernels uses sysctl interface, there is no reason to
access the swap area. Change kvm_open() to no longer require a swap area, and to not consider failure to open() it as fatal. Post-mortem analysis would need an image of the swap area at the time of the crash, anyway.
Diffstat (limited to 'lib/libkvm')
-rw-r--r--lib/libkvm/kvm.c8
-rw-r--r--lib/libkvm/kvm_open.39
-rw-r--r--lib/libkvm/kvm_proc.c7
3 files changed, 10 insertions, 14 deletions
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index 393dd5971db..c8b5fd333b4 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm.c,v 1.45 2006/03/31 03:59:40 deraadt Exp $ */
+/* $OpenBSD: kvm.c,v 1.46 2009/01/21 22:18:00 miod Exp $ */
/* $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94";
#else
-static char *rcsid = "$OpenBSD: kvm.c,v 1.45 2006/03/31 03:59:40 deraadt Exp $";
+static char *rcsid = "$OpenBSD: kvm.c,v 1.46 2009/01/21 22:18:00 miod Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -213,8 +213,6 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, const char *sf,
}
if (mf == 0)
mf = _PATH_MEM;
- if (sf == 0)
- sf = _PATH_DRUM;
if ((kd->pmfd = open(mf, flag, 0)) < 0) {
_kvm_syserr(kd, kd->program, "%s", mf);
@@ -241,7 +239,7 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, const char *sf,
goto failed;
}
kd->alive = 1;
- if ((kd->swfd = open(sf, flag, 0)) < 0) {
+ if (sf != NULL && (kd->swfd = open(sf, flag, 0)) < 0) {
_kvm_syserr(kd, kd->program, "%s", sf);
goto failed;
}
diff --git a/lib/libkvm/kvm_open.3 b/lib/libkvm/kvm_open.3
index ad8b8101908..d5c27805b07 100644
--- a/lib/libkvm/kvm_open.3
+++ b/lib/libkvm/kvm_open.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: kvm_open.3,v 1.12 2007/05/31 19:19:35 jmc Exp $
+.\" $OpenBSD: kvm_open.3,v 1.13 2009/01/21 22:18:00 miod Exp $
.\" $NetBSD: kvm_open.3,v 1.2 1996/03/18 22:33:52 thorpej Exp $
.\"
.\" Copyright (c) 1992, 1993
@@ -34,7 +34,7 @@
.\"
.\" @(#)kvm_open.3 8.3 (Berkeley) 4/19/94
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: January 21 2009 $
.Dt KVM_OPEN 3
.Os
.Sh NAME
@@ -96,10 +96,7 @@ is used.
should indicate the swap device.
If
.Dv NULL ,
-.Dv _PATH_DRUM
-from
-.Aq Pa paths.h
-is used.
+no swap device will be used.
.Pp
The
.Fa flags
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index eea2060cfce..a38ce59087d 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_proc.c,v 1.36 2008/06/26 05:42:05 ray Exp $ */
+/* $OpenBSD: kvm_proc.c,v 1.37 2009/01/21 22:18:00 miod Exp $ */
/* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
#if 0
static char sccsid[] = "@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93";
#else
-static char *rcsid = "$OpenBSD: kvm_proc.c,v 1.36 2008/06/26 05:42:05 ray Exp $";
+static char *rcsid = "$OpenBSD: kvm_proc.c,v 1.37 2009/01/21 22:18:00 miod Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -231,7 +231,8 @@ _kvm_ureadm(kvm_t *kd, const struct miniproc *p, u_long va, u_long *cnt)
(size_t)kd->nbpg, (off_t)pg.phys_addr) != kd->nbpg)
return (NULL);
} else {
- if (_kvm_pread(kd, kd->swfd, (void *)kd->swapspc,
+ if (kd->swfd == -1 ||
+ _kvm_pread(kd, kd->swfd, (void *)kd->swapspc,
(size_t)kd->nbpg,
(off_t)(anon.an_swslot * kd->nbpg)) != kd->nbpg)
return (NULL);