DragonFly submit List (threaded) for 2007-11
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
[patch] teach libkvm not to assume /dev/mem
This patch brings in a couple of trivial changes from freebsd that allow me to
use kgdb on /dev/fwmem0.0 (unfortunately, when using fwmem kgdb returns
nonsensical values for some variables, expected values for others and fails
to access some valid addresses). It also fixes what I think is an obvious
typo (vmfd -> pmfd).
Please apply,
Aggelos
Index: lib/libkvm/kvm.c
===================================================================
RCS file: /home/aggelos/imports/vcs/dcvs/src/lib/libkvm/kvm.c,v
retrieving revision 1.10
diff -u -r1.10 kvm.c
--- lib/libkvm/kvm.c 29 Apr 2007 01:36:04 -0000 1.10
+++ lib/libkvm/kvm.c 11 Nov 2007 15:55:14 -0000
@@ -167,6 +167,11 @@
_kvm_syserr(kd, kd->program, "%s", mf);
goto failed;
}
+ if (S_ISREG(st.st_mode) && st.st_size <= 0) {
+ errno = EINVAL;
+ _kvm_syserr(kd, kd->program, "empty file");
+ goto failed;
+ }
if (fcntl(kd->pmfd, F_SETFD, FD_CLOEXEC) < 0) {
_kvm_syserr(kd, kd->program, "%s", mf);
goto failed;
@@ -180,10 +185,6 @@
*/
if (strcmp(mf, _PATH_DEVNULL) == 0) {
kd->vmfd = 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;
} else {
if ((kd->vmfd = open(_PATH_KMEM, flag)) < 0) {
_kvm_syserr(kd, kd->program, "%s", _PATH_KMEM);
@@ -458,7 +459,7 @@
return NULL;
}
}
- cc = read(kd->vmfd, &ch, 1);
+ cc = read(kd->pmfd, &ch, 1);
if ((ssize_t)cc < 0) {
_kvm_syserr(kd, 0, "kvm_readstr");
return NULL;
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]