+#if HAVE_SYMLINKAT
+# undef symlinkat
+
+#include <sys/stat.h>
+#include <string.h>
+
+/* Create a symlink, but reject trailing slash. */
+int
+rpl_symlinkat (char const *contents, int fd, char const *name)
+{
+ size_t len = strlen (name);
+ if (len && name[len - 1] == '/')
+ {
+ struct stat st;
+ if (fstatat (fd, name, &st, 0) == 0)
+ errno = EEXIST;
+ return -1;
+ }
+ return symlinkat (contents, fd, name);
+}
+
+#elif !HAVE_SYMLINK