summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <vinschen@redhat.com>2006-10-23 15:14:04 +0000
committerCorinna Vinschen <vinschen@redhat.com>2006-10-23 15:14:04 +0000
commit883e6f2e1dfc19a59451b4c2d905e9bf2afa77a8 (patch)
tree2dba09723f14a3985ecb4d63ab9685ba488353b1
parentabeb770fd3b50347fed266107176cf3817f6aea7 (diff)
downloadgdb-883e6f2e1dfc19a59451b4c2d905e9bf2afa77a8.tar.gz
* fhandler_disk_file.cc (fhandler_disk_file::rewinddir): Accomodate
buggy RestartScan behaviour of Windows 2000. * wincap.h: Define has_buggy_restart_scan throughout. * wincap.cc: Ditto.
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc33
-rw-r--r--winsup/cygwin/wincap.cc887
-rw-r--r--winsup/cygwin/wincap.h151
4 files changed, 1077 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 022fab78831..a70ef3e5d33 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2006-10-23 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler_disk_file.cc (fhandler_disk_file::rewinddir): Accomodate
+ buggy RestartScan behaviour of Windows 2000.
+ * wincap.h: Define has_buggy_restart_scan throughout.
+ * wincap.cc: Ditto.
+
2006-10-17 Corinna Vinschen <corinna@vinschen.de>
* glob.c: Remove.
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 705af897dec..a14e89cd4d2 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -1870,7 +1870,38 @@ void
fhandler_disk_file::rewinddir (DIR *dir)
{
if (wincap.is_winnt ())
- d_cachepos (dir) = 0;
+ {
+ d_cachepos (dir) = 0;
+ if (wincap.has_buggy_restart_scan () && isremote ())
+ {
+ /* This works around a W2K bug. The RestartScan parameter in calls
+ to NtQueryDiretoryFile on remote shares is ignored, thus resulting
+ in not being able to rewind on remote shares. By reopening the
+ directory, we get a fresh new directory pointers. w*/
+ UNICODE_STRING fname = {0, CYG_MAX_PATH * 2, (WCHAR *) L""};
+ OBJECT_ATTRIBUTES attr;
+ NTSTATUS status;
+ IO_STATUS_BLOCK io;
+ HANDLE new_dir;
+
+ InitializeObjectAttributes (&attr, &fname, OBJ_CASE_INSENSITIVE,
+ dir->__handle, NULL);
+ status = NtOpenFile (&new_dir, SYNCHRONIZE | FILE_LIST_DIRECTORY,
+ &attr, &io, wincap.shared (),
+ FILE_SYNCHRONOUS_IO_NONALERT
+ | FILE_OPEN_FOR_BACKUP_INTENT
+ | FILE_DIRECTORY_FILE);
+ if (!NT_SUCCESS (stat))
+ debug_printf ("Unable to reopen dir %s, NT error: 0x%08x, "
+ "win32: %lu", get_name (), status,
+ RtlNtStatusToDosError (status));
+ else
+ {
+ CloseHandle (dir->__handle);
+ dir->__handle = new_dir;
+ }
+ }
+ }
else if (dir->__handle != INVALID_HANDLE_VALUE)
{
if (dir->__handle)
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
new file mode 100644
index 00000000000..9c82e45a7bd
--- /dev/null
+++ b/winsup/cygwin/wincap.cc
@@ -0,0 +1,887 @@
+/* wincap.cc -- figure out on which OS we're running. Set the
+ capability class to the appropriate values.
+
+ Copyright 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
+
+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 "winsup.h"
+
+static NO_COPY wincaps wincap_unknown = {
+ lock_file_highword:0x0,
+ chunksize:0x0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ is_server:false,
+ access_denied_on_delete:false,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:false,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:false,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:false,
+ has_mmap_alignment_bug:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_named_pipes:false,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:false,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false,
+ has_terminal_services:false,
+ has_switch_to_thread:false,
+ cant_debug_dll_entry:false,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:true,
+ has_extended_priority_class:false,
+ has_guid_volumes:false,
+ detect_win16_exe:true,
+ has_null_console_handler_routine:false,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:false,
+ has_disabled_user_tos_setting:false,
+ has_fileid_dirinfo:false,
+ has_exclusiveaddruse:false,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_95 = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ is_server:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:false,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_mmap_alignment_bug:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_named_pipes:false,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:false,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false,
+ has_terminal_services:false,
+ has_switch_to_thread:false,
+ cant_debug_dll_entry:true,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:true,
+ has_extended_priority_class:false,
+ has_guid_volumes:false,
+ detect_win16_exe:true,
+ has_null_console_handler_routine:false,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:false,
+ has_disabled_user_tos_setting:false,
+ has_fileid_dirinfo:false,
+ has_exclusiveaddruse:false,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_95osr2 = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ is_server:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:false,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_mmap_alignment_bug:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_named_pipes:false,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:false,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false,
+ has_terminal_services:false,
+ has_switch_to_thread:false,
+ cant_debug_dll_entry:true,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:true,
+ has_extended_priority_class:false,
+ has_guid_volumes:false,
+ detect_win16_exe:true,
+ has_null_console_handler_routine:false,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:false,
+ has_disabled_user_tos_setting:false,
+ has_fileid_dirinfo:false,
+ has_exclusiveaddruse:false,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_98 = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ is_server:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:true,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_mmap_alignment_bug:true,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_named_pipes:false,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false,
+ has_terminal_services:false,
+ has_switch_to_thread:false,
+ cant_debug_dll_entry:true,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:true,
+ has_extended_priority_class:false,
+ has_guid_volumes:false,
+ detect_win16_exe:true,
+ has_null_console_handler_routine:false,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:false,
+ has_disabled_user_tos_setting:false,
+ has_fileid_dirinfo:false,
+ has_exclusiveaddruse:false,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_98se = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ is_server:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:true,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_mmap_alignment_bug:true,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_named_pipes:false,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false,
+ has_terminal_services:false,
+ has_switch_to_thread:false,
+ cant_debug_dll_entry:true,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:true,
+ has_extended_priority_class:false,
+ has_guid_volumes:false,
+ detect_win16_exe:true,
+ has_null_console_handler_routine:false,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:false,
+ has_disabled_user_tos_setting:false,
+ has_fileid_dirinfo:false,
+ has_exclusiveaddruse:false,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_me = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ is_server:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:true,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_mmap_alignment_bug:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_named_pipes:false,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false,
+ has_terminal_services:false,
+ has_switch_to_thread:false,
+ cant_debug_dll_entry:true,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:true,
+ has_extended_priority_class:false,
+ has_guid_volumes:false,
+ detect_win16_exe:true,
+ has_null_console_handler_routine:false,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:false,
+ has_disabled_user_tos_setting:false,
+ has_fileid_dirinfo:false,
+ has_exclusiveaddruse:false,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_nt3 = {
+ lock_file_highword:UINT32_MAX,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ is_server:false,
+ access_denied_on_delete: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:false,
+ has_eventlog:true,
+ has_ip_helper_lib:false,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_mmap_alignment_bug:false,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_named_pipes:true,
+ has_try_enter_critical_section:false,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true,
+ has_terminal_services:false,
+ has_switch_to_thread:false,
+ cant_debug_dll_entry:false,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:false,
+ has_extended_priority_class:false,
+ has_guid_volumes:false,
+ detect_win16_exe:false,
+ has_null_console_handler_routine:true,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:true,
+ has_disabled_user_tos_setting:false,
+ has_fileid_dirinfo:false,
+ has_exclusiveaddruse:false,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_nt4 = {
+ lock_file_highword:UINT32_MAX,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ is_server:false,
+ access_denied_on_delete: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,
+ has_ip_helper_lib:false,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_mmap_alignment_bug:false,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_named_pipes:true,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true,
+ has_terminal_services:false,
+ has_switch_to_thread:true,
+ cant_debug_dll_entry:false,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:false,
+ has_extended_priority_class:false,
+ has_guid_volumes:false,
+ detect_win16_exe:false,
+ has_null_console_handler_routine:true,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:true,
+ has_disabled_user_tos_setting:false,
+ has_fileid_dirinfo:false,
+ has_exclusiveaddruse:false,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_nt4sp4 = {
+ lock_file_highword:UINT32_MAX,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ is_server:false,
+ access_denied_on_delete: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,
+ has_ip_helper_lib:true,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_mmap_alignment_bug:false,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_named_pipes:true,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true,
+ has_terminal_services:false,
+ has_switch_to_thread:true,
+ cant_debug_dll_entry:false,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:false,
+ has_extended_priority_class:false,
+ has_guid_volumes:false,
+ detect_win16_exe:false,
+ has_null_console_handler_routine:true,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:true,
+ has_disabled_user_tos_setting:false,
+ has_fileid_dirinfo:false,
+ has_exclusiveaddruse:true,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_2000 = {
+ lock_file_highword:UINT32_MAX,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ is_server:false,
+ access_denied_on_delete: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,
+ has_ip_helper_lib:true,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:true,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_mmap_alignment_bug:false,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_named_pipes:true,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:true,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true,
+ has_terminal_services:true,
+ has_switch_to_thread:true,
+ cant_debug_dll_entry:false,
+ has_ioctl_storage_get_media_types_ex:false,
+ start_proc_suspended:false,
+ has_extended_priority_class:true,
+ has_guid_volumes:true,
+ detect_win16_exe:false,
+ has_null_console_handler_routine:true,
+ has_disk_ex_ioctls:false,
+ has_working_virtual_lock:true,
+ has_disabled_user_tos_setting:true,
+ has_fileid_dirinfo:true,
+ has_exclusiveaddruse:true,
+ has_buggy_restart_scan:true,
+};
+
+static NO_COPY wincaps wincap_xp = {
+ lock_file_highword:UINT32_MAX,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ is_server:false,
+ access_denied_on_delete: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,
+ has_ip_helper_lib:true,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:true,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_mmap_alignment_bug:false,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_named_pipes:true,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:true,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true,
+ has_terminal_services:true,
+ has_switch_to_thread:true,
+ cant_debug_dll_entry:false,
+ has_ioctl_storage_get_media_types_ex:true,
+ start_proc_suspended:false,
+ has_extended_priority_class:true,
+ has_guid_volumes:true,
+ detect_win16_exe:false,
+ has_null_console_handler_routine:true,
+ has_disk_ex_ioctls:true,
+ has_working_virtual_lock:true,
+ has_disabled_user_tos_setting:true,
+ has_fileid_dirinfo:true,
+ has_exclusiveaddruse:true,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_2003 = {
+ lock_file_highword:UINT32_MAX,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ is_server:true,
+ access_denied_on_delete: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,
+ has_ip_helper_lib:true,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:true,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_mmap_alignment_bug:false,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_named_pipes:true,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:true,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true,
+ has_terminal_services:true,
+ has_switch_to_thread:true,
+ cant_debug_dll_entry:false,
+ has_ioctl_storage_get_media_types_ex:true,
+ start_proc_suspended:false,
+ has_extended_priority_class:true,
+ has_guid_volumes:true,
+ detect_win16_exe:false,
+ has_null_console_handler_routine:true,
+ has_disk_ex_ioctls:true,
+ has_working_virtual_lock:true,
+ has_disabled_user_tos_setting:true,
+ has_fileid_dirinfo:true,
+ has_exclusiveaddruse:true,
+ has_buggy_restart_scan:false,
+};
+
+static NO_COPY wincaps wincap_vista = {
+ lock_file_highword:UINT32_MAX,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ is_server:true,
+ access_denied_on_delete: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,
+ has_ip_helper_lib:true,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:true,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_mmap_alignment_bug:false,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_named_pipes:true,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:true,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true,
+ has_terminal_services:true,
+ has_switch_to_thread:true,
+ cant_debug_dll_entry:false,
+ has_ioctl_storage_get_media_types_ex:true,
+ start_proc_suspended:false,
+ has_extended_priority_class:true,
+ has_guid_volumes:true,
+ detect_win16_exe:false,
+ has_null_console_handler_routine:true,
+ has_disk_ex_ioctls:true,
+ has_working_virtual_lock:true,
+ has_disabled_user_tos_setting:true,
+ has_fileid_dirinfo:true,
+ has_exclusiveaddruse:true,
+ has_buggy_restart_scan:false,
+};
+
+wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
+
+void
+wincapc::init ()
+{
+ const char *os;
+ bool has_osversioninfoex = false;
+
+ if (caps)
+ return; // already initialized
+
+ memset (&version, 0, sizeof version);
+ /* Request simple version info first. */
+ version.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+ GetVersionEx (reinterpret_cast<LPOSVERSIONINFO>(&version));
+
+ switch (version.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32_NT:
+ switch (version.dwMajorVersion)
+ {
+ case 3:
+ os = "NT";
+ caps = &wincap_nt3;
+ break;
+ case 4:
+ os = "NT";
+ if (strcmp (version.szCSDVersion, "Service Pack 4") < 0)
+ caps = &wincap_nt4;
+ else
+ {
+ caps = &wincap_nt4sp4;
+ if (strcmp (version.szCSDVersion, "Service Pack 6") >= 0)
+ has_osversioninfoex = true;
+ }
+ break;
+ case 5:
+ os = "NT";
+ has_osversioninfoex = true;
+ switch (version.dwMinorVersion)
+ {
+ case 0:
+ caps = &wincap_2000;
+ break;
+
+ case 1:
+ caps = &wincap_xp;
+ break;
+
+ default:
+ caps = &wincap_2003;
+ }
+ break;
+ case 6:
+ os = "NT";
+ has_osversioninfoex = true;
+ caps = &wincap_vista;
+ break;
+ default:
+ os = "??";
+ caps = &wincap_unknown;
+ break;
+ }
+ break;
+ case VER_PLATFORM_WIN32_WINDOWS:
+ switch (version.dwMinorVersion)
+ {
+ case 0:
+ os = "95";
+ if (strchr (version.szCSDVersion, 'C'))
+ caps = &wincap_95osr2;
+ else
+ caps = &wincap_95;
+ break;
+ case 10:
+ os = "98";
+ if (strchr (version.szCSDVersion, 'A'))
+ caps = &wincap_98se;
+ else
+ caps = &wincap_98;
+ break;
+ case 90:
+ os = "ME";
+ caps = &wincap_me;
+ break;
+ default:
+ os = "??";
+ caps = &wincap_unknown;
+ break;
+ }
+ break;
+ default:
+ os = "??";
+ caps = &wincap_unknown;
+ break;
+ }
+
+ if (has_osversioninfoex)
+ {
+ /* Request extended version to get server info.
+ Available since NT4 SP6. */
+ version.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
+ GetVersionEx (reinterpret_cast<LPOSVERSIONINFO>(&version));
+ if (version.wProductType != VER_NT_WORKSTATION)
+ ((wincaps *)this->caps)->is_server = true;
+ }
+
+ BOOL is_wow64_proc = FALSE;
+ if (IsWow64Process (GetCurrentProcess (), &is_wow64_proc))
+ wow64 = is_wow64_proc;
+
+ __small_sprintf (osnam, "%s-%d.%d", os, version.dwMajorVersion,
+ version.dwMinorVersion);
+}
+
+void
+wincapc::set_chunksize (DWORD nchunksize)
+{
+ ((wincaps *)this->caps)->chunksize = nchunksize;
+}
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
new file mode 100644
index 00000000000..0f1b95a15b5
--- /dev/null
+++ b/winsup/cygwin/wincap.h
@@ -0,0 +1,151 @@
+/* wincap.h: Header for OS capability class.
+
+ Copyright 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
+
+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. */
+
+#ifndef _WINCAP_H
+#define _WINCAP_H
+
+struct wincaps
+{
+ DWORD lock_file_highword;
+ DWORD chunksize;
+ int shared;
+ unsigned is_winnt : 1;
+ unsigned is_server : 1;
+ unsigned access_denied_on_delete : 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;
+ unsigned has_ip_helper_lib : 1;
+ unsigned has_set_handle_information : 1;
+ unsigned has_set_handle_information_on_console_handles: 1;
+ unsigned supports_smp : 1;
+ unsigned map_view_of_file_ex_sucks : 1;
+ unsigned altgr_is_ctrl_alt : 1;
+ unsigned has_physical_mem_access : 1;
+ unsigned has_working_copy_on_write : 1;
+ unsigned share_mmaps_only_by_name : 1;
+ unsigned virtual_protect_works_on_shared_pages : 1;
+ unsigned has_mmap_alignment_bug : 1;
+ unsigned has_hard_links : 1;
+ unsigned can_open_directories : 1;
+ unsigned has_move_file_ex : 1;
+ unsigned has_negative_pids : 1;
+ unsigned has_unreliable_pipes : 1;
+ unsigned has_named_pipes : 1;
+ unsigned has_try_enter_critical_section : 1;
+ unsigned has_raw_devices : 1;
+ unsigned has_valid_processorlevel : 1;
+ unsigned has_64bit_file_access : 1;
+ unsigned has_process_io_counters : 1;
+ unsigned supports_reading_modem_output_lines : 1;
+ unsigned needs_memory_protection : 1;
+ unsigned pty_needs_alloc_console : 1;
+ unsigned has_terminal_services : 1;
+ unsigned has_switch_to_thread : 1;
+ unsigned cant_debug_dll_entry : 1;
+ unsigned has_ioctl_storage_get_media_types_ex : 1;
+ unsigned start_proc_suspended : 1;
+ unsigned has_extended_priority_class : 1;
+ unsigned has_guid_volumes : 1;
+ unsigned detect_win16_exe : 1;
+ unsigned has_null_console_handler_routine : 1;
+ unsigned has_disk_ex_ioctls : 1;
+ unsigned has_working_virtual_lock : 1;
+ unsigned has_disabled_user_tos_setting : 1;
+ unsigned has_fileid_dirinfo : 1;
+ unsigned has_exclusiveaddruse : 1;
+ unsigned has_buggy_restart_scan : 1;
+};
+
+class wincapc
+{
+ OSVERSIONINFOEX version;
+ char osnam[40];
+ bool wow64;
+ void *caps;
+
+public:
+ void init ();
+
+ void set_chunksize (DWORD nchunksize);
+
+ const char *osname () const { return osnam; }
+ const bool is_wow64 () const { return wow64; }
+
+#define IMPLEMENT(cap) cap() const { return ((wincaps *) this->caps)->cap; }
+
+ DWORD IMPLEMENT (lock_file_highword)
+ DWORD IMPLEMENT (chunksize)
+ int IMPLEMENT (shared)
+ bool IMPLEMENT (is_winnt)
+ bool IMPLEMENT (is_server)
+ bool IMPLEMENT (access_denied_on_delete)
+ 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)
+ bool IMPLEMENT (has_ip_helper_lib)
+ bool IMPLEMENT (has_set_handle_information)
+ bool IMPLEMENT (has_set_handle_information_on_console_handles)
+ bool IMPLEMENT (supports_smp)
+ bool IMPLEMENT (map_view_of_file_ex_sucks)
+ bool IMPLEMENT (altgr_is_ctrl_alt)
+ bool IMPLEMENT (has_physical_mem_access)
+ bool IMPLEMENT (has_working_copy_on_write)
+ bool IMPLEMENT (share_mmaps_only_by_name)
+ bool IMPLEMENT (virtual_protect_works_on_shared_pages)
+ bool IMPLEMENT (has_mmap_alignment_bug)
+ bool IMPLEMENT (has_hard_links)
+ bool IMPLEMENT (can_open_directories)
+ bool IMPLEMENT (has_move_file_ex)
+ bool IMPLEMENT (has_negative_pids)
+ bool IMPLEMENT (has_unreliable_pipes)
+ bool IMPLEMENT (has_named_pipes)
+ bool IMPLEMENT (has_try_enter_critical_section)
+ bool IMPLEMENT (has_raw_devices)
+ bool IMPLEMENT (has_valid_processorlevel)
+ bool IMPLEMENT (has_64bit_file_access)
+ bool IMPLEMENT (has_process_io_counters)
+ bool IMPLEMENT (supports_reading_modem_output_lines)
+ bool IMPLEMENT (needs_memory_protection)
+ bool IMPLEMENT (pty_needs_alloc_console)
+ bool IMPLEMENT (has_terminal_services)
+ bool IMPLEMENT (has_switch_to_thread)
+ bool IMPLEMENT (cant_debug_dll_entry)
+ bool IMPLEMENT (has_ioctl_storage_get_media_types_ex)
+ bool IMPLEMENT (start_proc_suspended)
+ bool IMPLEMENT (has_extended_priority_class)
+ bool IMPLEMENT (has_guid_volumes)
+ bool IMPLEMENT (detect_win16_exe)
+ bool IMPLEMENT (has_null_console_handler_routine)
+ bool IMPLEMENT (has_disk_ex_ioctls)
+ bool IMPLEMENT (has_working_virtual_lock)
+ bool IMPLEMENT (has_disabled_user_tos_setting)
+ bool IMPLEMENT (has_fileid_dirinfo)
+ bool IMPLEMENT (has_exclusiveaddruse)
+ bool IMPLEMENT (has_buggy_restart_scan)
+
+#undef IMPLEMENT
+};
+
+extern wincapc wincap;
+
+#endif /* _WINCAP_H */