index 93ee4a2937098f05526cd4f8722171e2a0049892..45dbeb4d1986798a0189a1e773c807c4e0012604 100755 (executable)
fi
+ac_fn_c_check_func "$LINENO" "link" "ac_cv_func_link"
+if test "x$ac_cv_func_link" = xyes; then :
+ $as_echo "#define HAVE_LINK 1" >>confdefs.h
+
+else
+ case " $LIBOBJS " in
+ *" link.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS link.$ac_objext"
+ ;;
+esac
+
+fi
+
ac_fn_c_check_func "$LINENO" "mkdtemp" "ac_cv_func_mkdtemp"
if test "x$ac_cv_func_mkdtemp" = xyes; then :
$as_echo "#define HAVE_MKDTEMP 1" >>confdefs.h
index e2ae4e2d3e1693a56e958cfcd38cd544b247b70c..22f096a5ac7a0742c7a72d838f1fd74a3c787d71 100644 (file)
getpeereid
getrusage
inet_aton
+ link
mkdtemp
pread
pwrite
index 09bf886ed71480418602d4bfa997deaf4b6eda2c..cc8a675d0095cbd3995e47bb70d4e06f03424413 100644 (file)
#include "storage/checksum.h"
#include "storage/checksum_impl.h"
-#ifdef WIN32
-static int win32_pghardlink(const char *src, const char *dst);
-#endif
-
/*
* cloneFile()
linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName)
{
- if (pg_link_file(src, dst) < 0)
+ if (link(src, dst) < 0)
pg_fatal("error while creating link for relation \"%s.%s\" (\"%s\" to \"%s\"): %s\n",
schemaName, relName, src, dst, strerror(errno));
}
snprintf(new_link_file, sizeof(new_link_file), "%s/PG_VERSION.linktest", new_cluster.pgdata);
unlink(new_link_file); /* might fail */
- if (pg_link_file(existing_file, new_link_file) < 0)
+ if (link(existing_file, new_link_file) < 0)
pg_fatal("could not create hard link between old and new data directories: %s\n"
"In link mode the old and new data directories must be on the same file system.\n",
strerror(errno));
unlink(new_link_file);
}
-
-#ifdef WIN32
-/* implementation of pg_link_file() on Windows */
-static int
-win32_pghardlink(const char *src, const char *dst)
-{
- /*
- * CreateHardLinkA returns zero for failure
- * https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createhardlinka
- */
- if (CreateHardLinkA(dst, src, NULL) == 0)
- {
- _dosmaperr(GetLastError());
- return -1;
- }
- else
- return 0;
-}
-#endif
index b156b516cce2d5be5faf50cb383e64c762a9d5d6..8b90cefbe0989e35c96be66f4f46447365cfbd18 100644 (file)
#ifndef WIN32
#define pg_mv_file rename
-#define pg_link_file link
#define PATH_SEPARATOR '/'
#define PATH_QUOTE '\''
#define RM_CMD "rm -f"
#define ECHO_BLANK ""
#else
#define pg_mv_file pgrename
-#define pg_link_file win32_pghardlink
#define PATH_SEPARATOR '\\'
#define PATH_QUOTE '"'
#define RM_CMD "DEL /q"
index 4fa0f770aaac0ac62f0cc89a26bcea262efdb750..d758dfd36ee164ac66ec386978a819cd495342a2 100644 (file)
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
+/* Define to 1 if you have the `link' function. */
+#undef HAVE_LINK
+
/* Define to 1 if the system has the type `locale_t'. */
#undef HAVE_LOCALE_T
index 3be994b43c738ca71391735ac7ba25ff5f7c728d..29f3e39e5b30597c6b9985da1f124c017861b965 100644 (file)
@@ -381,6 +381,10 @@ extern float pg_strtof(const char *nptr, char **endptr);
#define strtof(a,b) (pg_strtof((a),(b)))
#endif
+#ifndef HAVE_LINK
+extern int link(const char *src, const char *dst);
+#endif
+
#ifndef HAVE_MKDTEMP
extern char *mkdtemp(char *path);
#endif
new file mode 100644
(file)
index 0000000..
c7e4385
--- /dev/null
+/*-------------------------------------------------------------------------
+ *
+ * link.c
+ *
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ * src/port/link.c
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "c.h"
+
+#ifdef WIN32
+
+int
+link(const char *src, const char *dst)
+{
+ /*
+ * CreateHardLinkA returns zero for failure
+ * https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createhardlinka
+ */
+ if (CreateHardLinkA(dst, src, NULL) == 0)
+ {
+ _dosmaperr(GetLastError());
+ return -1;
+ }
+ else
+ return 0;
+}
+
+#endif
index 834c2c39d18bf4072c70c90764c55feb3162fb25..ec25042933684fd219237c1dd2ad9dcdc58f590b 100644 (file)
chklocale.c explicit_bzero.c fls.c getpeereid.c getrusage.c inet_aton.c random.c
srandom.c getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c
erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
- dirent.c dlopen.c getopt.c getopt_long.c
+ dirent.c dlopen.c getopt.c getopt_long.c link.c
pread.c pwrite.c pg_bitutils.c
pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c
pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c
index 9bb8f57150a49a2dfcfa29691363e3a7226d18d4..4244a4a8ac11f31470f7cc705d682537f4ad3c3d 100644 (file)
HAVE_LIBXML2 => undef,
HAVE_LIBXSLT => undef,
HAVE_LIBZ => $self->{options}->{zlib} ? 1 : undef,
+ HAVE_LINK => undef,
HAVE_LOCALE_T => 1,
HAVE_LONG_INT_64 => undef,
HAVE_LONG_LONG_INT_64 => 1,