diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 907f46b8c..4e813d43d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2008-10-09 Corinna Vinschen + + * fhandler_floppy.cc (fhandler_dev_floppy::raw_read): Keep track of + current position in non-buffered case, too. + 2008-10-09 Corinna Vinschen * grp.cc (pwdgrp::read_group): Generate more speaking group name diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index f0e19c952..9e19b52aa 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -338,20 +338,26 @@ fhandler_dev_floppy::raw_read (void *ptr, size_t& ulen) } } } - else if (!read_file (p, len, &bytes_read, &ret)) + else { - if (!IS_EOM (ret)) + _off64_t current_position = get_current_position (); + if (current_position + bytes_to_read >= drive_size) + bytes_to_read = drive_size - current_position; + if (bytes_to_read && !read_file (p, len, &bytes_read, &ret)) { - __seterrno (); - goto err; - } - if (bytes_read) - eom_detected (true); - else - { - debug_printf ("return -1, set errno to ENOSPC"); - set_errno (ENOSPC); - goto err; + if (!IS_EOM (ret)) + { + __seterrno (); + goto err; + } + if (bytes_read) + eom_detected (true); + else + { + debug_printf ("return -1, set errno to ENOSPC"); + set_errno (ENOSPC); + goto err; + } } }