diff --git a/winsup/cygwin/fhandler/socket_inet.cc b/winsup/cygwin/fhandler/socket_inet.cc index 22dfed63d6..5ed0cb0ec7 100644 --- a/winsup/cygwin/fhandler/socket_inet.cc +++ b/winsup/cygwin/fhandler/socket_inet.cc @@ -20,7 +20,12 @@ #undef u_long #define u_long __ms_u_long #include +/* 2025-06-09: win32api headers v13 now define a cmsghdr type which clashes with + our socket.h. Arrange not to see it here. */ +#undef cmsghdr +#define cmsghdr __ms_cmsghdr #include +#undef cmsghdr #include #include #include diff --git a/winsup/cygwin/fhandler/socket_local.cc b/winsup/cygwin/fhandler/socket_local.cc index ea5ee67cc1..0498edc40b 100644 --- a/winsup/cygwin/fhandler/socket_local.cc +++ b/winsup/cygwin/fhandler/socket_local.cc @@ -21,7 +21,12 @@ #define u_long __ms_u_long #include "ntsecapi.h" #include +/* 2025-06-09: win32api headers v13 now define a cmsghdr type which clashes with + our socket.h. Arrange not to see it here. */ +#undef cmsghdr +#define cmsghdr __ms_cmsghdr #include +#undef cmsghdr #include #include #include diff --git a/winsup/cygwin/local_includes/ntdll.h b/winsup/cygwin/local_includes/ntdll.h index 4497fe53f9..2991672172 100644 --- a/winsup/cygwin/local_includes/ntdll.h +++ b/winsup/cygwin/local_includes/ntdll.h @@ -489,6 +489,8 @@ typedef struct _FILE_DISPOSITION_INFORMATION_EX // 64 ULONG Flags; } FILE_DISPOSITION_INFORMATION_EX, *PFILE_DISPOSITION_INFORMATION_EX; +#if __MINGW64_VERSION_MAJOR < 13 + typedef struct _FILE_STAT_INFORMATION // 68 { LARGE_INTEGER FileId; @@ -509,6 +511,8 @@ typedef struct _FILE_CASE_SENSITIVE_INFORMATION // 71 ULONG Flags; } FILE_CASE_SENSITIVE_INFORMATION, *PFILE_CASE_SENSITIVE_INFORMATION; +#endif + enum { FILE_LINK_REPLACE_IF_EXISTS = 0x01, FILE_LINK_POSIX_SEMANTICS = 0x02, diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 9d7224a21c..579b1a70b4 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -18,7 +18,12 @@ details. */ #undef u_long #define u_long __ms_u_long #include +/* 2025-06-09: win32api headers v13 now define a cmsghdr type which clashes with + our socket.h. Arrange not to see it here. */ +#undef cmsghdr +#define cmsghdr __ms_cmsghdr #include +#undef cmsghdr #include #define gethostname cygwin_gethostname #include diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 43e07d1312..21f3baaa12 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2031,9 +2031,18 @@ symlink_native (const char *oldpath, path_conv &win32_newpath) while (towupper (*++c_old) == towupper (*++c_new)) ; /* The last component could share a common prefix, so make sure we end - up on the first char after the last common backslash. */ - while (c_old[-1] != L'\\') - --c_old, --c_new; + up on the first char after the last common backslash. + + However, if c_old is a strict prefix of c_new (at a component + boundary), or vice versa, then do not try to find the last common + backslash. */ + if ((!*c_old || *c_old == L'\\') && (!*c_new || *c_new == L'\\')) + c_old += !!*c_old, c_new += !!*c_new; + else + { + while (c_old[-1] != L'\\') + --c_old, --c_new; + } /* 2. Check if prefix is long enough. The prefix must at least points to a complete device: \\?\X:\ or \\?\UNC\server\share\ are the minimum @@ -2058,8 +2067,10 @@ symlink_native (const char *oldpath, path_conv &win32_newpath) final_oldpath = &final_oldpath_buf; final_oldpath->Buffer = tp.w_get (); PWCHAR e_old = final_oldpath->Buffer; - while (num-- > 0) - e_old = wcpcpy (e_old, L"..\\"); + while (num > 1 || (num == 1 && *c_old)) + e_old = wcpcpy (e_old, L"..\\"), num--; + if (num > 0) + e_old = wcpcpy (e_old, L".."); wcpcpy (e_old, c_old); } }