diff options
author | Mateusz Kusiak <mateusz.kusiak@intel.com> | 2023-01-02 09:35:15 +0100 |
---|---|---|
committer | Jes Sorensen <jes@trained-monkey.org> | 2023-01-04 16:20:58 +0100 |
commit | 2568ce89ea5c26225e8984733adc2ea7559d853a (patch) | |
tree | ff1429fa3379e0a974d34d68aaa1721814bf8c2d /ReadMe.c | |
parent | mdadm: create ident_init() (diff) | |
download | mdadm-2568ce89ea5c26225e8984733adc2ea7559d853a.tar.xz mdadm-2568ce89ea5c26225e8984733adc2ea7559d853a.zip |
mdadm: Add option validation for --update-subarray
Subset of options available for "--update" is not same as for "--update-subarray".
Define maps and enum for update options and use them instead of direct comparisons.
Add proper error message.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
Diffstat (limited to 'ReadMe.c')
-rw-r--r-- | ReadMe.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -655,3 +655,34 @@ char *mode_help[mode_count] = { [GROW] = Help_grow, [INCREMENTAL] = Help_incr, }; + +/** + * fprint_update_options() - Print valid update options depending on the mode. + * @outf: File (output stream) + * @update_mode: Used to distinguish update and update_subarray + */ +void fprint_update_options(FILE *outf, enum update_opt update_mode) +{ + int counter = UOPT_NAME, breakpoint = UOPT_HELP; + mapping_t *map = update_options; + + if (!outf) + return; + if (update_mode == UOPT_SUBARRAY_ONLY) { + breakpoint = UOPT_SUBARRAY_ONLY; + fprintf(outf, "Valid --update options for update-subarray are:\n\t"); + } else + fprintf(outf, "Valid --update options are:\n\t"); + while (map->num) { + if (map->num >= breakpoint) + break; + fprintf(outf, "'%s', ", map->name); + if (counter % 5 == 0) + fprintf(outf, "\n\t"); + counter++; + map++; + } + if ((counter - 1) % 5) + fprintf(outf, "\n"); + fprintf(outf, "\r"); +} |