From patchwork Fri Nov 29 14:23:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 3258751 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C9C629F1F4 for ; Fri, 29 Nov 2013 14:23:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C28A20680 for ; Fri, 29 Nov 2013 14:23:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B627B20671 for ; Fri, 29 Nov 2013 14:23:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754764Ab3K2OXc (ORCPT ); Fri, 29 Nov 2013 09:23:32 -0500 Received: from mail-pd0-f171.google.com ([209.85.192.171]:54809 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751636Ab3K2OXc (ORCPT ); Fri, 29 Nov 2013 09:23:32 -0500 Received: by mail-pd0-f171.google.com with SMTP id z10so13841120pdj.2 for ; Fri, 29 Nov 2013 06:23:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=IKqvlYH+La6d0ojkH+OiOWzv3UXQPZC5mvs+BtSH1Ug=; b=TWgZaIbxmgVTOi9pd49Cnv9njgsPBaYzX4V1IbPS8FWsB3m4zrAh0C5tlteYDpW0et RgnXML8ybBfN/g/7Tb0HqvYsTTZ1qzXfAw7xAtzFKEPczKzPoEYLnc15dC1ovESJpCkI IzQhjNRG0AaxmEzoLlcWooGGnpQgtMGnfOJy0mFCtb/QHKMLzq+49zkh4tKR8mLjutDJ ObviXL6Ce5u0koMTh+dMb57AYZW5QkaOfhwTp38KRUt/Rr0rwjuk0StkEtX2oBZROl9c kA7QtpWUKfRKqsbWJAN46r3Oh59XZHeYLWBMWuzItxDeJK3kwoUAtZUckqkTh7wRgJx9 kH5A== X-Received: by 10.68.218.3 with SMTP id pc3mr16687624pbc.71.1385735011528; Fri, 29 Nov 2013 06:23:31 -0800 (PST) Received: from linux-b0ol.localdomain ([223.65.188.195]) by mx.google.com with ESMTPSA id vk17sm116136500pab.5.2013.11.29.06.23.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2013 06:23:30 -0800 (PST) From: Wang Shilong To: linux-btrfs@vger.kernel.org Cc: Wang Shilong Subject: [PATCH] Btrfs-progs: avoid using btrfs internal subvolume path to send Date: Fri, 29 Nov 2013 22:23:09 +0800 Message-Id: <1385734989-8839-1-git-send-email-wangshilong1991@gmail.com> X-Mailer: git-send-email 1.8.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong Steps to reproduce: # mkfs.btrfs -f /dev/sda # mount /dev/sda /mnt # btrfs subvolume create /mnt/foo # umount /mnt # mount -o subvol=foo /dev/sda /mnt # btrfs sub snapshot -r /mnt /mnt/snap # btrfs send /mnt/snap > /dev/null We will fail to send '/mnt/snap',this is because btrfs send try to open '/mnt/snap' by btrfs internal subvolume path 'foo/snap' rather than relative path based on mounted point, this will return us 'no such file or directory',this is not right, fix it. Reported-by: Thomas Scheiblauer Signed-off-by: Wang Shilong --- cmds-send.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmds-send.c b/cmds-send.c index 53e9a53..b3dde83 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -283,7 +283,7 @@ out: } static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root_id, - int is_first_subvol, int is_last_subvol) + int is_first_subvol, int is_last_subvol, char *subvol) { int ret; pthread_t t_read; @@ -303,10 +303,10 @@ static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root_id, goto out; } - subvol_fd = openat(send->mnt_fd, si->path, O_RDONLY | O_NOATIME); + subvol_fd = openat(send->mnt_fd, subvol, O_RDONLY | O_NOATIME); if (subvol_fd < 0) { ret = -errno; - fprintf(stderr, "ERROR: open %s failed. %s\n", si->path, + fprintf(stderr, "ERROR: open %s failed. %s\n", subvol, strerror(-ret)); goto out; } @@ -701,7 +701,7 @@ int cmd_send(int argc, char **argv) is_last_subvol = 1; } ret = do_send(&send, root_id, parent_root_id, - is_first_subvol, is_last_subvol); + is_first_subvol, is_last_subvol, subvol); if (ret < 0) goto out;