OSDN Git Service

* fhandler.cc (fhandler_base::write): Remove wincap.has_lseek_bug case.
authorcorinna <corinna>
Thu, 22 Feb 2007 16:22:38 +0000 (16:22 +0000)
committercorinna <corinna>
Thu, 22 Feb 2007 16:22:38 +0000 (16:22 +0000)
Simplify seek beyond EOF case.
* times.cc (times): Remove wincap.has_get_process_times case.
* wincap.cc: Remove has_delete_on_close, has_page_guard,
has_get_process_times and has_lseek_bug throughout.
* wincap.h: Ditto.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.cc
winsup/cygwin/times.cc
winsup/cygwin/wincap.cc
winsup/cygwin/wincap.h

index c856679..8a00284 100644 (file)
@@ -1,5 +1,14 @@
 2007-02-22  Corinna Vinschen  <corinna@vinschen.de>
 
+       * fhandler.cc (fhandler_base::write): Remove wincap.has_lseek_bug case.
+       Simplify seek beyond EOF case.
+       * times.cc (times): Remove wincap.has_get_process_times case.
+       * wincap.cc: Remove has_delete_on_close, has_page_guard,
+       has_get_process_times and has_lseek_bug throughout.
+       * wincap.h: Ditto.
+
+2007-02-22  Corinna Vinschen  <corinna@vinschen.de>
+
        Throughout remove all usage of wincap.access_denied_on_delete.
        * dir.cc (rmdir): Add existance check to be errno-compatible with Linux.
        * fhandler_disk_file.cc (fhandler_disk_file::rmdir): Drop test for
index ce1e9f7..572be2a 100644 (file)
@@ -841,66 +841,18 @@ fhandler_base::write (const void *ptr, size_t len)
                                         FILE_CURRENT);
       current_position += ((_off64_t) pos_high) << 32;
 
-      if (current_position > actual_length)
+      if (current_position >= actual_length + (128 * 1024)
+         && get_fs_flags (FILE_SUPPORTS_SPARSE_FILES))
        {
-         if ((get_fs_flags (FILE_SUPPORTS_SPARSE_FILES))
-             && current_position >= actual_length + (128 * 1024))
-           {
-             /* If the file systemn supports sparse files and the application
-                is writing after a long seek beyond EOF, convert the file to
-                a sparse file. */
-             DWORD dw;
-             HANDLE h = get_output_handle ();
-             BOOL r = DeviceIoControl (h, FSCTL_SET_SPARSE, NULL, 0, NULL,
-                                       0, &dw, NULL);
-             syscall_printf ("%d = DeviceIoControl(%p, FSCTL_SET_SPARSE)",
-                             r, h);
-           }
-         else if (wincap.has_lseek_bug ())
-           {
-             /* Oops, this is the bug case - Win95 uses whatever is on the
-                disk instead of some known (safe) value, so we must seek
-                back and fill in the gap with zeros. - DJ
-                Note: this bug doesn't happen on NT4, even though the
-                documentation for WriteFile() says that it *may* happen
-                on any OS. */
-             /* Check there is enough space */
-             if (!SetEndOfFile (get_output_handle ()))
-               {
-                 __seterrno ();
-                 return -1;
-               }
-             char zeros[512];
-             int number_of_zeros_to_write = current_position - actual_length;
-             memset (zeros, 0, 512);
-             SetFilePointer (get_output_handle (), actual_length, NULL,
-                             FILE_BEGIN);
-             while (number_of_zeros_to_write > 0)
-               {
-                 DWORD zeros_this_time = (number_of_zeros_to_write > 512
-                                        ? 512 : number_of_zeros_to_write);
-                 DWORD written;
-                 DWORD ret = WriteFile (get_output_handle (), zeros,
-                                        zeros_this_time, &written, NULL);
-                 if (!ret || written < zeros_this_time)
-                   {
-                     if (!ret)
-                       {
-                         __seterrno ();
-                         if (get_errno () == EPIPE)
-                           raise (SIGPIPE);
-                       }
-                     else
-                       set_errno (ENOSPC);
-                     /* This might fail, but it's the best we can hope for */
-                     SetFilePointer (get_output_handle (), current_position,
-                                     NULL, FILE_BEGIN);
-                     return -1;
-
-                   }
-                 number_of_zeros_to_write -= written;
-               }
-           }
+         /* If the file system supports sparse files and the application
+            is writing after a long seek beyond EOF, convert the file to
+            a sparse file. */
+         DWORD dw;
+         HANDLE h = get_output_handle ();
+         BOOL r = DeviceIoControl (h, FSCTL_SET_SPARSE, NULL, 0, NULL,
+                                   0, &dw, NULL);
+         syscall_printf ("%d = DeviceIoControl(%p, FSCTL_SET_SPARSE)",
+                         r, h);
        }
     }
 
