Changeset 45 in MondoRescue for trunk/mondo/mondo/common/libmondo-raid.c
- Timestamp:
- Oct 5, 2005, 12:51:47 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-raid.c
r43 r45 1 /* subroutines for handling RAID2 $Id$1 /* $Id$ 2 subroutines for handling RAID 3 3 */ 4 4 … … 48 48 49 49 if (raidno == -1) { 50 asprintf(&command, "cat /proc/mdstat | grep \"linear\" > /dev/null 2> /dev/null"); 50 asprintf(&command, 51 "cat /proc/mdstat | grep \"linear\" > /dev/null 2> /dev/null"); 51 52 } else { 52 asprintf(&command, "cat /proc/mdstat | grep \"raid%d\" > /dev/null 2> /dev/null", raidno); 53 asprintf(&command, 54 "cat /proc/mdstat | grep \"raid%d\" > /dev/null 2> /dev/null", 55 raidno); 53 56 } 54 57 log_it("Is raid %d registered? Command = '%s'", raidno, command); … … 62 65 #endif 63 66 } 67 64 68 65 69 /** … … 378 382 int get_next_raidtab_line(FILE * fin, char *label, char *value) 379 383 { 380 char *incoming ;384 char *incoming = NULL; 381 385 char *p; 386 size_t n = 0; 382 387 383 388 assert(fin != NULL); … … 390 395 } 391 396 392 malloc_string(incoming); 393 for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin); 394 fgets(incoming, MAX_STR_LEN - 1, fin)) { 397 for (getline(&incoming, &n, fin); !feof(fin); 398 getline(&incoming, &n, fin)) { 395 399 strip_spaces(incoming); 396 400 p = strchr(incoming, ' '); … … 555 559 int v; 556 560 557 malloc_string(label);558 malloc_string(value);559 561 assert(raidlist != NULL); 560 562 assert_string_is_neither_NULL_nor_zerolength(fname); … … 563 565 log_it("Raidtab is very small or non-existent. Ignoring it."); 564 566 raidlist->entries = 0; 565 paranoid_free(label);566 paranoid_free(value);567 567 return (0); 568 568 } 569 569 if (!(fin = fopen(fname, "r"))) { 570 570 log_it("Cannot open raidtab"); 571 paranoid_free(label);572 paranoid_free(value);573 571 return (1); 574 572 } 575 573 items = 0; 576 574 log_it("Loading raidtab..."); 575 malloc_string(label); 576 malloc_string(value); 577 577 get_next_raidtab_line(fin, label, value); 578 578 while (!feof(fin)) { … … 671 671 if (!disklist) { 672 672 asprintf(&tmp, 673 "Ignoring '%s %s' pair of disk %s", labelB, valueB,674 label);673 "Ignoring '%s %s' pair of disk %s", labelB, valueB, 674 label); 675 675 log_it(tmp); 676 676 paranoid_free(tmp); … … 904 904 char *tmp; 905 905 char *stub; 906 char *incoming ;906 char *incoming = NULL; 907 907 char *raid_devname; 908 908 char *p, *q, *r; 909 909 int diskno; 910 size_t n = 0; 910 911 911 912 malloc_string(incoming); … … 915 916 } 916 917 mdstat->entries = 0; 917 for ( fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);918 fgets(incoming, MAX_STR_LEN - 1, fin)) {918 for (getline(&incoming, &n, fin); !feof(fin); 919 getline(&incoming, &n, fin)) { 919 920 p = incoming; 920 921 if (*p != 'm' && *(p + 1) == 'm') { … … 964 965 asprintf(&tmp, "/dev/%s", stub); 965 966 paranoid_free(stub); 967 966 968 log_msg(8, "/dev/md%d : disk#%d : %s (%d)", 967 969 mdstat->el[mdstat->entries].md, diskno, tmp, 968 970 mdstat->el[mdstat->entries].disks.el[diskno].index); 969 strcpy(mdstat->el[mdstat->entries].disks.el[diskno].device, tmp); 971 strcpy(mdstat->el[mdstat->entries].disks.el[diskno].device, 972 tmp); 970 973 paranoid_free(tmp); 974 971 975 while (*p != ' ' && *p) { 972 976 p++; … … 979 983 // next line --- skip it 980 984 if (!feof(fin)) { 981 fgets(incoming, MAX_STR_LEN - 1, fin);985 getline(&incoming, &n, fin); 982 986 } else { 983 987 continue; … … 985 989 // next line --- the 'progress' line 986 990 if (!feof(fin)) { 987 fgets(incoming, MAX_STR_LEN - 1, fin);991 getline(&incoming, &n, fin); 988 992 } else { 989 993 continue; … … 1042 1046 1043 1047 1044 1045 1048 /* @} - end of raidGroup */
Note:
See TracChangeset
for help on using the changeset viewer.