diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5d8a9644e..7d59097af 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,38 @@ +Mon May 29 20:31:01 2000 Christopher Faylor + + * Makefile.in: Remove libadvapi32.a. + * autoload.h: Add additional field to autoload block for handling + unimplemented functions. + (LoadDLLfuncEx): New function which accepts additional parameter for + controlling unimplemented function behavior. + (LoadDLLfunc): Use LoadDLLfuncEx. + * dcrt0.cc: Use new arguments for LoadDLLfunc. Add advapi32 routines. + (noload): Rewrite in assembler. Handle new unimplemented function + type. + * exceptions.cc: Eliminate another vestige of StackWalk stuff. + * net.cc: Use new arguments for LoadDLLfunc. + * uinfo.cc: Ditto. + +Mon May 29 20:18:47 2000 Christopher Faylor + + * config.h.in: Remove obsolete define. + * path.h (isdrive): New macro. + * dcrt0.cc (globify): Use new macro to determine if a string refers to + an MS-DOS drive. + * environ.cc (winenv): Ditto. + * spawn.cc (find_exec): Ditto. + * path.cc (get_raw_device_number): Ditto. + (mount_info::conv_to_posix_path): Ditto. + (chdir): Ditto. + (cygwin_posix_path_list_p): Ditto. + (cygwin_split_path): Ditto. + (path_conv::check): Move tmp_buf to beginning of function since it can + be used earlier in the loop. Use tmp_buf rather than 'root' to hold + root information. + (mount_info::conv_to_win32_path): Add trailing slash to end of mount + path when it translates to a drive. Add defensive code to avoid + writing beyond the end of 'dst'. + Wed May 27 15:57:00 2000 Corinna Vinschen * fhandler_random.cc (read): Use CRYPT_MACHINE_KEYSET in @@ -32,13 +67,13 @@ Wed May 24 21:59:00 2000 Corinna Vinschen * security.cc (get_nt_attribute): Fix error in debug output. Never set FILE_DELETE_CHILD for files. Construct appropriate inherit attribute according to file type. - + 2000-05-23 DJ Delorie * syscalls.cc (_cygwin_istext_for_stdio): New, for newlib * include/cygwin/version.h: Bump API number for detect old programs using old getc/putc macros - + 2000-05-23 DJ Delorie * dir.cc (writable_directory): handle root directories @@ -350,7 +385,7 @@ Wed Apr 26 23:23:23 2000 Christopher Faylor 2000-04-26 DJ Delorie * Makefile.in (install): install regexp.h - + Wed Apr 26 16:20:00 2000 Corinna Vinschen * syscalls.cc (stat_worker): Previous patch could succeed diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index 9fdbe6687..d7a23c492 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -114,7 +114,7 @@ EXTRA_DLL_OFILES:=${addsuffix .o,${basename ${notdir ${wildcard $(CONFIG_DIR)/*. EXTRA_OFILES=$(bupdir1)/libiberty/random.o $(bupdir1)/libiberty/strsignal.o -DLL_IMPORTS:=$(w32api_lib)/libkernel32.a $(w32api_lib)/libadvapi32.a +DLL_IMPORTS:=$(w32api_lib)/libkernel32.a DLL_OFILES:=assert.o dcrt0.o debug.o delqueue.o dir.o dlfcn.o dll_init.o \ environ.o errno.o exceptions.o exec.o external.o fcntl.o fhandler.o \ diff --git a/winsup/cygwin/autoload.h b/winsup/cygwin/autoload.h index 71a51c28b..be5aa164a 100644 --- a/winsup/cygwin/autoload.h +++ b/winsup/cygwin/autoload.h @@ -47,29 +47,35 @@ static int dllname ## _init () * So, immediately following the the call to one of the above routines * we have: * foojmp (4 bytes) Pointer to a word containing the routine used - * to eventually invokethe function. Initially + * to eventually invoke the function. Initially * points to an init function which loads the - * DLL, gets the processes load address, + * DLL, gets the process's load address, * changes the contents here to point to the * function address, and changes the call *(%eax) * to a jmp %eax. If the initialization has been * done, only the load part is done. * DLL handle (4 bytes) The handle to use when loading the DLL. + * flag (4 bytes) If "TRUE" then it is not a fatal error if this + * function cannot be found. Instead, error is set + * to ERROR_PROC_NOT_FOUND and 0 is returned. * func name (n bytes) asciz string containing the name of the function * to be loaded. */ -#define LoadDLLfunc(name, mangled, dllname) \ +#define LoadDLLmangle(name, n) #name "@" #n +#define LoadDLLfunc(name, n, dllname) LoadDLLfuncEx (name, n, dllname, 0) +#define LoadDLLfuncEx(name, n, dllname, notimp) \ __asm__ (".section .data_cygwin_nocopy,\"w\""); \ -__asm__ (".global _" #mangled); \ -__asm__ (".global _win32_" #mangled); \ +__asm__ (".global _" LoadDLLmangle (name, n)); \ +__asm__ (".global _win32_" LoadDLLmangle (name, n)); \ __asm__ (".align 8"); \ -__asm__ ("_" #mangled ":"); \ -__asm__ ("_win32_" #mangled ":"); \ +__asm__ ("_" LoadDLLmangle (name, n) ":"); \ +__asm__ ("_win32_" LoadDLLmangle (name, n) ":"); \ __asm__ ("movl (" #name "jump),%eax"); \ __asm__ ("call *(%eax)"); \ __asm__ (#name "jump: .long " #dllname "_init_holder"); \ __asm__ (" .long _" #dllname "_handle"); \ +__asm__ (" .long " #n "+" #notimp); \ __asm__ (".asciz \"" #name "\""); \ __asm__ (".text"); diff --git a/winsup/cygwin/config.h.in b/winsup/cygwin/config.h.in index e160104f3..6ae0dbc7d 100644 --- a/winsup/cygwin/config.h.in +++ b/winsup/cygwin/config.h.in @@ -33,6 +33,3 @@ /* Define if building thread-safe Cygwin DLL. */ #undef _MT_SAFE - -/* Define if strace log output has date/time stamp. */ -#undef STRACE_HHMMSS diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index d5f15c593..c363d2e2f 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -309,9 +309,9 @@ globify (char *word, char **&argv, int &argc, int &argvlen) int n = 0; char *p, *s; - int dos_spec = isalpha(*word) && word[1] == ':' ? 1 : 0; + int dos_spec = isdrive (word); if (!dos_spec && isquote(*word) && word[1] && word[2]) - dos_spec = isalpha(word[1]) && word[2] == ':' ? 1 : 0; + dos_spec = isdrive (word + 1); /* We'll need more space if there are quoting characters in word. If that is the case, doubling the size of the @@ -653,7 +653,7 @@ dll_crt0_1 () /* Allow backup semantics. It's better done only once on process start instead of each time a file is opened. */ set_process_privileges (); - + /* Initialize SIGSEGV handling, etc... Because the exception handler references data in the shared area, this must be done after shared_init. */ @@ -987,31 +987,52 @@ __api_fatal (const char *fmt, ...) } extern "C" { -static void noload (HANDLE h, char *s) __asm__ ("noload"); -static void __attribute__((unused)) -noload (HANDLE h, char *s) + +/* This struct is unused, but it illustrates the layout of a DLL + information block. */ +struct DLLinfo { - api_fatal ("couldn't dynamically determine load address for '%s' (handle %p), %E", s, h); -} + char jmpinst[4]; + HANDLE h; + DWORD flag; + char name[0]; +}; /* FIXME: This is not thread-safe! */ __asm__ (" -.globl cygwin_dll_func_load +msg1: + .ascii \"couldn't dynamically determine load address for '%s' (handle %p), %E\\0\" + + .align 32 +noload: + popl %edx # Get the address of the information block + movl 8(%edx),%eax # Should we 'ignore' the lack + test $1,%eax # of this function? + jz 1f # Nope. + decl %eax # Yes. This is the # of bytes + 1 + popl %edx # Caller's caller + addl %eax,%esp # Pop off bytes + xor %eax,%eax # Zero functional return + jmp *%edx # Return +1: + movl 4(%edx),%eax # Handle value + pushl (%eax) + leal 12(%edx),%eax # Location of name of function + push %eax + push $msg1 # The message + call ___api_fatal # Print message. Never returns + + .globl cygwin_dll_func_load cygwin_dll_func_load: movl (%esp),%eax # 'Return address' contains load info - addl $8,%eax # Address of name of function to load + addl $12,%eax # Address of name of function to load pushl %eax # Second argument - movl -4(%eax),%eax # Address of Handle to DLL + movl -8(%eax),%eax # Address of Handle to DLL pushl (%eax) # Handle to DLL call _GetProcAddress@8# Load it test %eax,%eax # Success? jne gotit # Yes - popl %eax # No. Get back - addl $8,%eax # pointer to name - pushl %eax # and - movl -4(%eax),%eax # Address of Handle to DLL - pushl (%eax) # Handle to DLL - call noload # issue an error + jmp noload # Issue an error or return gotit: popl %ecx # Pointer to 'return address' movb $0xe0,-1(%ecx) # Turn preceding call to a jmp *%eax @@ -1033,24 +1054,81 @@ LoadDLLinitfunc (user32) } LoadDLLinit (user32) -LoadDLLfunc (CharToOemA, CharToOemA@8, user32) -LoadDLLfunc (CreateWindowExA, CreateWindowExA@48, user32) -LoadDLLfunc (DefWindowProcA, DefWindowProcA@16, user32) -LoadDLLfunc (DispatchMessageA, DispatchMessageA@4, user32) -LoadDLLfunc (FindWindowA, FindWindowA@8, user32) -LoadDLLfunc (GetMessageA, GetMessageA@16, user32) -LoadDLLfunc (GetProcessWindowStation, GetProcessWindowStation@0, user32) -LoadDLLfunc (GetThreadDesktop, GetThreadDesktop@4, user32) -LoadDLLfunc (GetUserObjectInformationA, GetUserObjectInformationA@20, user32) -LoadDLLfunc (KillTimer, KillTimer@8, user32) -LoadDLLfunc (MessageBoxA, MessageBoxA@16, user32) -LoadDLLfunc (MsgWaitForMultipleObjects, MsgWaitForMultipleObjects@20, user32) -LoadDLLfunc (OemToCharA, OemToCharA@8, user32) -LoadDLLfunc (OemToCharW, OemToCharW@8, user32) -LoadDLLfunc (PeekMessageA, PeekMessageA@20, user32) -LoadDLLfunc (PostMessageA, PostMessageA@16, user32) -LoadDLLfunc (PostQuitMessage, PostQuitMessage@4, user32) -LoadDLLfunc (RegisterClassA, RegisterClassA@4, user32) -LoadDLLfunc (SendMessageA, SendMessageA@16, user32) -LoadDLLfunc (SetTimer, SetTimer@16, user32) -LoadDLLfunc (SetUserObjectSecurity, SetUserObjectSecurity@12, user32) +LoadDLLfunc (CharToOemA, 8, user32) +LoadDLLfunc (CreateWindowExA, 48, user32) +LoadDLLfunc (DefWindowProcA, 16, user32) +LoadDLLfunc (DispatchMessageA, 4, user32) +LoadDLLfunc (FindWindowA, 8, user32) +LoadDLLfunc (GetMessageA, 16, user32) +LoadDLLfunc (GetProcessWindowStation, 0, user32) +LoadDLLfunc (GetThreadDesktop, 4, user32) +LoadDLLfunc (GetUserObjectInformationA, 20, user32) +LoadDLLfunc (KillTimer, 8, user32) +LoadDLLfunc (MessageBoxA, 16, user32) +LoadDLLfunc (MsgWaitForMultipleObjects, 20, user32) +LoadDLLfunc (OemToCharA, 8, user32) +LoadDLLfunc (OemToCharW, 8, user32) +LoadDLLfunc (PeekMessageA, 20, user32) +LoadDLLfunc (PostMessageA, 16, user32) +LoadDLLfunc (PostQuitMessage, 4, user32) +LoadDLLfunc (RegisterClassA, 4, user32) +LoadDLLfunc (SendMessageA, 16, user32) +LoadDLLfunc (SetTimer, 16, user32) +LoadDLLfunc (SetUserObjectSecurity, 12, user32) + +LoadDLLinitfunc (advapi32) +{ + HANDLE h; + + if ((h = LoadLibrary ("advapi32.dll")) != NULL) + advapi32_handle = h; + else if (!advapi32_handle) + api_fatal ("could not load advapi32.dll, %E"); + + return 0; /* Already done by another thread? */ +} + +LoadDLLinit (advapi32) +LoadDLLfunc (AddAccessAllowedAce, 16, advapi32) +LoadDLLfunc (AddAccessDeniedAce, 16, advapi32) +LoadDLLfunc (AddAce, 20, advapi32) +LoadDLLfunc (AdjustTokenPrivileges, 24, advapi32) +LoadDLLfunc (CopySid, 12, advapi32) +LoadDLLfunc (CreateProcessAsUserA, 44, advapi32) +LoadDLLfunc (CryptAcquireContextA, 20, advapi32) +LoadDLLfunc (CryptGenRandom, 12, advapi32) +LoadDLLfunc (CryptReleaseContext, 8, advapi32) +LoadDLLfunc (DeregisterEventSource, 4, advapi32) +LoadDLLfunc (EqualSid, 8, advapi32) +LoadDLLfunc (GetAce, 12, advapi32) +LoadDLLfunc (GetFileSecurityA, 20, advapi32) +LoadDLLfunc (GetLengthSid, 4, advapi32) +LoadDLLfunc (GetSecurityDescriptorDacl, 16, advapi32) +LoadDLLfunc (GetSecurityDescriptorGroup, 12, advapi32) +LoadDLLfunc (GetSecurityDescriptorOwner, 12, advapi32) +LoadDLLfunc (GetSidSubAuthority, 8, advapi32) +LoadDLLfunc (GetSidSubAuthorityCount, 4, advapi32) +LoadDLLfunc (GetTokenInformation, 20, advapi32) +LoadDLLfunc (GetUserNameA, 8, advapi32) +LoadDLLfunc (InitializeAcl, 12, advapi32) +LoadDLLfunc (InitializeSecurityDescriptor, 8, advapi32) +LoadDLLfunc (InitializeSid, 12, advapi32) +LoadDLLfunc (IsValidSid, 4, advapi32) +LoadDLLfunc (LookupAccountNameA, 28, advapi32) +LoadDLLfunc (LookupAccountSidA, 28, advapi32) +LoadDLLfunc (LookupPrivilegeValueA, 12, advapi32) +LoadDLLfunc (MakeSelfRelativeSD, 12, advapi32) +LoadDLLfunc (OpenProcessToken, 12, advapi32) +LoadDLLfunc (RegCloseKey, 4, advapi32) +LoadDLLfunc (RegCreateKeyExA, 36, advapi32) +LoadDLLfunc (RegDeleteKeyA, 8, advapi32) +LoadDLLfunc (RegEnumKeyExA, 32, advapi32) +LoadDLLfunc (RegOpenKeyExA, 20, advapi32) +LoadDLLfunc (RegQueryValueExA, 24, advapi32) +LoadDLLfunc (RegSetValueExA, 24, advapi32) +LoadDLLfunc (RegisterEventSourceA, 8, advapi32) +LoadDLLfunc (ReportEventA, 36, advapi32) +LoadDLLfunc (SetKernelObjectSecurity, 12, advapi32) +LoadDLLfunc (SetSecurityDescriptorDacl, 16, advapi32) +LoadDLLfunc (SetSecurityDescriptorGroup, 12, advapi32) +LoadDLLfunc (SetSecurityDescriptorOwner, 12, advapi32) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index bb493b0e2..415b24c4e 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -543,8 +543,7 @@ winenv (const char * const *envp, int keep_posix) else *dstp = *srcp; tl += strlen (*dstp) + 1; - if ((*dstp)[0] == '!' && isalpha((*dstp)[1]) && (*dstp)[2] == ':' && - (*dstp)[3] == '=') + if ((*dstp)[0] == '!' && isdrive ((*dstp) + 1) && (*dstp)[3] == '=') { char *p = (char *) alloca (strlen (*dstp) + 1); strcpy (p, *dstp); diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 5ebf8de36..376367432 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -195,17 +195,6 @@ exception (EXCEPTION_RECORD *e, CONTEXT *in) #define HAVE_STACK_TRACE -/* The function used to load the imagehlp DLL. Returns TRUE if the - DLL was found. */ -static LoadDLLinitfunc (imagehlp) -{ - imagehlp_handle = LoadLibrary ("imagehlp.dll"); - return !!imagehlp_handle; -} - -LoadDLLinit (imagehlp) /* Set up storage for imagehlp.dll autoload */ -LoadDLLfunc (StackWalk, StackWalk@36, imagehlp) - /* A class for manipulating the stack. */ class stack_info { diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 8e3f9f4de..0f9e38a87 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -1815,38 +1815,38 @@ LoadDLLinitfunc (wsock32) LoadDLLinit (wsock32) -LoadDLLfunc (WSAAsyncSelect, WSAAsyncSelect@16, wsock32) -LoadDLLfunc (WSACleanup, WSACleanup@0, wsock32) -LoadDLLfunc (WSAGetLastError, WSAGetLastError@0, wsock32) -LoadDLLfunc (WSAStartup, WSAStartup@8, wsock32) -LoadDLLfunc (__WSAFDIsSet, __WSAFDIsSet@8, wsock32) -LoadDLLfunc (accept, accept@12, wsock32) -LoadDLLfunc (bind, bind@12, wsock32) -LoadDLLfunc (closesocket, closesocket@4, wsock32) -LoadDLLfunc (connect, connect@12, wsock32) -LoadDLLfunc (gethostbyaddr, gethostbyaddr@12, wsock32) -LoadDLLfunc (gethostbyname, gethostbyname@4, wsock32) -LoadDLLfunc (gethostname, gethostname@8, wsock32) -LoadDLLfunc (getpeername, getpeername@12, wsock32) -LoadDLLfunc (getprotobyname, getprotobyname@4, wsock32) -LoadDLLfunc (getprotobynumber, getprotobynumber@4, wsock32) -LoadDLLfunc (getservbyname, getservbyname@8, wsock32) -LoadDLLfunc (getservbyport, getservbyport@8, wsock32) -LoadDLLfunc (getsockname, getsockname@12, wsock32) -LoadDLLfunc (getsockopt, getsockopt@20, wsock32) -LoadDLLfunc (inet_addr, inet_addr@4, wsock32) -LoadDLLfunc (inet_network, inet_network@4, wsock32) -LoadDLLfunc (inet_ntoa, inet_ntoa@4, wsock32) -LoadDLLfunc (ioctlsocket, ioctlsocket@12, wsock32) -LoadDLLfunc (listen, listen@8, wsock32) -LoadDLLfunc (rcmd, rcmd@24, wsock32) -LoadDLLfunc (recv, recv@16, wsock32) -LoadDLLfunc (recvfrom, recvfrom@24, wsock32) -LoadDLLfunc (rexec, rexec@24, wsock32) -LoadDLLfunc (rresvport, rresvport@4, wsock32) -LoadDLLfunc (select, select@20, wsock32) -LoadDLLfunc (send, send@16, wsock32) -LoadDLLfunc (sendto, sendto@24, wsock32) -LoadDLLfunc (setsockopt, setsockopt@20, wsock32) -LoadDLLfunc (shutdown, shutdown@8, wsock32) -LoadDLLfunc (socket, socket@12, wsock32) +LoadDLLfunc (WSAAsyncSelect, 16, wsock32) +LoadDLLfunc (WSACleanup, 0, wsock32) +LoadDLLfunc (WSAGetLastError, 0, wsock32) +LoadDLLfunc (WSAStartup, 8, wsock32) +LoadDLLfunc (__WSAFDIsSet, 8, wsock32) +LoadDLLfunc (accept, 12, wsock32) +LoadDLLfunc (bind, 12, wsock32) +LoadDLLfunc (closesocket, 4, wsock32) +LoadDLLfunc (connect, 12, wsock32) +LoadDLLfunc (gethostbyaddr, 12, wsock32) +LoadDLLfunc (gethostbyname, 4, wsock32) +LoadDLLfunc (gethostname, 8, wsock32) +LoadDLLfunc (getpeername, 12, wsock32) +LoadDLLfunc (getprotobyname, 4, wsock32) +LoadDLLfunc (getprotobynumber, 4, wsock32) +LoadDLLfunc (getservbyname, 8, wsock32) +LoadDLLfunc (getservbyport, 8, wsock32) +LoadDLLfunc (getsockname, 12, wsock32) +LoadDLLfunc (getsockopt, 20, wsock32) +LoadDLLfunc (inet_addr, 4, wsock32) +LoadDLLfunc (inet_network, 4, wsock32) +LoadDLLfunc (inet_ntoa, 4, wsock32) +LoadDLLfunc (ioctlsocket, 12, wsock32) +LoadDLLfunc (listen, 8, wsock32) +LoadDLLfunc (rcmd, 24, wsock32) +LoadDLLfunc (recv, 16, wsock32) +LoadDLLfunc (recvfrom, 24, wsock32) +LoadDLLfunc (rexec, 24, wsock32) +LoadDLLfunc (rresvport, 4, wsock32) +LoadDLLfunc (select, 20, wsock32) +LoadDLLfunc (send, 16, wsock32) +LoadDLLfunc (sendto, 24, wsock32) +LoadDLLfunc (setsockopt, 20, wsock32) +LoadDLLfunc (shutdown, 8, wsock32) +LoadDLLfunc (socket, 12, wsock32) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index dd52d18e1..4cb26369f 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -189,6 +189,7 @@ path_conv::check (const char *src, symlink_follow follow_mode, trailer. */ char path_buf[MAX_PATH]; char path_copy[MAX_PATH]; + char tmp_buf[MAX_PATH]; symlink_info sym; char *rel_path, *full_path; @@ -353,7 +354,6 @@ path_conv::check (const char *src, symlink_follow follow_mode, system_printf ("problem parsing %s - '%s'", src, full_path); else { - char tmp_buf[MAX_PATH]; int headlen = 1 + tail - path_copy; p = sym.contents - headlen; memcpy (p, path_copy, headlen); @@ -378,19 +378,18 @@ fillin: out: DWORD serial, volflags; - char root[strlen(full_path) + 10]; - strcpy (root, full_path); - if (!rootdir (root) || - !GetVolumeInformation (root, NULL, 0, &serial, NULL, &volflags, NULL, 0)) + strcpy (tmp_buf, full_path); + if (!rootdir (tmp_buf) || + !GetVolumeInformation (tmp_buf, NULL, 0, &serial, NULL, &volflags, NULL, 0)) { debug_printf ("GetVolumeInformation(%s) = ERR, full_path(%s), set_has_acls(FALSE)", - root, full_path, GetLastError ()); + tmp_buf, full_path, GetLastError ()); set_has_acls (FALSE); } else { debug_printf ("GetVolumeInformation(%s) = OK, full_path(%s), set_has_acls(%d)", - root, full_path, volflags & FS_PERSISTENT_ACLS); + tmp_buf, full_path, volflags & FS_PERSISTENT_ACLS); set_has_acls (volflags & FS_PERSISTENT_ACLS); } } @@ -446,7 +445,7 @@ get_raw_device_number (const char *uxname, const char *w32path, int &unit) if (! strncasecmp (uxname, "/dev/n", 6)) unit += 128; } - else if (isalpha (w32path[4]) && w32path[5] == ':') + else if (isdrive (w32path + 4)) { devn = FH_FLOPPY; unit = tolower (w32path[4]) - 'a'; @@ -1023,6 +1022,8 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path, int n = mi->native_pathlen; memcpy (dst, mi->native_path, n); char *p = pathbuf + mi->posix_pathlen; + if (!trailing_slash_p && isdrive (mi->native_path) && !mi->native_path[2]) + trailing_slash_p = 1; if (!trailing_slash_p && !*p) dst[n] = '\0'; else @@ -1048,17 +1049,23 @@ fillin: path_prefix_p (current_directory_name, dst, cwdlen = strlen (current_directory_name))) { - if (strlen (dst) == cwdlen) - dst += cwdlen; + size_t n = strlen (dst); + if (n < cwdlen) + strcpy (win32_path, dst); else - dst += isdirsep (current_directory_name[cwdlen - 1]) ? cwdlen : cwdlen + 1; - - memmove (win32_path, dst, strlen (dst) + 1); - if (!*win32_path) { - strcpy (win32_path, "."); - if (trailing_slash_p) - strcat (win32_path, "\\"); + if (n == cwdlen) + dst += cwdlen; + else + dst += isdirsep (current_directory_name[cwdlen - 1]) ? cwdlen : cwdlen + 1; + + memmove (win32_path, dst, strlen (dst) + 1); + if (!*win32_path) + { + strcpy (win32_path, "."); + if (trailing_slash_p) + strcat (win32_path, "\\"); + } } } else if (win32_path != dst) @@ -1220,7 +1227,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path, letter not covered by the mount table. If it's a relative path then the caller must want an absolute path (otherwise we would have returned above). So we always return an absolute path at this point. */ - if ((isalpha (pathbuf[0])) && (pathbuf[1] == ':')) + if (isdrive (pathbuf)) cygdrive_posix_path (pathbuf, posix_path, trailing_slash_p); else { @@ -2500,13 +2507,13 @@ chdir (const char *dir) If it does, append a \ to the native directory specification to defeat the Windows 95 (i.e. MS-DOS) tendency of returning to the last directory visited on the given drive. */ - if (isalpha (native_dir[0]) && native_dir[1] == ':' && !native_dir[2]) + if (isdrive (native_dir) && !native_dir[2]) { native_dir[2] = '\\'; native_dir[3] = '\0'; } - int res = SetCurrentDirectoryA (native_dir); - if (!res) + int res = SetCurrentDirectoryA (native_dir) ? 0 : -1; + if (res == -1) __seterrno (); /* Clear the cache until we need to retrieve the directory again. */ @@ -2521,8 +2528,8 @@ chdir (const char *dir) current_directory_posix_name = NULL; } - syscall_printf ("%d = chdir (%s) (dos %s)", res ? 0 : -1, dir, native_dir); - return res ? 0 : -1; + syscall_printf ("%d = chdir (%s) (dos %s)", res, dir, native_dir); + return res; } /******************** Exported Path Routines *********************/ @@ -2629,8 +2636,7 @@ extern "C" int cygwin_posix_path_list_p (const char *path) { - int posix_p = ! (strchr (path, ';') - || (isalpha (path[0]) && path[1] == ':')); + int posix_p = ! (strchr (path, ';') || isdrive (path)); return posix_p; } @@ -2725,7 +2731,7 @@ cygwin_split_path (const char *path, char *dir, char *file) /* Deal with drives. Remember that c:foo <==> c:/foo. */ - if (isalpha (path[0]) && path[1] == ':') + if (isdrive (path)) { *dir++ = *path++; *dir++ = *path++; diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 2a3c95c77..1ff08e4bc 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -85,7 +85,7 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv, /* Return the error condition if this is an absolute path or if there is no PATH to search. */ if (strchr (name, '/') || strchr (name, '\\') || - isalpha (name[0]) && name[1] == ':' || + isdrive (name) || !(winpath = getwinenv (mywinenv)) || !(path = winpath->get_native ()) || *path == '\0') diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 97c754ce6..5305527ed 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -190,7 +190,7 @@ LoadDLLinitfunc (netapi32) return 0; } LoadDLLinit (netapi32) -LoadDLLfunc (NetWkstaUserGetInfo, NetWkstaUserGetInfo@12, netapi32) -LoadDLLfunc (NetGetDCName, NetGetDCName@12, netapi32) -LoadDLLfunc (NetApiBufferFree, NetApiBufferFree@4, netapi32) +LoadDLLfunc (NetWkstaUserGetInfo, 12, netapi32) +LoadDLLfunc (NetGetDCName, 12, netapi32) +LoadDLLfunc (NetApiBufferFree, 4, netapi32)