summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-03-02 13:07:47 +0000
committerCorinna Vinschen <corinna@vinschen.de>2004-03-02 13:07:47 +0000
commit7cdd029300f70e30295ad0d06557c73ea121c339 (patch)
tree2cd244e5c6273be2718886f616391e7fba1ffed1 /winsup/cygwin
parentddb1a4c10afbf2e9af6047d7e844c9d0330dbaa0 (diff)
downloadcygnal-7cdd029300f70e30295ad0d06557c73ea121c339.tar.gz
cygnal-7cdd029300f70e30295ad0d06557c73ea121c339.tar.bz2
cygnal-7cdd029300f70e30295ad0d06557c73ea121c339.zip
* 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.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/fhandler_raw.cc37
-rw-r--r--winsup/cygwin/fhandler_tape.cc1
3 files changed, 36 insertions, 11 deletions
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 <corinna@vinschen.de>
+
+ * 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 <ford@vss.fsi.com>
* 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);
}