* fhandler.h (class fhandler_dev_raw): Remove is_writing flag.
Remove declaration of writebuf. (class fhandler_dev_floppy): Remove declaration of close. * fhandler_floppy.cc (fhandler_dev_floppy::close): Delete. (fhandler_dev_floppy::lseek): Remove calls to writebuf. Set eom_detected to false after successful seek. * fhandler_raw.cc (fhandler_dev_raw::writebuf): Delete. (fhandler_dev_raw::raw_read): Remove calls to writebuf. (fhandler_dev_raw::raw_write): Always invalidate buffer.
This commit is contained in:
parent
fcedcf9488
commit
4243412aa5
|
@ -1,3 +1,15 @@
|
|||
2004-07-15 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler.h (class fhandler_dev_raw): Remove is_writing flag.
|
||||
Remove declaration of writebuf.
|
||||
(class fhandler_dev_floppy): Remove declaration of close.
|
||||
* fhandler_floppy.cc (fhandler_dev_floppy::close): Delete.
|
||||
(fhandler_dev_floppy::lseek): Remove calls to writebuf. Set
|
||||
eom_detected to false after successful seek.
|
||||
* fhandler_raw.cc (fhandler_dev_raw::writebuf): Delete.
|
||||
(fhandler_dev_raw::raw_read): Remove calls to writebuf.
|
||||
(fhandler_dev_raw::raw_write): Always invalidate buffer.
|
||||
|
||||
2004-07-15 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* mmap.cc (class mmap_record): Fix return type of get_offset.
|
||||
|
|
|
@ -482,22 +482,19 @@ class fhandler_dev_raw: public fhandler_base
|
|||
unsigned eom_detected : 1;
|
||||
unsigned eof_detected : 1;
|
||||
unsigned lastblk_to_read : 1;
|
||||
unsigned is_writing : 1;
|
||||
public:
|
||||
status_flags () :
|
||||
eom_detected (0), eof_detected (0), lastblk_to_read (0), is_writing (0)
|
||||
eom_detected (0), eof_detected (0), lastblk_to_read (0)
|
||||
{}
|
||||
} status;
|
||||
|
||||
IMPLEMENT_STATUS_FLAG (bool, eom_detected)
|
||||
IMPLEMENT_STATUS_FLAG (bool, eof_detected)
|
||||
IMPLEMENT_STATUS_FLAG (bool, lastblk_to_read)
|
||||
IMPLEMENT_STATUS_FLAG (bool, is_writing)
|
||||
|
||||
virtual BOOL write_file (const void *buf, DWORD to_write,
|
||||
DWORD *written, int *err);
|
||||
virtual BOOL read_file (void *buf, DWORD to_read, DWORD *read, int *err);
|
||||
virtual int writebuf (void);
|
||||
|
||||
/* returns not null, if `win_error' determines an end of media condition */
|
||||
virtual int is_eom(int win_error);
|
||||
|
@ -535,7 +532,6 @@ class fhandler_dev_floppy: public fhandler_dev_raw
|
|||
fhandler_dev_floppy ();
|
||||
|
||||
virtual int open (int flags, mode_t mode = 0);
|
||||
virtual int close (void);
|
||||
|
||||
virtual _off64_t lseek (_off64_t offset, int whence);
|
||||
|
||||
|
|
|
@ -66,20 +66,6 @@ fhandler_dev_floppy::open (int flags, mode_t)
|
|||
return fhandler_dev_raw::open (flags);
|
||||
}
|
||||
|
||||
int
|
||||
fhandler_dev_floppy::close (void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = writebuf ();
|
||||
if (ret)
|
||||
{
|
||||
fhandler_dev_raw::close ();
|
||||
return ret;
|
||||
}
|
||||
return fhandler_dev_raw::close ();
|
||||
}
|
||||
|
||||
_off64_t
|
||||
fhandler_dev_floppy::lseek (_off64_t offset, int whence)
|
||||
{
|
||||
|
@ -144,10 +130,8 @@ fhandler_dev_floppy::lseek (_off64_t offset, int whence)
|
|||
return -1;
|
||||
}
|
||||
current_position = low + ((_off64_t) high << 32);
|
||||
if (is_writing ())
|
||||
current_position += devbufend - devbufstart;
|
||||
else
|
||||
current_position -= devbufend - devbufstart;
|
||||
/* devbufend and devbufstart are always 0 when writing. */
|
||||
current_position -= devbufend - devbufstart;
|
||||
|
||||
lloffset += current_position;
|
||||
whence = SEEK_SET;
|
||||
|
@ -167,9 +151,6 @@ fhandler_dev_floppy::lseek (_off64_t offset, int whence)
|
|||
if (whence == SEEK_SET)
|
||||
{
|
||||
/* Invalidate buffer. */
|
||||
ret = writebuf ();
|
||||
if (ret)
|
||||
return ret;
|
||||
devbufstart = devbufend = 0;
|
||||
|
||||
low = sector_aligned_offset & UINT32_MAX;
|
||||
|
@ -181,6 +162,7 @@ fhandler_dev_floppy::lseek (_off64_t offset, int whence)
|
|||
return -1;
|
||||
}
|
||||
|
||||
eom_detected (false);
|
||||
size_t len = bytes_left;
|
||||
raw_read (buf, len);
|
||||
return sector_aligned_offset + bytes_left;
|
||||
|
|
|
@ -40,8 +40,7 @@ fhandler_dev_raw::is_eof (int)
|
|||
}
|
||||
|
||||
|
||||
/* Wrapper functions to allow fhandler_dev_tape to detect and care for
|
||||
media changes and bus resets. */
|
||||
/* Wrapper functions to simplify error handling. */
|
||||
|
||||
BOOL
|
||||
fhandler_dev_raw::write_file (const void *buf, DWORD to_write,
|
||||
|
@ -70,28 +69,6 @@ fhandler_dev_raw::read_file (void *buf, DWORD to_read, DWORD *read, int *err)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
fhandler_dev_raw::writebuf (void)
|
||||
{
|
||||
DWORD written;
|
||||
int ret = 0;
|
||||
|
||||
if (is_writing () && devbuf && devbufend)
|
||||
{
|
||||
DWORD to_write;
|
||||
int ret = 0;
|
||||
|
||||
memset (devbuf + devbufend, 0, devbufsiz - devbufend);
|
||||
to_write = ((devbufend - 1) / 512 + 1) * 512;
|
||||
if (!write_file (devbuf, to_write, &written, &ret)
|
||||
&& is_eom (ret))
|
||||
eom_detected (true);
|
||||
devbufstart = devbufend = 0;
|
||||
}
|
||||
is_writing (false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
fhandler_dev_raw::fhandler_dev_raw ()
|
||||
: fhandler_base (), status ()
|
||||
{
|
||||
|
@ -172,17 +149,6 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen)
|
|||
char *tgt;
|
||||
char *p = (char *) ptr;
|
||||
|
||||
/* In mode O_RDWR the buffer has to be written to device first */
|
||||
ret = writebuf ();
|
||||
if (ret)
|
||||
{
|
||||
if (is_eom (ret))
|
||||
set_errno (ENOSPC);
|
||||
else
|
||||
__seterrno ();
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Checking a previous end of file */
|
||||
if (eof_detected () && !lastblk_to_read ())
|
||||
{
|
||||
|
@ -320,9 +286,8 @@ fhandler_dev_raw::raw_write (const void *ptr, size_t len)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!is_writing ())
|
||||
devbufstart = devbufend = 0;
|
||||
is_writing (true);
|
||||
/* Invalidate buffer. */
|
||||
devbufstart = devbufend = 0;
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue