From patchwork Mon Jun 18 08:41:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 10470199 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 5A3896029B for ; Mon, 18 Jun 2018 08:41:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C0AE28448 for ; Mon, 18 Jun 2018 08:41:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 410B628863; Mon, 18 Jun 2018 08:41:48 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 C4F1528448 for ; Mon, 18 Jun 2018 08:41:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967200AbeFRIln (ORCPT ); Mon, 18 Jun 2018 04:41:43 -0400 Received: from mgwym02.jp.fujitsu.com ([211.128.242.41]:33183 "EHLO mgwym02.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968200AbeFRIiQ (ORCPT ); Mon, 18 Jun 2018 04:38:16 -0400 Received: from yt-mxoi2.gw.nic.fujitsu.com (unknown [192.168.229.69]) by mgwym02.jp.fujitsu.com with smtp id 3c51_1b38_ae12b077_9191_429c_96ab_4e72ff273294; Mon, 18 Jun 2018 17:38:11 +0900 Received: from g01jpfmpwkw01.exch.g01.fujitsu.local (g01jpfmpwkw01.exch.g01.fujitsu.local [10.0.193.38]) by yt-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id C7D0BAC0142 for ; Mon, 18 Jun 2018 17:38:10 +0900 (JST) Received: from g01jpexchkw33.g01.fujitsu.local (unknown [10.0.193.4]) by g01jpfmpwkw01.exch.g01.fujitsu.local (Postfix) with ESMTP id 07E116925F1 for ; Mon, 18 Jun 2018 17:38:10 +0900 (JST) Received: from luna3.soft.fujitsu.com (10.124.196.199) by g01jpexchkw33.g01.fujitsu.local (10.0.193.36) with Microsoft SMTP Server id 14.3.352.0; Mon, 18 Jun 2018 17:38:08 +0900 From: Misono Tomohiro To: Subject: [PATCH v2 13/20] btrfs-progs: sub list: Update -a option and remove meaningless filter Date: Mon, 18 Jun 2018 17:41:01 +0900 Message-ID: X-Mailer: git-send-email 2.14.4 In-Reply-To: References: MIME-Version: 1.0 X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable 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 Currently, -a option add filter and change subvolume path as follows: - If a subvolume is a child of the specified path, nothing changes - otherwise, adds to head This is rather meaningless, so let's remove this filter. As a result, the behavior of -a option becomes the same as default behavior of sub list in progs <= 4.17 [Example] $ mkfs.btrfs -f $DEV $ mount $DEV /mnt $ btrfs subvolume create /mnt/AAA $ btrfs subvolume create /mnt/AAA/BBB $ btrfs subvolume create /mnt/ZZZ $ btrfs subvolume list -a /mnt ID 256 gen 9 top level 5 path AAA ID 257 gen 9 top level 256 path AAA/BBB ID 258 gen 10 top level 5 path ZZZ ** output of progs <= 4.17 $ btrfs subvolume list -a /mnt ID 256 gen 9 top level 5 path AAA ID 257 gen 9 top level 256 path /AAA/BBB ID 258 gen 10 top level 5 path ZZZ Signed-off-by: Misono Tomohiro --- Documentation/btrfs-subvolume.asciidoc | 6 ++++-- cmds-subvolume.c | 35 ++++------------------------------ 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/Documentation/btrfs-subvolume.asciidoc b/Documentation/btrfs-subvolume.asciidoc index cd91385a..20fae1e1 100644 --- a/Documentation/btrfs-subvolume.asciidoc +++ b/Documentation/btrfs-subvolume.asciidoc @@ -118,8 +118,10 @@ Path filtering;; -o:::: print only subvolumes below specified . -a:::: -print all the subvolumes in the filesystem and distinguish between -absolute and relative path with respect to the given . +print all the subvolumes in the filesystem, including subvolumes +which cannot be accessed from current mount point. +path to be shown is relative to the top-level subvolume +(require root privileges). -f:::: follow mounted subvolumes below recursively and list them too (only if it is the same filesystem). If top-level subvolume is mounted diff --git a/cmds-subvolume.c b/cmds-subvolume.c index 802f5c5e..dab266aa 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -759,28 +759,6 @@ static int filter_topid_equal(struct listed_subvol *subvol, uint64_t data) return subvol->info.parent_id == data; } -static int filter_full_path(struct listed_subvol *subvol, uint64_t data) -{ - /* - * This implements the same behavior as before the conversion to - * libbtrfsutil, which is mostly nonsensical. - */ - if (subvol->info.parent_id != data) { - char *tmp; - int ret; - - ret = asprintf(&tmp, "/%s", subvol->path); - if (ret == -1) { - error("out of memory"); - exit(1); - } - - free(subvol->path); - subvol->path = tmp; - } - return 1; -} - static int filter_by_parent(struct listed_subvol *subvol, uint64_t data) { return !uuid_compare(subvol->info.parent_uuid, @@ -798,7 +776,6 @@ static btrfs_list_filter_func_v2 all_filter_funcs[] = { [BTRFS_LIST_FILTER_CGEN_LESS] = filter_cgen_less, [BTRFS_LIST_FILTER_CGEN_EQUAL] = filter_cgen_equal, [BTRFS_LIST_FILTER_TOPID_EQUAL] = filter_topid_equal, - [BTRFS_LIST_FILTER_FULL_PATH] = filter_full_path, [BTRFS_LIST_FILTER_BY_PARENT] = filter_by_parent, }; @@ -1574,9 +1551,9 @@ static const char * const cmd_subvol_list_usage[] = { "", "Path filtering:", "-o print only subvolumes below specified path", - "-a print all the subvolumes in the filesystem and", - " distinguish absolute and relative path with respect", - " to the given (require root privileges)", + "-a print all the subvolumes in the filesystem.", + " path to be shown is relative to the top-level", + " subvolume (require root privileges)", "-f follow mounted subvolumes below the specified path", " and list them too (only if it is the same filesystem)", "", @@ -1783,11 +1760,7 @@ static int cmd_subvol_list(int argc, char **argv) if (ret) goto out; - if (is_list_all) - btrfs_list_setup_filter_v2(&filter_set, - BTRFS_LIST_FILTER_FULL_PATH, - top_id); - else if (is_only_in_path) + if (is_only_in_path) btrfs_list_setup_filter_v2(&filter_set, BTRFS_LIST_FILTER_TOPID_EQUAL, top_id);