From: Corinna Vinschen Date: Mon, 21 May 2007 09:11:27 +0000 (+0000) Subject: * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Set buf size to X-Git-Tag: preoverlapped~130 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=b7a37e8d7cb7cbd6fc650b9b1c538a5e87032f0b;p=newlib-cygwin.git * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Set buf size to sector size. Simplify non-sector aligned case. Handle errors from raw_read. --- diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9da3832f3..f9f4aeab0 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2007-05-21 Christian Franke + Corinna Vinschen + + * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Set buf size to + sector size. Simplify non-sector aligned case. Handle errors from + raw_read. + 2007-05-15 Corinna Vinschen * fhandler_socket.cc (adjust_socket_file_mode): New inline function. diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index c4ebcc0ff..ee8d56b57 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -408,10 +408,10 @@ fhandler_dev_floppy::raw_write (const void *ptr, size_t len) _off64_t fhandler_dev_floppy::lseek (_off64_t offset, int whence) { - char buf[512]; + char buf[bytes_per_sector]; _off64_t lloffset = offset; LARGE_INTEGER sector_aligned_offset; - _off64_t bytes_left; + size_t bytes_left; if (whence == SEEK_END) { @@ -453,9 +453,11 @@ fhandler_dev_floppy::lseek (_off64_t offset, int whence) if (bytes_left) { - size_t len = bytes_left; - raw_read (buf, len); + raw_read (buf, bytes_left); + if (bytes_left == (size_t) -1) + return -1; } + return sector_aligned_offset.QuadPart + bytes_left; }