diff -uNr postgresql-15.0/contrib/basic_archive/basic_archive.c postgresql-15.0.mod/contrib/basic_archive/basic_archive.c --- postgresql-15.0/contrib/basic_archive/basic_archive.c 2022-10-10 22:57:37.000000000 +0200 +++ postgresql-15.0.mod/contrib/basic_archive/basic_archive.c 2022-10-14 15:49:45.037458815 +0200 @@ -284,7 +284,7 @@ * Sync the temporary file to disk and move it to its final destination. * This will fail if destination already exists. */ - (void) durable_rename_excl(temp, destination, ERROR); + (void) durable_link_or_rename(temp, destination, ERROR); ereport(DEBUG1, (errmsg("archived \"%s\" via basic_archive", file))); diff -uNr postgresql-15.0/src/backend/access/transam/timeline.c postgresql-15.0.mod/src/backend/access/transam/timeline.c --- postgresql-15.0/src/backend/access/transam/timeline.c 2022-10-10 22:57:37.000000000 +0200 +++ postgresql-15.0.mod/src/backend/access/transam/timeline.c 2022-10-14 15:20:34.736940580 +0200 @@ -446,7 +446,7 @@ * Perform the rename using link if available, paranoidly trying to avoid * overwriting an existing file (there shouldn't be one). */ - durable_rename_excl(tmppath, path, ERROR); + durable_link_or_rename(tmppath, path, ERROR); /* The history file can be archived immediately. */ if (XLogArchivingActive()) @@ -524,7 +524,7 @@ * Perform the rename using link if available, paranoidly trying to avoid * overwriting an existing file (there shouldn't be one). */ - durable_rename_excl(tmppath, path, ERROR); + durable_link_or_rename(tmppath, path, ERROR); } /* diff -uNr postgresql-15.0/src/backend/access/transam/xlog.c postgresql-15.0.mod/src/backend/access/transam/xlog.c --- postgresql-15.0/src/backend/access/transam/xlog.c 2022-10-10 22:57:37.000000000 +0200 +++ postgresql-15.0.mod/src/backend/access/transam/xlog.c 2022-10-14 15:53:55.126687831 +0200 @@ -3327,10 +3327,10 @@ * Perform the rename using link if available, paranoidly trying to avoid * overwriting an existing file (there shouldn't be one). */ - if (durable_rename_excl(tmppath, path, LOG) != 0) + if (durable_link_or_rename(tmppath, path, LOG) != 0) { LWLockRelease(ControlFileLock); - /* durable_rename_excl already emitted log message */ + /* durable_link_or_rename already emitted log message */ return false; } diff -uNr postgresql-15.0/src/backend/storage/file/fd.c postgresql-15.0.mod/src/backend/storage/file/fd.c --- postgresql-15.0/src/backend/storage/file/fd.c 2022-10-10 22:57:37.000000000 +0200 +++ postgresql-15.0.mod/src/backend/storage/file/fd.c 2022-10-14 15:20:34.736940580 +0200 @@ -808,7 +808,7 @@ } /* - * durable_rename_excl -- rename a file in a durable manner. + * durable_link_or_rename -- rename a file in a durable manner. * * Similar to durable_rename(), except that this routine tries (but does not * guarantee) not to overwrite the target file. @@ -826,7 +826,7 @@ * valid upon return. */ int -durable_rename_excl(const char *oldfile, const char *newfile, int elevel) +durable_link_or_rename(const char *oldfile, const char *newfile, int elevel) { /* * Ensure that, if we crash directly after the rename/link, a file with diff -uNr postgresql-15.0/src/include/pg_config_manual.h postgresql-15.0.mod/src/include/pg_config_manual.h --- postgresql-15.0/src/include/pg_config_manual.h 2022-10-10 22:57:37.000000000 +0200 +++ postgresql-15.0.mod/src/include/pg_config_manual.h 2022-10-14 15:20:34.736940580 +0200 @@ -155,7 +155,7 @@ /* * Define this if your operating system supports link() */ -#if !defined(WIN32) && !defined(__CYGWIN__) +#if !defined(WIN32) && !defined(__CYGWIN__) && !defined(__ANDROID__) #define HAVE_WORKING_LINK 1 #endif diff -uNr postgresql-15.0/src/include/storage/fd.h postgresql-15.0.mod/src/include/storage/fd.h --- postgresql-15.0/src/include/storage/fd.h 2022-10-10 22:57:37.000000000 +0200 +++ postgresql-15.0.mod/src/include/storage/fd.h 2022-10-14 15:20:34.736940580 +0200 @@ -187,7 +187,7 @@ extern int fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel); extern int durable_rename(const char *oldfile, const char *newfile, int loglevel); extern int durable_unlink(const char *fname, int loglevel); -extern int durable_rename_excl(const char *oldfile, const char *newfile, int loglevel); +extern int durable_link_or_rename(const char *oldfile, const char *newfile, int loglevel); extern void SyncDataDirectory(void); extern int data_sync_elevel(int elevel);