Changeset 1080 in MondoRescue for branches/stable/mondo/src/common/libmondo-raid.c
- Timestamp:
- Jan 28, 2007, 7:04:41 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-raid.c
r1075 r1080 18 18 #include "libmondo-raid.h" 19 19 #include "mr_str.h" 20 #include "mr_mem.h" 20 21 21 22 #ifdef __FreeBSD__ … … 49 50 int res; 50 51 51 command = m alloc(MAX_STR_LEN * 2);52 command = mr_malloc(MAX_STR_LEN * 2); 52 53 strcpy(command, "grep \" /proc/mdstat"); 53 54 if (raidno == -1) { … … 59 60 log_it("Is raid %d registered? Command = '%s'", raidno, command); 60 61 res = system(command); 61 paranoid_free(command);62 mr_free(command); 62 63 if (res) { 63 64 return (FALSE); … … 200 201 strcpy(raidrec->additional_vars.el[lino].label, label); 201 202 strcpy(raidrec->additional_vars.el[lino].value, sz_value); 202 paranoid_free(sz_value);203 mr_free(sz_value); 203 204 } 204 205 #endif … … 436 437 label[0] = value[0] = '\0'; 437 438 if (feof(fin)) { 438 paranoid_free(incoming);439 mr_free(incoming); 439 440 return (1); 440 441 } … … 452 453 strcpy(label, incoming); 453 454 strcpy(value, p); 454 paranoid_free(incoming);455 mr_free(incoming); 455 456 return (0); 456 457 } … … 480 481 log_it("Raidtab is very small or non-existent. Ignoring it."); 481 482 raidlist->entries = 0; 482 paranoid_free(tmp);483 mr_free(tmp); 483 484 return (0); 484 485 } 485 486 if (!(fin = fopen(fname, "r"))) { 486 487 log_it("Cannot open raidtab"); 487 paranoid_free(tmp);488 mr_free(tmp); 488 489 return (1); 489 490 } … … 590 591 sprintf(tmp, "%d RAID devices in raidtab", raidlist->entries); 591 592 log_it(tmp); 592 paranoid_free(tmp);593 mr_free(tmp); 593 594 return (0); 594 595 } … … 616 617 log_it("Raidtab is very small or non-existent. Ignoring it."); 617 618 raidlist->entries = 0; 618 paranoid_free(tmp);619 paranoid_free(label);620 paranoid_free(value);619 mr_free(tmp); 620 mr_free(label); 621 mr_free(value); 621 622 return (0); 622 623 } 623 624 if (!(fin = fopen(fname, "r"))) { 624 625 log_it("Cannot open raidtab"); 625 paranoid_free(tmp);626 paranoid_free(label);627 paranoid_free(value);626 mr_free(tmp); 627 mr_free(label); 628 mr_free(value); 628 629 return (1); 629 630 } … … 661 662 log_msg(1, "Raidtab loaded successfully."); 662 663 log_msg(1, "%d RAID devices in raidtab", items); 663 paranoid_free(tmp);664 paranoid_free(label);665 paranoid_free(value);664 mr_free(tmp); 665 mr_free(label); 666 mr_free(value); 666 667 return (0); 667 668 } … … 762 763 raidrec->additional_vars.entries = ++v; 763 764 } 764 paranoid_free(tmp);765 paranoid_free(labelB);766 paranoid_free(valueB);765 mr_free(tmp); 766 mr_free(labelB); 767 mr_free(valueB); 767 768 } 768 769 #endif … … 820 821 static char *argv[64]; 821 822 char **ap; 822 char *line = (char *) malloc(MAX_STR_LEN); 823 if (!line) 824 errx(1, 825 "unable to allocate %i bytes of memory for `char *line' at %s:%i", 826 MAX_STR_LEN, __FILE__, __LINE__); 823 char *line = (char *) mr_malloc(MAX_STR_LEN); 827 824 (void) fgets(line, MAX_STR_LEN, f); 828 825 if (feof(f)) { … … 868 865 int i, j; 869 866 static char **ret; 870 ret = (char **) m alloc(nval * sizeof(char *));867 ret = (char **) mr_malloc(nval * sizeof(char *)); 871 868 for (i = 0; i < (argc - nval); ++i) { 872 869 if (!strcmp(argv[i], option)) { 873 870 for (j = 0; j < nval; ++j) { 874 ret[j] = (char *) m alloc(strlen(argv[i + j + 1]) + 1);871 ret[j] = (char *) mr_malloc(strlen(argv[i + j + 1]) + 1); 875 872 strcpy(ret[j], argv[i + j + 1]); 876 873 } … … 1014 1011 asprintf(&strtmp, pos); 1015 1012 strcpy(string, strtmp); 1016 paranoid_free(strtmp);1013 mr_free(strtmp); 1017 1014 // if we have newline after only spaces, this is a blank line, update 1018 1015 // counters, otherwise do normal parsing … … 1035 1032 asprintf(&strtmp,"%s%s", device_prefix, token); 1036 1033 strcpy(raidlist->el[raidlist->entries].raid_device, strtmp); 1037 paranoid_free(strtmp);1038 paranoid_free(token);1034 mr_free(strtmp); 1035 mr_free(token); 1039 1036 // skip ':' and status 1040 1037 token = mr_strtok (string, delims, &lastpos); 1041 paranoid_free(token);1038 mr_free(token); 1042 1039 token = mr_strtok (string, delims, &lastpos); 1043 1040 if (!strcmp(token, "inactive")) { 1044 1041 log_msg(1, "RAID device '%s' inactive.\n", 1045 1042 raidlist->el[raidlist->entries].raid_device); 1046 paranoid_free(string);1047 paranoid_free(token);1043 mr_free(string); 1044 mr_free(token); 1048 1045 return 1; 1049 1046 } 1050 paranoid_free(token);1047 mr_free(token); 1051 1048 1052 1049 // get RAID level … … 1070 1067 } else { 1071 1068 log_msg(1, "Unknown RAID level '%s'.\n", token); 1072 paranoid_free(string);1073 paranoid_free(token);1069 mr_free(string); 1070 mr_free(token); 1074 1071 return 1; 1075 1072 } 1076 paranoid_free(token);1073 mr_free(token); 1077 1074 1078 1075 // get RAID devices (type, index, device) … … 1094 1091 asprintf(&strtmp,"%s%s", device_prefix, token); 1095 1092 strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp); 1096 paranoid_free(strtmp);1093 mr_free(strtmp); 1097 1094 raidlist->el[raidlist->entries].data_disks.entries++; 1098 1095 break; … … 1101 1098 asprintf(&strtmp,"%s%s", device_prefix, token); 1102 1099 strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp); 1103 paranoid_free(strtmp);1100 mr_free(strtmp); 1104 1101 raidlist->el[raidlist->entries].spare_disks.entries++; 1105 1102 break; … … 1108 1105 asprintf(&strtmp,"%s%s", device_prefix, token); 1109 1106 strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp); 1110 paranoid_free(strtmp);1107 mr_free(strtmp); 1111 1108 raidlist->el[raidlist->entries].failed_disks.entries++; 1112 1109 log_it("At least one failed disk found in RAID array.\n"); … … 1114 1111 default: // error 1115 1112 log_msg(1, "Unknown device type '%c'\n", type); 1116 paranoid_free(string);1117 paranoid_free(token);1113 mr_free(string); 1114 mr_free(token); 1118 1115 return 1; 1119 1116 break; 1120 1117 } 1121 paranoid_free(token);1118 mr_free(token); 1122 1119 } 1123 1120 … … 1172 1169 if (pos < string) { 1173 1170 log_it("String underflow!\n"); 1174 paranoid_free(string);1171 mr_free(string); 1175 1172 return 1; 1176 1173 } … … 1197 1194 if (pos < string) { 1198 1195 printf("ERROR: String underflow!\n"); 1199 paranoid_free(string);1196 mr_free(string); 1200 1197 return 1; 1201 1198 } … … 1214 1211 fclose(fin); 1215 1212 // free string 1216 paranoid_free(string);1213 mr_free(string); 1217 1214 // return success 1218 1215 return 0; … … 1228 1225 int retval = 0; 1229 1226 1230 raidlist = m alloc(sizeof(struct raidlist_itself));1227 raidlist = mr_malloc(sizeof(struct raidlist_itself)); 1231 1228 1232 1229 // FIXME: Prefix '/dev/' should really be dynamic!
Note:
See TracChangeset
for help on using the changeset viewer.