diff options
author | Darrick J. Wong <djwong@kernel.org> | 2023-12-20 08:53:45 -0800 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2023-12-21 18:29:14 -0800 |
commit | 1067f3cd67aebb712b7b7ad2d79e0d96c4da25bc (patch) | |
tree | 052580e72025f08a2b6079e70e9ab0bce3ec70a9 | |
parent | 2cbc52f5c9a9588e1e9c8e54c0435c121424fe5a (diff) | |
download | xfsprogs-dev-1067f3cd67aebb712b7b7ad2d79e0d96c4da25bc.tar.gz |
xfs_io: set exitcode = 1 on parsing errors in scrub/repair command
Set exitcode to 1 if there is an error parsing the CLI arguments to the
scrub or repair commands, like we do most other places in xfs_io.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | io/scrub.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/io/scrub.c b/io/scrub.c index fc22ba49f8..8b3bdd779f 100644 --- a/io/scrub.c +++ b/io/scrub.c @@ -103,11 +103,14 @@ parse_args( while ((c = getopt(argc, argv, "")) != EOF) { switch (c) { default: + exitcode = 1; return command_usage(cmdinfo); } } - if (optind > argc - 1) + if (optind > argc - 1) { + exitcode = 1; return command_usage(cmdinfo); + } for (i = 0, d = xfrog_scrubbers; i < XFS_SCRUB_TYPE_NR; i++, d++) { if (strcmp(d->name, argv[optind]) == 0) { @@ -117,6 +120,7 @@ parse_args( } if (type < 0) { printf(_("Unknown type '%s'.\n"), argv[optind]); + exitcode = 1; return command_usage(cmdinfo); } optind++; @@ -132,19 +136,22 @@ parse_args( fprintf(stderr, _("Bad inode number '%s'.\n"), argv[optind]); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } control2 = strtoul(argv[optind + 1], &p, 0); if (*p != '\0') { fprintf(stderr, _("Bad generation number '%s'.\n"), argv[optind + 1]); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } } else { fprintf(stderr, _("Must specify inode number and generation.\n")); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } break; case XFROG_SCRUB_TYPE_AGHEADER: @@ -152,13 +159,15 @@ parse_args( if (optind != argc - 1) { fprintf(stderr, _("Must specify one AG number.\n")); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } control = strtoul(argv[optind], &p, 0); if (*p != '\0') { fprintf(stderr, _("Bad AG number '%s'.\n"), argv[optind]); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } break; case XFROG_SCRUB_TYPE_FS: @@ -166,7 +175,8 @@ parse_args( if (optind != argc) { fprintf(stderr, _("No parameters allowed.\n")); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } break; default: |