index 3922caf..f3a6f0e 100644 (file)
@@ -75,33 +75,21 @@ times (struct tms *buf)
   /* Ticks is in milliseconds, convert to our ticks. Use long long to prevent
      overflow. */
   clock_t tc = (clock_t) (ticks * CLOCKS_PER_SEC / 1000);
-  if (wincap.has_get_process_times ())
-    {
-      GetProcessTimes (hMainProc, &creation_time, &exit_time,
-                      &kernel_time, &user_time);
-
-      syscall_printf ("ticks %d, CLOCKS_PER_SEC %d", ticks, CLOCKS_PER_SEC);
-      syscall_printf ("user_time %d, kernel_time %d, creation_time %d, exit_time %d",
-                     user_time, kernel_time, creation_time, exit_time);
-      buf->tms_stime = __to_clock_t (&kernel_time, 0);
-      buf->tms_utime = __to_clock_t (&user_time, 0);
-      timeval_to_filetime (&myself->rusage_children.ru_stime, &kernel_time);
-      buf->tms_cstime = __to_clock_t (&kernel_time, 1);
-      timeval_to_filetime (&myself->rusage_children.ru_utime, &user_time);
-      buf->tms_cutime = __to_clock_t (&user_time, 1);
-    }
-  else
-    /* GetProcessTimes() does not work for non-NT versions of Windows.  The
-       return values are undefined, so instead just copy the ticks value
-       into utime so that clock() will work properly on these systems */
-    {
-      buf->tms_utime = tc;
-      buf->tms_stime = 0;
-      buf->tms_cstime = 0;
-      buf->tms_cutime = 0;
-    }
 
-   return tc;
+  GetProcessTimes (hMainProc, &creation_time, &exit_time,
+                  &kernel_time, &user_time);
+
+  syscall_printf ("ticks %d, CLOCKS_PER_SEC %d", ticks, CLOCKS_PER_SEC);
+  syscall_printf ("user_time %d, kernel_time %d, creation_time %d, exit_time %d",
+                 user_time, kernel_time, creation_time, exit_time);
+  buf->tms_stime = __to_clock_t (&kernel_time, 0);
+  buf->tms_utime = __to_clock_t (&user_time, 0);
+  timeval_to_filetime (&myself->rusage_children.ru_stime, &kernel_time);
+  buf->tms_cstime = __to_clock_t (&kernel_time, 1);
+  timeval_to_filetime (&myself->rusage_children.ru_utime, &user_time);
+  buf->tms_cutime = __to_clock_t (&user_time, 1);
+
+  return tc;
 }
 
 EXPORT_ALIAS (times, _times)
