@@ -43,7 +43,7 @@ static int excl_create(int argc, char **argv, struct command *acmd,
4343 struct plugin * plugin )
4444{
4545 const char * desc = "Create a new NVMeoF exclusion list." ;
46- const char * name_help = "exclusion list name" ;
46+ const char * name_help = "exclusion list name (omit for the default list) " ;
4747 __cleanup_nvme_global_ctx struct libnvme_global_ctx * ctx = NULL ;
4848 int ret ;
4949
@@ -58,11 +58,6 @@ static int excl_create(int argc, char **argv, struct command *acmd,
5858 if (ret )
5959 return ret ;
6060
61- if (!cfg .name ) {
62- fprintf (stderr , "--name required\n" );
63- return - EINVAL ;
64- }
65-
6661 ret = require_root ();
6762 if (ret )
6863 return ret ;
@@ -80,7 +75,7 @@ static int excl_delete(int argc, char **argv, struct command *acmd,
8075 struct plugin * plugin )
8176{
8277 const char * desc = "Delete an NVMeoF exclusion list entirely." ;
83- const char * name_help = "exclusion list name" ;
78+ const char * name_help = "exclusion list name (omit for the default list) " ;
8479 __cleanup_nvme_global_ctx struct libnvme_global_ctx * ctx = NULL ;
8580 int ret ;
8681
@@ -95,11 +90,6 @@ static int excl_delete(int argc, char **argv, struct command *acmd,
9590 if (ret )
9691 return ret ;
9792
98- if (!cfg .name ) {
99- fprintf (stderr , "--name required\n" );
100- return - EINVAL ;
101- }
102-
10393 ret = require_root ();
10494 if (ret )
10595 return ret ;
@@ -163,7 +153,7 @@ static int excl_add(int argc, char **argv, struct command *acmd,
163153 struct plugin * plugin )
164154{
165155 const char * desc = "Add an entry to an NVMeoF exclusion list." ;
166- const char * name_help = "exclusion list name" ;
156+ const char * name_help = "exclusion list name (omit for the default list) " ;
167157 const char * entry_help = "semicolon-separated key=value entry "
168158 "(e.g. \"transport=tcp;traddr=192.168.1.1\")" ;
169159 __cleanup_nvme_global_ctx struct libnvme_global_ctx * ctx = NULL ;
@@ -182,8 +172,8 @@ static int excl_add(int argc, char **argv, struct command *acmd,
182172 if (ret )
183173 return ret ;
184174
185- if (!cfg .name || ! cfg . entry ) {
186- fprintf (stderr , "--name and -- entry required\n" );
175+ if (!cfg .entry ) {
176+ fprintf (stderr , "--entry required\n" );
187177 return - EINVAL ;
188178 }
189179
@@ -192,9 +182,14 @@ static int excl_add(int argc, char **argv, struct command *acmd,
192182 return ret ;
193183
194184 ctx = libnvme_create_global_ctx ();
185+ if (!libnvmf_exclusion_entry_valid (ctx , cfg .entry )) {
186+ fprintf (stderr , "invalid entry: %s\n" , cfg .entry );
187+ return - EINVAL ;
188+ }
189+
195190 ret = libnvmf_exclusion_add (ctx , cfg .name , cfg .entry );
196191 if (ret == - EINVAL )
197- fprintf (stderr , "invalid entry (unknown key) : %s\n" , cfg .entry );
192+ fprintf (stderr , "invalid list name : %s\n" , cfg .name );
198193 else if (ret )
199194 fprintf (stderr , "add failed: %s\n" , libnvme_strerror (- ret ));
200195 return ret ;
@@ -232,7 +227,7 @@ static int excl_remove(int argc, char **argv, struct command *acmd,
232227 struct plugin * plugin )
233228{
234229 const char * desc = "Interactively remove an entry from an NVMeoF exclusion list." ;
235- const char * name_help = "exclusion list name" ;
230+ const char * name_help = "exclusion list name (omit for the default list) " ;
236231 __cleanup_nvme_global_ctx struct libnvme_global_ctx * ctx = NULL ;
237232 struct entry_collection ec = { 0 };
238233 char answer [32 ];
@@ -250,11 +245,6 @@ static int excl_remove(int argc, char **argv, struct command *acmd,
250245 if (ret )
251246 return ret ;
252247
253- if (!cfg .name ) {
254- fprintf (stderr , "--name required\n" );
255- return - EINVAL ;
256- }
257-
258248 ret = require_root ();
259249 if (ret )
260250 return ret ;
@@ -490,7 +480,7 @@ static int excl_edit(int argc, char **argv, struct command *acmd,
490480 struct plugin * plugin )
491481{
492482 const char * desc = "Interactively edit an NVMeoF exclusion list." ;
493- const char * name_help = "exclusion list name" ;
483+ const char * name_help = "exclusion list name (omit for the default list) " ;
494484 __cleanup_nvme_global_ctx struct libnvme_global_ctx * ctx = NULL ;
495485 __cleanup_free char * text = NULL ;
496486 const char * tmpdir ;
@@ -509,11 +499,6 @@ static int excl_edit(int argc, char **argv, struct command *acmd,
509499 if (ret )
510500 return ret ;
511501
512- if (!cfg .name ) {
513- fprintf (stderr , "--name required\n" );
514- return - EINVAL ;
515- }
516-
517502 ret = require_root ();
518503 if (ret )
519504 return ret ;
0 commit comments