Changeset 431b513 in mainline


Ignore:
Timestamp:
2025-06-09T12:45:40Z (8 days ago)
Author:
Miroslav Cimerman <mc@…>
Children:
e0bbecb
Parents:
d482b05
git-author:
Miroslav Cimerman <mc@…> (2025-06-09 12:41:42)
git-committer:
Miroslav Cimerman <mc@…> (2025-06-09 12:45:40)
Message:

hrctl: also parse levels as words

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/hrctl/hrctl.c

    rd482b05 r431b513  
    7878    "  -s, --state                               Display state of active volumes.\n"
    7979    "\n"
     80    "level can be one of:\n"
     81    "  0 | stripe | striping |\n"
     82    "  1 | mirror | mirroring |\n"
     83    "  4 | parity_dedicated |\n"
     84    "  5 | parity | parity_distributed\n"
     85    "\n"
    8086    "Example usage:\n"
    8187    "\t\thrctl --create hr0 --level 5 disk1 disk2 disk3\n"
     
    311317
    312318        const char *level_str = argv[optind++];
    313         if (str_size(level_str) != 1 && !isdigit(level_str[0])) {
    314                 printf(NAME ": unknown level \"%s\"\n", level_str);
    315                 goto error;
    316         }
    317 
    318         vol_config->level = strtol(level_str, NULL, 10);
     319        if (str_size(level_str) == 1 && isdigit(level_str[0])) {
     320                vol_config->level = strtol(level_str, NULL, 10);
     321        } else {
     322                if (str_cmp(level_str, "mirror") == 0 ||
     323                    str_cmp(level_str, "mirroring") == 0) {
     324                        vol_config->level = HR_LVL_1;
     325                } else if (str_cmp(level_str, "stripe") == 0 ||
     326                    str_cmp(level_str, "striping") == 0) {
     327                        vol_config->level = HR_LVL_0;
     328                } else if (str_cmp(level_str, "parity") == 0 ||
     329                    str_cmp(level_str, "parity_distributed") == 0) {
     330                        vol_config->level = HR_LVL_5;
     331                } else if (str_cmp(level_str, "parity_dedicated") == 0) {
     332                        vol_config->level = HR_LVL_4;
     333                } else {
     334                        printf(NAME ": unknown level \"%s\"\n", level_str);
     335                        goto error;
     336                }
     337        }
    319338
    320339        errno_t rc = fill_config_devs(argc, argv, vol_config);
Note: See TracChangeset for help on using the changeset viewer.