+static int lfs_mv(int argc, char **argv)
+{
+ struct find_param param = {
+ .fp_max_depth = -1,
+ .mdtindex = -1,
+ };
+ char *end;
+ int c;
+ int rc = 0;
+ struct option long_opts[] = {
+ {"--mdt-index", required_argument, 0, 'M'},
+ {"verbose", no_argument, 0, 'v'},
+ {0, 0, 0, 0}
+ };
+
+ while ((c = getopt_long(argc, argv, "M:v", long_opts, NULL)) != -1) {
+ switch (c) {
+ case 'M': {
+ param.mdtindex = strtoul(optarg, &end, 0);
+ if (*end != '\0') {
+ fprintf(stderr, "%s: invalid MDT index'%s'\n",
+ argv[0], optarg);
+ return CMD_HELP;
+ }
+ break;
+ }
+ case 'v': {
+ param.verbose = VERBOSE_DETAIL;
+ break;
+ }
+ default:
+ fprintf(stderr, "error: %s: unrecognized option '%s'\n",
+ argv[0], argv[optind - 1]);
+ return CMD_HELP;
+ }
+ }
+
+ if (param.mdtindex == -1) {
+ fprintf(stderr, "%s MDT index must be indicated\n", argv[0]);
+ return CMD_HELP;
+ }
+
+ if (optind >= argc) {
+ fprintf(stderr, "%s missing operand path\n", argv[0]);
+ return CMD_HELP;
+ }
+
+ param.migrate = 1;
+ rc = llapi_mv(argv[optind], ¶m);
+ if (rc != 0)
+ fprintf(stderr, "cannot migrate '%s' to MDT%04x: %s\n",
+ argv[optind], param.mdtindex, strerror(-rc));
+ return rc;
+}
+