From patchwork Fri Aug 25 20:49:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Verma X-Patchwork-Id: 9922809 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 D153860349 for ; Fri, 25 Aug 2017 20:51:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9018280FC for ; Fri, 25 Aug 2017 20:51:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADC31284AA; Fri, 25 Aug 2017 20:51:18 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 58964280FC for ; Fri, 25 Aug 2017 20:51:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3A6EB2095AE69; Fri, 25 Aug 2017 13:48:41 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5774621E11D3B for ; Fri, 25 Aug 2017 13:48:39 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Aug 2017 13:51:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,426,1498546800"; d="scan'208";a="142089197" Received: from omniknight.lm.intel.com ([10.232.112.27]) by orsmga005.jf.intel.com with ESMTP; 25 Aug 2017 13:51:15 -0700 From: Vishal Verma To: Subject: [ndctl PATCH] ndctl, bash_completion: add completion for --sector-size= Date: Fri, 25 Aug 2017 14:49:22 -0600 Message-Id: <20170825204922.29374-1-stellarhopper@gmail.com> X-Mailer: git-send-email 2.9.3 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Sector size options were missing completion. Add completion based on the mode of the namespace if specified. 'raw' and 'memory' can only do 512 or 4096, where as with 'sector', more sector sizes are possible. 'dax' doesn't accept a sector size option, so refrain from completing that. $ ndctl create-namespace --mode=sector --sector-size= 4096 4104 4160 4224 512 520 528 $ ndctl create-namespace --mode=dax --sector-size= $ ndctl create-namespace --mode=raw --sector-size= 4096 512 When no mode has been specified yet, it is open game, and everything is shown. $ ndctl create-namespace --sector-size= 4096 4104 4160 4224 512 520 528 Signed-off-by: Vishal Verma --- contrib/ndctl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contrib/ndctl b/contrib/ndctl index e77d680..9410572 100755 --- a/contrib/ndctl +++ b/contrib/ndctl @@ -141,6 +141,17 @@ __ndctl_get_dimms() echo "$(ndctl list $opts | grep -E "^\s*\"dev\":" | cut -d\" -f4)" } +__ndctl_get_sector_sizes() +{ + if [[ "$mode_filter" == @(raw|memory) ]]; then + echo "512 4096" + elif [[ "$mode_filter" == @(dax) ]]; then + return + else + echo "512 520 528 4096 4104 4160 4224" + fi +} + __ndctl_file_comp() { local cur="$1" @@ -182,6 +193,9 @@ __ndctl_comp_options() opts="raw sector" fi ;; + --sector-size) + opts=$(__ndctl_get_sector_sizes) + ;; --map) opts="mem dev" ;;