From patchwork Tue Dec 11 14:24:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Czerner X-Patchwork-Id: 1862651 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 C49E7DF215 for ; Tue, 11 Dec 2012 14:25:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753801Ab2LKOZW (ORCPT ); Tue, 11 Dec 2012 09:25:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8321 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753771Ab2LKOZT (ORCPT ); Tue, 11 Dec 2012 09:25:19 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBBEPH6Z026305 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Dec 2012 09:25:17 -0500 Received: from dhcp-1-104.brq.redhat.com (dhcp-1-104.brq.redhat.com [10.34.1.104]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBBEP2V5015324; Tue, 11 Dec 2012 09:25:15 -0500 From: Lukas Czerner To: linux-btrfs@vger.kernel.org Cc: chris.mason@fusionio.com, cwillu@cwillu.com, Lukas Czerner Subject: [PATCH 2/3] Btrfs-progs: add '-o' option into subvolume list command Date: Tue, 11 Dec 2012 15:24:59 +0100 Message-Id: <1355235900-10252-2-git-send-email-lczerner@redhat.com> In-Reply-To: <1355235900-10252-1-git-send-email-lczerner@redhat.com> References: <1355235900-10252-1-git-send-email-lczerner@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This commit introduces new option '-o' to list only subvolumes under the specified path. This does not change subvolume list behaviour. It has been default in the past and it is even with this commit. Signed-off-by: Lukas Czerner --- cmds-subvolume.c | 11 ++++++++--- man/btrfs.8.in | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cmds-subvolume.c b/cmds-subvolume.c index 37cb8cc..0aa7467 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -272,7 +272,7 @@ out: } static const char * const cmd_subvol_list_usage[] = { - "btrfs subvolume list [-apurts] [-g [+|-]value] [-c [+|-]value] " + "btrfs subvolume list [-aopurts] [-g [+|-]value] [-c [+|-]value] " "[--sort=gen,ogen,rootid,path] ", "List subvolumes (and snapshots)", "", @@ -280,6 +280,7 @@ static const char * const cmd_subvol_list_usage[] = { "-a print all the subvolumes in the filesystem and", " distinguish absolute and relative path with respect", " to the given ", + "-o print only subvolumes bellow specified path", "-u print the uuid of subvolumes (and snapshots)", "-t print the result as a table", "-s list snapshots only in the filesystem", @@ -309,6 +310,7 @@ static int cmd_subvol_list(int argc, char **argv) char *subvol; int is_tab_result = 0; int is_list_all = 0; + int is_only_in_path = 1; struct option long_options[] = { {"sort", 1, NULL, 'S'}, {0, 0, 0, 0} @@ -320,7 +322,7 @@ static int cmd_subvol_list(int argc, char **argv) optind = 1; while(1) { c = getopt_long(argc, argv, - "apsurg:c:t", long_options, NULL); + "aopsurg:c:t", long_options, NULL); if (c < 0) break; @@ -331,6 +333,9 @@ static int cmd_subvol_list(int argc, char **argv) case 'a': is_list_all = 1; break; + case 'o': + is_only_in_path = 1; + break; case 't': is_tab_result = 1; break; @@ -407,7 +412,7 @@ static int cmd_subvol_list(int argc, char **argv) btrfs_list_setup_filter(&filter_set, BTRFS_LIST_FILTER_FULL_PATH, top_id); - else + else if (is_only_in_path) btrfs_list_setup_filter(&filter_set, BTRFS_LIST_FILTER_TOPID_EQUAL, top_id); diff --git a/man/btrfs.8.in b/man/btrfs.8.in index d6d8e94..1e314eb 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -11,7 +11,7 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBsubvolume create\fP\fI [/]\fP .PP -\fBbtrfs\fP \fBsubvolume list\fP\fI [-aprts] [-g [+|-]value] [-c [+|-]value] [--rootid=rootid,gen,ogen,path] \fP +\fBbtrfs\fP \fBsubvolume list\fP\fI [-aoprts] [-g [+|-]value] [-c [+|-]value] [--rootid=rootid,gen,ogen,path] \fP .PP \fBbtrfs\fP \fBsubvolume set-default\fP\fI \fP .PP @@ -108,7 +108,7 @@ Create a subvolume in \fI\fR (or in the current directory if \fI\fR is omitted). .TP -\fBsubvolume list\fR\fI [-aprts][-g [+|-]value] [-c [+|-]value] [--sort=gen,ogen,rootid,path] \fR +\fBsubvolume list\fR\fI [-aoprts][-g [+|-]value] [-c [+|-]value] [--sort=gen,ogen,rootid,path] \fR .RS List the subvolumes present in the filesystem \fI\fR. For every subvolume the following information is shown by default. @@ -127,6 +127,8 @@ and top level. The parent's ID may be used at mount time via the \fB-a\fP print all the subvolumes in the filesystem and distinguish between absolute and relative path with respect to the given . +\fB-o\fP print only subvolumes bellow specified . + \fB-r\fP only readonly subvolumes in the filesystem wille be listed. \fB-s\fP only snapshot subvolumes in the filesystem will be listed.