Change the return value of kvm_read/kvm_write to be -1 on error, to

match the documented interface.

Previously it returned 0 on error.

PR:		bin/10511
This commit is contained in:
Jacques Vidrine 2000-03-31 15:04:25 +00:00
parent 07aa6ef0c9
commit 91a594d823

View File

@ -375,12 +375,12 @@ kvm_read(kd, kva, buf, len)
errno = 0; errno = 0;
if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) { if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) {
_kvm_err(kd, 0, "invalid address (%x)", kva); _kvm_err(kd, 0, "invalid address (%x)", kva);
return (0); return (-1);
} }
cc = read(kd->vmfd, buf, len); cc = read(kd->vmfd, buf, len);
if (cc < 0) { if (cc < 0) {
_kvm_syserr(kd, 0, "kvm_read"); _kvm_syserr(kd, 0, "kvm_read");
return (0); return (-1);
} else if (cc < len) } else if (cc < len)
_kvm_err(kd, kd->program, "short read"); _kvm_err(kd, kd->program, "short read");
return (cc); return (cc);
@ -391,7 +391,7 @@ kvm_read(kd, kva, buf, len)
cc = _kvm_kvatop(kd, kva, &pa); cc = _kvm_kvatop(kd, kva, &pa);
if (cc == 0) if (cc == 0)
return (0); return (-1);
if (cc > len) if (cc > len)
cc = len; cc = len;
errno = 0; errno = 0;
@ -437,19 +437,19 @@ kvm_write(kd, kva, buf, len)
errno = 0; errno = 0;
if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) { if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) {
_kvm_err(kd, 0, "invalid address (%x)", kva); _kvm_err(kd, 0, "invalid address (%x)", kva);
return (0); return (-1);
} }
cc = write(kd->vmfd, buf, len); cc = write(kd->vmfd, buf, len);
if (cc < 0) { if (cc < 0) {
_kvm_syserr(kd, 0, "kvm_write"); _kvm_syserr(kd, 0, "kvm_write");
return (0); return (-1);
} else if (cc < len) } else if (cc < len)
_kvm_err(kd, kd->program, "short write"); _kvm_err(kd, kd->program, "short write");
return (cc); return (cc);
} else { } else {
_kvm_err(kd, kd->program, _kvm_err(kd, kd->program,
"kvm_write not implemented for dead kernels"); "kvm_write not implemented for dead kernels");
return (0); return (-1);
} }
/* NOTREACHED */ /* NOTREACHED */
} }