From 7196b7979be870fbf6636dbc9354195bbe835c2d Mon Sep 17 00:00:00 2001 From: "v.popolitov" Date: Thu, 30 Jul 2026 13:14:51 +0300 Subject: [PATCH v2] zic: fix PostgreSQL build failure on filesystems without hard link support zic: fix PostgreSQL build failure on filesystems without hard link support --- src/port/win32link.c | 10 +++++++++- src/timezone/zic.c | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/port/win32link.c b/src/port/win32link.c index e7c8623810f..cf60f20f1b9 100644 --- a/src/port/win32link.c +++ b/src/port/win32link.c @@ -23,7 +23,15 @@ link(const char *src, const char *dst) */ if (CreateHardLinkA(dst, src, NULL) == 0) { - _dosmaperr(GetLastError()); + DWORD errcode; + + errcode = GetLastError(); + + if (errcode == ERROR_INVALID_FUNCTION) + errno = ENOTSUP; + else + _dosmaperr(errcode); + return -1; } else diff --git a/src/timezone/zic.c b/src/timezone/zic.c index cc6550bdb14..c790f1e25ea 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -1902,7 +1902,13 @@ dolink(char const *target, char const *linkname, bool staysymlink) } link_errno = errno; } - if (link_errno == EXDEV || link_errno == ENOTSUP) + if (link_errno == EXDEV +#if defined(__linux__) + || link_errno == EPERM +#elif defined(__FreeBSD__) || defined(__NetBSD__) + || link_errno == EOPNOTSUPP +#endif + || link_errno == ENOTSUP) break; if (link_errno == EEXIST) @@ -1983,7 +1989,13 @@ dolink(char const *target, char const *linkname, bool staysymlink) putc(c, tp); close_file(tp, directory, linkname, tempname); close_file(fp, directory, target, NULL); - if (link_errno != ENOTSUP) + if (link_errno != ENOTSUP +#if defined(__linux__) + && link_errno != EPERM +#elif defined(__FreeBSD__) || defined(__NetBSD__) + && link_errno != EOPNOTSUPP +#endif + ) warning(_("copy used because hard link failed: %s"), strerror(link_errno)); #ifdef HAVE_SYMLINK -- 2.52.0.windows.1