index 0be5446..a209dce 100644 (file)
@@ -17,12 +17,8 @@ static NO_COPY wincaps wincap_unknown = {
   chunksize:0,
   heapslop:0x0,
   is_server:false,
-  has_delete_on_close:true,
-  has_page_guard:true,
   has_security:true,
   has_security_descriptor_control:false,
-  has_get_process_times:true,
-  has_lseek_bug:false,
   has_lock_file_ex:true,
   has_signal_object_and_wait:true,
   has_eventlog:true,
@@ -80,12 +76,8 @@ static NO_COPY wincaps wincap_nt4 = {
   chunksize:0,
   heapslop:0x0,
   is_server:false,
-  has_delete_on_close:true,
-  has_page_guard:true,
   has_security:true,
   has_security_descriptor_control:false,
-  has_get_process_times:true,
-  has_lseek_bug:false,
   has_lock_file_ex:true,
   has_signal_object_and_wait:true,
   has_eventlog:true,
@@ -143,12 +135,8 @@ static NO_COPY wincaps wincap_nt4sp4 = {
   chunksize:0,
   heapslop:0x0,
   is_server:false,
-  has_delete_on_close:true,
-  has_page_guard:true,
   has_security:true,
   has_security_descriptor_control:false,
-  has_get_process_times:true,
-  has_lseek_bug:false,
   has_lock_file_ex:true,
   has_signal_object_and_wait:true,
   has_eventlog:true,
@@ -206,12 +194,8 @@ static NO_COPY wincaps wincap_2000 = {
   chunksize:0,
   heapslop:0x0,
   is_server:false,
-  has_delete_on_close:true,
-  has_page_guard:true,
   has_security:true,
   has_security_descriptor_control:true,
-  has_get_process_times:true,
-  has_lseek_bug:false,
   has_lock_file_ex:true,
   has_signal_object_and_wait:true,
   has_eventlog:true,
@@ -269,12 +253,8 @@ static NO_COPY wincaps wincap_xp = {
   chunksize:0,
   heapslop:0x0,
   is_server:false,
-  has_delete_on_close:true,
-  has_page_guard:true,
   has_security:true,
   has_security_descriptor_control:true,
-  has_get_process_times:true,
-  has_lseek_bug:false,
   has_lock_file_ex:true,
   has_signal_object_and_wait:true,
   has_eventlog:true,
@@ -332,12 +312,8 @@ static NO_COPY wincaps wincap_2003 = {
   chunksize:0,
   heapslop:0x4,
   is_server:true,
-  has_delete_on_close:true,
-  has_page_guard:true,
   has_security:true,
   has_security_descriptor_control:true,
-  has_get_process_times:true,
-  has_lseek_bug:false,
   has_lock_file_ex:true,
   has_signal_object_and_wait:true,
   has_eventlog:true,
@@ -395,12 +371,8 @@ static NO_COPY wincaps wincap_vista = {
   chunksize:0,
   heapslop:0x4,
   is_server:false,
-  has_delete_on_close:true,
-  has_page_guard:true,
   has_security:true,
   has_security_descriptor_control:true,
-  has_get_process_times:true,
-  has_lseek_bug:false,
   has_lock_file_ex:true,
   has_signal_object_and_wait:true,
   has_eventlog:true,
index 645ded1..d8310d3 100644 (file)
@@ -17,12 +17,8 @@ struct wincaps
   DWORD    chunksize;
   DWORD    heapslop;
   unsigned is_server                                    : 1;
-  unsigned has_delete_on_close                          : 1;
-  unsigned has_page_guard                               : 1;
   unsigned has_security                                 : 1;
   unsigned has_security_descriptor_control              : 1;
-  unsigned has_get_process_times                        : 1;
-  unsigned has_lseek_bug                                : 1;
   unsigned has_lock_file_ex                             : 1;
   unsigned has_signal_object_and_wait                   : 1;
   unsigned has_eventlog                                 : 1;
@@ -96,12 +92,8 @@ public:
   DWORD IMPLEMENT (chunksize)
   DWORD IMPLEMENT (heapslop)
   bool  IMPLEMENT (is_server)
-  bool  IMPLEMENT (has_delete_on_close)
-  bool  IMPLEMENT (has_page_guard)
   bool  IMPLEMENT (has_security)
   bool  IMPLEMENT (has_security_descriptor_control)
-  bool  IMPLEMENT (has_get_process_times)
-  bool  IMPLEMENT (has_lseek_bug)
   bool  IMPLEMENT (has_lock_file_ex)
   bool  IMPLEMENT (has_signal_object_and_wait)
   bool  IMPLEMENT (has_eventlog)