From patchwork Tue Mar 8 23:37:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 8538391 Return-Path: X-Original-To: patchwork-linux-nvdimm@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 1E6B59F372 for ; Tue, 8 Mar 2016 23:37:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 44BEA200E8 for ; Tue, 8 Mar 2016 23:37:42 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 58ADE20035 for ; Tue, 8 Mar 2016 23:37:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DF21D1A1F3A; Tue, 8 Mar 2016 15:37:54 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id CC4CA1A1F3A for ; Tue, 8 Mar 2016 15:37:53 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 08 Mar 2016 15:37:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,558,1449561600"; d="scan'208";a="919748352" Received: from dwillia2-desk3.jf.intel.com ([10.54.39.14]) by fmsmga001.fm.intel.com with ESMTP; 08 Mar 2016 15:37:30 -0800 Subject: [ndctl PATCH 7/8] ndctl: add filter-by-type to the 'list' command From: Dan Williams To: linux-nvdimm@lists.01.org Date: Tue, 08 Mar 2016 15:37:04 -0800 Message-ID: <20160308233704.18628.58923.stgit@dwillia2-desk3.jf.intel.com> In-Reply-To: <20160308233628.18628.13786.stgit@dwillia2-desk3.jf.intel.com> References: <20160308233628.18628.13786.stgit@dwillia2-desk3.jf.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Limit region, and subsequently namespace, scanning by interface type ('pmem' or 'blk'). Signed-off-by: Dan Williams --- Documentation/ndctl-list.txt | 4 ++++ builtin-list.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Documentation/ndctl-list.txt b/Documentation/ndctl-list.txt index 53847c56236e..abf3ff07cfa9 100644 --- a/Documentation/ndctl-list.txt +++ b/Documentation/ndctl-list.txt @@ -60,6 +60,10 @@ OPTIONS --region=:: include::xable-region-options.txt[] +-t:: +--type=:: + Filter listing by region type ('pmem' or 'blk') + -B:: --buses:: Include bus info in the listing diff --git a/builtin-list.c b/builtin-list.c index 12a6d32b124a..413b36ac0208 100644 --- a/builtin-list.c +++ b/builtin-list.c @@ -29,6 +29,7 @@ static struct { static struct { const char *bus; const char *region; + const char *type; } param; static int did_fail; @@ -197,6 +198,8 @@ int cmd_list(int argc, const char **argv) OPT_STRING('b', "bus", ¶m.bus, "bus-id", "filter by bus"), OPT_STRING('r', "region", ¶m.region, "region-id", "filter by region"), + OPT_STRING('t', "type", ¶m.type, "region-type", + "filter by region-type"), OPT_BOOLEAN('B', "buses", &list.buses, "include bus info"), OPT_BOOLEAN('D', "dimms", &list.dimms, "include dimm info"), OPT_BOOLEAN('R', "regions", &list.regions, @@ -216,14 +219,29 @@ int cmd_list(int argc, const char **argv) struct json_object *jbuses = NULL; struct ndctl_ctx *ctx; struct ndctl_bus *bus; + unsigned int type = 0; int i, rc; argc = parse_options(argc, argv, options, u, 0); for (i = 0; i < argc; i++) error("unknown parameter \"%s\"\n", argv[i]); + if (param.type && (strcmp(param.type, "pmem") != 0 + && strcmp(param.type, "blk") != 0)) { + error("unknown type \"%s\" must be \"pmem\" or \"blk\"\n", + param.type); + argc++; + } + if (argc) usage_with_options(u, options); + if (param.type) { + if (strcmp(param.type, "pmem") == 0) + type = ND_DEVICE_REGION_PMEM; + else + type = ND_DEVICE_REGION_BLK; + } + rc = ndctl_new(&ctx); if (rc < 0) return rc; @@ -293,6 +311,9 @@ int cmd_list(int argc, const char **argv) if (!util_region_filter(region, param.region)) continue; + if (type && ndctl_region_get_type(region) != type) + continue; + if (!list.regions) { jnamespaces = list_namespaces(region, jbus, jnamespaces, true);