From patchwork Wed Jun 24 16:09:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 6669021 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BC0839F399 for ; Wed, 24 Jun 2015 16:12:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D73D5205AA for ; Wed, 24 Jun 2015 16:12:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E845320595 for ; Wed, 24 Jun 2015 16:12:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753255AbbFXQJy (ORCPT ); Wed, 24 Jun 2015 12:09:54 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:43151 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753198AbbFXQJv (ORCPT ); Wed, 24 Jun 2015 12:09:51 -0400 Received: from pps.filterd (m0044010 [127.0.0.1]) by mx0a-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id t5OG9nbt012962 for ; Wed, 24 Jun 2015 09:09:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=tT5bxZhx3Ba3H3Rj6ZYmYnn3sHgAD6QzyJHGjZzhi6w=; b=UXbxSfP61/GiOh/GF93+/X2pI4gQa7CTmlT1lpyMD9YoJVNSXIdhidnvmSy3ZnYxKR70 o9dIg1Hmxd+LfU1UhjppDFf3mXA1Jc19jxVVjv7GBnn1+DbPc8Ar4oXsHWpzSRxNuHzm o7cWO3jdQkh7HuTwJ2pH23KxBP+R/5JFIAo= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 1v7yn200v4-4 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Wed, 24 Jun 2015 09:09:51 -0700 Received: from huxley.localdomain (192.168.54.13) by mail.TheFacebook.com (192.168.16.17) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 24 Jun 2015 09:09:44 -0700 From: Omar Sandoval To: CC: Omar Sandoval Subject: [PATCH 1/2] btrfs-progs: replace struct cmd_group->hidden with flags Date: Wed, 24 Jun 2015 09:09:16 -0700 Message-ID: <2368516acde293032f9dae5117136fbf138e33c3.1435161735.git.osandov@fb.com> X-Mailer: git-send-email 2.4.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [192.168.54.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151, 1.0.33, 0.0.0000 definitions=2015-06-24_06:2015-06-23, 2015-06-24, 1970-01-01 signatures=0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 We're also going to want to support aliases, so rather than adding another member, replace "hidden" with a "flags" member. Signed-off-by: Omar Sandoval --- cmds-filesystem.c | 2 +- commands.h | 8 ++++++-- help.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index b93bb33028f2..284dc87bc464 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -1327,7 +1327,7 @@ const struct cmd_group filesystem_cmd_group = { { "show", cmd_show, cmd_show_usage, NULL, 0 }, { "sync", cmd_sync, cmd_sync_usage, NULL, 0 }, { "defragment", cmd_defrag, cmd_defrag_usage, NULL, 0 }, - { "balance", cmd_balance, NULL, &balance_cmd_group, 1 }, + { "balance", cmd_balance, NULL, &balance_cmd_group, CMD_HIDDEN }, { "resize", cmd_resize, cmd_resize_usage, NULL, 0 }, { "label", cmd_label, cmd_label_usage, NULL, 0 }, { "usage", cmd_filesystem_usage, diff --git a/commands.h b/commands.h index bd23340d45ae..42d31781f1a3 100644 --- a/commands.h +++ b/commands.h @@ -17,6 +17,10 @@ #ifndef __BTRFS_COMMANDS_H__ #define __BTRFS_COMMANDS_H__ +enum { + CMD_HIDDEN = (1 << 0), /* should not be in help listings */ +}; + struct cmd_struct { const char *token; int (*fn)(int, char **); @@ -47,8 +51,8 @@ struct cmd_struct { /* should be NULL if token is not a subgroup */ const struct cmd_group *next; - /* if true don't list this token in help listings */ - int hidden; + /* CMD_* flags above */ + int flags; }; #define NULL_CMD_STRUCT {NULL, NULL, NULL, NULL, 0} diff --git a/help.c b/help.c index 56aaf9c3c64c..34754c16e6fe 100644 --- a/help.c +++ b/help.c @@ -133,7 +133,7 @@ static void usage_command_group_internal(const struct cmd_group *grp, int full, int do_sep = 0; for (; cmd->token; cmd++) { - if (cmd->hidden) + if (cmd->flags & CMD_HIDDEN) continue; if (full && cmd != grp->commands)