[sheepdog] [PATCH v2] collie: correct command-line options parser
ChenZhe
cz at de3eb.cn
Mon Mar 18 07:55:03 CET 2013
"collie cluster recover disable -p7001" not work.
getopt_long() will permutes the elements of ARGV.
so,the subcmd who needs third arg shoud take argv[optind] instead of
argv[3].
Signed-off-by: ChenZhe <cz at de3eb.cn>
---
collie/cluster.c | 2 +-
collie/debug.c | 2 +-
collie/vdi.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/collie/cluster.c b/collie/cluster.c
index 9c5974a..2eadc32 100644
--- a/collie/cluster.c
+++ b/collie/cluster.c
@@ -442,7 +442,7 @@ static int cluster_recover(int argc, char **argv)
int i;
for (i = 0; cluster_recover_cmd[i].name; i++) {
- if (!strcmp(cluster_recover_cmd[i].name, argv[3]))
+ if (!strcmp(cluster_recover_cmd[i].name, argv[optind]))
return cluster_recover_cmd[i].fn(argc, argv);
}
diff --git a/collie/debug.c b/collie/debug.c
index 708ba25..f3a245f 100644
--- a/collie/debug.c
+++ b/collie/debug.c
@@ -211,7 +211,7 @@ static int debug_trace(int argc, char **argv)
int i;
for (i = 0; trace_cmd[i].name; i++) {
- if (!strcmp(trace_cmd[i].name, argv[3]))
+ if (!strcmp(trace_cmd[i].name, argv[optind]))
return trace_cmd[i].fn(argc, argv);
}
diff --git a/collie/vdi.c b/collie/vdi.c
index 94acca9..424527d 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -1923,7 +1923,7 @@ static int vdi_cache(int argc, char **argv)
int i;
for (i = 0; vdi_cache_cmd[i].name; i++) {
- if (!strcmp(vdi_cache_cmd[i].name, argv[3])) {
+ if (!strcmp(vdi_cache_cmd[i].name, argv[optind])) {
optind++;
return vdi_cache_cmd[i].fn(argc, argv);
}
--
1.7.1
More information about the sheepdog
mailing list