I spoke too soon about EOPNOTSUPP.  Although it equals ENOTSUP on
FreeBSD, this is not true of NetBSD and OpenBSD.
* private.h (EOPNOTSUPP): Default to ENOTSUP.
* zic.c (dolink): Treat EOPNOTSUPP like ENOTSUP.
---
 private.h | 4 ++++
 zic.c     | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/private.h b/private.h
index 8ef03daf..f6a649f5 100644
--- a/private.h
+++ b/private.h
@@ -271,6 +271,10 @@ strnlen (char const *s, size_t maxlen)
 # define EPERM EINVAL
 #endif
 
+#ifndef EOPNOTSUPP
+# define EOPNOTSUPP ENOTSUP
+#endif
+
 #if HAVE_GETTEXT
 # include <libintl.h>
 #endif /* HAVE_GETTEXT */
diff --git a/zic.c b/zic.c
index 5ed884e5..fe475abb 100644
--- a/zic.c
+++ b/zic.c
@@ -1764,6 +1764,8 @@ dolink(char const *target, char const *linkname, bool 
staysymlink)
            break;
          }
          link_errno = errno;
+         if (link_errno == EOPNOTSUPP)
+           link_errno = ENOTSUP;
          /* Linux 2.6.16 and 2.6.17 mishandle AT_SYMLINK_FOLLOW.  */
          if (link_errno == EINVAL)
            link_errno = ENOTSUP;
@@ -1781,6 +1783,8 @@ dolink(char const *target, char const *linkname, bool 
staysymlink)
              break;
            }
            link_errno = errno;
+           if (link_errno == EOPNOTSUPP)
+             link_errno = ENOTSUP;
            /* When hard links are not supported, some MS-Windows file system
               drivers fail with EINVAL, contrary to the intent of
               MS-FSA 42.0 (2025) section 2.1.5.15.7.  */
@@ -1862,7 +1866,7 @@ dolink(char const *target, char const *linkname, bool 
staysymlink)
            else if (symlink_errno < 0)
              warning(N_("copy used because symbolic link not obvious"));
            else if (symlink_errno != ENOSYS && symlink_errno != ENOTSUP
-                    && symlink_errno != EPERM)
+                    && symlink_errno != EOPNOTSUPP && symlink_errno != EPERM)
              warning(N_("copy used because symbolic link failed: %s"),
                      strerror(symlink_errno));
          }
-- 
2.53.0

Reply via email to