diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2004-03-26 21:43:49 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2004-03-26 21:43:49 +0000 |
commit | dee563095deb2bbdba5d4e04e48c99694061e302 (patch) | |
tree | a2134a3b338c171f09e28111b883621f712b3bd1 /winsup/cygwin/fhandler_raw.cc | |
parent | 359b6e4c49105718a9ff5341172685d98790dd7e (diff) | |
download | newlib-dee563095deb2bbdba5d4e04e48c99694061e302.zip newlib-dee563095deb2bbdba5d4e04e48c99694061e302.tar.gz newlib-dee563095deb2bbdba5d4e04e48c99694061e302.tar.bz2 |
* errno.cc (errmap): Map ERROR_SHARING_VIOLATION to EBUSY,
ERROR_EOM_OVERFLOW and ERROR_NO_DATA_DETECTED to EIO. Add mappings
for ERROR_NO_MEDIA_IN_DRIVE, ERROR_DEVICE_REQUIRES_CLEANING and
ERROR_DEVICE_DOOR_OPEN.
* fhandler.h (class fhandler_dev_raw): Drop varblkop member.
(fhandler_dev_raw::is_eom): De-virtualize.
(fhandler_dev_raw::is_eof): Ditto.
(class fhandler_dev_tape): Drop lasterr and dp member. Add mt_mtx
member. Drop all private methods formerly used by ioctl.
(fhandler_dev_tape::is_rewind_device): Use get_minor for clarity.
(fhandler_dev_tape::driveno): New method.
(fhandler_dev_tape::drive_init): New method.
(fhandler_dev_tape::clear): Remove method.
(fhandler_dev_tape::is_eom): Ditto.
(fhandler_dev_tape::is_eof): Ditto.
(fhandler_dev_tape::write_file): Ditto.
(fhandler_dev_tape::read_file): Ditto.
(fhandler_dev_tape::_lock): New method.
(fhandler_dev_tape::unlock): New method.
(fhandler_dev_tape::raw_read): New method.
(fhandler_dev_tape::raw_write): New method.
* fhandler_raw.cc (fhandler_dev_raw::is_eom): New method.
(fhandler_dev_raw::is_eof): New method.
(fhandler_dev_raw::open): Allow setting write through option by
using the O_TEXT flag as ... flag.
(fhandler_dev_raw::writebuf): Remove usage of varblkop and other
tape specific code.
(fhandler_dev_raw::raw_read): Ditto.
(fhandler_dev_raw::dup): Ditto.
* fhandler_tape.cc: Rewrite tape operations entirely. Implement
new tape driver classes mtinfo, mtinfo_drive and mtinfo_part.
Reduce fhandler_dev_tape methods to mostly just calling appropriate
mtinfo_drive methods.
(mtinfo_init): New function adding the mtinfo shared memory area.
* mtinfo.h: New file, containing the definition of the new tape
driver classes.
* shared.cc: Include mtinfo.h.
(offsets): Add entry for mtinfo shared memory area.
(memory_init): Call mtinfo_init.
* shared_info.h (shared_locations): Add SH_MTINFO shared location.
* include/cygwin/mtio.h: Change and add various comments. Add GMT_xxx
macros for new generic flags. Add MT_ST_xxx bitfield definitions
for MTSETDRVBUFFER ioctl.
* include/cygwin/version.h: Bump API minor version number.
Diffstat (limited to 'winsup/cygwin/fhandler_raw.cc')
-rw-r--r-- | winsup/cygwin/fhandler_raw.cc | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 93356ab..44c4495 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -37,9 +37,21 @@ fhandler_dev_raw::clear (void) eom_detected = 0; eof_detected = 0; lastblk_to_read = 0; - varblkop = 0; } +int +fhandler_dev_raw::is_eom (int win_error) +{ + return 0; +} + +int +fhandler_dev_raw::is_eof (int) +{ + return 0; +} + + /* Wrapper functions to allow fhandler_dev_tape to detect and care for media changes and bus resets. */ @@ -76,16 +88,13 @@ fhandler_dev_raw::writebuf (void) DWORD written; int ret = 0; - if (!varblkop && is_writing && devbuf && devbufend) + if (is_writing && devbuf && devbufend) { DWORD to_write; int ret = 0; memset (devbuf + devbufend, 0, devbufsiz - devbufend); - if (get_major () != DEV_TAPE_MAJOR) - to_write = ((devbufend - 1) / 512 + 1) * 512; - else - to_write = devbufsiz; + to_write = ((devbufend - 1) / 512 + 1) * 512; if (!write_file (devbuf, to_write, &written, &ret) && is_eom (ret)) eom_detected = 1; @@ -141,7 +150,7 @@ fhandler_dev_raw::open (int flags, mode_t) } /* Check for illegal flags. */ - if (flags & (O_APPEND | O_EXCL)) + if (get_major () != DEV_TAPE_MAJOR && (flags & (O_APPEND | O_EXCL))) { set_errno (EINVAL); return 0; @@ -162,11 +171,16 @@ fhandler_dev_raw::open (int flags, mode_t) WCHAR devname[CYG_MAX_PATH + 1]; str2buf2uni (dev, devname, get_win32_name ()); OBJECT_ATTRIBUTES attr; + ULONG options = FILE_SYNCHRONOUS_IO_NONALERT; + /* The O_TEXT flag is used to indicate write-through on tape devices */ + if (get_major () == DEV_TAPE_MAJOR && (flags & O_TEXT)) + options |= FILE_WRITE_THROUGH; + flags &= ~O_TEXT; InitializeObjectAttributes (&attr, &dev, OBJ_CASE_INSENSITIVE, NULL, NULL); HANDLE h; IO_STATUS_BLOCK io; - NTSTATUS status = NtOpenFile (&h, access, &attr, &io, wincap.shared (), + NTSTATUS status = NtOpenFile (&h, access, &attr, &io, 0 /* excl. access */, FILE_SYNCHRONOUS_IO_NONALERT); if (!NT_SUCCESS (status)) { @@ -234,7 +248,8 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen) { bytes_to_read = min (len, devbufend - devbufstart); debug_printf ("read %d bytes from buffer (rest %d)", - bytes_to_read, devbufend - devbufend); + bytes_to_read, + devbufend - devbufstart - bytes_to_read); memcpy (p, devbuf + devbufstart, bytes_to_read); len -= bytes_to_read; p += bytes_to_read; @@ -251,10 +266,7 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen) { if (len >= devbufsiz) { - if (get_major () == DEV_TAPE_MAJOR) - bytes_to_read = (len / devbufsiz) * devbufsiz; - else - bytes_to_read = (len / 512) * 512; + bytes_to_read = (len / 512) * 512; tgt = p; debug_printf ("read %d bytes direct from file",bytes_to_read); } @@ -310,11 +322,6 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen) { if (!is_eof (ret) && !is_eom (ret)) { - if (varblkop && ret == ERROR_MORE_DATA) - /* *ulen < blocksize. Linux returns ENOMEM here - when reading with variable blocksize . */ - set_errno (ENOMEM); - else __seterrno (); goto err; } @@ -470,7 +477,6 @@ fhandler_dev_raw::dup (fhandler_base *child) fhc->eom_detected = eom_detected; fhc->eof_detected = eof_detected; fhc->lastblk_to_read = 0; - fhc->varblkop = varblkop; } return ret; } |