diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-08-19 18:54:49 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-08-19 18:54:49 +0000 |
commit | 1f1c73524add8181e3f63eebdebc2fb3aa31e62d (patch) | |
tree | 1cb6a547bfdae658f1ab7cc69e830f8211608133 /lib/libkvm.old/kvm.c | |
parent | de4b811be36d2813412918d0347076bebcd94114 (diff) |
Don't print 'unknown dbopen() error' when kvm_bsd.db doesn't exist
Print sane error message when __fdnlist() fails
Diffstat (limited to 'lib/libkvm.old/kvm.c')
-rw-r--r-- | lib/libkvm.old/kvm.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/libkvm.old/kvm.c b/lib/libkvm.old/kvm.c index 4e1ab390da2..9e692160a0f 100644 --- a/lib/libkvm.old/kvm.c +++ b/lib/libkvm.old/kvm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm.c,v 1.8 1998/06/29 23:25:44 angelos Exp $ */ +/* $OpenBSD: kvm.c,v 1.9 1998/08/19 18:54:48 millert Exp $ */ /* $NetBSD: kvm.c,v 1.2 1996/05/13 02:30:22 thorpej Exp $ */ /*- @@ -371,6 +371,9 @@ kvm_dbopen(kd, uf) { switch (errno) { + case ENOENT: + /* No kvm_bsd.db, fall back to /bsd silently */ + break; case EFTYPE: _kvm_err(kd, kd->program, "file %s is incorrectly formatted", @@ -436,14 +439,18 @@ kvm_nlist(kd, nl) struct nlist *nl; { register struct nlist *p; - register int nvalid; + register int nvalid, rv; /* * If we can't use the data base, revert to the * slow library call. */ - if (kd->db == 0) - return (__fdnlist(kd->nlfd, nl)); + if (kd->db == 0) { + rv = __fdnlist(kd->nlfd, nl); + if (rv == -1) + _kvm_err(kd, 0, "bad namelist"); + return (rv); + } /* * We can use the kvm data base. Go through each nlist entry @@ -461,6 +468,12 @@ kvm_nlist(kd, nl) } rec.data = p->n_name; rec.size = len; + + /* + * Make sure that n_value = 0 when the symbol isn't found + */ + p->n_value = 0; + if ((kd->db->get)(kd->db, (DBT *)&rec, (DBT *)&rec, 0)) continue; if (rec.data == 0 || rec.size != sizeof(struct nlist)) |