All of lore.kernel.org
 help / color / mirror / Atom feed
* [ndctl PATCH] ndctl, bash_completion: add completion for --sector-size=
@ 2017-08-25 20:49 Vishal Verma
  2017-08-29 20:13 ` Dan Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Vishal Verma @ 2017-08-25 20:49 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Dan Williams, Vishal Verma

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=
<blank>

$ 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 <stellarhopper@gmail.com>
---
 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"
 			;;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [ndctl PATCH] ndctl, bash_completion: add completion for --sector-size=
  2017-08-25 20:49 [ndctl PATCH] ndctl, bash_completion: add completion for --sector-size= Vishal Verma
@ 2017-08-29 20:13 ` Dan Williams
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2017-08-29 20:13 UTC (permalink / raw)
  To: Vishal Verma; +Cc: linux-nvdimm

On Fri, Aug 25, 2017 at 1:49 PM, Vishal Verma <stellarhopper@gmail.com> wrote:
> 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=
> <blank>
>
> $ 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 <stellarhopper@gmail.com>

Looks good to me, applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-29 20:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25 20:49 [ndctl PATCH] ndctl, bash_completion: add completion for --sector-size= Vishal Verma
2017-08-29 20:13 ` Dan Williams

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.