diff options
author | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:38:33 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:38:33 +0000 |
commit | 1fd5e000ace55b323124c7e556a7a864b972a5c4 (patch) | |
tree | dc4fcf1e5e22a040716ef92c496b8d94959b2baa /winsup/cygwin/fhandler_floppy.cc | |
parent | 369d8a8fd5e887eca547bf34bccfdf755c9e5397 (diff) | |
download | newlib-1fd5e000ace55b323124c7e556a7a864b972a5c4.zip newlib-1fd5e000ace55b323124c7e556a7a864b972a5c4.tar.gz newlib-1fd5e000ace55b323124c7e556a7a864b972a5c4.tar.bz2 |
import winsup-2000-02-17 snapshot
Diffstat (limited to 'winsup/cygwin/fhandler_floppy.cc')
-rw-r--r-- | winsup/cygwin/fhandler_floppy.cc | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc new file mode 100644 index 0000000..7c58982 --- /dev/null +++ b/winsup/cygwin/fhandler_floppy.cc @@ -0,0 +1,90 @@ +/* fhandler_floppy.cc. See fhandler.h for a description of the + fhandler classes. + + Copyright 1999 Cygnus Solutions. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +#include <sys/termios.h> +#include <fcntl.h> +#include <errno.h> +#include <unistd.h> +#include "winsup.h" + +/**********************************************************************/ +/* fhandler_dev_floppy */ + +int +fhandler_dev_floppy::is_eom (int win_error) +{ + int ret = (win_error == ERROR_INVALID_PARAMETER); + if (ret) + debug_printf ("end of medium"); + return ret; +} + +int +fhandler_dev_floppy::is_eof (int win_error) +{ + int ret = 0; + if (ret) + debug_printf ("end of file"); + return ret; +} + +fhandler_dev_floppy::fhandler_dev_floppy (const char *name, int unit) : fhandler_dev_raw (FH_FLOPPY, name, unit) +{ + set_cb (sizeof *this); +} + +int +fhandler_dev_floppy::open (const char *path, int flags, mode_t) +{ + /* The correct size of the buffer would be 512 bytes, + * which is the atomic size, supported by WinNT. + * Unfortunately, the performance is worse than + * access to file system on same device! + * Setting buffer size to a relatively big value + * increases performance by means. + * The new ioctl call with 'rdevio.h' header file + * supports changing this value. + * + * Let's be smart: Let's take a multiplier of typical tar + * and cpio buffer sizes by default! + */ + devbufsiz = 61440L; /* 512L; */ + return fhandler_dev_raw::open (path, flags); +} + +int +fhandler_dev_floppy::close (void) +{ + int ret; + + ret = writebuf (); + if (ret) + { + fhandler_dev_raw::close (); + return ret; + } + return fhandler_dev_raw::close (); +} + +off_t +fhandler_dev_floppy::lseek (off_t offset, int whence) +{ + /* FIXME: Need to implement better. */ + offset = (offset / 512) * 512; + return fhandler_base::lseek (offset, whence); +} + +int +fhandler_dev_floppy::ioctl (unsigned int cmd, void *buf) +{ + return fhandler_dev_raw::ioctl (cmd, buf); +} + |