Changeset 95ca19d in mainline for uspace/app/hrctl/hrctl.c
- Timestamp:
- 2025-06-30T09:31:21Z (3 weeks ago)
- Children:
- 059885c
- Parents:
- 640250b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hrctl/hrctl.c
r640250b r95ca19d 55 55 static int create_from_argv(hr_t *, int, char **, uint8_t); 56 56 static int handle_create(hr_t *, int, char **); 57 static int assemble_from_config(hr_t *, const char * );58 static int assemble_from_argv(hr_t *, int, char ** );57 static int assemble_from_config(hr_t *, const char *, uint8_t); 58 static int assemble_from_argv(hr_t *, int, char **, uint8_t); 59 59 static int handle_assemble(hr_t *, int, char **); 60 60 static int handle_disassemble(hr_t *, int, char **); … … 70 70 " -h, --help Display this message and exit.\n" 71 71 "\n" 72 " -c, --create [--no _meta]Create a volume, options:\n"72 " -c, --create [--no-meta] [--read-only] Create a volume, options:\n" 73 73 " name {-l , --level level} device... manual device specification, or\n" 74 74 " -f configuration.sif create from configuration file.\n" 75 75 "\n" 76 76 " -a, --assemble Assemble volume(s), options:\n" 77 " [ device...]manual device specification, or\n"78 " [ -f configuration.sif]assemble from configuration file, or\n"77 " [[--read-only] device...] manual device specification, or\n" 78 " [[--read-only] -f configuration.sif] assemble from configuration file, or\n" 79 79 " no option is automatic assembly.\n" 80 80 "\n" … … 108 108 "\n" 109 109 "Notes:\n" 110 " Add --no _meta after --create to disable storing on-disk metadata.\n"110 " Add --no-meta after --create to disable storing on-disk metadata.\n" 111 111 " Simulating an extent failure with -m volume -f index is dangerous. It marks\n" 112 112 " metadata as dirty in other healthy extents, and zeroes out the superblock\n" … … 445 445 } 446 446 447 static bool try_to_get_additional_flags(int argc, char **argv, 448 uint8_t test_flags, uint8_t *flags) 449 { 450 if (test_flags & HR_VOL_FLAG_NOOP_META) { 451 if (str_cmp(argv[optind], "--no-meta") == 0) { 452 *flags |= HR_VOL_FLAG_NOOP_META; 453 optind++; 454 return true; 455 } 456 } 457 458 if (test_flags & HR_VOL_FLAG_READ_ONLY) { 459 if (str_cmp(argv[optind], "--read-only") == 0) { 460 *flags |= HR_VOL_FLAG_READ_ONLY; 461 optind++; 462 return true; 463 } 464 } 465 466 return false; 467 } 468 447 469 static int handle_create(hr_t *hr, int argc, char **argv) 448 470 { 449 471 int rc; 450 uint8_t v ol_flags = 0;472 uint8_t vflags = 0; 451 473 452 474 if (optind >= argc) { … … 455 477 } 456 478 457 if (str_cmp(argv[optind], "--no_meta") == 0) { 458 vol_flags |= HR_VOL_FLAG_NOOP_META; 459 optind++; 460 } 479 uint8_t test_flags = HR_VOL_FLAG_NOOP_META | HR_VOL_FLAG_READ_ONLY; 480 while (try_to_get_additional_flags(argc, argv, test_flags, &vflags)) 481 ; 461 482 462 483 if (str_cmp(argv[optind], "-f") == 0) { … … 474 495 } 475 496 476 rc = create_from_config(hr, config_path, v ol_flags);497 rc = create_from_config(hr, config_path, vflags); 477 498 } else { 478 rc = create_from_argv(hr, argc, argv, v ol_flags);499 rc = create_from_argv(hr, argc, argv, vflags); 479 500 } 480 501 … … 482 503 } 483 504 484 static int assemble_from_config(hr_t *hr, const char *config_path) 505 static int assemble_from_config(hr_t *hr, const char *config_path, 506 uint8_t vflags) 485 507 { 486 508 hr_config_t *vol_configs = NULL; … … 496 518 for (size_t i = 0; i < vol_count; i++) { 497 519 size_t tmpcnt = 0; 520 vol_configs[i].vol_flags = vflags; 498 521 (void)hr_assemble(hr, &vol_configs[i], &tmpcnt); 499 522 cnt += tmpcnt; … … 506 529 } 507 530 508 static int assemble_from_argv(hr_t *hr, int argc, char **argv )531 static int assemble_from_argv(hr_t *hr, int argc, char **argv, uint8_t vflags) 509 532 { 510 533 hr_config_t *vol_config = calloc(1, sizeof(hr_config_t)); … … 513 536 return ENOMEM; 514 537 } 538 539 vol_config->vol_flags = vflags; 515 540 516 541 errno_t rc = fill_config_devs(argc, argv, vol_config); … … 551 576 } 552 577 578 uint8_t vflags = 0; 579 uint8_t test_flags = HR_VOL_FLAG_NOOP_META | HR_VOL_FLAG_READ_ONLY; 580 while (try_to_get_additional_flags(argc, argv, test_flags, &vflags)) 581 ; 582 583 if (test_flags & HR_VOL_FLAG_NOOP_META) 584 printf(NAME ": assembling, --no-meta flag will be ignored\n"); 585 553 586 if (str_cmp(argv[optind], "-f") == 0) { 554 587 if (++optind >= argc) { … … 563 596 } 564 597 565 rc = assemble_from_config(hr, config_path );598 rc = assemble_from_config(hr, config_path, vflags); 566 599 } else { 567 rc = assemble_from_argv(hr, argc, argv );600 rc = assemble_from_argv(hr, argc, argv, vflags); 568 601 } 569 602 … … 658 691 printf("| metadata type: %s\n", 659 692 hr_get_metadata_type_str(info->meta_type)); 693 694 printf("| vflags: "); 695 for (size_t v = 0; v < HR_VOL_FLAG_COUNT; v++) { 696 if (info->vflags & (1 << v)) { 697 printf("%s ", 698 hr_get_vol_flag_str(info->vflags & (1 << v))); 699 } 700 } 701 printf("\n"); 702 660 703 printf("| level: %s\n", hr_get_level_str(info->level)); 661 704 if (info->layout != HR_LAYOUT_NONE)
Note:
See TracChangeset
for help on using the changeset viewer.