Changeset 2207 in MondoRescue
- Timestamp:
- May 15, 2009, 3:59:12 AM (16 years ago)
- Location:
- branches/2.2.9/mondo/src
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-mountlist.c
r2206 r2207 10 10 11 11 #include "my-stuff.h" 12 #include "mr_str.h" 12 13 #include "mondostructures.h" 13 14 #include "libmondo-mountlist.h" … … 37 38 * @param mountlist The mountlist to check. 38 39 * @param drive The drive to check (e.g. @c /dev/hda). 39 * @param flaws_str Where to put the found flaws (human-readable). 40 * @return The number of flaws found (0 for success). 40 * @return The flaws string found (NULL for success) allocated to be freed 41 41 * @see evaluate_mountlist 42 42 */ 43 int evaluate_drive_within_mountlist(struct mountlist_itself *mountlist, 44 char *drive, char *flaws_str) 43 char *evaluate_drive_within_mountlist(struct mountlist_itself *mountlist, char *drive) 45 44 #ifdef __FreeBSD__ 46 45 { … … 71 70 72 71 /*@ initialize ***************************************************** */ 73 flaws_str[0] = '\0';74 72 prev_part_no = 0; 75 73 tmp[0] = '\0'; … … 80 78 if (physical_drive_size < 0) { 81 79 sprintf(tmp, " %s does not exist.", drive); 82 strcat(flaws_str, tmp);80 asprintf(&flaws_str, "%s", tmp); 83 81 } else { 84 82 sprintf(tmp, "%s is %ld MB", drive, physical_drive_size); … … 105 103 sprintf(tmp, " Can only have up to 'h' in disklabel."); 106 104 log_it(tmp); 107 strcat(flaws_str, tmp);105 mr_strcat(flaws_str, tmp); 108 106 res++; 109 107 } … … 120 118 if (!strstr(flaws_str, tmp)) { 121 119 log_it(tmp); 122 strcat(flaws_str, tmp);120 mr_strcat(flaws_str, tmp); 123 121 res++; 124 122 } … … 129 127 sprintf(tmp, " %s is tiny!", device); 130 128 log_it(tmp); 131 strcat(flaws_str, tmp);129 mr_strcat(flaws_str, tmp); 132 130 res++; 133 131 } … … 141 139 sprintf(tmp, " %s has a weird mountpoint.", device); 142 140 log_it(tmp); 143 strcat(flaws_str, tmp);141 mr_strcat(flaws_str, tmp); 144 142 res++; 145 143 } … … 148 146 sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 149 147 log_it(tmp); 150 strcat(flaws_str, tmp);148 mr_strcat(flaws_str, tmp); 151 149 res++; 152 150 } … … 167 165 } 168 166 if (((pos >= 0) || npos) && foundsome) { 169 sprintf(flaws_str + strlen(flaws_str), 170 " %s has both DD and PC-style partitions.", drive); 167 mr_strcat(flaws_str, " %s has both DD and PC-style partitions.", drive); 171 168 return ++res; // fatal error 172 169 } … … 180 177 sprintf(tmp, " Gap prior to %s.", device); 181 178 log_it(tmp); 182 strcat(flaws_str, tmp);179 mr_strcat(flaws_str, tmp); 183 180 res++; 184 181 } else if (curr_part_no > 5 … … 187 184 prev_part_no, curr_part_no); 188 185 log_it(tmp); 189 strcat(flaws_str, tmp);186 mr_strcat(flaws_str, tmp); 190 187 res++; 191 188 } … … 198 195 sprintf(tmp, " Partition %ss4 is occupied.", drive); 199 196 log_it(tmp); 200 strcat(flaws_str, tmp);197 mr_strcat(flaws_str, tmp); 201 198 res++; 202 199 } … … 213 210 if (!strstr(flaws_str, tmp)) { 214 211 log_it(tmp); 215 strcat(flaws_str, tmp);212 mr_strcat(flaws_str, tmp); 216 213 res++; 217 214 } … … 222 219 sprintf(tmp, " %s is tiny!", device); 223 220 log_it(tmp); 224 strcat(flaws_str, tmp);221 mr_strcat(flaws_str, tmp); 225 222 res++; 226 223 } … … 234 231 sprintf(tmp, " %s has a weird mountpoint.", device); 235 232 log_it(tmp); 236 strcat(flaws_str, tmp);233 mr_strcat(flaws_str, tmp); 237 234 res++; 238 235 } … … 241 238 sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 242 239 log_it(tmp); 243 strcat(flaws_str, tmp);240 mr_strcat(flaws_str, tmp); 244 241 res++; 245 242 } … … 257 254 sprintf(tmp, " Can only have up to 'h' in disklabel."); 258 255 log_it(tmp); 259 strcat(flaws_str, tmp);256 mr_strcat(flaws_str, tmp); 260 257 res++; 261 258 } … … 272 269 if (!strstr(flaws_str, tmp)) { 273 270 log_it(tmp); 274 strcat(flaws_str, tmp);271 mr_strcat(flaws_str, tmp); 275 272 res++; 276 273 } … … 281 278 sprintf(tmp, " %s is tiny!", device); 282 279 log_it(tmp); 283 strcat(flaws_str, tmp);280 mr_strcat(flaws_str, tmp); 284 281 res++; 285 282 } … … 293 290 sprintf(tmp, " %s has a weird mountpoint.", device); 294 291 log_it(tmp); 295 strcat(flaws_str, tmp);292 mr_strcat(flaws_str, tmp); 296 293 res++; 297 294 } … … 301 298 sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 302 299 log_it(tmp); 303 strcat(flaws_str, tmp);300 mr_strcat(flaws_str, tmp); 304 301 res++; 305 302 } … … 320 317 amount_allocated - physical_drive_size, drive); 321 318 log_it(tmp); 322 strcat(flaws_str, tmp);319 mr_strcat(flaws_str, tmp); 323 320 res++; 324 321 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ … … 326 323 physical_drive_size - amount_allocated, drive); 327 324 log_it(tmp); 328 strcat(flaws_str, tmp);325 mr_strcat(flaws_str, tmp); 329 326 } 330 327 if (res) { … … 517 514 518 515 drivelist = malloc(sizeof(struct list_of_disks)); 519 malloc_string(tmp);520 516 malloc_string(flaws_str); 521 517 assert(mountlist != NULL); … … 533 529 (drivelist->el[i].device, 534 530 DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) { 535 sprintf(tmp, " Not evaluating %s (I don't know how yet)",531 asprintf(&tmp, " Not evaluating %s (I don't know how yet)", 536 532 drivelist->el[i].device); 537 533 log_it(tmp); 538 tmp[0] = '\0';534 paranoid_free(tmp); 539 535 } else { 540 if (!evaluate_drive_within_mountlist 541 (mountlist, drivelist->el[i].device, tmp)) { 542 res++; 543 } 544 } 545 strcat(flaws_str, tmp); 536 if ((tmp = evaluate_drive_within_mountlist(mountlist, drivelist->el[i].device)) == NULL) { 537 res++; 538 } 539 } 540 log_msg(8,"Entry: %d (%s)", i, drivelist->el[i].device); 541 log_msg(8,"Adding: %s to %s", tmp, flaws_str); 542 strncat(flaws_str, tmp, MAX_STR_LEN -1); 543 paranoid_free(tmp); 546 544 } 547 545 res += look_for_duplicate_mountpoints(mountlist, flaws_str);
Note:
See TracChangeset
for help on using the changeset viewer.