delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/11/06/03:58:55

From: corinna DOT vinschen AT cityweb DOT de (Corinna Vinschen)
Subject: B20 patch: fhandler_base::open()
6 Nov 1998 03:58:55 -0800 :
Message-ID: <3642DBF1.F6EAE5EB.cygnus.cygwin32.developers@cityweb.de>
Mime-Version: 1.0
To: cygwin32-developers AT cygnus DOT com

The behaviour of fhandler_base::open is incorrect for access to
raw tape and disk devices. The access to tapes must allow
GENERIC_WRITE, if you want to control (e.g. ioctl calls) the
tape device. In this case, the Windows access mode is not
equivalent to the mode given as parameter, which can still be
O_RDONLY.

Regards,
Corinna

ChangeLog:
----------
Tue Nov 03 00:08:33 1998 Corinna Vinschen <corinna DOT vinschen AT cityweb DOT de>

        * fhandler.cc (fhandler_base::open): Changed access and
        behaviour of append mode in case of raw tape or disk device.

---- snip ----
--- fhandler.cc.orig    Tue Nov 03 00:08:33 1998
+++ fhandler.cc Tue Nov 03 00:14:17 1998
@@ -220,7 +220,12 @@ fhandler_base::open (int flags, mode_t m
       goto done;
     }

-  if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY)
+  if (get_device () == FH_TAPE
+      || get_device () == FH_FLOPPY)
+    {
+      access_ = GENERIC_READ | GENERIC_WRITE;
+    }
+  else if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY)
     {
       access_ = GENERIC_READ;
     }
@@ -325,10 +330,14 @@ fhandler_base::open (int flags, mode_t m
       syscall_printf ("filemode defaulting to text");
     }

-  if (flags & O_APPEND)
-    SetFilePointer (get_handle(), 0, 0, FILE_END);
-  else
-    SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);
+  if (get_device () != FH_TAPE
+      && get_device () != FH_FLOPPY)
+    {
+      if (flags & O_APPEND)
+       SetFilePointer (get_handle(), 0, 0, FILE_END);
+      else
+       SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);
+    }

   res = 1;
 done:

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019