mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
do a better job with 64-bit files
This commit is contained in:
parent
75a69d3b20
commit
39ef727f46
1 changed files with 11 additions and 7 deletions
|
@ -5,6 +5,7 @@ off_t
|
|||
Bseek(Biobuf *bp, off_t offset, int base)
|
||||
{
|
||||
vlong n, d;
|
||||
int bufsz;
|
||||
|
||||
switch(bp->state) {
|
||||
default:
|
||||
|
@ -28,13 +29,16 @@ Bseek(Biobuf *bp, off_t offset, int base)
|
|||
*/
|
||||
if(base == 0) {
|
||||
d = n - Boffset(bp);
|
||||
bp->icount += d;
|
||||
if(d >= 0) {
|
||||
if(bp->icount <= 0)
|
||||
return n;
|
||||
} else {
|
||||
if(bp->ebuf - bp->gbuf >= -bp->icount)
|
||||
return n;
|
||||
bufsz = bp->ebuf - bp->gbuf;
|
||||
if(-bufsz <= d && d <= bufsz){
|
||||
bp->icount += d;
|
||||
if(d >= 0) {
|
||||
if(bp->icount <= 0)
|
||||
return n;
|
||||
} else {
|
||||
if(bp->ebuf - bp->gbuf >= -bp->icount)
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue