* 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.
This commit is contained in:
Corinna Vinschen 2007-02-22 10:54:47 +00:00
parent 8782b2a2af
commit 570858c30f
24 changed files with 485 additions and 1252 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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 ());
}
const char *test_uid (char *&, const char *, size_t)

View File

@ -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,

View File

@ -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);

View File

@ -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 ();

View File

@ -209,10 +209,6 @@ 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;
@ -259,41 +255,16 @@ fhandler_base::fstat_by_handle (struct __stat64 *buf)
debug_printf ("%u = NtQueryInformationFile)",
RtlNtStatusToDosError (status));
}
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)
{
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);
}
else
{
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);
/* 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,12 +794,6 @@ fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
if (!allow_truncate && length < actual_length)
return 0;
if (wincap.is_winnt ())
{
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. */
@ -871,22 +816,6 @@ fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
else
res = 0;
}
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);
}
}
}
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)));
int rc = !(err = unlink_nt (pc, pc.has_attribute (FILE_ATTRIBUTE_READONLY)));
if (err)
SetLastError (err);
}
else
rc = RemoveDirectory (get_win32_name ());
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,9 +1495,8 @@ 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 ())
{
OBJECT_ATTRIBUTES attr;
@ -1628,7 +1536,6 @@ fhandler_disk_file::opendir ()
dir->__flags |= dirent_get_d_ino;
}
}
}
/* Filling fd with `this' (aka storing this in the file descriptor table
should only happen after it's clear that opendir doesn't fail,
otherwise we end up cfree'ing the fhandler twice, once in opendir()
@ -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)
{
@ -1977,8 +1832,6 @@ 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 ())
@ -2010,13 +1863,6 @@ fhandler_disk_file::rewinddir (DIR *dir)
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,19 +1879,11 @@ fhandler_disk_file::closedir (DIR *dir)
set_errno (EBADF);
res = -1;
}
else
{
BOOL winres;
if (wincap.is_winnt ())
winres = CloseHandle (dir->__handle);
else
winres = FindClose (dir->__handle);
if (!winres)
else if (!NtClose (dir->__handle))
{
__seterrno ();
res = -1;
}
}
syscall_printf ("%d = closedir (%p, %s)", res, dir, get_name ());
return res;
}

View File

@ -479,8 +479,6 @@ 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;
@ -506,7 +504,7 @@ format_proc_uptime (char *destbuf, size_t maxsize)
}
uptime /= sbi.NumberProcessors;
idle_time /= sbi.NumberProcessors;
}
if (!uptime)
uptime = GetTickCount () / 10;
@ -523,10 +521,6 @@ 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;
@ -550,7 +544,8 @@ format_proc_stat (char *destbuf, size_t maxsize)
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;
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;
}
@ -594,15 +589,7 @@ format_proc_stat (char *destbuf, size_t maxsize)
swap_out = spi.PagefilePagesWritten;
context_switches = spi.ContextSwitches;
boot_time = to_time_t ((FILETIME *) &stodi.BootTime.QuadPart);
}
/*
* 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.
* }
*/
eobuf += __small_sprintf (eobuf, "page %u %u\n"
"swap %u %u\n"
"intr %u\n"
@ -697,8 +684,6 @@ 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);
@ -720,7 +705,6 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
if (IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE))
print (" sse2");
}
}
else
{
bufptr += __small_sprintf (bufptr, "processor : %d\n", cpu_number);
@ -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 ())
{
bufptr += __small_sprintf (bufptr, "vendor_id : %s\n",
(char *)vendor_id);
read_value ("~Mhz", REG_DWORD);
cpu_mhz = *(DWORD *)szBuffer;
}
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,8 +772,6 @@ 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"
@ -810,28 +792,6 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
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");
}
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;

View File

@ -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,11 +634,10 @@ 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;
@ -716,7 +712,6 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
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))
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;
}
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

View File

@ -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

View File

@ -152,120 +152,8 @@ 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,
CreateMapping (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
int prot, int flags, const char *)
{
HANDLE h;
@ -318,35 +206,7 @@ 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,
MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
int prot, int flags, _off64_t off)
{
NTSTATUS ret;
@ -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,32 +909,8 @@ 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))
{
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 = &fh_disk_file;
}
/* On NT you can't create mappings with PAGE_EXECUTE protection if
/* You can't create mappings with PAGE_EXECUTE protection if
the file isn't explicitely opened with EXECUTE access. */
if (wincap.is_winnt ())
{
HANDLE h = CreateFile (fh->get_win32_name (),
fh->get_access () | GENERIC_EXECUTE,
wincap.shared (), &sec_none_nih,
@ -1126,7 +929,6 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
set_errno (EACCES);
goto out;
}
}
if (fh->fstat (&st))
{
@ -1759,7 +1561,7 @@ fhandler_dev_zero::mmap (caddr_t *addr, size_t len, int prot,
}
else
{
h = mmap_func->CreateMapping (get_handle (), len, off, get_access (),
h = CreateMapping (get_handle (), len, off, get_access (),
prot, flags, get_win32_name ());
if (!h)
{
@ -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,7 +1641,7 @@ 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 (),
HANDLE h = CreateMapping (get_handle (), len, off, get_access (),
prot, flags, get_win32_name ());
if (!h)
{
@ -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,7 +1790,7 @@ 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,
void *base = MapView (h, address, size, get_access (), prot,
flags | MAP_ANONYMOUS, offset);
if (base != address)
{

View File

@ -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;
}

View File

@ -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, "\\");
}
strcat (win32_name, relative_path);
cygwin_conv_to_full_posix_path (win32_name, posix_name);
debug_printf ("netdb file to open %s", win32_name);

View File

@ -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

View File

@ -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);
}

View File

@ -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");
if ((ret = RegLoadKeyA (HKEY_USERS, name, path)) != ERROR_SUCCESS)
debug_printf ("Loading user registry hive for %s failed: %d", name, ret);
}

View File

@ -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);

View File

@ -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,7 +114,6 @@ 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);
#endif
offsets[0] = 0;

View File

@ -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);
}

View File

@ -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;

View File

@ -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,

View File

@ -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)

View File

@ -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,