Changeset 689 in MondoRescue for trunk/mondo/mondo/common/libmondo-raid.c
- Timestamp:
- Jul 17, 2006, 7:43:58 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-raid.c
r688 r689 403 403 * @return 0 if the line was read and stored successfully, 1 if we're at end of file. 404 404 */ 405 int get_next_raidtab_line(FILE * 405 int get_next_raidtab_line(FILE *fin, char *label, char *value) 406 406 { 407 407 char *incoming = NULL; 408 char *p ;408 char *p = NULL; 409 409 size_t n = 0; 410 410 411 411 assert(fin != NULL); 412 assert(label != NULL); 413 assert(value != NULL); 414 415 label[0] = value[0] = '\0'; 412 416 413 if (feof(fin)) { 417 414 return (1); … … 429 426 p++; 430 427 } 431 strcpy(label, incoming); 432 strcpy(value, p); 433 paranoid_free(incoming); 428 label = incoming; 429 value = p; 434 430 return (0); 435 431 } … … 576 572 char *fname) 577 573 { 578 FILE *fin ;579 char *label ;580 char *value ;574 FILE *fin = NULL; 575 char *label = NULL; 576 char *value = NULL; 581 577 int items; 582 578 int v; … … 596 592 items = 0; 597 593 log_it("Loading raidtab..."); 598 malloc_string(label);599 malloc_string(value);600 594 get_next_raidtab_line(fin, label, value); 601 595 while (!feof(fin)) { … … 605 599 /* find the 'raiddev' entry, indicating the start of the block of info */ 606 600 while (!feof(fin) && strcmp(label, "raiddev")) { 607 strcpy(raidlist->el[items].additional_vars.el[v].label, label);608 strcpy(raidlist->el[items].additional_vars.el[v].value, value);601 raidlist->el[items].additional_vars.el[v].label = label; 602 raidlist->el[items].additional_vars.el[v].value = value; 609 603 v++; 610 604 get_next_raidtab_line(fin, label, value); … … 616 610 } 617 611 log_msg(2, "Record #%d (%s) found", items, value); 618 strcpy(raidlist->el[items].raid_device, value);612 raidlist->el[items].raid_device = value; 619 613 for (get_next_raidtab_line(fin, label, value); 620 614 !feof(fin) && strcmp(label, "raiddev"); … … 628 622 log_msg(1, "Raidtab loaded successfully."); 629 623 log_msg(1, "%d RAID devices in raidtab", items); 630 paranoid_free(label);631 paranoid_free(value);632 624 return (0); 633 625 } … … 644 636 */ 645 637 void 646 process_raidtab_line(FILE * 638 process_raidtab_line(FILE *fin, 647 639 struct raid_device_record *raidrec, 648 640 char *label, char *value) … … 650 642 651 643 /*@ add mallocs * */ 652 char *tmp; 653 char *labelB; 654 char *valueB; 655 656 struct list_of_disks *disklist; 657 int index; 658 int v; 659 660 malloc_string(labelB); 661 malloc_string(valueB); 644 char *tmp = NULL; 645 char *labelB = NULL; 646 char *valueB = NULL; 647 648 struct list_of_disks *disklist = NULL; 649 int index = 0; 650 int v = 0; 651 662 652 assert(fin != NULL); 663 653 assert(raidrec != NULL); … … 716 706 add_disk_to_raid_device(disklist, value, index); 717 707 } 708 paranoid_free(labelB); 709 paranoid_free(valueB); 718 710 } else { 719 711 v = raidrec->additional_vars.entries; 720 strcpy(raidrec->additional_vars.el[v].label, label);721 strcpy(raidrec->additional_vars.el[v].value, value);712 raidrec->additional_vars.el[v].label = label; 713 raidrec->additional_vars.el[v].value = value; 722 714 raidrec->additional_vars.entries = ++v; 723 715 } 724 paranoid_free(labelB);725 paranoid_free(valueB);726 716 } 727 717 #endif
Note:
See TracChangeset
for help on using the changeset viewer.