+2007-05-21 Christian Franke <franke@computer.org>
+
+ * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Don't invalidate
+ devbuf if new position is within buffered range.
+
2007-05-21 Eric Blake <ebb9@byu.net>
* include/search.h (hsearch_r): Provide declaration.
{
char buf[bytes_per_sector];
_off64_t lloffset = offset;
+ _off64_t current_pos = (_off64_t) -1;
LARGE_INTEGER sector_aligned_offset;
size_t bytes_left;
}
else if (whence == SEEK_CUR)
{
- lloffset += get_current_position () - (devbufend - devbufstart);
+ current_pos = get_current_position ();
+ lloffset += current_pos - (devbufend - devbufstart);
whence = SEEK_SET;
}
return -1;
}
+ /* If new position is in buffered range, adjust buffer and return */
+ if (devbufstart < devbufend)
+ {
+ if (current_pos == (_off64_t) -1)
+ current_pos = get_current_position ();
+ if (current_pos - devbufend <= lloffset && lloffset <= current_pos)
+ {
+ devbufstart = devbufend - (current_pos - lloffset);
+ return lloffset;
+ }
+ }
+
sector_aligned_offset.QuadPart = (lloffset / bytes_per_sector)
* bytes_per_sector;
bytes_left = lloffset - sector_aligned_offset.QuadPart;