Differences between 20080112 and 20080122 diff -p -N -d -r -U2 winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/fhandler_disk_file.cc winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/fhandler_disk_file.cc --- winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/fhandler_disk_file.cc 2007-12-13 12:55:37.000000000 +0000 +++ winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/fhandler_disk_file.cc 2008-01-23 00:27:15.000000000 +0000 @@ -1090,5 +1090,5 @@ fhandler_disk_file::link (const char *ne OBJECT_ATTRIBUTES attr; IO_STATUS_BLOCK io; - status = NtOpenFile (&fh, FILE_ANY_ACCESS, + status = NtOpenFile (&fh, READ_CONTROL, pc.get_object_attr (attr, sec_none_nih), &io, FILE_SHARE_VALID_FLAGS, diff -p -N -d -r -U2 winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/libc/memmem.cc winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/libc/memmem.cc --- winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/libc/memmem.cc 2007-12-21 15:05:56.000000000 +0000 +++ winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/libc/memmem.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 2005 Pascal Gloor - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if 0 -__FBSDID("$FreeBSD: src/lib/libc/string/memmem.c,v 1.1 2005/08/25 18:26:58 andre Exp $"); -#endif - -#include - -/* Find the first occurrence of the byte string s in byte string l. - */ - -extern "C" void * -memmem (const void *l, size_t l_len, - const void *s, size_t s_len) -{ - register char *cur, *last; - const char *cl = (const char *)l; - const char *cs = (const char *)s; - - /* we need something to compare */ - if (s_len == 0) - return (void *) l; - - /* "s" must be smaller or equal to "l" */ - if (l_len < s_len) - return NULL; - - /* special case where s_len == 1 */ - if (s_len == 1) - return memchr (l, (int) *cs, l_len); - - /* the last position where its possible to find "s" in "l" */ - last = (char *) cl + l_len - s_len; - - for (cur = (char *) cl; cur <= last; cur++) - if (cur[0] == cs[0] && memcmp (cur, cs, s_len) == 0) - return cur; - - return NULL; -} diff -p -N -d -r -U2 winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/Makefile.in winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/Makefile.in --- winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/Makefile.in 2007-12-13 12:55:34.000000000 +0000 +++ winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/Makefile.in 2008-01-23 00:27:15.000000000 +0000 @@ -136,5 +136,5 @@ DLL_OFILES:=assert.o autoload.o bsdlib.o fhandler_zero.o flock.o fnmatch.o fork.o fts.o ftw.o getopt.o glob.o \ grp.o heap.o hookapi.o inet_addr.o inet_network.o init.o ioctl.o ipc.o \ - localtime.o lsearch.o malloc_wrapper.o memmem.o minires-os-if.o \ + localtime.o lsearch.o malloc_wrapper.o minires-os-if.o \ minires.o miscfuncs.o mktemp.o mmap.o msg.o net.o netdb.o nftw.o \ passwd.o path.o pinfo.o pipe.o poll.o posix_ipc.o pthread.o random.o \ @@ -307,4 +307,5 @@ install-libs: $(TARGET_LIBS) $(INSTALL_DATA) $$i $(tooldir)/lib/`basename $$i` ; \ done + cd $(tooldir)/lib && ln -sf libcygwin.a libg.a install-headers: diff -p -N -d -r -U2 winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/ntdll.h winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/ntdll.h --- winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/ntdll.h 2007-12-13 12:55:39.000000000 +0000 +++ winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/ntdll.h 2008-01-23 00:27:15.000000000 +0000 @@ -713,4 +713,9 @@ typedef struct _FILE_FS_FULL_SIZE_INFORM } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; +typedef struct _FILE_FS_OBJECTID_INFORMATION { + UCHAR ObjectId[16]; + UCHAR ExtendedInfo[48]; +} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; + typedef enum _FSINFOCLASS { FileFsVolumeInformation = 1, diff -p -N -d -r -U2 winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/path.cc winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/path.cc --- winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/path.cc 2007-12-13 12:55:40.000000000 +0000 +++ winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/path.cc 2008-01-23 00:27:15.000000000 +0000 @@ -379,4 +379,20 @@ mkrelpath (char *path) } +/* Beginning with Samba 3.2, Samba allows to get version information using + the ExtendedInfo member returned by a FileFsObjectIdInformation request. + We just store the samba_version information for now. Older versions than + 3.2 are still guessed at by testing the file system flags. */ +#define SAMBA_EXTENDED_INFO_MAGIC 0x536d4261 /* "SmBa" */ +#define SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH 28 +#pragma pack(push,4) +struct smb_extended_info { + DWORD samba_magic; /* Always SAMBA_EXTENDED_INFO_MAGIC */ + DWORD samba_version; /* Major/Minor/Release/Revision */ + DWORD samba_subversion; /* Prerelease/RC/Vendor patch */ + LARGE_INTEGER samba_gitcommitdate; + char samba_version_string[SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH]; +}; +#pragma pack(pop) + bool fs_info::update (PUNICODE_STRING upath, bool exists) @@ -388,4 +404,5 @@ fs_info::update (PUNICODE_STRING upath, bool no_media = false; FILE_FS_DEVICE_INFORMATION ffdi; + FILE_FS_OBJECTID_INFORMATION ffoi; PFILE_FS_ATTRIBUTE_INFORMATION pffai; UNICODE_STRING fsname, testname; @@ -445,9 +462,9 @@ fs_info::update (PUNICODE_STRING upath, attr.ObjectName, status); has_buggy_open (false); - flags () = 0; + flags (0); NtClose (vol); return false; } - flags () = pffai->FileSystemAttributes; + flags (pffai->FileSystemAttributes); /* Should be reevaluated for each new OS. Right now this mask is valid up to Vista. The important point here is to test only flags indicating @@ -477,10 +494,28 @@ fs_info::update (PUNICODE_STRING upath, is_fat (RtlEqualUnicodePathPrefix (&fsname, L"FAT", TRUE)); RtlInitUnicodeString (&testname, L"NTFS"); - is_samba (RtlEqualUnicodeString (&fsname, &testname, FALSE) - && (ffdi.Characteristics & FILE_REMOTE_DEVICE) - && (FS_IS_SAMBA || FS_IS_SAMBA_WITH_QUOTA)); - is_netapp (RtlEqualUnicodeString (&fsname, &testname, FALSE) - && (ffdi.Characteristics & FILE_REMOTE_DEVICE) - && FS_IS_NETAPP_DATAONTAP); + if (is_remote_drive ()) + { + /* This always fails on NT4. */ + status = NtQueryVolumeInformationFile (vol, &io, &ffoi, sizeof ffoi, + FileFsObjectIdInformation); + if (NT_SUCCESS (status)) + { + smb_extended_info *extended_info = (smb_extended_info *) + &ffoi.ExtendedInfo; + if (extended_info->samba_magic == SAMBA_EXTENDED_INFO_MAGIC) + { + is_samba (true); + samba_version (extended_info->samba_version); + } + } + /* Test for older Samba releases not supporting the extended info. */ + if (!is_samba ()) + is_samba (RtlEqualUnicodeString (&fsname, &testname, FALSE) + && (FS_IS_SAMBA || FS_IS_SAMBA_WITH_QUOTA)); + + is_netapp (!is_samba () + && RtlEqualUnicodeString (&fsname, &testname, FALSE) + && FS_IS_NETAPP_DATAONTAP); + } is_ntfs (RtlEqualUnicodeString (&fsname, &testname, FALSE) && !is_samba () && !is_netapp ()); diff -p -N -d -r -U2 winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/path.h winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/path.h --- winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/cygwin/path.h 2007-08-21 12:37:39.000000000 +0000 +++ winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/cygwin/path.h 2008-01-23 00:27:15.000000000 +0000 @@ -98,5 +98,6 @@ struct fs_info struct status_flags { - DWORD flags; /* Volume flags */ + DWORD flags; /* Volume flags */ + DWORD samba_version; /* Samba version if available */ unsigned is_remote_drive : 1; unsigned has_buggy_open : 1; @@ -111,9 +112,9 @@ struct fs_info } status; public: - void clear () { memset (this, 0 , sizeof *this); } + void clear () { memset (&status, 0 , sizeof status); } fs_info () { clear (); } - inline DWORD& flags () {return status.flags;}; - + IMPLEMENT_STATUS_FLAG (DWORD, flags) + IMPLEMENT_STATUS_FLAG (DWORD, samba_version) IMPLEMENT_STATUS_FLAG (bool, is_remote_drive) IMPLEMENT_STATUS_FLAG (bool, has_buggy_open) diff -p -N -d -r -U2 winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/utils/cygcheck.cc winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/utils/cygcheck.cc --- winsup-src-20080112/cygwin-snapshot-20080112-1/winsup/utils/cygcheck.cc 2007-08-03 19:41:48.000000000 +0000 +++ winsup-src-20080122/cygwin-snapshot-20080122-1/winsup/utils/cygcheck.cc 2008-01-23 00:27:16.000000000 +0000 @@ -59,5 +59,5 @@ void dump_dodgy_apps (int verbose); -static const char version[] = "$Revision: 1.96 $"; +static const char version[] = "$Revision: 1.97 $"; static const char *known_env_vars[] = { @@ -1180,4 +1180,6 @@ dump_sysinfo () char *found_cygwin_dll; bool is_nt = false; + bool more_info = true; + char osname[80]; printf ("\nCygwin Configuration Diagnostics\n"); @@ -1185,91 +1187,147 @@ dump_sysinfo () printf ("Current System Time: %s\n", ctime (&now)); - OSVERSIONINFO osversion; - osversion.dwOSVersionInfoSize = sizeof (osversion); - if (!GetVersionEx (&osversion)) - display_error ("dump_sysinfo: GetVersionEx()"); - const char *osname = "unknown OS"; + OSVERSIONINFOEX osversion; + osversion.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); + if (!GetVersionEx (reinterpret_cast(&osversion))) + { + more_info = false; + osversion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + if (!GetVersionEx (reinterpret_cast(&osversion))) + display_error ("dump_sysinfo: GetVersionEx()"); + } + + HMODULE k32 = LoadLibrary ("kernel32.dll"); + switch (osversion.dwPlatformId) { case VER_PLATFORM_WIN32s: - osname = "32s"; + strcpy (osname, "32s (not supported)"); break; case VER_PLATFORM_WIN32_WINDOWS: - switch (osversion.dwMinorVersion) - { - case 0: - osname = "95 (not supported)"; - break; - case 10: - osname = "98 (not supported)"; - break; - case 90: - osname = "ME (not supported)"; - break; - default: - osname = "9X (not supported)"; - break; - } + strcpy (osname, "95/98/Me (not supported)"); break; case VER_PLATFORM_WIN32_NT: is_nt = true; if (osversion.dwMajorVersion == 6) - osname = "Vista"; + { + BOOL (WINAPI *GetProductInfo) (DWORD, DWORD, DWORD, DWORD, PDWORD) = + (BOOL (WINAPI *)(DWORD, DWORD, DWORD, DWORD, PDWORD)) + GetProcAddress (k32, "GetProductInfo"); + if (osversion.wProductType == VER_NT_WORKSTATION) + strcpy (osname, "Vista"); + else + strcpy (osname, "2008"); + DWORD prod; + if (GetProductInfo (osversion.dwMajorVersion, + osversion.dwMinorVersion, + osversion.wServicePackMajor, + osversion.wServicePackMinor, + &prod)) + { +#define PRODUCT_UNLICENSED 0xabcdabcd +#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x19 + const char *products[] = + { + "", + " Ultimate Edition", + " Home Basic Edition", + " Home Premium Edition", + " Enterprise Edition", + " Home Basic N Edition", + " Business Edition", + " Server Standard Edition", + " Server Datacenter Edition", + " Small Business Server", + " Server Enterprise Edition", + " Starter Edition", + " Server Datacenter Edition Core", + " Server Standard Edition Core", + " Server Enterprise Edition Core", + " Server Enterprise Edition for Itanium-based Systems", + " Business N Edition", + " Web Server Edition", + " Cluster Server Edition", + " Home Server Edition", + " Storage Server Express Edition", + " Storage Server Standard Edition", + " Storage Server Workgroup Edition", + " Storage Server Enterprise Edition", + " Server for Small Business Edition", + " Small Business Server Premium Edition" + }; + if (prod == PRODUCT_UNLICENSED) + strcat (osname, "Unlicensed"); + else if (prod > PRODUCT_SMALLBUSINESS_SERVER_PREMIUM) + strcat (osname, ""); + else + strcat (osname, products[prod]); + } + else + { + } + } else if (osversion.dwMajorVersion == 5) { - BOOL more_info = FALSE; - OSVERSIONINFOEX osversionex; - osversionex.dwOSVersionInfoSize = sizeof (osversionex); - if (GetVersionEx ((OSVERSIONINFO *) &osversionex)) - more_info = TRUE; if (osversion.dwMinorVersion == 0) { - if (!more_info) - osname = "2000"; - else if (osversionex.wProductType == VER_NT_SERVER - || osversionex.wProductType == VER_NT_DOMAIN_CONTROLLER) - { - if (osversionex.wSuiteMask & VER_SUITE_DATACENTER) - osname = "2000 Datacenter Server"; - else if (osversionex.wSuiteMask & VER_SUITE_ENTERPRISE) - osname = "2000 Advanced Server"; - else - osname = "2000 Server"; - } + strcpy (osname, "2000"); + if (osversion.wProductType == VER_NT_WORKSTATION) + strcat (osname, " Professional"); + else if (osversion.wSuiteMask & VER_SUITE_DATACENTER) + strcat (osname, " Datacenter Server"); + else if (osversion.wSuiteMask & VER_SUITE_ENTERPRISE) + strcat (osname, " Advanced Server"); else - osname = "2000 Professional"; + strcat (osname, " Server"); } else if (osversion.dwMinorVersion == 1) { + strcpy (osname, "XP"); if (GetSystemMetrics (SM_MEDIACENTER)) - osname = "XP Media Center Edition"; + strcat (osname, " Media Center Edition"); else if (GetSystemMetrics (SM_TABLETPC)) - osname = "XP Tablet PC Edition"; - else if (!more_info) - osname = "XP"; - else if (osversionex.wSuiteMask & VER_SUITE_PERSONAL) - osname = "XP Home Edition"; + strcat (osname, " Tablet PC Edition"); + else if (GetSystemMetrics (SM_STARTER)) + strcat (osname, " Starter Edition"); + else if (osversion.wSuiteMask & VER_SUITE_PERSONAL) + strcat (osname, " Home Edition"); else - osname = "XP Professional"; + strcat (osname, " Professional"); } else if (osversion.dwMinorVersion == 2) { - if (!more_info) - osname = "2003 Server"; - else if (osversionex.wSuiteMask & VER_SUITE_BLADE) - osname = "2003 Web Server"; - else if (osversionex.wSuiteMask & VER_SUITE_DATACENTER) - osname = "2003 Datacenter Server"; - else if (osversionex.wSuiteMask & VER_SUITE_ENTERPRISE) - osname = "2003 Enterprise Server"; + strcpy (osname, "2003 Server"); + if (GetSystemMetrics (SM_SERVERR2)) + strcat (osname, " R2"); + if (osversion.wSuiteMask & VER_SUITE_BLADE) + strcat (osname, " Web Edition"); + else if (osversion.wSuiteMask & VER_SUITE_DATACENTER) + strcat (osname, " Datacenter Edition"); + else if (osversion.wSuiteMask & VER_SUITE_ENTERPRISE) + strcat (osname, " Enterprise Edition"); + else if (osversion.wSuiteMask & VER_SUITE_COMPUTE_SERVER) + strcat (osname, " Compute Cluster Edition"); + } + } + else if (osversion.dwMajorVersion == 4) + { + strcpy (osname, "NT 4"); + if (more_info) + { + if (osversion.wProductType == VER_NT_WORKSTATION) + strcat (osname, " Workstation"); else - osname = "2003 Server"; + { + strcat (osname, " Server"); + if (osversion.wSuiteMask & VER_SUITE_ENTERPRISE) + strcat (osname, " Enterprise Edition"); + } } } else - osname = "NT"; + strcpy (osname, "NT"); break; default: - osname = "??"; + strcpy (osname, "??"); break; } @@ -1281,5 +1339,7 @@ dump_sysinfo () osversion.szCSDVersion : ""); - HMODULE k32 = LoadLibrary ("kernel32.dll"); + if (osversion.dwPlatformId == VER_PLATFORM_WIN32s + || osversion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + exit (EXIT_FAILURE); BOOL (WINAPI *wow64_func) (HANDLE, PBOOL) = (BOOL (WINAPI *) (HANDLE, PBOOL))