diff options
author | 2002-06-08 22:31:24 +0000 | |
---|---|---|
committer | 2002-06-08 22:31:24 +0000 | |
commit | 2d420eaf8b38f5f0d8bbf9cb967a2ccf3028e93b (patch) | |
tree | 63d73870317617db6d5e94d67224c3d021752e7d /lib/libkvm/kvm.c | |
parent | Sysctl for getting process arguments and environment. (diff) | |
download | wireguard-openbsd-2d420eaf8b38f5f0d8bbf9cb967a2ccf3028e93b.tar.xz wireguard-openbsd-2d420eaf8b38f5f0d8bbf9cb967a2ccf3028e93b.zip |
Add a flag - KVM_NO_FILES which tells kvm_openfiles to not
open any files, just return an kvm handle that we can use to some
of the functions.
Diffstat (limited to 'lib/libkvm/kvm.c')
-rw-r--r-- | lib/libkvm/kvm.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c index 17684922068..4599cc48cfa 100644 --- a/lib/libkvm/kvm.c +++ b/lib/libkvm/kvm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm.c,v 1.30 2002/03/05 00:15:08 deraadt Exp $ */ +/* $OpenBSD: kvm.c,v 1.31 2002/06/08 22:31:24 art 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.30 2002/03/05 00:15:08 deraadt Exp $"; +static char *rcsid = "$OpenBSD: kvm.c,v 1.31 2002/06/08 22:31:24 art Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -191,6 +191,7 @@ _kvm_open(kd, uf, mf, sf, flag, errout) kd->vmfd = -1; kd->swfd = -1; kd->nlfd = -1; + kd->alive = 0; kd->procbase = 0; kd->nbpg = getpagesize(); kd->swapspc = 0; @@ -204,6 +205,11 @@ _kvm_open(kd, uf, mf, sf, flag, errout) kd->cpu_data = 0; kd->dump_off = 0; + if (flag & KVM_NO_FILES) { + kd->alive = 1; + return (kd); + } + if (uf && strlen(uf) >= MAXPATHLEN) { _kvm_err(kd, kd->program, "exec file name too long"); goto failed; @@ -241,6 +247,7 @@ _kvm_open(kd, uf, mf, sf, flag, errout) _kvm_syserr(kd, kd->program, "%s", _PATH_KMEM); goto failed; } + kd->alive = 1; if ((kd->swfd = open(sf, flag, 0)) < 0) { _kvm_syserr(kd, kd->program, "%s", sf); goto failed; @@ -641,6 +648,7 @@ kvm_close(kd) error |= close(kd->pmfd); if (kd->vmfd >= 0) error |= close(kd->vmfd); + kd->alive = 0; if (kd->nlfd >= 0) error |= close(kd->nlfd); if (kd->swfd >= 0) |