diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 203ffae9f..7ae7a4388 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2004-03-02 Corinna Vinschen + + * fhandler_raw.cc (fhandler_dev_raw::raw_read): When reading with + variable block size, read only one block, read directly into user + supplied buffer, return ENOMEM if user supplied buffer is smaller + than size of next block to read. Use read2 instead of bytes_to_read + to count number of bytes read. + * fhandler_tape.cc (fhandler_dev_tape::open): Add debug output. + 2004-02-26 Brian Ford * miscfuncs.cc (check_invalid_virtual_addr): Assure the last page diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index afa478b7f..8baa6ae09 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -275,21 +275,29 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen) tgt = (char *) ptr; debug_printf ("read %d bytes direct from file",bytes_to_read); } + else if (varblkop) + { + tgt = (char *) ptr; + bytes_to_read = len; + debug_printf ("read variable bytes direct from file"); + } else { - bytes_to_read = devbufsiz; tgt = devbuf; - if (varblkop) - debug_printf ("read variable bytes from file into buffer"); - else - debug_printf ("read %d bytes from file into buffer", - bytes_to_read); + bytes_to_read = devbufsiz; + debug_printf ("read %d bytes from file into buffer", + bytes_to_read); } if (!read_file (get_handle (), tgt, bytes_to_read, &read2, &ret)) { if (!is_eof (ret) && !is_eom (ret)) { - __seterrno (); + if (varblkop && ret == ERROR_MORE_DATA) + /* *ulen < blocksize. Linux returns ENOMEM here + when reading with variable blocksize . */ + set_errno (ENOMEM); + else + __seterrno (); goto err; } @@ -310,18 +318,25 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen) } lastblk_to_read = 1; } - if (! read2) + if (!read2) break; if (tgt == devbuf) { devbufstart = 0; devbufend = read2; } + else if (varblkop) + { + /* When reading tapes with variable block size, we + leave right after reading one block. */ + bytes_read = read2; + break; + } else { - len -= bytes_to_read; - ptr = (void *) ((char *) ptr + bytes_to_read); - bytes_read += bytes_to_read; + len -= read2; + ptr = (void *) ((char *) ptr + read2); + bytes_read += read2; } } } diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc index e63a1ba99..7d159dc66 100644 --- a/winsup/cygwin/fhandler_tape.cc +++ b/winsup/cygwin/fhandler_tape.cc @@ -90,6 +90,7 @@ fhandler_dev_tape::open (int flags, mode_t) * The call to tape_set_pos seems to reset some internal flags. */ if ((!ioctl (MTIOCPOS, &pos)) && (!pos.mt_blkno)) { + debug_printf ("rewinding"); op.mt_op = MTREW; ioctl (MTIOCTOP, &op); }