- struct option long_opts[] = {
- {"count", 0, 0, 'c'},
- {"directory", 0, 0, 'd'},
- {"index", 0, 0, 'i'},
- {"mdt", 0, 0, 'M'},
- {"offset", 0, 0, 'o'},
- {"obd", 1, 0, 'O'},
- {"pool", 0, 0, 'p'},
- {"quiet", 0, 0, 'q'},
- {"recursive", 0, 0, 'r'},
- {"raw", 0, 0, 'R'},
- {"size", 0, 0, 's'},
- {"verbose", 0, 0, 'v'},
- {0, 0, 0, 0}
- };
- int c, rc;
- struct find_param param = { 0 };
-
- param.maxdepth = 1;
- optind = 0;
- while ((c = getopt_long(argc, argv, "cdhiMoO:pqrRsv",
- long_opts, NULL)) != -1) {
- switch (c) {
- case 'O':
- if (param.obduuid) {
- fprintf(stderr,
- "error: %s: only one obduuid allowed",
- argv[0]);
- return CMD_HELP;
- }
- param.obduuid = (struct obd_uuid *)optarg;
- break;
- case 'q':
- param.quiet++;
- break;
- case 'd':
- param.maxdepth = 0;
- break;
- case 'r':
- param.recursive = 1;
- break;
- case 'v':
- param.verbose = VERBOSE_ALL | VERBOSE_DETAIL;
- break;
- case 'c':
- if (!(param.verbose & VERBOSE_DETAIL)) {
- param.verbose |= VERBOSE_COUNT;
- param.maxdepth = 0;
- }
- break;
- case 's':
- if (!(param.verbose & VERBOSE_DETAIL)) {
- param.verbose |= VERBOSE_SIZE;
- param.maxdepth = 0;
- }
- break;
- case 'i':
- case 'o':
- if (!(param.verbose & VERBOSE_DETAIL)) {
- param.verbose |= VERBOSE_OFFSET;
- param.maxdepth = 0;
- }
- break;
- case 'p':
- if (!(param.verbose & VERBOSE_DETAIL)) {
- param.verbose |= VERBOSE_POOL;
- param.maxdepth = 0;
- }
- break;
- case 'M':
- param.get_mdt_index = 1;
- break;
- case 'R':
- param.raw = 1;
- break;
- case '?':
- return CMD_HELP;
- default:
- fprintf(stderr, "error: %s: option '%s' unrecognized\n",
- argv[0], argv[optind - 1]);
- return CMD_HELP;
- }
- }
-
- if (optind >= argc)
- return CMD_HELP;
-
- if (param.recursive)
- param.maxdepth = -1;
-
- if (!param.verbose)
- param.verbose = VERBOSE_ALL;
- if (param.quiet)
- param.verbose = VERBOSE_OBJID;
-
- do {
- rc = llapi_getstripe(argv[optind], ¶m);
- } while (++optind < argc && !rc);
-
- if (rc)
- fprintf(stderr, "error: %s failed for %s.\n",
- argv[0], argv[optind - 1]);
- return rc;
+ struct option long_opts[] = {
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0)
+ /* This formerly implied "stripe-count", but was explicitly
+ * made "stripe-count" for consistency with other options,
+ * and to separate it from "mdt-count" when DNE arrives. */
+ {"count", no_argument, 0, 'c'},
+#endif
+ {"stripe-count", no_argument, 0, 'c'},
+ {"stripe_count", no_argument, 0, 'c'},
+ {"directory", no_argument, 0, 'd'},
+ {"default", no_argument, 0, 'D'},
+ {"generation", no_argument, 0, 'g'},
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0)
+ /* This formerly implied "stripe-index", but was explicitly
+ * made "stripe-index" for consistency with other options,
+ * and to separate it from "mdt-index" when DNE arrives. */
+ {"index", no_argument, 0, 'i'},
+#endif
+ {"stripe-index", no_argument, 0, 'i'},
+ {"stripe_index", no_argument, 0, 'i'},
+ {"layout", no_argument, 0, 'L'},
+ {"mdt-index", no_argument, 0, 'M'},
+ {"mdt_index", no_argument, 0, 'M'},
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0)
+ /* This formerly implied "stripe-index", but was confusing
+ * with "file offset" (which will eventually be needed for
+ * with different layouts by offset), so deprecate it. */
+ {"offset", no_argument, 0, 'o'},
+#endif
+ {"obd", required_argument, 0, 'O'},
+ {"ost", required_argument, 0, 'O'},
+ {"pool", no_argument, 0, 'p'},
+ {"quiet", no_argument, 0, 'q'},
+ {"recursive", no_argument, 0, 'r'},
+ {"raw", no_argument, 0, 'R'},
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0)
+ /* This formerly implied "--stripe-size", but was confusing
+ * with "lfs find --size|-s", which means "file size", so use
+ * the consistent "--stripe-size|-S" for all commands. */
+ {"size", no_argument, 0, 's'},
+#endif
+ {"stripe-size", no_argument, 0, 'S'},
+ {"stripe_size", no_argument, 0, 'S'},
+ {"verbose", no_argument, 0, 'v'},
+ {0, 0, 0, 0}
+ };
+ int c, rc;
+
+ param->maxdepth = 1;
+ optind = 0;
+ while ((c = getopt_long(argc, argv, "cdDghiLMoO:pqrRsSv",
+ long_opts, NULL)) != -1) {
+ switch (c) {
+ case 'O':
+ if (param->obduuid) {
+ fprintf(stderr,
+ "error: %s: only one obduuid allowed",
+ argv[0]);
+ return CMD_HELP;
+ }
+ param->obduuid = (struct obd_uuid *)optarg;
+ break;
+ case 'q':
+ param->quiet++;
+ break;
+ case 'd':
+ param->maxdepth = 0;
+ break;
+ case 'D':
+ param->get_default_lmv = 1;
+ break;
+ case 'r':
+ param->recursive = 1;
+ break;
+ case 'v':
+ param->verbose = VERBOSE_ALL | VERBOSE_DETAIL;
+ break;
+ case 'c':
+#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0)
+ if (strcmp(argv[optind - 1], "--count") == 0)
+ fprintf(stderr, "warning: '--count' deprecated,"
+ " use '--stripe-count' instead\n");
+#endif
+ if (!(param->verbose & VERBOSE_DETAIL)) {
+ param->verbose |= VERBOSE_COUNT;
+ param->maxdepth = 0;
+ }
+ break;
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0)
+ case 's':
+#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0)
+ fprintf(stderr, "warning: '--size|-s' deprecated, "
+ "use '--stripe-size|-S' instead\n");
+#endif
+#endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) */
+ case 'S':
+ if (!(param->verbose & VERBOSE_DETAIL)) {
+ param->verbose |= VERBOSE_SIZE;
+ param->maxdepth = 0;
+ }
+ break;
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0)
+ case 'o':
+ fprintf(stderr, "warning: '--offset|-o' deprecated, "
+ "use '--stripe-index|-i' instead\n");
+#endif
+ case 'i':
+#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0)
+ if (strcmp(argv[optind - 1], "--index") == 0)
+ fprintf(stderr, "warning: '--index' deprecated"
+ ", use '--stripe-index' instead\n");
+#endif
+ if (!(param->verbose & VERBOSE_DETAIL)) {
+ param->verbose |= VERBOSE_OFFSET;
+ param->maxdepth = 0;
+ }
+ break;
+ case 'p':
+ if (!(param->verbose & VERBOSE_DETAIL)) {
+ param->verbose |= VERBOSE_POOL;
+ param->maxdepth = 0;
+ }
+ break;
+ case 'g':
+ if (!(param->verbose & VERBOSE_DETAIL)) {
+ param->verbose |= VERBOSE_GENERATION;
+ param->maxdepth = 0;
+ }
+ break;
+ case 'L':
+ if (!(param->verbose & VERBOSE_DETAIL)) {
+ param->verbose |= VERBOSE_LAYOUT;
+ param->maxdepth = 0;
+ }
+ break;
+ case 'M':
+ if (!(param->verbose & VERBOSE_DETAIL))
+ param->maxdepth = 0;
+ param->verbose |= VERBOSE_MDTINDEX;
+ break;
+ case 'R':
+ param->raw = 1;
+ break;
+ default:
+ return CMD_HELP;
+ }
+ }
+
+ if (optind >= argc)
+ return CMD_HELP;
+
+ if (param->recursive)
+ param->maxdepth = -1;
+
+ if (!param->verbose)
+ param->verbose = VERBOSE_ALL;
+ if (param->quiet)
+ param->verbose = VERBOSE_OBJID;
+
+ do {
+ rc = llapi_getstripe(argv[optind], param);
+ } while (++optind < argc && !rc);
+
+ if (rc)
+ fprintf(stderr, "error: %s failed for %s.\n",
+ argv[0], argv[optind - 1]);
+ return rc;