summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>1998-06-29 23:23:30 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>1998-06-29 23:23:30 +0000
commitbcc222ddd24328261c12397a94f5a7756ad1706a (patch)
tree5d7353190a09fc9176beb5a59d4aee80f3f15ce6
parent3a9b3acd3e783ff9ec6b7ce414b202b3ffcfb13e (diff)
Fix a couple of error return values that I shouldn't have changed,
add some more verbose error messages.
-rw-r--r--lib/libkvm/kvm.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index 2c3560ecf5e..bcc13805c00 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm.c,v 1.12 1998/06/29 22:39:12 angelos Exp $ */
+/* $OpenBSD: kvm.c,v 1.13 1998/06/29 23:23:29 angelos Exp $ */
/* $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $ */
/*-
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94";
#else
-static char *rcsid = "$OpenBSD: kvm.c,v 1.12 1998/06/29 22:39:12 angelos Exp $";
+static char *rcsid = "$OpenBSD: kvm.c,v 1.13 1998/06/29 23:23:29 angelos Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -639,7 +639,7 @@ kvm_openfiles(uf, mf, sf, flag, errout)
if ((kd = malloc(sizeof(*kd))) == NULL) {
(void)strncpy(errout, strerror(errno), _POSIX2_LINE_MAX - 1);
- return (-1);
+ return (0);
}
kd->program = 0;
return (_kvm_open(kd, uf, mf, sf, flag, errout));
@@ -657,7 +657,7 @@ kvm_open(uf, mf, sf, flag, program)
if ((kd = malloc(sizeof(*kd))) == NULL && program != NULL) {
(void)fprintf(stderr, "%s: %s\n", strerror(errno));
- return (-1);
+ return (0);
}
kd->program = program;
return (_kvm_open(kd, uf, mf, sf, flag, NULL));
@@ -719,7 +719,28 @@ kvm_dbopen(kd)
kd->db = dbopen(_PATH_KVMDB, O_RDONLY, 0, DB_HASH, NULL);
if (kd->db == 0)
- return (-1);
+ {
+ switch (errno)
+ {
+ case EFTYPE:
+ _kvm_err(kd, kd->program,
+ "file %s is incorrectly formatted",
+ _PATH_KVMDB);
+ break;
+ case EINVAL:
+ _kvm_err(kd, kd->program,
+ "invalid argument to dbopen()");
+ break;
+
+ default:
+ _kvm_err(kd, kd->program,
+ "unknown dbopen() error");
+ break;
+ }
+
+ return (-1);
+ }
+
/*
* read version out of database
*/
@@ -894,6 +915,7 @@ kvm_read(kd, kva, buf, len)
u_long pa;
off_t foff;
+ /* In case of error, _kvm_kvatop sets the err string */
cc = _kvm_kvatop(kd, kva, &pa);
if (cc == 0)
return (-1);