From: Benedikt Morbach <benedikt.morbach@googlemail.com>
To: linux-btrfs@vger.kernel.org
Cc: Benedikt Morbach <benedikt.morbach@googlemail.com>
Subject: [PATCH] btrfs-progs: receive: handle root subvol path in clone
Date: Wed, 15 Jun 2016 01:26:15 +0200 [thread overview]
Message-ID: <20160614232615.20467-1-benedikt.morbach@googlemail.com> (raw)
In-Reply-To: <1465945606.18810.1.camel@googlemail.com>
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>
---
resend with 'btrfs-progs:' in the subject.
Sorry for the noise
cheers
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
next prev parent reply other threads:[~2016-06-14 23:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Benedikt Morbach [this message]
2016-06-17 17:18 ` David Sterba
2016-07-11 14:07 ` Benedikt Morbach
2016-07-13 15:46 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160614232615.20467-1-benedikt.morbach@googlemail.com \
--to=benedikt.morbach@googlemail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).