Changeset 2211 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-raid.c
- Timestamp:
- Jun 3, 2009, 7:10:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-raid.c
r2190 r2211 1 1 /* libmondo-raid.c subroutines for handling RAID 2 2 $Id$ 3 .4 5 6 06/297 - added create_raidtab_from_mdstat()8 - changed char[MAX_STR_LEN] to char*9 10 10/21/200311 - get_next_raidtab_line() --- correctly handle multiple spaces12 between label and value13 14 07/0315 - line 447 - changed assert()16 17 05/0818 - cleaned up some FreeBSd-specific stuff19 20 05/0521 - added Joshua Oreman's FreeBSD patches22 23 04/2524 - added a bunch of RAID utilities from mondorestore/mondo-restore.c25 26 04/24/200327 - added some assert()'s and log_OS_error()'s28 29 10/19/200230 - added some comments31 32 07/2433 - created34 3 */ 35 4 … … 49 18 #include "libmondo-raid.h" 50 19 #include "mr_string.h" 20 #include "mr_mem.h" 51 21 52 22 #ifdef __FreeBSD__ … … 77 47 #else 78 48 /*@ buffer ********************************************************** */ 79 char *command ;49 char *command = NULL; 80 50 int res; 81 51 82 command = malloc(MAX_STR_LEN * 2); 83 strcpy(command, "grep \""); 52 mr_asprintf(&command, "grep \""); 84 53 if (raidno == -1) { 85 strcat(command, "linear");54 mr_strcat(command, "linear"); 86 55 } else { 87 sprintf(command + strlen(command), "raid%d", raidno);88 } 89 strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null");56 mr_strcat(command, "raid%d", raidno); 57 } 58 mr_strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null"); 90 59 log_it("Is raid %d registered? Command = '%s'", raidno, command); 91 60 res = system(command); 92 61 paranoid_free(command); 62 93 63 if (res) { 94 64 return (FALSE); … … 1043 1013 pos = string; 1044 1014 while (*pos == ' ') pos += 1; 1045 asprintf(&strtmp, "%s", pos);1015 mr_asprintf(&strtmp, "%s", pos); 1046 1016 strcpy(string, strtmp); 1047 1017 paranoid_free(strtmp); … … 1064 1034 token = mr_strtok (string, delims, &lastpos); 1065 1035 // get RAID device name 1066 asprintf(&strtmp,"%s%s", device_prefix, token);1036 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1067 1037 strcpy(raidlist->el[raidlist->entries].raid_device, strtmp); 1068 1038 paranoid_free(strtmp); … … 1123 1093 case ' ': // normal data disks 1124 1094 raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1); 1125 asprintf(&strtmp,"%s%s", device_prefix, token);1095 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1126 1096 strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp); 1127 1097 paranoid_free(strtmp); … … 1130 1100 case 'S': // spare disks 1131 1101 raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1); 1132 asprintf(&strtmp,"%s%s", device_prefix, token);1102 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1133 1103 strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp); 1134 1104 paranoid_free(strtmp); … … 1137 1107 case 'F': // failed disks 1138 1108 raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1); 1139 asprintf(&strtmp,"%s%s", device_prefix, token);1109 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1140 1110 strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp); 1141 1111 paranoid_free(strtmp);
Note:
See TracChangeset
for help on using the changeset viewer.