public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tomas Vondra <[email protected]>
To: Peter Eisentraut <[email protected]>
To: pgsql-hackers <[email protected]>
Subject: Re: pg_combinebackup --clone doesn't work
Date: Fri, 21 Jun 2024 00:07:32 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
Here's a fix adding the missing headers to pg_combinebackup, and fixing
some compile-time issues in the ifdef-ed block.
I've done some basic manual testing today - I plan to test this a bit
more tomorrow, and I'll also look at integrating this into the existing
tests.
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachments:
[text/x-patch] 0001-fix-clone-headers.patch (2.0K, ../[email protected]/2-0001-fix-clone-headers.patch)
download | inline diff:
From ae712aa6316c8f7035edee9fb49e1bfe1ea30b94 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <[email protected]>
Date: Thu, 20 Jun 2024 23:50:22 +0200
Subject: [PATCH] fix clone headers
---
src/bin/pg_combinebackup/copy_file.c | 12 +++++++++++-
src/bin/pg_combinebackup/pg_combinebackup.c | 8 ++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/bin/pg_combinebackup/copy_file.c b/src/bin/pg_combinebackup/copy_file.c
index 08c3b875420..8b50e937346 100644
--- a/src/bin/pg_combinebackup/copy_file.c
+++ b/src/bin/pg_combinebackup/copy_file.c
@@ -13,6 +13,10 @@
#ifdef HAVE_COPYFILE_H
#include <copyfile.h>
#endif
+#ifdef __linux__
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#endif
#include <fcntl.h>
#include <limits.h>
#include <sys/stat.h>
@@ -214,6 +218,9 @@ copy_file_clone(const char *src, const char *dest,
pg_fatal("error while cloning file \"%s\" to \"%s\": %m", src, dest);
#elif defined(__linux__) && defined(FICLONE)
{
+ int src_fd;
+ int dest_fd;
+
if ((src_fd = open(src, O_RDONLY | PG_BINARY, 0)) < 0)
pg_fatal("could not open file \"%s\": %m", src);
@@ -228,8 +235,11 @@ copy_file_clone(const char *src, const char *dest,
unlink(dest);
pg_fatal("error while cloning file \"%s\" to \"%s\": %s",
- src, dest);
+ src, dest, strerror(save_errno));
}
+
+ close(src_fd);
+ close(dest_fd);
}
#else
pg_fatal("file cloning not supported on this platform");
diff --git a/src/bin/pg_combinebackup/pg_combinebackup.c b/src/bin/pg_combinebackup/pg_combinebackup.c
index 01d7fb98e79..f67ccf76ea2 100644
--- a/src/bin/pg_combinebackup/pg_combinebackup.c
+++ b/src/bin/pg_combinebackup/pg_combinebackup.c
@@ -16,6 +16,14 @@
#include <fcntl.h>
#include <limits.h>
+#ifdef HAVE_COPYFILE_H
+#include <copyfile.h>
+#endif
+#ifdef __linux__
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#endif
+
#include "backup_label.h"
#include "common/blkreftable.h"
#include "common/checksum_helper.h"
--
2.45.2
view thread (4+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: pg_combinebackup --clone doesn't work
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox