From patchwork Tue Jun 14 23:26:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benedikt Morbach X-Patchwork-Id: 9177173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE1186021C for ; Tue, 14 Jun 2016 23:26:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DECDB282F9 for ; Tue, 14 Jun 2016 23:26:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D369128338; Tue, 14 Jun 2016 23:26:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B010B282F9 for ; Tue, 14 Jun 2016 23:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751705AbcFNX0V (ORCPT ); Tue, 14 Jun 2016 19:26:21 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34964 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751518AbcFNX0U (ORCPT ); Tue, 14 Jun 2016 19:26:20 -0400 Received: by mail-wm0-f67.google.com with SMTP id k184so1904592wme.2 for ; Tue, 14 Jun 2016 16:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aQ5FZUBVHDotqbGFYsMxzWAg5rAKrjg8lMmJvf+BPsg=; b=yEknHSQm8NBEbYsediAZ5XMbwoYZO2UsP+kZ/Tf1LY+TjnaQzWEQDxPn5N8o2oWHDv jVaANu4Z65bD4yQBy4G37G0Gwm3un0xDH++xQA9cTstdVItf1RxVsBxoQVPKybebw55W tgAe+Ll7lsU0StStq6DBvmeMXABM+G/HdF6gaWtD3oEQTA2jnrJiiyxNHe6iPLGJAadP e0JJDuKtXepDDZ7SdBAWmH+bTCmtF4WgtGKFm67V220ECvo+JLFVuzI2p4RFGNhzAxsK VfFQZsF1tAth5a370vvAxuufyBXcrLr4TzFOZJaxlXZNoJoesKi8+B0dyVWlvpUItbbe LijQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aQ5FZUBVHDotqbGFYsMxzWAg5rAKrjg8lMmJvf+BPsg=; b=f840Blr0G6gdAZ/Ku+o5ouh69wg2cQ+eLBZIr7Me1BIhoxL4uklkafajaSvi5MrgkB Zqca7AKUMXelVhNFVpfnNwn9y3Rjn9/6yWUJ/w5tAfZOv2E/Z6oj8fqnU97lQcsiCc62 EQ0HYUy1ngO/pIjuwsXcAPpfgbC8w/cv2YVGZlrIz3X5l3S5H9vVjWmoDGz6XmWQrI3H 66wcetuErn3DXap1CGSXICluQT2t4t81CHP8vZBMcZis4i1h9ET+ImqqtvgtFpERA6vX gQzNc3rjaBw0nCdyKHwjfn65Bfy+dGFbUX8xZLlS2i5/pdcggwcBTlXaZRMLO3kJPf5/ 7sCQ== X-Gm-Message-State: ALyK8tJaLuBRqi+rcOmI74Wa6h5PAi7El5tIsMSn9Oxqf2ISS5KA2vH72HEYuogc8hp//g== X-Received: by 10.194.32.103 with SMTP id h7mr8356660wji.163.1465946779177; Tue, 14 Jun 2016 16:26:19 -0700 (PDT) Received: from detritus.atuin (p4FDCC87F.dip0.t-ipconnect.de. [79.220.200.127]) by smtp.gmail.com with ESMTPSA id z5sm558850wme.5.2016.06.14.16.26.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Jun 2016 16:26:18 -0700 (PDT) From: Benedikt Morbach To: linux-btrfs@vger.kernel.org Cc: Benedikt Morbach Subject: [PATCH] btrfs-progs: receive: handle root subvol path in clone Date: Wed, 15 Jun 2016 01:26:15 +0200 Message-Id: <20160614232615.20467-1-benedikt.morbach@googlemail.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <1465945606.18810.1.camel@googlemail.com> References: <1465945606.18810.1.camel@googlemail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP otherwise we get ERROR: cannot open : No such file or directory because / doesn't exist, so openat() will fail below. Signed-off-by: Benedikt Morbach --- 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);