aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-receive.c
diff options
context:
space:
mode:
authorEmil Karlson <jekarlson@gmail.com>2015-05-21 18:42:29 +0300
committerDavid Sterba <dsterba@suse.cz>2015-05-26 16:31:32 +0200
commit5d4f3ea9b41e7dd0812da1cdd7eb9049fe289066 (patch)
tree48d28cb8157e48b75df521a7ad2f3dc91a13052c /cmds-receive.c
parentb51cc1d32555082d02a68d946cbbed0983f82270 (diff)
downloadbtrfs-progs-5d4f3ea9b41e7dd0812da1cdd7eb9049fe289066.tar.gz
btrfs-progs-5d4f3ea9b41e7dd0812da1cdd7eb9049fe289066.tar.xz
btrfs-progs-5d4f3ea9b41e7dd0812da1cdd7eb9049fe289066.zip
btrfs-progs: use openat for process_clone in receive
This will fix breakage, when doing chrooted receive with cloned paths outside main subvolume. Steps to reproduce: $ create subvolume $ create file $ snapshot to snap1 $ delete file $ snapshot to snap2 $ reflink file from snap1 $ snapsthot to snap3 $ send full snap1 | receive --chroot $ send incremental snap2 | receive --chroot $ send incremental snap3 | receive --chroot The last step would fail with: Chroot to /mnt/recvdir At snapshot snap3 ERROR: failed to open /recvdir/snap1/file. No such file or directory Signed-off-by: Emil Karlson <jekarlson@gmail.com> [added reproducer] Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-receive.c')
-rw-r--r--cmds-receive.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmds-receive.c b/cmds-receive.c
index b7cf3f9..b0a312c 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -609,9 +609,9 @@ static int process_clone(const char *path, u64 offset, u64 len,
subvol_path = strdup(si->path);
}
- full_clone_path = path_cat3(r->root_path, subvol_path, clone_path);
+ full_clone_path = path_cat(subvol_path, clone_path);
- clone_fd = open(full_clone_path, O_RDONLY | O_NOATIME);
+ clone_fd = openat(r->mnt_fd, full_clone_path, O_RDONLY | O_NOATIME);
if (clone_fd < 0) {
ret = -errno;
fprintf(stderr, "ERROR: failed to open %s. %s\n",