+2024-06-03 Bruno Haible <bruno@clisp.org>
+
+ readlinkat: Work around a Cygwin 3.3.6 bug.
+ * m4/readlinkat.m4 (gl_FUNC_READLINKAT): Set REPLACE_READLINKAT to 1 on
+ Cygwin.
+ * lib/readlinkat.c (rpl_readlinkat): On Cygwin, for /dev/* files, don't
+ return results that start with a backslash.
+ * doc/posix-functions/readlinkat.texi: Mention the Cygwin bug.
+
2024-06-03 Bruno Haible <bruno@clisp.org>
readlink: Work around a Cygwin 3.3.6 bug.
On some platforms, this function returns @code{int} instead of
@code{ssize_t}:
AIX 7.1.
+@item
+For the file name @file{/dev/null}, this function returns @file{\Device\Null},
+which is unusable, on some platforms:
+Cygwin 3.3.6.
@end itemize
Portability problems mostly fixed by Gnulib:
/* Read a symlink relative to an open directory.
- Copyright (C) 2009-2023 Free Software Foundation, Inc.
+ Copyright (C) 2009-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
# endif
+# if defined __CYGWIN__
+ /* On Cygwin 3.3.6, readlinkat(AT_FDCWD,"/dev/null") returns "\\Device\\Null",
+ which is unusable. Better fail with EINVAL. */
+ if (r > 0 && strncmp (file, "/dev/", 5) == 0 && buf[0] == '\\')
+ {
+ errno = EINVAL;
+ return -1;
+ }
+# endif
+
return r;
}
-# serial 8
+# serial 9
# See if we need to provide readlinkat replacement.
-dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
[AC_LANG_PROGRAM(
[[#include <unistd.h>
/* Check whether original declaration has correct type. */
- ssize_t readlinkat (int, char const *, char *, size_t);]])],
+ ssize_t readlinkat (int, char const *, char *, size_t);
+ ]])
+ ],
[gl_cv_decl_readlinkat_works=yes],
- [gl_cv_decl_readlinkat_works=no])])
+ [gl_cv_decl_readlinkat_works=no])
+ ])
# Assume readlinkat has the same bugs as readlink,
# as is the case on OS X 10.10 with trailing slashes.
case $gl_cv_decl_readlinkat_works,$gl_cv_func_readlink_trailing_slash,$gl_cv_func_readlink_truncate in
REPLACE_READLINKAT=1
;;
esac
+
+ dnl On Cygwin 3.3.6, readlinkat(AT_FDCWD,"/dev/null") returns
+ dnl "\\Device\\Null", which is unusable.
+ case "$host_os" in
+ cygwin*)
+ REPLACE_READLINKAT=1
+ ;;
+ esac
fi
])