From patchwork Fri Oct 12 05:20:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 1585291 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 9CC9940276 for ; Fri, 12 Oct 2012 05:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932342Ab2JLFRh (ORCPT ); Fri, 12 Oct 2012 01:17:37 -0400 Received: from rcsinet15.oracle.com ([148.87.113.117]:32632 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755744Ab2JLFRg (ORCPT ); Fri, 12 Oct 2012 01:17:36 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q9C5HZir031286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 12 Oct 2012 05:17:35 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q9C5HYcZ014549 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 12 Oct 2012 05:17:34 GMT Received: from abhmt109.oracle.com (abhmt109.oracle.com [141.146.116.61]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q9C5HYOc024723 for ; Fri, 12 Oct 2012 00:17:34 -0500 Received: from localhost.localdomain (/10.186.101.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2012 22:17:33 -0700 From: Anand jain To: linux-btrfs@vger.kernel.org Cc: Anand Jain Subject: [PATCH 1/4] Btrfs-progs: introduce btrfs_get_subvols function Date: Fri, 12 Oct 2012 13:20:51 +0800 Message-Id: <1350019254-22036-2-git-send-email-Anand.Jain@oracle.com> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1350019254-22036-1-git-send-email-Anand.Jain@oracle.com> References: <1350019254-22036-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 From: Anand Jain Having this not part of btrfs_list_subvols will help code reuse. Signed-off-by: Anand Jain --- btrfs-list.c | 35 +++++++++++++++++++++-------------- 1 files changed, 21 insertions(+), 14 deletions(-) diff --git a/btrfs-list.c b/btrfs-list.c index 20da828..657e4db 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -1323,6 +1323,26 @@ static int __list_subvol_fill_paths(int fd, struct root_lookup *root_lookup) return 0; } +static int btrfs_get_subvols(int fd, struct root_lookup *root_lookup) +{ + int ret; + + ret = __list_subvol_search(fd, root_lookup); + if (ret) { + fprintf(stderr, "ERROR: can't perform the search - %s\n", + strerror(errno)); + return ret; + } + + /* + * now we have an rbtree full of root_info objects, but we need to fill + * in their path names within the subvol that is referencing each one. + */ + ret = __list_subvol_fill_paths(fd, root_lookup); + + return ret; +} + static void print_subvolume_column(struct root_info *subv, enum btrfs_list_column_enum column) { @@ -1471,20 +1491,7 @@ int btrfs_list_subvols(int fd, struct btrfs_list_filter_set *filter_set, struct root_lookup root_sort; int ret; - ret = __list_subvol_search(fd, &root_lookup); - if (ret) { - fprintf(stderr, "ERROR: can't perform the search - %s\n", - strerror(errno)); - return ret; - } - - /* - * now we have an rbtree full of root_info objects, but we need to fill - * in their path names within the subvol that is referencing each one. - */ - ret = __list_subvol_fill_paths(fd, &root_lookup); - if (ret < 0) - return ret; + ret = btrfs_get_subvols(fd, &root_lookup); __filter_and_sort_subvol(&root_lookup, &root_sort, filter_set, comp_set, fd);