mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 09:10:28 +00:00
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:
parent
07aa6ef0c9
commit
91a594d823
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=58870
|
@ -375,12 +375,12 @@ kvm_read(kd, kva, buf, len)
|
|||
errno = 0;
|
||||
if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) {
|
||||
_kvm_err(kd, 0, "invalid address (%x)", kva);
|
||||
return (0);
|
||||
return (-1);
|
||||
}
|
||||
cc = read(kd->vmfd, buf, len);
|
||||
if (cc < 0) {
|
||||
_kvm_syserr(kd, 0, "kvm_read");
|
||||
return (0);
|
||||
return (-1);
|
||||
} else if (cc < len)
|
||||
_kvm_err(kd, kd->program, "short read");
|
||||
return (cc);
|
||||
|
@ -391,7 +391,7 @@ kvm_read(kd, kva, buf, len)
|
|||
|
||||
cc = _kvm_kvatop(kd, kva, &pa);
|
||||
if (cc == 0)
|
||||
return (0);
|
||||
return (-1);
|
||||
if (cc > len)
|
||||
cc = len;
|
||||
errno = 0;
|
||||
|
@ -437,19 +437,19 @@ kvm_write(kd, kva, buf, len)
|
|||
errno = 0;
|
||||
if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) {
|
||||
_kvm_err(kd, 0, "invalid address (%x)", kva);
|
||||
return (0);
|
||||
return (-1);
|
||||
}
|
||||
cc = write(kd->vmfd, buf, len);
|
||||
if (cc < 0) {
|
||||
_kvm_syserr(kd, 0, "kvm_write");
|
||||
return (0);
|
||||
return (-1);
|
||||
} else if (cc < len)
|
||||
_kvm_err(kd, kd->program, "short write");
|
||||
return (cc);
|
||||
} else {
|
||||
_kvm_err(kd, kd->program,
|
||||
"kvm_write not implemented for dead kernels");
|
||||
return (0);
|
||||
return (-1);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue