diff options
author | phk <phk@FreeBSD.org> | 1998-06-30 21:29:44 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-06-30 21:29:44 +0000 |
commit | 6658078ab314ed6133739f3639793c8fde5b5a71 (patch) | |
tree | d11fac9f99243c98cb111f66972d82594c86d5fd /lib/libkvm/kvm.c | |
parent | 107b074e2348937933283de1a7851d864a95ff23 (diff) | |
download | FreeBSD-src-6658078ab314ed6133739f3639793c8fde5b5a71.zip FreeBSD-src-6658078ab314ed6133739f3639793c8fde5b5a71.tar.gz |
Allow /dev/null as path for the "/dev/mem" file, and assume that people
know what they're doing if they do that. This will allow ps to use
the kvm_proc.c bits without having access to /dev/mem.
Fix kvm_proc.c to not need /dev/mem for access to argv/envp
Diffstat (limited to 'lib/libkvm/kvm.c')
-rw-r--r-- | lib/libkvm/kvm.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c index a2ea42a..f8aaab5 100644 --- a/lib/libkvm/kvm.c +++ b/lib/libkvm/kvm.c @@ -212,18 +212,22 @@ _kvm_open(kd, uf, mf, sf, flag, errout) * make it work for either /dev/mem or /dev/kmem -- in either * case you're working with a live kernel.) */ - if (strcmp(mf, _PATH_MEM) != 0) { /* XXX */ + if (strcmp(mf, _PATH_DEVNULL) == 0) { + kd->vmfd = open(_PATH_DEVNULL, O_RDONLY); + kd->swfd = open(_PATH_DEVNULL, O_RDONLY); + } else if (strcmp(mf, _PATH_MEM) != 0) { _kvm_err(kd, kd->program, "%s: not physical memory device", mf); goto failed; - } - if ((kd->vmfd = open(_PATH_KMEM, flag)) < 0) { - _kvm_syserr(kd, kd->program, "%s", _PATH_KMEM); - goto failed; - } - if ((kd->swfd = open(sf, flag, 0)) < 0) { - _kvm_syserr(kd, kd->program, "%s", sf); - goto failed; + } else { + if ((kd->vmfd = open(_PATH_KMEM, flag)) < 0) { + _kvm_syserr(kd, kd->program, "%s", _PATH_KMEM); + goto failed; + } + if ((kd->swfd = open(sf, flag, 0)) < 0) { + _kvm_syserr(kd, kd->program, "%s", sf); + goto failed; + } } /* * Open kvm nlist database. We go ahead and do this @@ -241,7 +245,7 @@ _kvm_open(kd, uf, mf, sf, flag, errout) } else { /* * This is a crash dump. - * Initalize the virtual address translation machinery, + * Initialize the virtual address translation machinery, * but first setup the namelist fd. */ if ((kd->nlfd = open(uf, O_RDONLY, 0)) < 0) { |