diff options
Diffstat (limited to 'winsup/cygwin/fhandler_floppy.cc')
-rw-r--r-- | winsup/cygwin/fhandler_floppy.cc | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index 994bba9f1..f0380dc88 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -1,7 +1,7 @@ /* fhandler_floppy.cc. See fhandler.h for a description of the fhandler classes. - Copyright 1999, 2000, 2001 Red Hat, Inc. + Copyright 1999, 2000, 2001, 2002 Red Hat, Inc. This file is part of Cygwin. @@ -11,7 +11,6 @@ details. */ #include "winsup.h" #include <sys/termios.h> -#include <fcntl.h> #include <errno.h> #include <unistd.h> #include <winioctl.h> @@ -40,13 +39,12 @@ fhandler_dev_floppy::is_eof (int) return ret; } -fhandler_dev_floppy::fhandler_dev_floppy (const char *name, int unit) : fhandler_dev_raw (FH_FLOPPY, name, unit) +fhandler_dev_floppy::fhandler_dev_floppy (int unit) : fhandler_dev_raw (FH_FLOPPY, unit) { - set_cb (sizeof *this); } int -fhandler_dev_floppy::open (const char *path, int flags, mode_t) +fhandler_dev_floppy::open (path_conv *real_path, int flags, mode_t) { /* The correct size of the buffer would be 512 bytes, * which is the atomic size, supported by WinNT. @@ -61,7 +59,7 @@ fhandler_dev_floppy::open (const char *path, int flags, mode_t) * and cpio buffer sizes by default! */ devbufsiz = 61440L; /* 512L; */ - return fhandler_dev_raw::open (path, flags); + return fhandler_dev_raw::open (real_path, flags); } int @@ -78,16 +76,16 @@ fhandler_dev_floppy::close (void) return fhandler_dev_raw::close (); } -off_t -fhandler_dev_floppy::lseek (off_t offset, int whence) +__off64_t +fhandler_dev_floppy::lseek (__off64_t offset, int whence) { int ret; char buf[512]; - long long drive_size = 0; - long long lloffset = offset; - long long current_position; - off_t sector_aligned_offset; - off_t bytes_left; + __off64_t drive_size = 0; + __off64_t lloffset = offset; + __off64_t current_position; + __off64_t sector_aligned_offset; + __off64_t bytes_left; DWORD low; LONG high = 0; @@ -95,7 +93,7 @@ fhandler_dev_floppy::lseek (off_t offset, int whence) PARTITION_INFORMATION pi; DWORD bytes_read; - if (!DeviceIoControl (get_handle(), + if (!DeviceIoControl (get_handle (), IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &di, sizeof (di), @@ -118,11 +116,11 @@ fhandler_dev_floppy::lseek (off_t offset, int whence) debug_printf ("partition info: %ld (%ld)", pi.StartingOffset.LowPart, pi.PartitionLength.LowPart); - drive_size = (long long) pi.PartitionLength.QuadPart; + drive_size = pi.PartitionLength.QuadPart; } else { - drive_size = (long long) di.Cylinders.QuadPart * di.TracksPerCylinder * + drive_size = di.Cylinders.QuadPart * di.TracksPerCylinder * di.SectorsPerTrack * di.BytesPerSector; } debug_printf ("drive size: %ld", drive_size); @@ -141,7 +139,7 @@ fhandler_dev_floppy::lseek (off_t offset, int whence) __seterrno (); return -1; } - current_position = (long long) low + ((long long) high << 32); + current_position = low + ((__off64_t) high << 32); if (is_writing) current_position += devbufend - devbufstart; else @@ -157,18 +155,10 @@ fhandler_dev_floppy::lseek (off_t offset, int whence) set_errno (EINVAL); return -1; } - high = lloffset >> 32; - low = lloffset & 0xffffffff; - if (high || (off_t) low < 0) - { - set_errno (EFBIG); - return -1; - } - offset = (off_t) low; /* FIXME: sector can possibly be not 512 bytes long */ - sector_aligned_offset = (offset / 512) * 512; - bytes_left = offset - sector_aligned_offset; + sector_aligned_offset = (lloffset / 512) * 512; + bytes_left = lloffset - sector_aligned_offset; if (whence == SEEK_SET) { @@ -178,8 +168,10 @@ fhandler_dev_floppy::lseek (off_t offset, int whence) return ret; devbufstart = devbufend = 0; - if (SetFilePointer (get_handle (), sector_aligned_offset, NULL, FILE_BEGIN) - == INVALID_SET_FILE_POINTER) + low = sector_aligned_offset & 0xffffffff; + high = sector_aligned_offset >> 32; + if (SetFilePointer (get_handle (), low, &high, FILE_BEGIN) + == INVALID_SET_FILE_POINTER && GetLastError ()) { __seterrno (); return -1; |