From 1204c515fe00335920c5707cc136e9562fd7cf38 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 28 Sep 2005 19:02:53 +0000 Subject: * fhandler.h (class fhandler_dev_raw): Delete current_position and eof_detected status flag. Delete is_eom and is_eof methods. Move drive_size, bytes_per_sector, eom_detected status flag, as well as the methods read_file, write_file, raw_read and raw_write to ... (class fhandler_dev_floppy): ... here. Remove is_eom and is_eof methods. Add dup method. * fhandler_floppy.cc (IS_EOM): New macro. (fhandler_dev_floppy::is_eom): Remove. (fhandler_dev_floppy::is_eof): Remove. (fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags. (fhandler_dev_floppy::get_drive_info): Only call EX functions on systems supporting them and stop suffering strange delays. (fhandler_dev_floppy::read_file): Move here, drop setting current_position. (fhandler_dev_floppy::write_file): Move here, drop setting current_position. (fhandler_dev_floppy::open): Rearrange comment. (fhandler_dev_floppy::dup): New method. (fhandler_dev_floppy::get_current_position): New inline method. Use instead of former current_position were appropriate. (fhandler_dev_floppy::raw_read): Move here. Drop EOF handling. (fhandler_dev_floppy::raw_write): Move here. Drop EOF handling. (fhandler_dev_floppy::lseek): Remove useless conditions. Convert sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call. (fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case to here. * fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove. (fhandler_dev_raw::is_eof): Remove. (fhandler_dev_raw::write_file): Remove. (fhandler_dev_raw::read_file): Remove. (fhandler_dev_raw::raw_read): Remove. (fhandler_dev_raw::raw_write): Remove. (fhandler_dev_raw::dup): Drop copying removed members. (fhandler_dev_raw::ioctl): Drop blocksize testing. * wincap.h: Implement has_disk_ex_ioctls throughout. * wincap.cc: Ditto. (wincap_vista): Preliminary wincaps for Windows Vista/Longhorn. (wincapc::init): Add Vista/Longhorn handling. --- winsup/cygwin/fhandler.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'winsup/cygwin/fhandler.cc') diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index a8a27862a..eae83e965 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -555,12 +555,13 @@ fhandler_base::open (int flags, mode_t mode) if (!wincap.is_winnt ()) return fhandler_base::open_9x (flags, mode); - WCHAR wpath[CYG_MAX_PATH + 10]; - UNICODE_STRING upath = {0, sizeof (wpath), wpath}; - pc.get_nt_native_path (upath); - - if (RtlIsDosDeviceName_U (upath.Buffer)) - return fhandler_base::open_9x (flags, mode); + UNICODE_STRING upath; + if (!pc.get_nt_native_path (upath)) + { + syscall_printf ("0 = fhandler_base::open (%s, %p)", + get_win32_name (), flags); + return 0; + } int res = 0; HANDLE x; @@ -576,7 +577,8 @@ fhandler_base::open (int flags, mode_t mode) syscall_printf ("(%s, %p)", get_win32_name (), flags); - InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE | OBJ_INHERIT, + InitializeObjectAttributes (&attr, &upath, + OBJ_CASE_INSENSITIVE | OBJ_INHERIT, sa.lpSecurityDescriptor, NULL); switch (query_open ()) @@ -681,6 +683,7 @@ done: syscall_printf ("%d = fhandler_base::open (%s, %p)", res, get_win32_name (), flags); + RtlFreeUnicodeString (&upath); return res; } @@ -1263,14 +1266,15 @@ fhandler_base::init (HANDLE f, DWORD a, mode_t bin) } int -fhandler_base::dup (fhandler_base *child) +fhandler_base::dup (fhandler_base *child, HANDLE from_proc) { debug_printf ("in fhandler_base dup"); HANDLE nh; + set_flags (child->get_flags ()); if (!nohandle ()) { - if (!DuplicateHandle (hMainProc, get_handle (), hMainProc, &nh, 0, TRUE, + if (!DuplicateHandle (from_proc, get_handle (), hMainProc, &nh, 0, TRUE, DUPLICATE_SAME_ACCESS)) { debug_printf ("dup(%s) failed, handle %x, %E", @@ -1282,7 +1286,6 @@ fhandler_base::dup (fhandler_base *child) VerifyHandle (nh); child->set_io_handle (nh); } - set_flags (child->get_flags ()); return 0; } -- cgit v1.2.3