diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-10-13 12:34:18 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-10-13 12:34:18 +0000 |
commit | db8224e8be2d72a00e828a4af6db5cbd1853cebf (patch) | |
tree | b194832d0893c11dcb8dabb39279cffff002566b /winsup/cygwin/fhandler_raw.cc | |
parent | 93c9cdc1b0cf91b83c31e9bc52a2e94f07a79ad5 (diff) | |
download | newlib-db8224e8be2d72a00e828a4af6db5cbd1853cebf.zip newlib-db8224e8be2d72a00e828a4af6db5cbd1853cebf.tar.gz newlib-db8224e8be2d72a00e828a4af6db5cbd1853cebf.tar.bz2 |
* fhandler.h (class fhandler_dev_raw): Add members devbufalloc and
devbufalign.
(class fhandler_dev_floppy): Remove member bytes_per_sector;
* fhandler_floppy.cc (bytes_per_sector): Define as devbufalign.
(fhandler_dev_floppy::open): Set devbufalign to a multiple of the
sector size and handle devbuf allocation and alignment in !O_DIRECT
case here. Change comment accordingly.
Call FSCTL_ALLOW_EXTENDED_DASD_IO for partitions as well.
(fhandler_dev_floppy::raw_write): Fix comment. Rewrite and fix
writing behaviour when application uses read and lseek.
(fhandler_dev_floppy::lseek): Use rounddown macro. Call
SetFilePointerEx rather than the old SetFilePointer.
(fhandler_dev_floppy::ioctl): Reformat switch. Call
IOCTL_DISK_UPDATE_PROPERTIES rather than IOCTL_DISK_UPDATE_DRIVE_SIZE
in BLKRRPART case. Support BLKIOMIN, BLKIOOPT, BLKPBSZGET and
BLKALIGNOFF.
* fhandler_raw.cc (fhandler_dev_raw::fhandler_dev_raw): Initialize
all devbuf-related members.
(fhandler_dev_raw::~fhandler_dev_raw): Delete devbufalloc rather than
devbuf.
(fhandler_dev_raw::open): Drop allocating devbuf.
(fhandler_dev_raw::dup): Allocate devbufalloc and set devbuf to support
new sector-aligned devbuf handling.
(fhandler_dev_raw::fixup_after_exec): Ditto.
* fhandler_tape.cc (fhandler_dev_tape::open): Ditto, set devbufalign
to 1.
* include/cygwin/fs.h (BLKIOMIN): Define.
(BLKIOOPT): Define.
(BLKALIGNOFF): Define.
(BLKPBSZGET): Define.
Diffstat (limited to 'winsup/cygwin/fhandler_raw.cc')
-rw-r--r-- | winsup/cygwin/fhandler_raw.cc | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index a03f7aa..3054bc3 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -13,6 +13,7 @@ #include <cygwin/rdevio.h> #include <sys/mtio.h> +#include <sys/param.h> #include "cygerrno.h" #include "path.h" #include "fhandler.h" @@ -21,7 +22,14 @@ /* fhandler_dev_raw */ fhandler_dev_raw::fhandler_dev_raw () - : fhandler_base (), status () + : fhandler_base (), + devbufalloc (NULL), + devbuf (NULL), + devbufalign (0), + devbufsiz (0), + devbufstart (0), + devbufend (0), + status () { need_fork_fixup (true); } @@ -29,7 +37,7 @@ fhandler_dev_raw::fhandler_dev_raw () fhandler_dev_raw::~fhandler_dev_raw () { if (devbufsiz > 1L) - delete [] devbuf; + delete [] devbufalloc; } int __stdcall @@ -74,8 +82,6 @@ fhandler_dev_raw::open (int flags, mode_t) flags = ((flags & ~O_WRONLY) | O_RDWR); int res = fhandler_base::open (flags, 0); - if (res && devbufsiz > 1L) - devbuf = new char [devbufsiz]; return res; } @@ -90,7 +96,12 @@ fhandler_dev_raw::dup (fhandler_base *child, int flags) fhandler_dev_raw *fhc = (fhandler_dev_raw *) child; if (devbufsiz > 1L) - fhc->devbuf = new char [devbufsiz]; + { + /* Create sector-aligned buffer */ + fhc->devbufalloc = new char [devbufsiz + devbufalign]; + fhc->devbuf = (char *) roundup2 ((uintptr_t) fhc->devbufalloc, + devbufalign); + } fhc->devbufstart = 0; fhc->devbufend = 0; fhc->lastblk_to_read (false); @@ -112,7 +123,11 @@ fhandler_dev_raw::fixup_after_exec () if (!close_on_exec ()) { if (devbufsiz > 1L) - devbuf = new char [devbufsiz]; + { + /* Create sector-aligned buffer */ + devbufalloc = new char [devbufsiz + devbufalign]; + devbuf = (char *) roundup2 ((uintptr_t) devbufalloc, devbufalign); + } devbufstart = 0; devbufend = 0; lastblk_to_read (false); @@ -167,7 +182,7 @@ fhandler_dev_raw::ioctl (unsigned int cmd, void *buf) devbufend = 0; if (devbufsiz > 1L) - delete [] devbuf; + delete [] devbufalloc; devbufstart = 0; devbuf = buf; |