* 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.
This commit is contained in:
Corinna Vinschen 2004-03-02 13:07:47 +00:00
parent ddb1a4c10a
commit 7cdd029300
3 changed files with 36 additions and 11 deletions

View File

@ -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

View File

@ -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;
}
}
}

View File

@ -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);
}