- static struct option long_opt[] = {
- {"iam-dir", 0, 0, 'a'},
- {"backfstype", 1, 0, 'b'},
- {"stripe-count-hint", 1, 0, 'c'},
- {"comment", 1, 0, 'u'},
- {"configdev", 1, 0, 'C'},
- {"device-size", 1, 0, 'd'},
- {"dryrun", 0, 0, 'n'},
- {"erase-params", 0, 0, 'e'},
- {"failnode", 1, 0, 'f'},
- {"failover", 1, 0, 'f'},
- {"mgs", 0, 0, 'G'},
- {"help", 0, 0, 'h'},
- {"index", 1, 0, 'i'},
- {"mkfsoptions", 1, 0, 'k'},
- {"mgsnode", 1, 0, 'm'},
- {"mgsnid", 1, 0, 'm'},
- {"mdt", 0, 0, 'M'},
- {"fsname",1, 0, 'L'},
- {"noformat", 0, 0, 'n'},
- {"nomgs", 0, 0, 'N'},
- {"mountfsoptions", 1, 0, 'o'},
- {"ost", 0, 0, 'O'},
- {"param", 1, 0, 'p'},
- {"print", 0, 0, 'n'},
- {"quiet", 0, 0, 'q'},
- {"reformat", 0, 0, 'r'},
- {"servicenode", 1, 0, 's'},
- {"verbose", 0, 0, 'v'},
- {"writeconf", 0, 0, 'w'},
- {"upgrade_to_18", 0, 0, 'U'},
- {"network", 1, 0, 't'},
- {"quota", 0, 0, 'Q'},
- {0, 0, 0, 0}
- };
- char *optstring = "b:c:C:d:ef:Ghi:k:L:m:MnNo:Op:Pqrs:t:Uu:vw";
- int opt;
- int rc, longidx;
- int failnode_set = 0, servicenode_set = 0;
-
- while ((opt = getopt_long(argc, argv, optstring, long_opt, &longidx)) !=
- EOF) {
- switch (opt) {
- case 'a': {
- if (IS_MDT(&mop->mo_ldd))
- mop->mo_ldd.ldd_flags |= LDD_F_IAM_DIR;
- break;
- }
- case 'b': {
- int i = 0;
- while (i < LDD_MT_LAST) {
- if (strcmp(optarg, mt_str(i)) == 0) {
- mop->mo_ldd.ldd_mount_type = i;
- break;
- }
- i++;
- }
- if (i == LDD_MT_LAST) {
- fprintf(stderr, "%s: invalid backend filesystem"
- " type %s\n", progname, optarg);
+ static struct option long_opts[] = {
+ { .val = 'B', .name = "backfs-mount-opts",
+ .has_arg = required_argument},
+ { .val = 'f', .name = "failnode", .has_arg = required_argument},
+ { .val = 'f', .name = "failover", .has_arg = required_argument},
+ { .val = 'G', .name = "mgs", .has_arg = no_argument},
+ { .val = 'h', .name = "help", .has_arg = no_argument},
+ { .val = 'i', .name = "index", .has_arg = required_argument},
+ { .val = 'L', .name = "fsname", .has_arg = required_argument},
+ { .val = 'm', .name = "mgsnode", .has_arg = required_argument},
+ { .val = 'm', .name = "mgsnid", .has_arg = required_argument},
+ { .val = 'n', .name = "dryrun", .has_arg = no_argument},
+ { .val = 'N', .name = "nomgs", .has_arg = no_argument},
+ { .val = 'o', .name = "mountfsoptions",
+ .has_arg = required_argument},
+ { .val = 'p', .name = "param", .has_arg = required_argument},
+ { .val = 'q', .name = "quiet", .has_arg = no_argument},
+ { .val = 's', .name = "servicenode", .has_arg = required_argument},
+ { .val = 't', .name = "network", .has_arg = required_argument},
+ { .val = 'u', .name = "comment", .has_arg = required_argument},
+ { .val = 'U', .name = "force-nohostid",
+ .has_arg = no_argument},
+ { .val = 'v', .name = "verbose", .has_arg = no_argument},
+ { .val = 'V', .name = "version", .has_arg = no_argument},
+#ifndef TUNEFS
+ { .val = 'b', .name = "backfstype", .has_arg = required_argument},
+ { .val = 'c', .name = "stripe-count-hint",
+ .has_arg = required_argument},
+ { .val = 'd', .name = "device-size", .has_arg = required_argument},
+ { .val = 'k', .name = "mkfsoptions", .has_arg = required_argument},
+ { .val = 'M', .name = "mdt", .has_arg = no_argument},
+ { .val = 'O', .name = "ost", .has_arg = no_argument},
+ { .val = 'r', .name = "reformat", .has_arg = no_argument},
+ { .val = 'R', .name = "replace", .has_arg = no_argument},
+#else
+ { .val = 'E', .name = "erase-param", .has_arg = required_argument},
+ { .val = 'e', .name = "erase-params",
+ .has_arg = no_argument},
+ { .val = 'Q', .name = "quota", .has_arg = no_argument},
+ { .val = 'R', .name = "rename", .has_arg = optional_argument},
+ { .val = 'w', .name = "writeconf", .has_arg = no_argument},
+#endif
+ { .name = NULL } };
+ char *short_opts = "B:f:Ghi:L:m:nNo:p:qs:t:u:vV"
+#ifndef TUNEFS
+ "b:c:d:k:MOrR";
+#else
+ "E:eQR::w";
+#endif
+ struct lustre_disk_data *ldd = &mop->mo_ldd;
+ char new_fsname[16] = { 0 };
+ int opt;
+ int rc, longidx;
+ int failnode_set = 0, servicenode_set = 0;
+ int replace = 0;
+ bool index_option = false;
+
+#ifdef TUNEFS
+ /*
+ * For the right semantics, if '-e'/'--erase-params' is specified,
+ * it must be picked out and all old parameters should be erased
+ * before any other changes are done.
+ */
+ while ((opt = getopt_long(argc, argv, short_opts, long_opts,
+ &longidx)) != EOF) {
+ switch (opt) {
+ case 'e':
+ ldd->ldd_params[0] = '\0';
+ mop->mo_flags |= MO_ERASE_ALL;
+ ldd->ldd_flags |= LDD_F_UPDATE;
+ break;
+ default:
+ break;
+ }
+ if (mop->mo_flags & MO_ERASE_ALL)
+ break;
+ }
+ optind = 0;
+#endif
+ while ((opt = getopt_long(argc, argv, short_opts, long_opts,
+ &longidx)) != EOF) {
+ switch (opt) {
+ case 'B':
+ mop->mo_mountopts = optarg;
+ break;
+ case 'f':
+ case 's': {
+ char *nids;
+
+ if ((opt == 'f' && servicenode_set) ||
+ (opt == 's' && failnode_set)) {
+ fprintf(stderr, "%s: %s cannot use with --%s\n",
+ progname, long_opts[longidx].name,
+ opt == 'f' ? "servicenode" :
+ "failnode");