linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] receive: strip root subvol path during process_clone
@ 2016-06-14 22:55 Benedikt Morbach
  2016-06-14 23:06 ` Benedikt Morbach
  0 siblings, 1 reply; 6+ messages in thread
From: Benedikt Morbach @ 2016-06-14 22:55 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Benedikt Morbach

otherwise we get

    ERROR: cannot open <subvol_path>: No such file or directory

because <full_root_path>/<subvol_path> doesn't exist, so openat() will fail below.

Signed-off-by: Benedikt Morbach <benedikt.morbach@googlemail.com>
---
 cmds-receive.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/cmds-receive.c b/cmds-receive.c
index f4a3a4f..a975fdd 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -753,6 +753,17 @@ static int process_clone(const char *path, u64 offset, u64 len,
 		subvol_path = strdup(si->path);
 	}
 
+	/* strip the subvolume that we are receiving to from the start of subvol_path */
+	if (r->full_root_path &&
+		strstr(subvol_path, r->full_root_path) == subvol_path) {
+		size_t root_len = strlen(r->full_root_path);
+		size_t sub_len = strlen(subvol_path);
+
+		memmove(subvol_path,
+			subvol_path + root_len + 1,
+			sub_len - root_len);
+	}
+
 	ret = path_cat_out(full_clone_path, subvol_path, clone_path);
 	if (ret < 0) {
 		error("clone: target path invalid: %s", clone_path);
-- 
2.8.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-07-13 15:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-14 22:55 [PATCH] receive: strip root subvol path during process_clone Benedikt Morbach
2016-06-14 23:06 ` Benedikt Morbach
2016-06-14 23:26   ` [PATCH] btrfs-progs: receive: handle root subvol path in clone Benedikt Morbach
2016-06-17 17:18   ` [PATCH] receive: strip root subvol path during process_clone David Sterba
2016-07-11 14:07     ` Benedikt Morbach
2016-07-13 15:46       ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).