Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-02-22 13:54:47 +0300
committerCorinna Vinschen <corinna@vinschen.de>2007-02-22 13:54:47 +0300
commit570858c30fa6add591bf74907de4a7fb93312f20 (patch)
tree888b58b3528c6ad8eb9a749badf463ad66d457f1 /winsup/cygwin
parent8782b2a2af66bdbc9de30bb25351628295fbb7d1 (diff)
* Makefile.in (DLL_IMPORTS): Add libntdll.a.
* autoload.cc: Remove all symbols from advapi32.dll, kernel32.dll and ntdll.dll available on all platforms since NT4. Throughout remove all usage of wincap.is_winnt. * dcrt0.cc (dll_crt0_0): Remove call to mmap_init. * fhandler.h (class fhandler_base): Remove has_changed flag. (fhandler_disk_file::touch_ctime): Remove declaration. (fhandler_disk_file::readdir_9x): Ditto. (fhandler_disk_file::touch_ctime): Remove. (fhandler_disk_file::readdir_9x): Remove. (fhandler_disk_file::closedir): Call NtClose instead of CloseHandle. * mmap.cc: Throughout call CreateMapping and MapView directly. (VirtualProt9x): Remove. (VirtualProtNT): Remove. (VirtualProtEx9x): Remove. (VirtualProtExNT): Remove. (VirtualProtect): Remove define. (VirtualProtectEx): Remove define. (CreateMapping9x): Remove. (CreateMappingNT): Rename to CreateMapping. (MapView9x): Remove. (MapViewNT): Rename to MapView. (struct mmap_func_t): Remove definition. (mmap_funcs_9x): Remove. (mmap_funcs_nt): Remove. (mmap_func): Remove. (mmap_init): Remove. * net.cc (getdomainname): Drop comment. Use NT4 registry key only. (get_95_ifconf): Remove. * pinfo.cc (winpids::enumNT): Rename to winpids::enum_processes. (winpids::enum9x): Remove. (winpids::set): Just call enum_processes directly. (winpids::enum_init): Ditto. * pinfo.h (class winpids): Drop enum_processes pointer. Rename enumNT to enum_processes. Drop enum9x declaration. Drop initialization of enum_processes throughout. * registry.cc (get_registry_hive_path): Just create NT key. (load_registry_hive): Only load NT specific file. * syscalls.cc (unlink_9x): Remove. (unlink): Just call unlink_nt. * wincap.cc: Remove is_winnt flag throughout. * wincap.h: Ditto. * winsup.h: Remove mmap_init declaration.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog47
-rw-r--r--winsup/cygwin/Makefile.in2
-rw-r--r--winsup/cygwin/autoload.cc117
-rw-r--r--winsup/cygwin/cygheap.h7
-rw-r--r--winsup/cygwin/dcrt0.cc3
-rw-r--r--winsup/cygwin/fhandler.cc3
-rw-r--r--winsup/cygwin/fhandler.h7
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc446
-rw-r--r--winsup/cygwin/fhandler_proc.cc309
-rw-r--r--winsup/cygwin/fhandler_process.cc180
-rw-r--r--winsup/cygwin/libc/bsdlib.cc9
-rw-r--r--winsup/cygwin/mmap.cc261
-rw-r--r--winsup/cygwin/net.cc195
-rw-r--r--winsup/cygwin/netdb.cc18
-rw-r--r--winsup/cygwin/pinfo.cc40
-rw-r--r--winsup/cygwin/pinfo.h17
-rw-r--r--winsup/cygwin/registry.cc12
-rw-r--r--winsup/cygwin/sched.cc8
-rw-r--r--winsup/cygwin/shared.cc5
-rw-r--r--winsup/cygwin/spawn.cc6
-rw-r--r--winsup/cygwin/syscalls.cc15
-rw-r--r--winsup/cygwin/wincap.cc7
-rw-r--r--winsup/cygwin/wincap.h2
-rw-r--r--winsup/cygwin/winsup.h3
24 files changed, 476 insertions, 1243 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 5f0a93db2..b326f6e8e 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,50 @@
+2007-02-22 Corinna Vinschen <corinna@vinschen.de>
+
+ * Makefile.in (DLL_IMPORTS): Add libntdll.a.
+ * autoload.cc: Remove all symbols from advapi32.dll, kernel32.dll and
+ ntdll.dll available on all platforms since NT4.
+
+ Throughout remove all usage of wincap.is_winnt.
+ * dcrt0.cc (dll_crt0_0): Remove call to mmap_init.
+ * fhandler.h (class fhandler_base): Remove has_changed flag.
+ (fhandler_disk_file::touch_ctime): Remove declaration.
+ (fhandler_disk_file::readdir_9x): Ditto.
+ (fhandler_disk_file::touch_ctime): Remove.
+ (fhandler_disk_file::readdir_9x): Remove.
+ (fhandler_disk_file::closedir): Call NtClose instead of CloseHandle.
+ * mmap.cc: Throughout call CreateMapping and MapView directly.
+ (VirtualProt9x): Remove.
+ (VirtualProtNT): Remove.
+ (VirtualProtEx9x): Remove.
+ (VirtualProtExNT): Remove.
+ (VirtualProtect): Remove define.
+ (VirtualProtectEx): Remove define.
+ (CreateMapping9x): Remove.
+ (CreateMappingNT): Rename to CreateMapping.
+ (MapView9x): Remove.
+ (MapViewNT): Rename to MapView.
+ (struct mmap_func_t): Remove definition.
+ (mmap_funcs_9x): Remove.
+ (mmap_funcs_nt): Remove.
+ (mmap_func): Remove.
+ (mmap_init): Remove.
+ * net.cc (getdomainname): Drop comment. Use NT4 registry key only.
+ (get_95_ifconf): Remove.
+ * pinfo.cc (winpids::enumNT): Rename to winpids::enum_processes.
+ (winpids::enum9x): Remove.
+ (winpids::set): Just call enum_processes directly.
+ (winpids::enum_init): Ditto.
+ * pinfo.h (class winpids): Drop enum_processes pointer. Rename
+ enumNT to enum_processes. Drop enum9x declaration. Drop initialization
+ of enum_processes throughout.
+ * registry.cc (get_registry_hive_path): Just create NT key.
+ (load_registry_hive): Only load NT specific file.
+ * syscalls.cc (unlink_9x): Remove.
+ (unlink): Just call unlink_nt.
+ * wincap.cc: Remove is_winnt flag throughout.
+ * wincap.h: Ditto.
+ * winsup.h: Remove mmap_init declaration.
+
2007-02-21 Corinna Vinschen <corinna@vinschen.de>
* wincap.cc (wincap_unknown): Change settings for unknown to reflect
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 6aabf5d16..239a500a4 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -119,7 +119,7 @@ EXTRA_OFILES=$(bupdir1)/libiberty/random.o
MALLOC_OFILES=@MALLOC_OFILES@
-DLL_IMPORTS:=$(w32api_lib)/libkernel32.a $(w32api_lib)/libadvapi32.a
+DLL_IMPORTS:=$(w32api_lib)/libkernel32.a $(w32api_lib)/libadvapi32.a $(w32api_lib)/libntdll.a
MT_SAFE_OBJECTS:=
# Please maintain this list in sorted order, with maximum files per 86 col line
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 78974f373..df8747699 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -298,78 +298,7 @@ wsock_init ()
LoadDLLprime (ws2_32, _wsock_init)
-LoadDLLfunc (AccessCheck, 32, advapi32)
-LoadDLLfunc (AddAccessAllowedAce, 16, advapi32)
-LoadDLLfunc (AddAccessDeniedAce, 16, advapi32)
-LoadDLLfunc (AddAce, 20, advapi32)
-LoadDLLfunc (AdjustTokenPrivileges, 24, advapi32)
-LoadDLLfuncEx (AllocateLocallyUniqueId, 4, advapi32, 1)
-LoadDLLfunc (CopySid, 12, advapi32)
-LoadDLLfunc (CreateProcessAsUserA, 44, advapi32)
-LoadDLLfuncEx (CryptAcquireContextA, 20, advapi32, 1)
-LoadDLLfuncEx (CryptGenRandom, 12, advapi32, 1)
-LoadDLLfuncEx (CryptReleaseContext, 8, advapi32, 1)
-LoadDLLfunc (DeregisterEventSource, 4, advapi32)
-LoadDLLfunc (DuplicateToken, 12, advapi32)
-LoadDLLfuncEx (DuplicateTokenEx, 24, advapi32, 1)
-LoadDLLfunc (EqualPrefixSid, 8, advapi32)
-LoadDLLfunc (EqualSid, 8, advapi32)
-LoadDLLfunc (FindFirstFreeAce, 8, advapi32)
-LoadDLLfunc (GetAce, 12, advapi32)
-LoadDLLfunc (GetFileSecurityA, 20, advapi32)
-LoadDLLfunc (GetKernelObjectSecurity, 20, advapi32)
-LoadDLLfunc (GetLengthSid, 4, advapi32)
-LoadDLLfunc (GetSecurityDescriptorDacl, 16, advapi32)
-LoadDLLfunc (GetSecurityDescriptorGroup, 12, advapi32)
-LoadDLLfunc (GetSecurityDescriptorOwner, 12, advapi32)
-LoadDLLfunc (GetSecurityInfo, 32, advapi32)
-LoadDLLfunc (GetSidIdentifierAuthority, 4, advapi32)
-LoadDLLfunc (GetSidSubAuthority, 8, advapi32)
-LoadDLLfunc (GetSidSubAuthorityCount, 4, advapi32)
-LoadDLLfunc (GetTokenInformation, 20, advapi32)
-LoadDLLfunc (GetUserNameA, 8, advapi32)
-LoadDLLfunc (ImpersonateLoggedOnUser, 4, advapi32)
-LoadDLLfunc (ImpersonateNamedPipeClient, 4, advapi32)
-LoadDLLfunc (InitializeAcl, 12, advapi32)
-LoadDLLfunc (InitializeSecurityDescriptor, 8, advapi32)
-LoadDLLfunc (InitializeSid, 12, advapi32)
-LoadDLLfunc (IsValidSid, 4, advapi32)
-LoadDLLfunc (LogonUserA, 24, advapi32)
-LoadDLLfunc (LookupAccountNameA, 28, advapi32)
-LoadDLLfunc (LookupAccountNameW, 28, advapi32)
-LoadDLLfunc (LookupAccountSidA, 28, advapi32)
-LoadDLLfunc (LookupPrivilegeValueA, 12, advapi32)
-LoadDLLfunc (LsaClose, 4, advapi32)
-LoadDLLfunc (LsaEnumerateAccountRights, 16, advapi32)
-LoadDLLfunc (LsaFreeMemory, 4, advapi32)
-LoadDLLfunc (LsaNtStatusToWinError, 4, advapi32)
-LoadDLLfunc (LsaOpenPolicy, 16, advapi32)
-LoadDLLfunc (LsaQueryInformationPolicy, 12, advapi32)
-LoadDLLfunc (MakeSelfRelativeSD, 12, advapi32)
-LoadDLLfunc (OpenProcessToken, 12, advapi32)
-LoadDLLfunc (OpenThreadToken, 16, advapi32)
-LoadDLLfunc (PrivilegeCheck, 12, advapi32)
-// LoadDLLfunc (RegCloseKey, 4, advapi32)
-LoadDLLfunc (RegCreateKeyExA, 36, advapi32)
-LoadDLLfunc (RegDeleteKeyA, 8, advapi32)
-LoadDLLfunc (RegDeleteValueA, 8, advapi32)
-LoadDLLfunc (RegLoadKeyA, 12, advapi32)
-LoadDLLfunc (RegEnumKeyExA, 32, advapi32)
-LoadDLLfunc (RegEnumValueA, 32, advapi32)
-LoadDLLfunc (RegOpenKeyExA, 20, advapi32)
-LoadDLLfunc (RegQueryInfoKeyA, 48, advapi32)
-LoadDLLfunc (RegQueryValueExA, 24, advapi32)
-LoadDLLfunc (RegSetValueExA, 24, advapi32)
-LoadDLLfunc (RegisterEventSourceA, 8, advapi32)
-LoadDLLfunc (ReportEventA, 36, advapi32)
-LoadDLLfunc (RevertToSelf, 0, advapi32)
-LoadDLLfunc (SetKernelObjectSecurity, 12, advapi32)
LoadDLLfunc (SetSecurityDescriptorControl, 12, advapi32)
-LoadDLLfunc (SetSecurityDescriptorDacl, 16, advapi32)
-LoadDLLfunc (SetSecurityDescriptorGroup, 12, advapi32)
-LoadDLLfunc (SetSecurityDescriptorOwner, 12, advapi32)
-LoadDLLfunc (SetTokenInformation, 16, advapi32)
-LoadDLLfunc (RegGetKeySecurity, 16, advapi32)
/* 127 == ERROR_PROC_NOT_FOUND */
LoadDLLfuncEx2 (DsGetDcNameA, 24, netapi32, 1, 127)
@@ -382,39 +311,6 @@ LoadDLLfunc (NetUserGetGroups, 28, netapi32)
LoadDLLfunc (NetUserGetInfo, 16, netapi32)
LoadDLLfunc (NetWkstaUserGetInfo, 12, netapi32)
-/* 0xc000007a == STATUS_PROCEDURE_NOT_FOUND */
-#define LoadDLLfuncNt(name, n, dllname) \
- LoadDLLfuncEx2(name, n, dllname, 1, 0xc000007a)
-LoadDLLfuncNt (NtClose, 4, ntdll)
-LoadDLLfuncNt (NtCreateFile, 44, ntdll)
-LoadDLLfuncNt (NtCreateSection, 28, ntdll)
-LoadDLLfuncNt (NtCreateToken, 52, ntdll)
-LoadDLLfuncNt (NtLockVirtualMemory, 16, ntdll)
-LoadDLLfuncNt (NtMapViewOfSection, 40, ntdll)
-LoadDLLfuncNt (NtOpenDirectoryObject, 12, ntdll)
-LoadDLLfuncNt (NtOpenFile, 24, ntdll)
-LoadDLLfuncNt (NtOpenSection, 12, ntdll)
-LoadDLLfuncNt (NtQueryDirectoryObject, 28, ntdll)
-LoadDLLfuncNt (NtQueryDirectoryFile, 44, ntdll)
-LoadDLLfuncNt (NtQueryEaFile, 36, ntdll)
-LoadDLLfuncNt (NtQueryInformationFile, 20, ntdll)
-LoadDLLfuncNt (NtQueryInformationProcess, 20, ntdll)
-LoadDLLfuncNt (NtQueryObject, 20, ntdll)
-LoadDLLfuncNt (NtQuerySystemInformation, 16, ntdll)
-LoadDLLfuncNt (NtQuerySecurityObject, 20, ntdll)
-LoadDLLfuncNt (NtQueryVirtualMemory, 24, ntdll)
-LoadDLLfuncNt (NtQueryVolumeInformationFile, 20, ntdll)
-LoadDLLfuncNt (NtSetEaFile, 16, ntdll)
-LoadDLLfuncNt (NtSetInformationFile, 20, ntdll)
-LoadDLLfuncNt (NtSetSecurityObject, 12, ntdll)
-LoadDLLfuncNt (NtUnlockVirtualMemory, 16, ntdll)
-LoadDLLfuncNt (NtUnmapViewOfSection, 8, ntdll)
-LoadDLLfuncNt (RtlAnsiStringToUnicodeString, 12, ntdll)
-LoadDLLfuncNt (RtlInitUnicodeString, 8, ntdll)
-LoadDLLfuncNt (RtlIsDosDeviceName_U, 4, ntdll)
-LoadDLLfuncNt (RtlNtStatusToDosError, 4, ntdll)
-LoadDLLfuncNt (RtlOemStringToUnicodeString, 12, ntdll)
-
LoadDLLfuncEx (EnumProcessModules, 16, psapi, 1)
LoadDLLfuncEx (GetModuleFileNameExA, 16, psapi, 1)
LoadDLLfuncEx (GetModuleInformation, 16, psapi, 1)
@@ -505,29 +401,16 @@ LoadDLLfuncEx2 (SendARP, 16, iphlpapi, 1, 50)
LoadDLLfunc (CoTaskMemFree, 4, ole32)
-LoadDLLfuncEx (CancelIo, 4, kernel32, 1)
LoadDLLfuncEx (CreateHardLinkA, 12, kernel32, 1)
LoadDLLfuncEx (CreateToolhelp32Snapshot, 8, kernel32, 1)
LoadDLLfuncEx (FindFirstVolumeA, 8, kernel32, 1)
LoadDLLfuncEx (FindNextVolumeA, 12, kernel32, 1)
LoadDLLfuncEx (FindVolumeClose, 4, kernel32, 1)
-LoadDLLfuncEx2 (GetCompressedFileSizeA, 8, kernel32, 1, 0xffffffff)
LoadDLLfuncEx (GetConsoleWindow, 0, kernel32, 1)
-LoadDLLfuncEx (GetDiskFreeSpaceEx, 16, kernel32, 1)
-LoadDLLfuncEx (GetHandleInformation, 8, kernel32, 1)
-LoadDLLfuncEx (GetNativeSystemInfo, 4, kernel32, 1)
-LoadDLLfuncEx (GetProcessWorkingSetSize, 12, kernel32, 1)
LoadDLLfuncEx (GetVolumeNameForVolumeMountPointA, 12, kernel32, 1)
-LoadDLLfuncEx2 (IsDebuggerPresent, 0, kernel32, 1, 1)
-LoadDLLfunc (IsProcessorFeaturePresent, 4, kernel32);
LoadDLLfuncEx (IsWow64Process, 8, kernel32, 1);
LoadDLLfuncEx (Process32First, 8, kernel32, 1)
LoadDLLfuncEx (Process32Next, 8, kernel32, 1)
-LoadDLLfuncEx (RegisterServiceProcess, 8, kernel32, 1)
-LoadDLLfuncEx (SetHandleInformation, 12, kernel32, 1)
-LoadDLLfuncEx (SetProcessWorkingSetSize, 12, kernel32, 1)
-LoadDLLfuncEx (SignalObjectAndWait, 16, kernel32, 1)
-LoadDLLfuncEx (SwitchToThread, 0, kernel32, 1)
LoadDLLfuncEx (Wow64DisableWow64FsRedirection, 4, kernel32, 1)
LoadDLLfuncEx (Wow64RevertWow64FsRedirection, 4, kernel32, 1)
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index f15d6a8ae..49df3ff95 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -1,6 +1,6 @@
/* cygheap.h: Cygwin heap manager.
- Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
+ Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -208,10 +208,7 @@ public:
}
char * get_windows_id (char * buf)
{
- if (wincap.is_winnt ())
- return effec_cygsid.string (buf);
- else
- return strcpy (buf, name ());
+ return effec_cygsid.string (buf);
}
const char *test_uid (char *&, const char *, size_t)
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 8281f3676..c31bbb72f 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -1,7 +1,7 @@
/* dcrt0.cc -- essentially the main() for the Cygwin dll
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006 Red Hat, Inc.
+ 2006, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -726,7 +726,6 @@ dll_crt0_0 ()
_impure_ptr->_current_locale = "C";
user_data->impure_ptr = _impure_ptr;
user_data->impure_ptr_ptr = &_impure_ptr;
- mmap_init ();
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
GetCurrentProcess (), &hMainProc, 0, FALSE,
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 60f136476..c5f727781 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -579,9 +579,6 @@ done:
int
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);
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 5fce7a1d6..1da8cd6b2 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -109,14 +109,12 @@ class fhandler_base
read or write access */
unsigned close_on_exec : 1; /* close-on-exec */
unsigned need_fork_fixup : 1; /* Set if need to fixup after fork. */
- unsigned has_changed : 1; /* Flag used to set ctime on close. */
public:
status_flags () :
rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
uninterruptible_io (0), append_mode (0), did_lseek (0),
- query_open (no_query), close_on_exec (0), need_fork_fixup (0),
- has_changed (0)
+ query_open (no_query), close_on_exec (0), need_fork_fixup (0)
{}
} status, open_status;
@@ -197,7 +195,6 @@ class fhandler_base
IMPLEMENT_STATUS_FLAG (query_state, query_open)
IMPLEMENT_STATUS_FLAG (bool, close_on_exec)
IMPLEMENT_STATUS_FLAG (bool, need_fork_fixup)
- IMPLEMENT_STATUS_FLAG (bool, has_changed)
int get_default_fmode (int flags);
@@ -681,9 +678,7 @@ class fhandler_dev_tape: public fhandler_dev_raw
class fhandler_disk_file: public fhandler_base
{
- void touch_ctime ();
int readdir_helper (DIR *, dirent *, DWORD, DWORD, char *) __attribute__ ((regparm (3)));
- int readdir_9x (DIR *, dirent *) __attribute__ ((regparm (3)));
public:
fhandler_disk_file ();
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index f1a9dece4..d68872bec 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -210,90 +210,61 @@ path_conv::isgood_inode (__ino64_t ino) const
int __stdcall
fhandler_base::fstat_by_handle (struct __stat64 *buf)
{
- BY_HANDLE_FILE_INFORMATION local;
-
- if (wincap.is_winnt ())
- {
- NTSTATUS status;
- IO_STATUS_BLOCK io;
- /* The entries potentially contain a name of MAX_PATH wide characters. */
- const DWORD fvi_size = 2 * CYG_MAX_PATH
- + sizeof (FILE_FS_VOLUME_INFORMATION);
- const DWORD fai_size = 2 * CYG_MAX_PATH + sizeof (FILE_ALL_INFORMATION);
-
- PFILE_FS_VOLUME_INFORMATION pfvi = (PFILE_FS_VOLUME_INFORMATION)
- alloca (fvi_size);
- PFILE_ALL_INFORMATION pfai = (PFILE_ALL_INFORMATION) alloca (fai_size);
-
- status = NtQueryVolumeInformationFile (get_handle (), &io, pfvi, fvi_size,
- FileFsVolumeInformation);
- if (!NT_SUCCESS (status))
- {
- debug_printf ("%u = NtQueryVolumeInformationFile)",
- RtlNtStatusToDosError (status));
- pfvi->VolumeSerialNumber = 0; /* Set to pc.volser () in helper. */
- }
- status = NtQueryInformationFile (get_handle (), &io, pfai, fai_size,
- FileAllInformation);
- if (NT_SUCCESS (status))
- {
- /* If the change time is 0, it's a file system which doesn't
- support a change timestamp. In that case use the LastWriteTime
- entry, as in other calls to fstat_helper. */
- if (pc.is_rep_symlink ())
- pfai->BasicInformation.FileAttributes &= ~FILE_ATTRIBUTE_DIRECTORY;
- pc.file_attributes (pfai->BasicInformation.FileAttributes);
- return fstat_helper (buf,
- pfai->BasicInformation.ChangeTime.QuadPart ?
- *(FILETIME *) &pfai->BasicInformation.ChangeTime :
- *(FILETIME *) &pfai->BasicInformation.LastWriteTime,
- *(FILETIME *) &pfai->BasicInformation.LastAccessTime,
- *(FILETIME *) &pfai->BasicInformation.LastWriteTime,
- pfvi->VolumeSerialNumber,
- pfai->StandardInformation.EndOfFile.QuadPart,
- pfai->StandardInformation.AllocationSize.QuadPart,
- pfai->InternalInformation.FileId.QuadPart,
- pfai->StandardInformation.NumberOfLinks,
- pfai->BasicInformation.FileAttributes);
- }
+ NTSTATUS status;
+ IO_STATUS_BLOCK io;
+ /* The entries potentially contain a name of MAX_PATH wide characters. */
+ const DWORD fvi_size = 2 * CYG_MAX_PATH
+ + sizeof (FILE_FS_VOLUME_INFORMATION);
+ const DWORD fai_size = 2 * CYG_MAX_PATH + sizeof (FILE_ALL_INFORMATION);
- debug_printf ("%u = NtQueryInformationFile)",
- RtlNtStatusToDosError (status));
- }
+ PFILE_FS_VOLUME_INFORMATION pfvi = (PFILE_FS_VOLUME_INFORMATION)
+ alloca (fvi_size);
+ PFILE_ALL_INFORMATION pfai = (PFILE_ALL_INFORMATION) alloca (fai_size);
- BOOL res = GetFileInformationByHandle (get_handle (), &local);
- debug_printf ("%d = GetFileInformationByHandle (%s, %d)",
- res, get_win32_name (), get_handle ());
- /* GetFileInformationByHandle will fail if it's given stdio handle or pipe.
- It also fails on 9x when trying to access directories on shares. */
- if (!res)
+ status = NtQueryVolumeInformationFile (get_handle (), &io, pfvi, fvi_size,
+ FileFsVolumeInformation);
+ if (!NT_SUCCESS (status))
{
- memset (&local, 0, sizeof (local));
- local.nFileSizeLow = GetFileSize (get_handle (), &local.nFileSizeHigh);
- /* Even GetFileSize fails on 9x when trying to access directories
- on shares. In this case reset filesize to 0. */
- if (local.nFileSizeLow == 0xffffffff && GetLastError ())
- local.nFileSizeLow = 0;
- local.dwFileAttributes = DWORD (pc);
+ debug_printf ("%u = NtQueryVolumeInformationFile)",
+ RtlNtStatusToDosError (status));
+ pfvi->VolumeSerialNumber = 0; /* Set to pc.volser () in helper. */
}
- else
+ status = NtQueryInformationFile (get_handle (), &io, pfai, fai_size,
+ FileAllInformation);
+ if (NT_SUCCESS (status))
{
+ /* If the change time is 0, it's a file system which doesn't
+ support a change timestamp. In that case use the LastWriteTime
+ entry, as in other calls to fstat_helper. */
if (pc.is_rep_symlink ())
- local.dwFileAttributes &= ~FILE_ATTRIBUTE_DIRECTORY;
- pc.file_attributes (local.dwFileAttributes);
- }
- return fstat_helper (buf,
- local.ftLastWriteTime, /* see fstat_helper comment */
- local.ftLastAccessTime,
- local.ftLastWriteTime,
- local.dwVolumeSerialNumber,
- (ULONGLONG) local.nFileSizeHigh << 32
- | local.nFileSizeLow,
- -1LL,
- (ULONGLONG) local.nFileIndexHigh << 32
- | local.nFileIndexLow,
- local.nNumberOfLinks,
- local.dwFileAttributes);
+ pfai->BasicInformation.FileAttributes &= ~FILE_ATTRIBUTE_DIRECTORY;
+ pc.file_attributes (pfai->BasicInformation.FileAttributes);
+ return fstat_helper (buf,
+ pfai->BasicInformation.ChangeTime.QuadPart ?
+ *(FILETIME *) &pfai->BasicInformation.ChangeTime :
+ *(FILETIME *) &pfai->BasicInformation.LastWriteTime,
+ *(FILETIME *) &pfai->BasicInformation.LastAccessTime,
+ *(FILETIME *) &pfai->BasicInformation.LastWriteTime,
+ pfvi->VolumeSerialNumber,
+ pfai->StandardInformation.EndOfFile.QuadPart,
+ pfai->StandardInformation.AllocationSize.QuadPart,
+ pfai->InternalInformation.FileId.QuadPart,
+ pfai->StandardInformation.NumberOfLinks,
+ pfai->BasicInformation.FileAttributes);
+ }
+
+ debug_printf ("%u = NtQueryInformationFile)",
+ RtlNtStatusToDosError (status));
+
+ /* Last resort */
+ FILETIME ft = { 0, 0 };
+ DWORD lowfs, highfs;
+
+ lowfs = GetFileSize (get_handle (), &highfs);
+ if (lowfs == 0xffffffff && GetLastError ())
+ lowfs = highfs = 0;
+ return fstat_helper (buf, ft, ft, ft, 0, (ULONGLONG) highfs << 32 | lowfs,
+ -1LL, 0ULL, 1, DWORD (pc));
}
int __stdcall
@@ -556,26 +527,9 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
int __stdcall
fhandler_disk_file::fstat (struct __stat64 *buf)
{
- /* Changing inode data requires setting ctime (only 9x). */
- if (has_changed ())
- touch_ctime ();
return fstat_fs (buf);
}
-void
-fhandler_disk_file::touch_ctime ()
-{
- FILETIME ft;
-
- GetSystemTimeAsFileTime (&ft);
- /* Modification time is touched if the file data has changed as well.
- This happens for instance on write() or ftruncate(). */
- if (!SetFileTime (get_io_handle (), NULL, NULL, &ft))
- debug_printf ("SetFileTime (%s) failed, %E", get_win32_name ());
- else
- has_changed (false);
-}
-
int __stdcall
fhandler_disk_file::fchmod (mode_t mode)
{
@@ -623,10 +577,6 @@ fhandler_disk_file::fchmod (mode_t mode)
/* Correct NTFS security attributes have higher priority */
res = 0;
- /* Set ctime on success. */
- if (!res && !wincap.is_winnt ())
- has_changed (true);
-
if (oret)
close ();
@@ -783,9 +733,6 @@ fhandler_disk_file::fadvise (_off64_t offset, _off64_t length, int advice)
return -1;
}
- if (!wincap.is_winnt ())
- return 0;
-
/* Windows only supports advice flags for the whole file. We're using
a simplified test here so that we don't have to ask for the actual
file size. Length == 0 means all bytes starting at offset anyway.
@@ -835,6 +782,10 @@ fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
{
_off64_t actual_length;
DWORD size_high = 0;
+ NTSTATUS status;
+ IO_STATUS_BLOCK io;
+ FILE_END_OF_FILE_INFORMATION feofi;
+
actual_length = GetFileSize (get_handle (), &size_high);
actual_length += ((_off64_t) size_high) << 32;
@@ -843,49 +794,27 @@ fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
if (!allow_truncate && length < actual_length)
return 0;
- if (wincap.is_winnt ())
+ feofi.EndOfFile.QuadPart = length;
+ /* Create sparse files only when called through ftruncate, not when
+ called through posix_fallocate. */
+ if (allow_truncate
+ && get_fs_flags (FILE_SUPPORTS_SPARSE_FILES)
+ && length >= actual_length + (128 * 1024))
{
- NTSTATUS status;
- IO_STATUS_BLOCK io;
- FILE_END_OF_FILE_INFORMATION feofi;
-
- feofi.EndOfFile.QuadPart = length;
- /* Create sparse files only when called through ftruncate, not when
- called through posix_fallocate. */
- if (allow_truncate
- && get_fs_flags (FILE_SUPPORTS_SPARSE_FILES)
- && length >= actual_length + (128 * 1024))
- {
- DWORD dw;
- BOOL r = DeviceIoControl (get_handle (),
- FSCTL_SET_SPARSE, NULL, 0, NULL,
- 0, &dw, NULL);
- syscall_printf ("%d = DeviceIoControl(%p, FSCTL_SET_SPARSE)",
- r, get_handle ());
- }
- status = NtSetInformationFile (get_handle (), &io,
- &feofi, sizeof feofi,
- FileEndOfFileInformation);
- if (!NT_SUCCESS (status))
- __seterrno_from_nt_status (status);
- else
- res = 0;
+ DWORD dw;
+ BOOL r = DeviceIoControl (get_handle (),
+ FSCTL_SET_SPARSE, NULL, 0, NULL,
+ 0, &dw, NULL);
+ syscall_printf ("%d = DeviceIoControl(%p, FSCTL_SET_SPARSE)",
+ r, get_handle ());
}
+ status = NtSetInformationFile (get_handle (), &io,
+ &feofi, sizeof feofi,
+ FileEndOfFileInformation);
+ if (!NT_SUCCESS (status))
+ __seterrno_from_nt_status (status);
else
- {
- _off64_t prev_loc = lseek (0, SEEK_CUR);
- if (lseek (length, SEEK_SET) >= 0)
- {
- int res_bug = write (&res, 0);
- if (!SetEndOfFile (get_handle ()))
- __seterrno ();
- else
- res = res_bug;
- /* restore original file pointer location */
- lseek (prev_loc, SEEK_SET);
- }
-
- }
+ res = 0;
}
return res;
}
@@ -1050,9 +979,6 @@ docopy:
__seterrno ();
return -1;
}
- /* Set ctime on success (copy gets it automatically). */
- if (!wincap.is_winnt ())
- has_changed (true);
close ();
fhandler_disk_file fh (newpc);
fh.query_open (query_write_attributes);
@@ -1200,12 +1126,6 @@ out:
int
fhandler_disk_file::close ()
{
- if (!hExeced)
- {
- /* Changing inode data requires setting ctime (only 9x). */
- if (has_changed ())
- touch_ctime ();
- }
return close_fs ();
}
@@ -1462,16 +1382,10 @@ fhandler_disk_file::rmdir ()
(DWORD) pc & ~FILE_ATTRIBUTE_READONLY);
DWORD err, att = 0;
- int rc;
- if (wincap.is_winnt ())
- {
- rc = !(err = unlink_nt (pc, pc.has_attribute (FILE_ATTRIBUTE_READONLY)));
- if (err)
- SetLastError (err);
- }
- else
- rc = RemoveDirectory (get_win32_name ());
+ int rc = !(err = unlink_nt (pc, pc.has_attribute (FILE_ATTRIBUTE_READONLY)));
+ if (err)
+ SetLastError (err);
if (isremote () && exists ())
att = GetFileAttributes (get_win32_name ());
@@ -1503,10 +1417,6 @@ fhandler_disk_file::rmdir ()
__seterrno_from_win_error (err);
- /* Directory still exists, restore its characteristics. */
- if (!wincap.is_winnt () && pc.has_attribute (FILE_ATTRIBUTE_READONLY))
- SetFileAttributes (get_win32_name (), (DWORD) pc);
-
return res;
}
@@ -1547,9 +1457,8 @@ fhandler_disk_file::opendir ()
set_errno (ENAMETOOLONG);
else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
set_errno (ENOMEM);
- else if ((dir->__d_dirname = (char *) malloc (wincap.is_winnt ()
- ? sizeof (struct __DIR_cache)
- : len + 3)) == NULL)
+ else if ((dir->__d_dirname = (char *) malloc ( sizeof (struct __DIR_cache)))
+ == NULL)
{
set_errno (ENOMEM);
goto free_dir;
@@ -1586,47 +1495,45 @@ fhandler_disk_file::opendir ()
&& pc.normalized_path[1] == '\0')
? dirent_isroot : 0;
dir->__d_internal = (unsigned) new __DIR_mounts (pc.normalized_path);
- if (wincap.is_winnt ())
+ d_cachepos (dir) = 0;
+
+ if (!pc.iscygdrive ())
{
- d_cachepos (dir) = 0;
- if (!pc.iscygdrive ())
+ OBJECT_ATTRIBUTES attr;
+ WCHAR wpath[CYG_MAX_PATH + 10];
+ UNICODE_STRING upath = {0, sizeof (wpath), wpath};
+ IO_STATUS_BLOCK io;
+ NTSTATUS status;
+ SECURITY_ATTRIBUTES sa = sec_none;
+ pc.get_nt_native_path (upath);
+ InitializeObjectAttributes (&attr, &upath,
+ OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
+ NULL, sa.lpSecurityDescriptor);
+ status = NtOpenFile (&dir->__handle,
+ SYNCHRONIZE | FILE_LIST_DIRECTORY,
+ &attr, &io, wincap.shared (),
+ FILE_SYNCHRONOUS_IO_NONALERT
+ | FILE_OPEN_FOR_BACKUP_INTENT
+ | FILE_DIRECTORY_FILE);
+ if (!NT_SUCCESS (status))
{
- OBJECT_ATTRIBUTES attr;
- WCHAR wpath[CYG_MAX_PATH + 10];
- UNICODE_STRING upath = {0, sizeof (wpath), wpath};
- IO_STATUS_BLOCK io;
- NTSTATUS status;
- SECURITY_ATTRIBUTES sa = sec_none;
- pc.get_nt_native_path (upath);
- InitializeObjectAttributes (&attr, &upath,
- OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
- NULL, sa.lpSecurityDescriptor);
- status = NtOpenFile (&dir->__handle,
- SYNCHRONIZE | FILE_LIST_DIRECTORY,
- &attr, &io, wincap.shared (),
- FILE_SYNCHRONOUS_IO_NONALERT
- | FILE_OPEN_FOR_BACKUP_INTENT
- | FILE_DIRECTORY_FILE);
- if (!NT_SUCCESS (status))
- {
- __seterrno_from_nt_status (status);
- goto free_mounts;
- }
+ __seterrno_from_nt_status (status);
+ goto free_mounts;
+ }
- /* FileIdBothDirectoryInformation is apparently unsupported on
- XP when accessing directories on UDF. When trying to use it
- so, NtQueryDirectoryFile returns with STATUS_ACCESS_VIOLATION.
- It's not clear if the call isn't also unsupported on other
- OS/FS combinations (say, Win2K/CDFS or so). Instead of
- testing in readdir for yet another error code, let's use
- FileIdBothDirectoryInformation only on filesystems supporting
- persistent ACLs, FileBothDirectoryInformation otherwise. */
- if (pc.hasgood_inode ())
- {
- dir->__flags |= dirent_set_d_ino;
- if (wincap.has_fileid_dirinfo ())
- dir->__flags |= dirent_get_d_ino;
- }
+ /* FileIdBothDirectoryInformation is apparently unsupported on
+ XP when accessing directories on UDF. When trying to use it
+ so, NtQueryDirectoryFile returns with STATUS_ACCESS_VIOLATION.
+ It's not clear if the call isn't also unsupported on other
+ OS/FS combinations (say, Win2K/CDFS or so). Instead of
+ testing in readdir for yet another error code, let's use
+ FileIdBothDirectoryInformation only on filesystems supporting
+ persistent ACLs, FileBothDirectoryInformation otherwise. */
+ if (pc.hasgood_inode ())
+ {
+ dir->__flags |= dirent_set_d_ino;
+ if (wincap.has_fileid_dirinfo ())
+ dir->__flags |= dirent_get_d_ino;
}
}
/* Filling fd with `this' (aka storing this in the file descriptor table
@@ -1755,9 +1662,6 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
char fname[CYG_MAX_PATH];
IO_STATUS_BLOCK io;
- if (!wincap.is_winnt ())
- return readdir_9x (dir, de);
-
/* d_cachepos always refers to the next cache entry to use. If it's 0
we must reload the cache. */
if (d_cachepos (dir) == 0)
@@ -1911,55 +1815,6 @@ go_ahead:
return res;
}
-int
-fhandler_disk_file::readdir_9x (DIR *dir, dirent *de)
-{
- WIN32_FIND_DATA buf;
- int res = 0;
-
- if (!dir->__handle)
- {
- res = ENMFILE;
- goto out;
- }
- DWORD lasterr;
- if (dir->__d_position != 0)
- lasterr = FindNextFileA (dir->__handle, &buf) ? 0 : GetLastError ();
- else if (dir->__handle != INVALID_HANDLE_VALUE)
- {
- res = EBADF;
- goto out;
- }
- else
- {
- int len = strlen (dir->__d_dirname);
- strcpy (dir->__d_dirname + len, "*");
- dir->__handle = FindFirstFile (dir->__d_dirname, &buf);
- dir->__d_dirname[len] = '\0';
- if (dir->__handle != INVALID_HANDLE_VALUE)
- lasterr = 0;
- else if ((lasterr = GetLastError ()) != ERROR_NO_MORE_FILES)
- {
- res = geterrno_from_win_error (lasterr);
- goto out;
- }
- }
- if (!lasterr)
- de->d_ino = d_mounts (dir)->check_mount (buf.cFileName, de->d_ino);
- if (!(res = readdir_helper (dir, de, lasterr, buf.dwFileAttributes,
- buf.cFileName)))
- dir->__d_position++;
- else
- {
- FindClose (dir->__handle);
- dir->__handle = NULL;
- }
-
-out:
- syscall_printf ("%d = readdir (%p, %p) (%s)", res, dir, &de, res ? "***" : de->d_name);
- return res;
-}
-
_off64_t
fhandler_disk_file::telldir (DIR *dir)
{
@@ -1978,45 +1833,36 @@ fhandler_disk_file::seekdir (DIR *dir, _off64_t loc)
void
fhandler_disk_file::rewinddir (DIR *dir)
{
- if (wincap.is_winnt ())
- {
- d_cachepos (dir) = 0;
- if (wincap.has_buggy_restart_scan () && isremote ())
+ d_cachepos (dir) = 0;
+ if (wincap.has_buggy_restart_scan () && isremote ())
+ {
+ /* This works around a W2K bug. The RestartScan parameter in calls
+ to NtQueryDirectoryFile 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 pointer. */
+ 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
{
- /* This works around a W2K bug. The RestartScan parameter in calls
- to NtQueryDirectoryFile 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 pointer. */
- 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;
- }
+ CloseHandle (dir->__handle);
+ dir->__handle = new_dir;
}
}
- else if (dir->__handle != INVALID_HANDLE_VALUE)
- {
- if (dir->__handle)
- FindClose (dir->__handle);
- dir->__handle = INVALID_HANDLE_VALUE;
- }
dir->__d_position = 0;
d_mounts (dir)->rewind ();
}
@@ -2033,18 +1879,10 @@ fhandler_disk_file::closedir (DIR *dir)
set_errno (EBADF);
res = -1;
}
- else
+ else if (!NtClose (dir->__handle))
{
- BOOL winres;
- if (wincap.is_winnt ())
- winres = CloseHandle (dir->__handle);
- else
- winres = FindClose (dir->__handle);
- if (!winres)
- {
- __seterrno ();
- res = -1;
- }
+ __seterrno ();
+ res = -1;
}
syscall_printf ("%d = closedir (%p, %s)", res, dir, get_name ());
return res;
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index d4ea8b762..c08befea9 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -479,34 +479,32 @@ format_proc_uptime (char *destbuf, size_t maxsize)
{
unsigned long long uptime = 0ULL, idle_time = 0ULL;
- if (wincap.is_winnt ())
+ NTSTATUS ret;
+ SYSTEM_BASIC_INFORMATION sbi;
+
+ ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi,
+ sizeof sbi, NULL);
+ if (!NT_SUCCESS (ret))
{
- NTSTATUS ret;
- SYSTEM_BASIC_INFORMATION sbi;
+ __seterrno_from_nt_status (ret);
+ debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", ret);
+ sbi.NumberProcessors = 1;
+ }
- ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi,
- sizeof sbi, NULL);
- if (!NT_SUCCESS (ret))
- {
- __seterrno_from_nt_status (ret);
- debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", ret);
- sbi.NumberProcessors = 1;
- }
+ SYSTEM_PROCESSOR_TIMES spt[sbi.NumberProcessors];
+ ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
+ sizeof spt[0] * sbi.NumberProcessors,
+ NULL);
+ if (NT_SUCCESS (ret))
+ for (int i = 0; i < sbi.NumberProcessors; i++)
+ {
+ uptime += (spt[i].KernelTime.QuadPart + spt[i].UserTime.QuadPart)
+ / 100000ULL;
+ idle_time += spt[i].IdleTime.QuadPart / 100000ULL;
+ }
+ uptime /= sbi.NumberProcessors;
+ idle_time /= sbi.NumberProcessors;
- SYSTEM_PROCESSOR_TIMES spt[sbi.NumberProcessors];
- ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
- sizeof spt[0] * sbi.NumberProcessors,
- NULL);
- if (NT_SUCCESS (ret))
- for (int i = 0; i < sbi.NumberProcessors; i++)
- {
- uptime += (spt[i].KernelTime.QuadPart + spt[i].UserTime.QuadPart)
- / 100000ULL;
- idle_time += spt[i].IdleTime.QuadPart / 100000ULL;
- }
- uptime /= sbi.NumberProcessors;
- idle_time /= sbi.NumberProcessors;
- }
if (!uptime)
uptime = GetTickCount () / 10;
@@ -523,86 +521,75 @@ format_proc_stat (char *destbuf, size_t maxsize)
time_t boot_time = 0;
char *eobuf = destbuf;
- if (!wincap.is_winnt ())
- eobuf += __small_sprintf (destbuf, "cpu %U %U %U %U\n", 0ULL, 0ULL, 0ULL, 0ULL);
- else
+ NTSTATUS ret;
+ SYSTEM_PERFORMANCE_INFORMATION spi;
+ SYSTEM_TIME_OF_DAY_INFORMATION stodi;
+
+ SYSTEM_BASIC_INFORMATION sbi;
+ if ((ret = NtQuerySystemInformation (SystemBasicInformation,
+ (PVOID) &sbi, sizeof sbi, NULL))
+ != STATUS_SUCCESS)
+ {
+ __seterrno_from_nt_status (ret);
+ debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", ret);
+ sbi.NumberProcessors = 1;
+ }
+
+ SYSTEM_PROCESSOR_TIMES spt[sbi.NumberProcessors];
+ ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
+ sizeof spt[0] * sbi.NumberProcessors, NULL);
+ interrupt_count = 0;
+ if (ret == STATUS_SUCCESS)
{
- NTSTATUS ret;
- SYSTEM_PERFORMANCE_INFORMATION spi;
- SYSTEM_TIME_OF_DAY_INFORMATION stodi;
-
- SYSTEM_BASIC_INFORMATION sbi;
- if ((ret = NtQuerySystemInformation (SystemBasicInformation,
- (PVOID) &sbi, sizeof sbi, NULL))
- != STATUS_SUCCESS)
+ unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
+ for (int i = 0; i < sbi.NumberProcessors; i++)
{
- __seterrno_from_nt_status (ret);
- debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", ret);
- sbi.NumberProcessors = 1;
+ kernel_time += (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart)
+ * HZ / 10000000ULL;
+ user_time += spt[i].UserTime.QuadPart * HZ / 10000000ULL;
+ idle_time += spt[i].IdleTime.QuadPart * HZ / 10000000ULL;
}
- SYSTEM_PROCESSOR_TIMES spt[sbi.NumberProcessors];
- ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
- sizeof spt[0] * sbi.NumberProcessors, NULL);
- interrupt_count = 0;
- if (ret == STATUS_SUCCESS)
+ eobuf += __small_sprintf (eobuf, "cpu %U %U %U %U\n",
+ user_time, 0ULL, kernel_time, idle_time);
+ user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
+ for (int i = 0; i < sbi.NumberProcessors; i++)
{
- unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
- for (int i = 0; i < sbi.NumberProcessors; i++)
- {
- kernel_time += (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / 10000000ULL;
- user_time += spt[i].UserTime.QuadPart * HZ / 10000000ULL;
- idle_time += spt[i].IdleTime.QuadPart * HZ / 10000000ULL;
- }
-
- eobuf += __small_sprintf (eobuf, "cpu %U %U %U %U\n",
+ interrupt_count += spt[i].InterruptCount;
+ kernel_time = (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / 10000000ULL;
+ user_time = spt[i].UserTime.QuadPart * HZ / 10000000ULL;
+ idle_time = spt[i].IdleTime.QuadPart * HZ / 10000000ULL;
+ eobuf += __small_sprintf (eobuf, "cpu%d %U %U %U %U\n", i,
user_time, 0ULL, kernel_time, idle_time);
- user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
- for (int i = 0; i < sbi.NumberProcessors; i++)
- {
- interrupt_count += spt[i].InterruptCount;
- kernel_time = (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / 10000000ULL;
- user_time = spt[i].UserTime.QuadPart * HZ / 10000000ULL;
- idle_time = spt[i].IdleTime.QuadPart * HZ / 10000000ULL;
- eobuf += __small_sprintf (eobuf, "cpu%d %U %U %U %U\n", i,
- user_time, 0ULL, kernel_time, idle_time);
- }
-
- ret = NtQuerySystemInformation (SystemPerformanceInformation,
- (PVOID) &spi, sizeof spi, NULL);
- }
- if (ret == STATUS_SUCCESS)
- ret = NtQuerySystemInformation (SystemTimeOfDayInformation,
- (PVOID) &stodi,
- sizeof stodi, NULL);
- if (ret != STATUS_SUCCESS)
- {
- __seterrno_from_nt_status (ret);
- debug_printf("NtQuerySystemInformation: ret %d, Dos(ret) %E", ret);
- return 0;
}
- pages_in = spi.PagesRead;
- pages_out = spi.PagefilePagesWritten + spi.MappedFilePagesWritten;
- /*
- * Note: there is no distinction made in this structure between pages
- * read from the page file and pages read from mapped files, but there
- * is such a distinction made when it comes to writing. Goodness knows
- * why. The value of swap_in, then, will obviously be wrong but its our
- * best guess.
- */
- swap_in = spi.PagesRead;
- swap_out = spi.PagefilePagesWritten;
- context_switches = spi.ContextSwitches;
- boot_time = to_time_t ((FILETIME *) &stodi.BootTime.QuadPart);
+
+ ret = NtQuerySystemInformation (SystemPerformanceInformation,
+ (PVOID) &spi, sizeof spi, NULL);
}
+ if (ret == STATUS_SUCCESS)
+ ret = NtQuerySystemInformation (SystemTimeOfDayInformation,
+ (PVOID) &stodi,
+ sizeof stodi, NULL);
+ if (ret != STATUS_SUCCESS)
+ {
+ __seterrno_from_nt_status (ret);
+ debug_printf("NtQuerySystemInformation: ret %d, Dos(ret) %E", ret);
+ return 0;
+ }
+ pages_in = spi.PagesRead;
+ pages_out = spi.PagefilePagesWritten + spi.MappedFilePagesWritten;
/*
- * else
- * {
- * There are only two relevant performance counters on Windows 95/98/me,
- * VMM/cPageIns and VMM/cPageOuts. The extra effort needed to read these
- * counters is by no means worth it.
- * }
+ * Note: there is no distinction made in this structure between pages
+ * read from the page file and pages read from mapped files, but there
+ * is such a distinction made when it comes to writing. Goodness knows
+ * why. The value of swap_in, then, will obviously be wrong but its our
+ * best guess.
*/
+ swap_in = spi.PagesRead;
+ swap_out = spi.PagefilePagesWritten;
+ context_switches = spi.ContextSwitches;
+ boot_time = to_time_t ((FILETIME *) &stodi.BootTime.QuadPart);
+
eobuf += __small_sprintf (eobuf, "page %u %u\n"
"swap %u %u\n"
"intr %u\n"
@@ -697,29 +684,26 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
bufptr += __small_sprintf (bufptr, "vendor_id : %s\n", szBuffer);
read_value ("Identifier", REG_SZ);
bufptr += __small_sprintf (bufptr, "identifier : %s\n", szBuffer);
- if (wincap.is_winnt ())
- {
- read_value ("~Mhz", REG_DWORD);
- bufptr += __small_sprintf (bufptr, "cpu MHz : %u\n", *(DWORD *) szBuffer);
-
- print ("flags :");
- if (IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE))
- print (" 3dnow");
- if (IsProcessorFeaturePresent (PF_COMPARE_EXCHANGE_DOUBLE))
- print (" cx8");
- if (!IsProcessorFeaturePresent (PF_FLOATING_POINT_EMULATED))
- print (" fpu");
- if (IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE))
- print (" mmx");
- if (IsProcessorFeaturePresent (PF_PAE_ENABLED))
- print (" pae");
- if (IsProcessorFeaturePresent (PF_RDTSC_INSTRUCTION_AVAILABLE))
- print (" tsc");
- if (IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE))
- print (" sse");
- if (IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE))
- print (" sse2");
- }
+ read_value ("~Mhz", REG_DWORD);
+ bufptr += __small_sprintf (bufptr, "cpu MHz : %u\n", *(DWORD *) szBuffer);
+
+ print ("flags :");
+ if (IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE))
+ print (" 3dnow");
+ if (IsProcessorFeaturePresent (PF_COMPARE_EXCHANGE_DOUBLE))
+ print (" cx8");
+ if (!IsProcessorFeaturePresent (PF_FLOATING_POINT_EMULATED))
+ print (" fpu");
+ if (IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE))
+ print (" mmx");
+ if (IsProcessorFeaturePresent (PF_PAE_ENABLED))
+ print (" pae");
+ if (IsProcessorFeaturePresent (PF_RDTSC_INSTRUCTION_AVAILABLE))
+ print (" tsc");
+ if (IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE))
+ print (" sse");
+ if (IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE))
+ print (" sse2");
}
else
{
@@ -736,13 +720,10 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
else if (!strcmp ((char*)vendor_id, "GenuineIntel"))
is_intel = true;
- bufptr += __small_sprintf (bufptr, "vendor_id : %s\n", (char *)vendor_id);
- unsigned cpu_mhz = 0;
- if (wincap.is_winnt ())
- {
- read_value ("~Mhz", REG_DWORD);
- cpu_mhz = *(DWORD *)szBuffer;
- }
+ bufptr += __small_sprintf (bufptr, "vendor_id : %s\n",
+ (char *)vendor_id);
+ read_value ("~Mhz", REG_DWORD);
+ unsigned cpu_mhz = *(DWORD *)szBuffer;
if (maxf >= 1)
{
unsigned features2, features1, extra_info, cpuid_sig;
@@ -778,9 +759,12 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
if (maxe >= 0x80000004)
{
unsigned *model_name = (unsigned *) szBuffer;
- cpuid (&model_name[0], &model_name[1], &model_name[2], &model_name[3], 0x80000002);
- cpuid (&model_name[4], &model_name[5], &model_name[6], &model_name[7], 0x80000003);
- cpuid (&model_name[8], &model_name[9], &model_name[10], &model_name[11], 0x80000004);
+ cpuid (&model_name[0], &model_name[1], &model_name[2],
+ &model_name[3], 0x80000002);
+ cpuid (&model_name[4], &model_name[5], &model_name[6],
+ &model_name[7], 0x80000003);
+ cpuid (&model_name[8], &model_name[9], &model_name[10],
+ &model_name[11], 0x80000004);
model_name[12] = 0;
}
else
@@ -788,50 +772,26 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
// could implement a lookup table here if someone needs it
strcpy (szBuffer, "unknown");
}
- if (wincap.is_winnt ())
- {
- bufptr += __small_sprintf (bufptr, "type : %s\n"
- "cpu family : %d\n"
- "model : %d\n"
- "model name : %s\n"
- "stepping : %d\n"
- "brand id : %d\n"
- "cpu count : %d\n"
- "apic id : %d\n"
- "cpu MHz : %d\n"
- "fpu : %s\n",
- type_str,
- family,
- model,
- szBuffer + strspn (szBuffer, " "),
- stepping,
- brand_id,
- cpu_count,
- apic_id,
- cpu_mhz,
- (features1 & (1 << 0)) ? "yes" : "no");
- }
- else
- {
- bufptr += __small_sprintf (bufptr, "type : %s\n"
- "cpu family : %d\n"
- "model : %d\n"
- "model name : %s\n"
- "stepping : %d\n"
- "brand id : %d\n"
- "cpu count : %d\n"
- "apic id : %d\n"
- "fpu : %s\n",
- type_str,
- family,
- model,
- szBuffer,
- stepping,
- brand_id,
- cpu_count,
- apic_id,
- (features1 & (1 << 0)) ? "yes" : "no");
- }
+ bufptr += __small_sprintf (bufptr, "type : %s\n"
+ "cpu family : %d\n"
+ "model : %d\n"
+ "model name : %s\n"
+ "stepping : %d\n"
+ "brand id : %d\n"
+ "cpu count : %d\n"
+ "apic id : %d\n"
+ "cpu MHz : %d\n"
+ "fpu : %s\n",
+ type_str,
+ family,
+ model,
+ szBuffer + strspn (szBuffer, " "),
+ stepping,
+ brand_id,
+ cpu_count,
+ apic_id,
+ cpu_mhz,
+ (features1 & (1 << 0)) ? "yes" : "no");
print ("flags :");
if (features1 & (1 << 0))
print (" fpu");
@@ -935,7 +895,7 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
}
}
}
- else if (wincap.is_winnt ())
+ else
{
bufptr += __small_sprintf (bufptr, "cpu MHz : %d\n"
"fpu : %s\n",
@@ -961,9 +921,6 @@ format_proc_partitions (char *destbuf, size_t maxsize)
char *bufptr = destbuf;
print ("major minor #blocks name\n\n");
- if (!wincap.is_winnt ())
- return bufptr - destbuf;
-
char devname[CYG_MAX_PATH];
OBJECT_ATTRIBUTES attr;
HANDLE dirhdl, devhdl;
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index 852e891e1..4da413b7e 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -1,6 +1,6 @@
/* fhandler_process.cc: fhandler for /proc/<pid> virtual filesystem
- Copyright 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
+ Copyright 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -515,9 +515,6 @@ fhandler_process::fill_filebuf ()
static _off64_t
format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize)
{
- if (!wincap.is_winnt ())
- return 0;
-
HANDLE proc = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE,
p->dwProcessId);
@@ -637,86 +634,84 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
state = 'Z';
else if (p->process_state & PID_STOPPED)
state = 'T';
- else if (wincap.is_winnt ())
+ else
state = get_process_state (p->dwProcessId);
start_time = (GetTickCount () / 1000 - time (NULL) + p->start_time) * HZ;
- if (wincap.is_winnt ())
+
+ NTSTATUS ret;
+ HANDLE hProcess;
+ VM_COUNTERS vmc;
+ KERNEL_USER_TIMES put;
+ PROCESS_BASIC_INFORMATION pbi;
+ QUOTA_LIMITS ql;
+ SYSTEM_TIME_OF_DAY_INFORMATION stodi;
+ SYSTEM_PROCESSOR_TIMES spt;
+ hProcess = OpenProcess (PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
+ FALSE, p->dwProcessId);
+ if (hProcess != NULL)
{
- NTSTATUS ret;
- HANDLE hProcess;
- VM_COUNTERS vmc;
- KERNEL_USER_TIMES put;
- PROCESS_BASIC_INFORMATION pbi;
- QUOTA_LIMITS ql;
- SYSTEM_TIME_OF_DAY_INFORMATION stodi;
- SYSTEM_PROCESSOR_TIMES spt;
- hProcess = OpenProcess (PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
- FALSE, p->dwProcessId);
- if (hProcess != NULL)
- {
- ret = NtQueryInformationProcess (hProcess,
- ProcessVmCounters,
- (PVOID) &vmc,
- sizeof vmc, NULL);
- if (ret == STATUS_SUCCESS)
- ret = NtQueryInformationProcess (hProcess,
- ProcessTimes,
- (PVOID) &put,
- sizeof put, NULL);
- if (ret == STATUS_SUCCESS)
- ret = NtQueryInformationProcess (hProcess,
- ProcessBasicInformation,
- (PVOID) &pbi,
- sizeof pbi, NULL);
- if (ret == STATUS_SUCCESS)
- ret = NtQueryInformationProcess (hProcess,
- ProcessQuotaLimits,
- (PVOID) &ql,
- sizeof ql, NULL);
- CloseHandle (hProcess);
- }
- else
- {
- DWORD error = GetLastError ();
- __seterrno_from_win_error (error);
- debug_printf ("OpenProcess: ret %d", error);
- return 0;
- }
+ ret = NtQueryInformationProcess (hProcess,
+ ProcessVmCounters,
+ (PVOID) &vmc,
+ sizeof vmc, NULL);
if (ret == STATUS_SUCCESS)
- ret = NtQuerySystemInformation (SystemTimeOfDayInformation,
- (PVOID) &stodi,
- sizeof stodi, NULL);
+ ret = NtQueryInformationProcess (hProcess,
+ ProcessTimes,
+ (PVOID) &put,
+ sizeof put, NULL);
if (ret == STATUS_SUCCESS)
- ret = NtQuerySystemInformation (SystemProcessorTimes,
- (PVOID) &spt,
- sizeof spt, NULL);
- if (ret != STATUS_SUCCESS)
- {
- __seterrno_from_nt_status (ret);
- debug_printf ("NtQueryInformationProcess: ret %d, Dos(ret) %E", ret);
- return 0;
- }
- fault_count = vmc.PageFaultCount;
- utime = put.UserTime.QuadPart * HZ / 10000000ULL;
- stime = put.KernelTime.QuadPart * HZ / 10000000ULL;
+ ret = NtQueryInformationProcess (hProcess,
+ ProcessBasicInformation,
+ (PVOID) &pbi,
+ sizeof pbi, NULL);
+ if (ret == STATUS_SUCCESS)
+ ret = NtQueryInformationProcess (hProcess,
+ ProcessQuotaLimits,
+ (PVOID) &ql,
+ sizeof ql, NULL);
+ CloseHandle (hProcess);
+ }
+ else
+ {
+ DWORD error = GetLastError ();
+ __seterrno_from_win_error (error);
+ debug_printf ("OpenProcess: ret %d", error);
+ return 0;
+ }
+ if (ret == STATUS_SUCCESS)
+ ret = NtQuerySystemInformation (SystemTimeOfDayInformation,
+ (PVOID) &stodi,
+ sizeof stodi, NULL);
+ if (ret == STATUS_SUCCESS)
+ ret = NtQuerySystemInformation (SystemProcessorTimes,
+ (PVOID) &spt,
+ sizeof spt, NULL);
+ if (ret != STATUS_SUCCESS)
+ {
+ __seterrno_from_nt_status (ret);
+ debug_printf ("NtQueryInformationProcess: ret %d, Dos(ret) %E", ret);
+ return 0;
+ }
+ fault_count = vmc.PageFaultCount;
+ utime = put.UserTime.QuadPart * HZ / 10000000ULL;
+ stime = put.KernelTime.QuadPart * HZ / 10000000ULL;
#if 0
- if (stodi.CurrentTime.QuadPart > put.CreateTime.QuadPart)
- start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart -
- stodi.CurrentTime.QuadPart + put.CreateTime.QuadPart) * HZ / 10000000ULL;
- else
- /*
- * sometimes stodi.CurrentTime is a bit behind
- * Note: some older versions of procps are broken and can't cope
- * with process start times > time(NULL).
- */
- start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL;
+ if (stodi.CurrentTime.QuadPart > put.CreateTime.QuadPart)
+ start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart -
+ stodi.CurrentTime.QuadPart + put.CreateTime.QuadPart) * HZ / 10000000ULL;
+ else
+ /*
+ * sometimes stodi.CurrentTime is a bit behind
+ * Note: some older versions of procps are broken and can't cope
+ * with process start times > time(NULL).
+ */
+ start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL;
#endif
- priority = pbi.BasePriority;
- unsigned page_size = getsystempagesize ();
- vmsize = vmc.PagefileUsage;
- vmrss = vmc.WorkingSetSize / page_size;
- vmmaxrss = ql.MaximumWorkingSetSize / page_size;
- }
+ priority = pbi.BasePriority;
+ unsigned page_size = getsystempagesize ();
+ vmsize = vmc.PagefileUsage;
+ vmrss = vmc.WorkingSetSize / page_size;
+ vmmaxrss = ql.MaximumWorkingSetSize / page_size;
return __small_sprintf (destbuf, "%d (%s) %c "
"%d %d %d %d %d "
@@ -767,7 +762,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
state = 'Z';
else if (p->process_state & PID_STOPPED)
state = 'T';
- else if (wincap.is_winnt ())
+ else
state = get_process_state (p->dwProcessId);
switch (state)
{
@@ -788,14 +783,12 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
state_str = "stopped";
break;
}
- if (wincap.is_winnt ())
- {
- if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata, &vmlib, &vmshare))
- return 0;
- unsigned page_size = getsystempagesize ();
- vmsize *= page_size; vmrss *= page_size; vmdata *= page_size;
- vmtext *= page_size; vmlib *= page_size;
- }
+ if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata,
+ &vmlib, &vmshare))
+ return 0;
+ unsigned page_size = getsystempagesize ();
+ vmsize *= page_size; vmrss *= page_size; vmdata *= page_size;
+ vmtext *= page_size; vmlib *= page_size;
// The real uid value for *this* process is stored at cygheap->user.real_uid
// but we can't get at the real uid value for any other process, so
// just fake it as p->uid. Similar for p->gid.
@@ -823,7 +816,8 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
p->ppid,
p->uid, p->uid, p->uid, p->uid,
p->gid, p->gid, p->gid, p->gid,
- vmsize >> 10, 0, vmrss >> 10, vmdata >> 10, 0, vmtext >> 10, vmlib >> 10,
+ vmsize >> 10, 0, vmrss >> 10, vmdata >> 10, 0,
+ vmtext >> 10, vmlib >> 10,
0, 0, p->getsigmask ()
);
}
@@ -833,15 +827,11 @@ format_process_statm (_pinfo *p, char *destbuf, size_t maxsize)
{
unsigned long vmsize = 0UL, vmrss = 0UL, vmtext = 0UL, vmdata = 0UL,
vmlib = 0UL, vmshare = 0UL;
- if (wincap.is_winnt ())
- {
- if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata,
- &vmlib, &vmshare))
- return 0;
- }
+ if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata,
+ &vmlib, &vmshare))
+ return 0;
return __small_sprintf (destbuf, "%ld %ld %ld %ld %ld %ld %ld",
- vmsize, vmrss, vmshare, vmtext, vmlib, vmdata, 0
- );
+ vmsize, vmrss, vmshare, vmtext, vmlib, vmdata, 0);
}
static int
diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc
index 48ccc4578..6a007466f 100644
--- a/winsup/cygwin/libc/bsdlib.cc
+++ b/winsup/cygwin/libc/bsdlib.cc
@@ -53,15 +53,6 @@ daemon (int nochdir, int noclose)
case -1:
return -1;
case 0:
- if (!wincap.is_winnt ())
- {
- /* Register as service under 9x/Me which allows to close
- the parent window with the daemon still running.
- This function only exists on 9x/Me and is autoloaded
- so it fails silently on NT. */
- DWORD WINAPI RegisterServiceProcess (DWORD, DWORD);
- RegisterServiceProcess (0, 1);
- }
break;
default:
/* This sleep avoids a race condition which kills the
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 78801fe00..e0154a898 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -152,121 +152,9 @@ gen_access (DWORD openflags, int flags)
return ret;
}
-/* OS specific wrapper functions for map/section functions. */
-static BOOL
-VirtualProt9x (PVOID addr, SIZE_T len, DWORD prot, PDWORD oldprot)
-{
- if (addr >= (caddr_t)0x80000000 && addr <= (caddr_t)0xBFFFFFFF)
- return TRUE; /* FAKEALARM! */
- return VirtualProtect (addr, len, prot, oldprot);
-}
-
-static BOOL
-VirtualProtNT (PVOID addr, SIZE_T len, DWORD prot, PDWORD oldprot)
-{
- return VirtualProtect (addr, len, prot, oldprot);
-}
-
-static BOOL
-VirtualProtEx9x (HANDLE parent, PVOID addr, SIZE_T len, DWORD prot,
- PDWORD oldprot)
-{
- if (addr >= (caddr_t)0x80000000 && addr <= (caddr_t)0xBFFFFFFF)
- return TRUE; /* FAKEALARM! */
- return VirtualProtectEx (parent, addr, len, prot, oldprot);
-}
-static BOOL
-VirtualProtExNT (HANDLE parent, PVOID addr, SIZE_T len, DWORD prot,
- PDWORD oldprot)
-{
- return VirtualProtectEx (parent, addr, len, prot, oldprot);
-}
-
-/* This allows to stay lazy about VirtualProtect usage in subsequent code. */
-#define VirtualProtect(a,l,p,o) (mmap_func->VirtualProt((a),(l),(p),(o)))
-#define VirtualProtectEx(h,a,l,p,o) (mmap_func->VirtualProtEx((h),(a),(l),(p),(o)))
-
-static HANDLE
-CreateMapping9x (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
- int prot, int flags, const char *name)
-{
- HANDLE h;
- DWORD high, low;
-
- DWORD protect = gen_create_protect (openflags, flags);
-
- /* copy-on-write doesn't work properly on 9x with real files. While the
- changes are not propagated to the file, they are visible to other
- processes sharing the same file mapping object. Workaround: Don't
- use named file mapping. That should work since sharing file
- mappings only works reliable using named file mapping on 9x.
-
- On 9x/ME try first to open the mapping by name when opening a
- shared file object. This is needed since 9x/ME only shares objects
- between processes by name. What a mess... */
-
- if (fhdl != INVALID_HANDLE_VALUE && !priv (flags))
- {
- /* Grrr, the whole stuff is just needed to try to get a reliable
- mapping of the same file. Even that uprising isn't bullet
- proof but it does it's best... */
- char namebuf[CYG_MAX_PATH];
- cygwin_conv_to_full_posix_path (name, namebuf);
- for (int i = strlen (namebuf) - 1; i >= 0; --i)
- namebuf[i] = cyg_tolower (namebuf [i]);
-
- debug_printf ("named sharing");
- DWORD access = gen_access (openflags, flags);
- /* Different access modes result in incompatible mappings. So we
- create different maps per access mode by using different names. */
- switch (access)
- {
- case FILE_MAP_READ:
- namebuf[0] = 'R';
- break;
- case FILE_MAP_WRITE:
- namebuf[0] = 'W';
- break;
- case FILE_MAP_COPY:
- namebuf[0] = 'C';
- break;
- }
- if (!(h = OpenFileMapping (access, TRUE, namebuf)))
- h = CreateFileMapping (fhdl, &sec_none, protect, 0, 0, namebuf);
- }
- else if (fhdl == INVALID_HANDLE_VALUE)
- {
- /* Standard anonymous mapping needs non-zero len. */
- h = CreateFileMapping (fhdl, &sec_none, protect, 0, len, NULL);
- }
- else if (autogrow (flags))
- {
- high = (off + len) >> 32;
- low = (off + len) & UINT32_MAX;
- /* Auto-grow only works if the protection is PAGE_READWRITE. So,
- first we call CreateFileMapping with PAGE_READWRITE, then, if the
- requested protection is different, we close the mapping and
- reopen it again with the correct protection, if auto-grow worked. */
- h = CreateFileMapping (fhdl, &sec_none, PAGE_READWRITE,
- high, low, NULL);
- if (h && protect != PAGE_READWRITE)
- {
- CloseHandle (h);
- h = CreateFileMapping (fhdl, &sec_none, protect,
- high, low, NULL);
- }
- }
- else
- {
- /* Zero len creates mapping for whole file. */
- h = CreateFileMapping (fhdl, &sec_none, protect, 0, 0, NULL);
- }
- return h;
-}
-
static HANDLE
-CreateMappingNT (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
- int prot, int flags, const char *)
+CreateMapping (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
+ int prot, int flags, const char *)
{
HANDLE h;
NTSTATUS ret;
@@ -318,36 +206,8 @@ CreateMappingNT (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
}
void *
-MapView9x (HANDLE h, void *addr, size_t len, DWORD openflags,
- int prot, int flags, _off64_t off)
-{
- DWORD high = off >> 32;
- DWORD low = off & UINT32_MAX;
- DWORD access = gen_access (openflags, flags);
- void *base;
-
- /* Try mapping using the given address first, even if it's NULL.
- If it failed, and addr was not NULL and flags is not MAP_FIXED,
- try again with NULL address.
-
- Note: Retrying the mapping might be unnecessary, now that mmap64 checks
- for a valid memory area first. */
- if (!addr)
- base = MapViewOfFile (h, access, high, low, len);
- else
- {
- base = MapViewOfFileEx (h, access, high, low, len, addr);
- if (!base && !fixed (flags))
- base = MapViewOfFile (h, access, high, low, len);
- }
- debug_printf ("%x = MapViewOfFileEx (h:%x, access:%x, 0, off:%D, "
- "len:%u, addr:%x)", base, h, access, off, len, addr);
- return base;
-}
-
-void *
-MapViewNT (HANDLE h, void *addr, size_t len, DWORD openflags,
- int prot, int flags, _off64_t off)
+MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
+ int prot, int flags, _off64_t off)
{
NTSTATUS ret;
LARGE_INTEGER offset = { QuadPart:off };
@@ -382,39 +242,6 @@ MapViewNT (HANDLE h, void *addr, size_t len, DWORD openflags,
return base;
}
-struct mmap_func_t
-{
- HANDLE (*CreateMapping)(HANDLE, size_t, _off64_t, DWORD, int, int,
- const char *);
- void * (*MapView)(HANDLE, void *, size_t, DWORD, int, int, _off64_t);
- BOOL (*VirtualProt)(PVOID, SIZE_T, DWORD, PDWORD);
- BOOL (*VirtualProtEx)(HANDLE, PVOID, SIZE_T, DWORD, PDWORD);
-};
-
-mmap_func_t mmap_funcs_9x =
-{
- CreateMapping9x,
- MapView9x,
- VirtualProt9x,
- VirtualProtEx9x
-};
-
-mmap_func_t mmap_funcs_nt =
-{
- CreateMappingNT,
- MapViewNT,
- VirtualProtNT,
- VirtualProtExNT
-};
-
-mmap_func_t *mmap_func;
-
-void
-mmap_init ()
-{
- mmap_func = wincap.is_winnt () ? &mmap_funcs_nt : &mmap_funcs_9x;
-}
-
/* Class structure used to keep a record of all current mmap areas
in a process. Needed for bookkeeping all mmaps in a process and
for duplicating all mmaps after fork() since mmaps are not propagated
@@ -1082,50 +909,25 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
goto out;
}
- /* On 9x you can't create mappings with PAGE_WRITECOPY protection if
- the file isn't explicitely opened with WRITE access. */
- if (!wincap.is_winnt () && priv (flags)
- && !(fh->get_access () & GENERIC_WRITE))
+ /* You can't create mappings with PAGE_EXECUTE protection if
+ the file isn't explicitely opened with EXECUTE access. */
+ HANDLE h = CreateFile (fh->get_win32_name (),
+ fh->get_access () | GENERIC_EXECUTE,
+ wincap.shared (), &sec_none_nih,
+ OPEN_EXISTING, 0, NULL);
+ if (h != INVALID_HANDLE_VALUE)
{
- HANDLE h = CreateFile (fh->get_win32_name (),
- fh->get_access () | GENERIC_WRITE,
- wincap.shared (), &sec_none_nih,
- OPEN_EXISTING, 0, NULL);
- if (h == INVALID_HANDLE_VALUE)
- {
- set_errno (EACCES);
- goto out;
- }
fh_disk_file.set_io_handle (h);
- fh_disk_file.set_access (fh->get_access () | GENERIC_WRITE);
- path_conv pc;
- pc.set_name (fh->get_win32_name (), "");
- fh_disk_file.set_name (pc);
+ fh_disk_file.set_access (fh->get_access () | GENERIC_EXECUTE);
fh = &fh_disk_file;
}
-
- /* On NT you can't create mappings with PAGE_EXECUTE protection if
- the file isn't explicitely opened with EXECUTE access. */
- if (wincap.is_winnt ())
+ else if (prot & PROT_EXEC)
{
- HANDLE h = CreateFile (fh->get_win32_name (),
- fh->get_access () | GENERIC_EXECUTE,
- wincap.shared (), &sec_none_nih,
- OPEN_EXISTING, 0, NULL);
- if (h != INVALID_HANDLE_VALUE)
- {
- fh_disk_file.set_io_handle (h);
- fh_disk_file.set_access (fh->get_access () | GENERIC_EXECUTE);
- fh = &fh_disk_file;
- }
- else if (prot & PROT_EXEC)
- {
- /* TODO: To be or not to be... I'm opting for refusing this
- mmap request rather than faking it, but that might break
- some non-portable code. */
- set_errno (EACCES);
- goto out;
- }
+ /* TODO: To be or not to be... I'm opting for refusing this
+ mmap request rather than faking it, but that might break
+ some non-portable code. */
+ set_errno (EACCES);
+ goto out;
}
if (fh->fstat (&st))
@@ -1759,8 +1561,8 @@ fhandler_dev_zero::mmap (caddr_t *addr, size_t len, int prot,
}
else
{
- h = mmap_func->CreateMapping (get_handle (), len, off, get_access (),
- prot, flags, get_win32_name ());
+ h = CreateMapping (get_handle (), len, off, get_access (),
+ prot, flags, get_win32_name ());
if (!h)
{
__seterrno ();
@@ -1768,7 +1570,7 @@ fhandler_dev_zero::mmap (caddr_t *addr, size_t len, int prot,
return INVALID_HANDLE_VALUE;
}
- base = mmap_func->MapView (h, *addr, len, get_access(), prot, flags, off);
+ base = MapView (h, *addr, len, get_access(), prot, flags, off);
if (!base || (fixed (flags) && base != *addr))
{
if (!base)
@@ -1822,8 +1624,7 @@ fhandler_dev_zero::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
base = VirtualAlloc (address, size, alloc_type, PAGE_READWRITE);
}
else
- base = mmap_func->MapView (h, address, size, get_access (),
- prot, flags, offset);
+ base = MapView (h, address, size, get_access (), prot, flags, offset);
if (base != address)
{
MEMORY_BASIC_INFORMATION m;
@@ -1840,8 +1641,8 @@ HANDLE
fhandler_disk_file::mmap (caddr_t *addr, size_t len, int prot,
int flags, _off64_t off)
{
- HANDLE h = mmap_func->CreateMapping (get_handle (), len, off, get_access (),
- prot, flags, get_win32_name ());
+ HANDLE h = CreateMapping (get_handle (), len, off, get_access (),
+ prot, flags, get_win32_name ());
if (!h)
{
__seterrno ();
@@ -1849,8 +1650,7 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, int prot,
return INVALID_HANDLE_VALUE;
}
- void *base = mmap_func->MapView (h, *addr, len, get_access (),
- prot, flags, off);
+ void *base = MapView (h, *addr, len, get_access (), prot, flags, off);
if (!base || (fixed (flags) && base != *addr))
{
if (!base)
@@ -1894,8 +1694,7 @@ fhandler_disk_file::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
void *address)
{
/* Re-create the map */
- void *base = mmap_func->MapView (h, address, size, get_access (),
- prot, flags, offset);
+ void *base = MapView (h, address, size, get_access (), prot, flags, offset);
if (base != address)
{
MEMORY_BASIC_INFORMATION m;
@@ -1947,8 +1746,8 @@ fhandler_dev_mem::mmap (caddr_t *addr, size_t len, int prot,
return INVALID_HANDLE_VALUE;
}
- void *base = MapViewNT (h, *addr, len, get_access (),
- prot, flags | MAP_ANONYMOUS, off);
+ void *base = MapView (h, *addr, len, get_access (), prot,
+ flags | MAP_ANONYMOUS, off);
if (!base || (fixed (flags) && base != *addr))
{
if (!base)
@@ -1991,8 +1790,8 @@ fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
_off64_t offset, DWORD size,
void *address)
{
- void *base = MapViewNT (h, address, size, get_access (), prot,
- flags | MAP_ANONYMOUS, offset);
+ void *base = MapView (h, address, size, get_access (), prot,
+ flags | MAP_ANONYMOUS, offset);
if (base != address)
{
MEMORY_BASIC_INFORMATION m;
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index be9a44d43..fb0ba6ada 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -1076,13 +1076,6 @@ cygwin_send (int fd, const void *buf, size_t len, int flags)
extern "C" int
getdomainname (char *domain, size_t len)
{
- /*
- * This works for Win95 only if the machine is configured to use MS-TCP.
- * If a third-party TCP is being used this will fail.
- * FIXME: On Win95, is there a way to portably check the TCP stack
- * in use and include paths for the Domain name in each ?
- * Punt for now and assume MS-TCP on Win95.
- */
sig_dispatch_pending ();
myfault efault;
if (efault.faulted (EFAULT))
@@ -1099,16 +1092,11 @@ getdomainname (char *domain, size_t len)
return 0;
}
- /* This is only used by Win95 and NT <= 4.0.
- The registry names are language independent.
- FIXME: Handle DHCP on Win95. The DhcpDomain(s) may be available
- in ..VxD\DHCP\DhcpInfoXX\OptionInfo, RFC 1533 format */
-
+ /* This is only used by NT4.
+ The registry names are language independent. */
reg_key r (HKEY_LOCAL_MACHINE, KEY_READ,
- (!wincap.is_winnt ()) ? "System" : "SYSTEM",
- "CurrentControlSet", "Services",
- (!wincap.is_winnt ()) ? "VxD" : "Tcpip",
- (!wincap.is_winnt ()) ? "MSTCP" : "Parameters", NULL);
+ "SYSTEM", "CurrentControlSet", "Services",
+ "Tcpip", "Parameters", NULL);
if (!r.error ())
{
@@ -1834,177 +1822,6 @@ get_nt_ifconf (struct ifconf *ifc, int what)
ifc->ifc_len = cnt * sizeof (struct ifreq);
}
-/*
- * IFCONF Windows 95:
- * HKLM/Enum/Network/MSTCP/"*"
- * -> Value "Driver" enthält Subkey relativ zu
- * HKLM/System/CurrentControlSet/Class/
- * -> In Subkey "Bindings" die Values aufzählen
- * -> Enthält Subkeys der Form "VREDIR\*"
- * Das * ist ein Subkey relativ zu
- * HKLM/System/CurrentControlSet/Class/Net/
- * HKLM/System/CurrentControlSet/Class/"Driver"
- * -> Value "IPAddress"
- * -> Value "IPMask"
- * HKLM/System/CurrentControlSet/Class/Net/"*"(aus "VREDIR\*")
- * -> Wenn Value "AdapterName" == "MS$PPP" -> ppp interface
- * -> Value "DriverDesc" enthält den Namen
- *
- */
-static void
-get_95_ifconf (struct ifconf *ifc, int what)
-{
- HKEY key;
- unsigned long lip, lnp;
- struct sockaddr_in *sa = NULL;
- struct sockaddr *so = NULL;
- FILETIME update;
- LONG res;
- DWORD size;
- int cnt = 1;
- char ifname[256];
- char eth[2] = "/";
- char ppp[2] = "/";
-
- /* Union maps buffer to correct struct */
- struct ifreq *ifr = ifc->ifc_req;
-
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Enum\\Network\\MSTCP",
- 0, KEY_READ, &key) != ERROR_SUCCESS)
- {
- /* Set the correct length */
- ifc->ifc_len = cnt * sizeof (struct ifreq);
- return;
- }
-
- for (int i = 0;
- (res = RegEnumKeyEx (key, i, ifname,
- (size = sizeof ifname, &size),
- 0, 0, 0, &update)) != ERROR_NO_MORE_ITEMS;
- ++i)
- {
- HKEY ifkey, subkey;
- char driver[256], classname[256], netname[256];
- char adapter[256], ip[256], np[256];
-
- if (res != ERROR_SUCCESS
- || RegOpenKeyEx (key, ifname, 0, KEY_READ, &ifkey) != ERROR_SUCCESS)
- continue;
-
- if (RegQueryValueEx (ifkey, "Driver", 0,
- NULL, (unsigned char *) driver,
- (size = sizeof driver, &size)) != ERROR_SUCCESS)
- {
- RegCloseKey (ifkey);
- continue;
- }
-
- strcpy (classname, "System\\CurrentControlSet\\Services\\Class\\");
- strcat (classname, driver);
- if ((res = RegOpenKeyEx (HKEY_LOCAL_MACHINE, classname,
- 0, KEY_READ, &subkey)) != ERROR_SUCCESS)
- {
- RegCloseKey (ifkey);
- continue;
- }
-
- if (RegQueryValueEx (subkey, "IPAddress", 0,
- NULL, (unsigned char *) ip,
- (size = sizeof ip, &size)) == ERROR_SUCCESS
- && RegQueryValueEx (subkey, "IPMask", 0,
- NULL, (unsigned char *) np,
- (size = sizeof np, &size)) == ERROR_SUCCESS)
- {
- if ((caddr_t) ++ifr > ifc->ifc_buf
- + ifc->ifc_len - sizeof (struct ifreq))
- goto out;
-
- switch (what)
- {
- case SIOCGIFFLAGS:
- ifr->ifr_flags = IFF_UP | IFF_RUNNING | IFF_BROADCAST;
- break;
- case SIOCGIFCONF:
- case SIOCGIFADDR:
- sa = (struct sockaddr_in *) &ifr->ifr_addr;
- sa->sin_addr.s_addr = cygwin_inet_addr (ip);
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
- break;
- case SIOCGIFBRDADDR:
- lip = cygwin_inet_addr (ip);
- lnp = cygwin_inet_addr (np);
- sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
- sa->sin_addr.s_addr = lip & lnp | ~lnp;
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
- break;
- case SIOCGIFNETMASK:
- sa = (struct sockaddr_in *) &ifr->ifr_netmask;
- sa->sin_addr.s_addr = cygwin_inet_addr (np);
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
- break;
- case SIOCGIFHWADDR:
- so = &ifr->ifr_hwaddr;
- memset (so->sa_data, 0, IFHWADDRLEN);
- so->sa_family = AF_INET;
- break;
- case SIOCGIFMETRIC:
- ifr->ifr_metric = 1;
- break;
- case SIOCGIFMTU:
- ifr->ifr_mtu = 1500;
- break;
- case SIOCGIFINDEX:
- ifr->ifr_ifindex = -1;
- break;
- }
- }
-
- RegCloseKey (subkey);
-
- strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
- strcat (netname, ifname);
-
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
- 0, KEY_READ, &subkey) != ERROR_SUCCESS)
- {
- RegCloseKey (ifkey);
- --ifr;
- continue;
- }
-
- if (RegQueryValueEx (subkey, "AdapterName", 0,
- NULL, (unsigned char *) adapter,
- (size = sizeof adapter, &size)) == ERROR_SUCCESS
- && strcasematch (adapter, "MS$PPP"))
- {
- ++*ppp;
- strcpy (ifr->ifr_name, "ppp");
- strcat (ifr->ifr_name, ppp);
- }
- else
- {
- ++*eth;
- strcpy (ifr->ifr_name, "eth");
- strcat (ifr->ifr_name, eth);
- }
-
- RegCloseKey (subkey);
- RegCloseKey (ifkey);
-
- ++cnt;
- }
-
-out:
-
- RegCloseKey (key);
-
- /* Set the correct length */
- ifc->ifc_len = cnt * sizeof (struct ifreq);
-}
-
int
get_ifconf (SOCKET s, struct ifconf *ifc, int what)
{
@@ -2081,10 +1898,8 @@ get_ifconf (SOCKET s, struct ifconf *ifc, int what)
get_xp_ifconf (s, ifc, what);
else if (wincap.has_ip_helper_lib ())
get_2k_ifconf (ifc, what);
- else if (wincap.is_winnt ())
- get_nt_ifconf (ifc, what);
else
- get_95_ifconf (ifc, what);
+ get_nt_ifconf (ifc, what);
return 0;
}
diff --git a/winsup/cygwin/netdb.cc b/winsup/cygwin/netdb.cc
index 53f0412dc..1e5cbcc3b 100644
--- a/winsup/cygwin/netdb.cc
+++ b/winsup/cygwin/netdb.cc
@@ -1,6 +1,6 @@
/* netdb.cc: network database related routines.
- Copyright 2002 Red Hat, Inc.
+ Copyright 2002, 2003, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -32,18 +32,10 @@ open_system_file (const char *relative_path)
{
char win32_name[CYG_MAX_PATH];
char posix_name[CYG_MAX_PATH];
- if (wincap.is_winnt ())
- {
- if (!GetSystemDirectory (win32_name, CYG_MAX_PATH))
- return NULL;
- strcat (win32_name, "\\drivers\\etc\\");
- }
- else
- {
- if (!GetWindowsDirectory (win32_name, CYG_MAX_PATH))
- return NULL;
- strcat (win32_name, "\\");
- }
+
+ if (!GetSystemDirectory (win32_name, CYG_MAX_PATH))
+ return NULL;
+ strcat (win32_name, "\\drivers\\etc\\");
strcat (win32_name, relative_path);
cygwin_conv_to_full_posix_path (win32_name, posix_name);
debug_printf ("netdb file to open %s", win32_name);
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index ed2b0be31..2dffb5532 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -1,7 +1,7 @@
/* pinfo.cc: process table support
Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006 Red Hat, Inc.
+ 2006, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -1204,7 +1204,7 @@ out:
}
DWORD
-winpids::enumNT (bool winpid)
+winpids::enum_processes (bool winpid)
{
static DWORD szprocs;
static SYSTEM_PROCESSES *procs;
@@ -1243,38 +1243,11 @@ winpids::enumNT (bool winpid)
return nelem;
}
-DWORD
-winpids::enum9x (bool winpid)
-{
- DWORD nelem = 0;
-
- HANDLE h = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
- if (!h)
- {
- system_printf ("Couldn't create process snapshot, %E");
- return 0;
- }
-
- PROCESSENTRY32 proc;
- proc.dwSize = sizeof (proc);
-
- if (Process32First (h, &proc))
- do
- {
- if (proc.th32ProcessID)
- add (nelem, winpid, proc.th32ProcessID);
- }
- while (Process32Next (h, &proc));
-
- CloseHandle (h);
- return nelem;
-}
-
void
winpids::set (bool winpid)
{
__malloc_lock ();
- npids = (this->*enum_processes) (winpid);
+ npids = enum_processes (winpid);
if (pidlist)
pidlist[npids] = 0;
__malloc_unlock ();
@@ -1283,12 +1256,7 @@ winpids::set (bool winpid)
DWORD
winpids::enum_init (bool winpid)
{
- if (wincap.is_winnt ())
- enum_processes = &winpids::enumNT;
- else
- enum_processes = &winpids::enum9x;
-
- return (this->*enum_processes) (winpid);
+ return enum_processes (winpid);
}
void
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 7d32f0bd5..ee02a6180 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -1,6 +1,6 @@
/* pinfo.h: process table info
- Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+ Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -207,21 +207,18 @@ class winpids
DWORD *pidlist;
pinfo *pinfolist;
DWORD pinfo_access; // access type for pinfo open
- DWORD (winpids::* enum_processes) (bool winpid);
+ DWORD enum_processes (bool winpid);
DWORD enum_init (bool winpid);
- DWORD enumNT (bool winpid);
- DWORD enum9x (bool winpid);
void add (DWORD& nelem, bool, DWORD pid);
public:
DWORD npids;
inline void reset () { release (); npids = 0;}
void set (bool winpid);
- winpids (): make_copy (true), enum_processes (&winpids::enum_init) {}
- winpids (int): make_copy (false), npidlist (0), pidlist (NULL), pinfolist (NULL),
- pinfo_access (0), enum_processes (&winpids::enum_init), npids (0) {}
- winpids (DWORD acc): make_copy (false), npidlist (0), pidlist (NULL), pinfolist (NULL),
- pinfo_access (acc), enum_processes (&winpids::enum_init),
- npids (0)
+ winpids (): make_copy (true) {}
+ winpids (int): make_copy (false), npidlist (0), pidlist (NULL),
+ pinfolist (NULL), pinfo_access (0), npids (0) {}
+ winpids (DWORD acc): make_copy (false), npidlist (0), pidlist (NULL),
+ pinfolist (NULL), pinfo_access (acc), npids (0)
{
set (0);
}
diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc
index 723a71098..1c15aa553 100644
--- a/winsup/cygwin/registry.cc
+++ b/winsup/cygwin/registry.cc
@@ -1,7 +1,7 @@
/* registry.cc: registry interface
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006 Red Hat, Inc.
+ 2005, 2006, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -215,9 +215,8 @@ get_registry_hive_path (const char *name, char *path)
if (!name || !path)
return NULL;
- __small_sprintf (key, "SOFTWARE\\Microsoft\\Windows%s\\CurrentVersion\\ProfileList\\",
- wincap.is_winnt ()?" NT":"");
- strcat (key, name);
+ __small_sprintf (key, "SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\"
+ "ProfileList\\%s", name);
if (!RegOpenKeyExA (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hkey))
{
char buf[256];
@@ -253,10 +252,7 @@ load_registry_hive (const char * name)
}
if (get_registry_hive_path (name, path))
{
- if (wincap.is_winnt ())
- strcat (path, "\\NTUSER.DAT");
- else
- strcat (path, "\\USER.DAT");
+ strcat (path, "\\NTUSER.DAT");
if ((ret = RegLoadKeyA (HKEY_USERS, name, path)) != ERROR_SUCCESS)
debug_printf ("Loading user registry hive for %s failed: %d", name, ret);
}
diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc
index 15e605743..d7c80cd1b 100644
--- a/winsup/cygwin/sched.cc
+++ b/winsup/cygwin/sched.cc
@@ -1,6 +1,6 @@
/* sched.cc: scheduler interface for Cygwin
- Copyright 2001, 2002, 2006 Red Hat, Inc.
+ Copyright 2001, 2002, 2006, 2007 Red Hat, Inc.
Written by Robert Collins <rbtcollins@hotmail.com>
@@ -270,12 +270,6 @@ sched_rr_get_interval (pid_t pid, struct timespec *interval)
int vfindex, slindex, qindex, prisep;
long nsec;
- if (!wincap.is_winnt ())
- {
- set_errno (ESRCH);
- return -1;
- }
-
forwin = GetForegroundWindow ();
if (!forwin)
GetWindowThreadProcessId (forwin, &forprocid);
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 4e54a7558..705cc16f9 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -1,7 +1,7 @@
/* shared.cc: shared data area support.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006 Red Hat, Inc.
+ 2006, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -114,8 +114,7 @@ open_shared (const char *name, int n, HANDLE& shared_h, DWORD size,
FILE_MAP_READ|FILE_MAP_WRITE,
0, 0, 0, NULL);
#ifdef DEBUGGING
- if (wincap.is_winnt ())
- system_printf ("relocating shared object %s(%d) from %p to %p on Windows NT", name, n, addr, shared);
+ system_printf ("relocating shared object %s(%d) from %p to %p on Windows NT", name, n, addr, shared);
#endif
offsets[0] = 0;
}
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 4e352ac5b..11567221c 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -507,8 +507,7 @@ loop:
TRUE, /* inherit handles from parent */
c_flags,
envblock, /* environment */
- wincap.is_winnt () || real_path.iscygexec () ?
- NULL : cygheap->cwd.win32,
+ NULL,
&si,
&pi);
}
@@ -543,8 +542,7 @@ loop:
TRUE, /* inherit handles from parent */
c_flags,
envblock, /* environment */
- wincap.is_winnt () || real_path.iscygexec () ?
- NULL : cygheap->cwd.win32,
+ NULL,
&si,
&pi);
}
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 0cc3a3000..c72e2428b 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -231,14 +231,6 @@ try_to_bin (path_conv &win32_path, HANDLE h)
recycler, status);
}
-static DWORD
-unlink_9x (path_conv &win32_name)
-{
- BOOL ret = DeleteFile (win32_name);
- syscall_printf ("DeleteFile %s", ret ? "succeeded" : "failed");
- return GetLastError ();
-}
-
DWORD
unlink_nt (path_conv &win32_name, bool setattrs)
{
@@ -344,6 +336,7 @@ unlink (const char *ourname)
{
int res = -1;
DWORD devn;
+ DWORD lasterr;
path_conv win32_name (ourname, PC_SYM_NOFOLLOW,
transparent_exe ? stat_suffixes : NULL);
@@ -391,9 +384,7 @@ unlink (const char *ourname)
| FILE_ATTRIBUTE_HIDDEN));
}
- DWORD lasterr;
- lasterr = wincap.is_winnt () ? unlink_nt (win32_name, setattrs)
- : unlink_9x (win32_name);
+ lasterr = unlink_nt (win32_name, setattrs);
if (!lasterr)
res = 0;
else
@@ -1172,7 +1163,7 @@ sync ()
FindVolumeClose (sh);
}
}
- else if (wincap.is_winnt ()) /* 9x has no concept for opening volumes */
+ else
{
DWORD drives = GetLogicalDrives ();
DWORD mask = 1;
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index fca0b7566..74e1ec0ea 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -17,7 +17,6 @@ static NO_COPY wincaps wincap_unknown = {
chunksize:0,
heapslop:0x0,
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,
@@ -83,7 +82,6 @@ static NO_COPY wincaps wincap_nt4 = {
chunksize:0,
heapslop:0x0,
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,
@@ -149,7 +147,6 @@ static NO_COPY wincaps wincap_nt4sp4 = {
chunksize:0,
heapslop:0x0,
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,
@@ -215,7 +212,6 @@ static NO_COPY wincaps wincap_2000 = {
chunksize:0,
heapslop:0x0,
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,
@@ -281,7 +277,6 @@ static NO_COPY wincaps wincap_xp = {
chunksize:0,
heapslop:0x0,
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,
@@ -347,7 +342,6 @@ static NO_COPY wincaps wincap_2003 = {
chunksize:0,
heapslop:0x4,
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,
@@ -413,7 +407,6 @@ static NO_COPY wincaps wincap_vista = {
chunksize:0,
heapslop:0x4,
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,
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index 381a0c209..82a944207 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -17,7 +17,6 @@ struct wincaps
DWORD chunksize;
DWORD heapslop;
int shared;
- unsigned is_winnt : 1;
unsigned is_server : 1;
unsigned access_denied_on_delete : 1;
unsigned has_delete_on_close : 1;
@@ -99,7 +98,6 @@ public:
DWORD IMPLEMENT (chunksize)
DWORD IMPLEMENT (heapslop)
int IMPLEMENT (shared)
- bool IMPLEMENT (is_winnt)
bool IMPLEMENT (is_server)
bool IMPLEMENT (access_denied_on_delete)
bool IMPLEMENT (has_delete_on_close)
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 2a4ddf8ee..58e8ef1a0 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -1,7 +1,7 @@
/* winsup.h: main Cygwin header file.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006 Red Hat, Inc.
+ 2005, 2006, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -300,7 +300,6 @@ extern "C" int low_priority_sleep (DWORD) __attribute__ ((regparm (1)));
size_t getsystempagesize ();
/* mmap functions. */
-void mmap_init ();
enum mmap_region_status
{
MMAP_NONE,