From patchwork Wed Jan 23 08:12:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 2022711 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 601EFDF2E5 for ; Wed, 23 Jan 2013 08:07:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753738Ab3AWIHO (ORCPT ); Wed, 23 Jan 2013 03:07:14 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:49277 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753752Ab3AWIHF (ORCPT ); Wed, 23 Jan 2013 03:07:05 -0500 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id r0N86NT8024729 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 23 Jan 2013 08:06:24 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r0N86MAr005423 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Jan 2013 08:06:23 GMT Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r0N86M5l010525; Wed, 23 Jan 2013 02:06:22 -0600 Received: from wish.sg.oracle.com (/10.186.101.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 23 Jan 2013 00:06:22 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org, dsterba@suse.cz, gene@czarc.net Cc: Anand Jain Subject: [PATCH 09/10] Btrfs-progs: make get_subvol_name non cmds-send specific Date: Wed, 23 Jan 2013 16:12:50 +0800 Message-Id: <1358928771-31960-10-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 1.8.1.164.g2d0029e In-Reply-To: <1358928771-31960-1-git-send-email-anand.jain@oracle.com> References: <1358928771-31960-1-git-send-email-anand.jain@oracle.com> X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org get_subvol_name can be used other than the just with in cmds-send.c so this patch will make it possible with out changing the original intentions. Signed-off-by: Anand Jain --- cmds-send.c | 12 ++++++------ commands.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmds-send.c b/cmds-send.c index 9b47e70..beebac9 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -331,12 +331,12 @@ out: return ret; } -static const char *get_subvol_name(struct btrfs_send *s, const char *full_path) +char *get_subvol_name(char *mnt, char *full_path) { - int len = strlen(s->root_path); + int len = strlen(mnt); if (!len) return full_path; - if (s->root_path[len - 1] != '/') + if (mnt[len - 1] != '/') len += 1; return full_path + len; @@ -445,7 +445,7 @@ int cmd_send_start(int argc, char **argv) if (ret < 0) goto out; - ret = get_root_id(&send, get_subvol_name(&send, subvol), + ret = get_root_id(&send, get_subvol_name(send.root_path, subvol), &root_id); if (ret < 0) { fprintf(stderr, "ERROR: could not resolve " @@ -506,7 +506,7 @@ int cmd_send_start(int argc, char **argv) if (snapshot_parent != NULL) { ret = get_root_id(&send, - get_subvol_name(&send, snapshot_parent), + get_subvol_name(send.root_path, snapshot_parent), &parent_root_id); if (ret < 0) { fprintf(stderr, "ERROR: could not resolve root_id " @@ -565,7 +565,7 @@ int cmd_send_start(int argc, char **argv) goto out; } - ret = get_root_id(&send, get_subvol_name(&send, subvol), + ret = get_root_id(&send, get_subvol_name(send.root_path, subvol), &root_id); if (ret < 0) { fprintf(stderr, "ERROR: could not resolve root_id " diff --git a/commands.h b/commands.h index 9b77f3e..631fb6b 100644 --- a/commands.h +++ b/commands.h @@ -106,3 +106,4 @@ int test_issubvolume(char *path); /* send.c */ int find_mount_root(const char *path, char **mount_root); +char *get_subvol_name(char *mnt, char *full_path);