acme: apply nemos acmediskread patch (from sources)
pread does not guarantee that it would read all the data asked for. But acme usage of disk assumes that. This issues as many reads as needed to make acme work when read returns less data than it wanted.
This commit is contained in:
parent
389d6a1054
commit
3174ffc971
1 changed files with 11 additions and 1 deletions
|
@ -120,10 +120,20 @@ diskwrite(Disk *d, Block **bp, Rune *r, uint n)
|
|||
void
|
||||
diskread(Disk *d, Block *b, Rune *r, uint n)
|
||||
{
|
||||
int tot, nr;
|
||||
char *p;
|
||||
|
||||
if(n > b->n)
|
||||
error("internal error: diskread");
|
||||
|
||||
ntosize(b->n, nil);
|
||||
if(pread(d->fd, r, n*sizeof(Rune), b->addr) != n*sizeof(Rune))
|
||||
n *= sizeof(Rune);
|
||||
p = (char*)r;
|
||||
for(tot = 0; tot < n; tot += nr){
|
||||
nr = pread(d->fd, p+tot, n-tot, b->addr+tot);
|
||||
if(nr <= 0)
|
||||
error("read error from temp file");
|
||||
}
|
||||
if(tot != n)
|
||||
error("read error from temp file");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue