Skip to content

Commit e99e840

Browse files
committed
Add headers needed by pg_combinebackup --clone
The code for file cloning existed, but was not reachable as it relied on constants from missing headers. Due to that, on Linux --clone always failed with error: file cloning not supported on this platform Fixed by including the missing headers to relevant places. Adding the headers revealed a couple compile errors in copy_file_clone(), so fix those too. Reported-by: Peter Eisentraut Discussion: https://postgr.es/m/48da4a1f-ccd9-4988-9622-24f37b1de2b4%40eisentraut.org
1 parent 9177545 commit e99e840

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/bin/pg_combinebackup/copy_file.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#ifdef HAVE_COPYFILE_H
1414
#include <copyfile.h>
1515
#endif
16+
#ifdef __linux__
17+
#include <sys/ioctl.h>
18+
#include <linux/fs.h>
19+
#endif
1620
#include <fcntl.h>
1721
#include <limits.h>
1822
#include <sys/stat.h>
@@ -214,6 +218,9 @@ copy_file_clone(const char *src, const char *dest,
214218
pg_fatal("error while cloning file \"%s\" to \"%s\": %m", src, dest);
215219
#elif defined(__linux__) && defined(FICLONE)
216220
{
221+
int src_fd;
222+
int dest_fd;
223+
217224
if ((src_fd = open(src, O_RDONLY | PG_BINARY, 0)) < 0)
218225
pg_fatal("could not open file \"%s\": %m", src);
219226

@@ -228,8 +235,11 @@ copy_file_clone(const char *src, const char *dest,
228235
unlink(dest);
229236

230237
pg_fatal("error while cloning file \"%s\" to \"%s\": %s",
231-
src, dest);
238+
src, dest, strerror(save_errno));
232239
}
240+
241+
close(src_fd);
242+
close(dest_fd);
233243
}
234244
#else
235245
pg_fatal("file cloning not supported on this platform");

src/bin/pg_combinebackup/pg_combinebackup.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
#include <fcntl.h>
1717
#include <limits.h>
1818

19+
#ifdef HAVE_COPYFILE_H
20+
#include <copyfile.h>
21+
#endif
22+
#ifdef __linux__
23+
#include <sys/ioctl.h>
24+
#include <linux/fs.h>
25+
#endif
26+
1927
#include "backup_label.h"
2028
#include "common/blkreftable.h"
2129
#include "common/checksum_helper.h"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy