aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zhack
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2016-08-30 18:56:36 -0700
committerBrian Behlendorf <[email protected]>2016-08-31 14:32:46 -0700
commit9d69e9b268a1a0af3117871608fd3a87db1ce586 (patch)
tree67d43a30782de28e802b965291ce1800238abba4 /cmd/zhack
parent3f10fe07d645166d7513448feedd8e3ef3111a12 (diff)
Fix zhack argument processing
The argument processing is zhack makes the assumption that getopt() will not permute argv. This isn't true for the GNU implementation of getopt() unless the optstring is prefixed with a '+'. In which case this is equivalent to setting the POSIXLY_CORRECT environment variable In addition, update the usage() and optstrings to reflect the existing supported options. Signed-off-by: Brian Behlendorf <[email protected]> Signed-off-by: liaoyuxiangqin <[email protected]> Closes #5047
Diffstat (limited to 'cmd/zhack')
-rw-r--r--cmd/zhack/zhack.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd/zhack/zhack.c b/cmd/zhack/zhack.c
index cc4f174c6..e76945141 100644
--- a/cmd/zhack/zhack.c
+++ b/cmd/zhack/zhack.c
@@ -69,9 +69,10 @@ usage(void)
(void) fprintf(stderr,
" feature stat <pool>\n"
" print information about enabled features\n"
- " feature enable [-d desc] <pool> <feature>\n"
+ " feature enable [-r] [-d desc] <pool> <feature>\n"
" add a new enabled feature to the pool\n"
" -d <desc> sets the feature's description\n"
+ " -r set read-only compatible flag for feature\n"
" feature ref [-md] <pool> <feature>\n"
" change the refcount on the given feature\n"
" -d decrease instead of increase the refcount\n"
@@ -318,7 +319,7 @@ zhack_do_feature_enable(int argc, char **argv)
feature.fi_feature = SPA_FEATURE_NONE;
optind = 1;
- while ((c = getopt(argc, argv, "rmd:")) != -1) {
+ while ((c = getopt(argc, argv, "+rd:")) != -1) {
switch (c) {
case 'r':
feature.fi_flags |= ZFEATURE_FLAG_READONLY_COMPAT;
@@ -416,7 +417,7 @@ zhack_do_feature_ref(int argc, char **argv)
feature.fi_feature = SPA_FEATURE_NONE;
optind = 1;
- while ((c = getopt(argc, argv, "md")) != -1) {
+ while ((c = getopt(argc, argv, "+md")) != -1) {
switch (c) {
case 'm':
feature.fi_flags |= ZFEATURE_FLAG_MOS;
@@ -522,7 +523,7 @@ main(int argc, char **argv)
dprintf_setup(&argc, argv);
zfs_prop_init();
- while ((c = getopt(argc, argv, "c:d:")) != -1) {
+ while ((c = getopt(argc, argv, "+c:d:")) != -1) {
switch (c) {
case 'c':
g_importargs.cachefile = optarg;