Changeset 3185 in MondoRescue for branches/3.0/mondo/src/common/libmondo-mountlist.c
- Timestamp:
- Sep 20, 2013, 2:29:57 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/common/libmondo-mountlist.c
r3060 r3185 72 72 /*@ initialize ***************************************************** */ 73 73 prev_part_no = 0; 74 mr_asprintf( &flaws_str, "%s", "");74 mr_asprintf(flaws_str, "%s", ""); 75 75 76 76 … … 78 78 79 79 if (physical_drive_size < 0) { 80 mr_asprintf( &tmp, " %s does not exist.", drive);80 mr_asprintf(tmp, " %s does not exist.", drive); 81 81 mr_strcat(flaws_str, "%s", tmp); 82 82 } else { 83 mr_asprintf( &tmp, "%s is %ld MB", drive, physical_drive_size);83 mr_asprintf(tmp, "%s is %ld MB", drive, physical_drive_size); 84 84 } 85 85 log_it(tmp); … … 103 103 /* is it too big? */ 104 104 if (curr_part_no > 'h') { 105 mr_asprintf( &tmp, " Can only have up to 'h' in disklabel.");105 mr_asprintf(tmp, " Can only have up to 'h' in disklabel."); 106 106 log_it(tmp); 107 107 mr_strcat(flaws_str, tmp); … … 117 117 } 118 118 if (device_copies > 1) { 119 mr_asprintf( &tmp, " %s %s's.", number_to_text(device_copies), device);119 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device); 120 120 if (!strstr(flaws_str, tmp)) { 121 121 log_it(tmp); … … 128 128 if (mountlist->el[pos].size < 8192 129 129 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 130 mr_asprintf( &tmp, " %s is tiny!", device);130 mr_asprintf(tmp, " %s is tiny!", device); 131 131 log_it(tmp); 132 132 mr_strcat(flaws_str, tmp); … … 141 141 && strcmp(mountlist->el[pos].mountpoint, "none") 142 142 && mountlist->el[pos].mountpoint[0] != '/') { 143 mr_asprintf( &tmp, " %s has a weird mountpoint.", device);143 mr_asprintf(tmp, " %s has a weird mountpoint.", device); 144 144 log_it(tmp); 145 145 mr_strcat(flaws_str, tmp); … … 149 149 /* is format sensible? */ 150 150 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 151 mr_asprintf( &tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);151 mr_asprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 152 152 log_it(tmp); 153 153 mr_strcat(flaws_str, tmp); … … 181 181 if (curr_part_no - prev_part_no > 1) { 182 182 if (prev_part_no == 0) { 183 mr_asprintf( &tmp, " Gap prior to %s.", device);183 mr_asprintf(tmp, " Gap prior to %s.", device); 184 184 log_it(tmp); 185 185 mr_strcat(flaws_str, "%s", tmp); … … 188 188 } else if (curr_part_no > 5 189 189 || (curr_part_no <= 4 && prev_part_no > 0)) { 190 mr_asprintf( &tmp, " Gap between %ss%d and %d.", drive, prev_part_no, curr_part_no);190 mr_asprintf(tmp, " Gap between %ss%d and %d.", drive, prev_part_no, curr_part_no); 191 191 log_it(tmp); 192 192 mr_strcat(flaws_str, "%s", tmp); … … 200 200 if ((curr_part_no >= 5 && prev_part_no == 4) 201 201 && (strcmp(part_table_fmt, "MBR") == 0)) { 202 mr_asprintf( &tmp, " Partition %ss4 is occupied.", drive);202 mr_asprintf(tmp, " Partition %ss4 is occupied.", drive); 203 203 log_it(tmp); 204 204 mr_strcat(flaws_str, "%s", tmp); … … 214 214 } 215 215 if (device_copies > 1) { 216 mr_asprintf( &tmp, " %s %s's.", number_to_text(device_copies), device);216 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device); 217 217 if (!strstr(flaws_str, "%s", tmp)) { 218 218 log_it(tmp); … … 225 225 if (mountlist->el[pos].size < 8192 226 226 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 227 mr_asprintf( &tmp, " %s is tiny!", device);227 mr_asprintf(tmp, " %s is tiny!", device); 228 228 log_it(tmp); 229 229 mr_strcat(flaws_str, "%s", tmp); … … 238 238 && strcmp(mountlist->el[pos].mountpoint, "none") 239 239 && mountlist->el[pos].mountpoint[0] != '/') { 240 mr_asprintf( &tmp, " %s has a weird mountpoint.", device);240 mr_asprintf(tmp, " %s has a weird mountpoint.", device); 241 241 log_it(tmp); 242 242 mr_strcat(flaws_str, "%s", tmp); … … 246 246 /* is format sensible? */ 247 247 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 248 mr_asprintf( &tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);248 mr_asprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 249 249 log_it(tmp); 250 250 mr_strcat(flaws_str, "%s", tmp); … … 263 263 /* is it too big? */ 264 264 if (curr_part_no > 'h') { 265 mr_asprintf( &tmp, " Can only have up to 'h' in disklabel.");265 mr_asprintf(tmp, " Can only have up to 'h' in disklabel."); 266 266 log_it(tmp); 267 267 mr_strcat(flaws_str, "%s", tmp); … … 277 277 } 278 278 if (device_copies > 1) { 279 mr_asprintf( &tmp, " %s %s's.", number_to_text(device_copies), device);279 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device); 280 280 if (!strstr(flaws_str, tmp)) { 281 281 log_it(tmp); … … 288 288 if (mountlist->el[pos].size < 8192 289 289 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 290 mr_asprintf( &tmp, " %s is tiny!", device);290 mr_asprintf(tmp, " %s is tiny!", device); 291 291 log_it(tmp); 292 292 mr_strcat(flaws_str, "%s", tmp); … … 301 301 && strcmp(mountlist->el[pos].mountpoint, "none") 302 302 && mountlist->el[pos].mountpoint[0] != '/') { 303 mr_asprintf( &tmp, " %s has a weird mountpoint.", device);303 mr_asprintf(tmp, " %s has a weird mountpoint.", device); 304 304 log_it(tmp); 305 305 mr_strcat(flaws_str, "%s", tmp); … … 310 310 if (!is_this_a_valid_disk_format 311 311 (mountlist->el[pos].format)) { 312 mr_asprintf( &tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);312 mr_asprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 313 313 log_it(tmp); 314 314 mr_strcat(flaws_str, "%s", tmp); … … 327 327 if (amount_allocated > physical_drive_size) { 328 328 // Used to be +1, but what if you're 1 MB too high? 329 mr_asprintf( &tmp, " %ld MB over-allocated on %s.",329 mr_asprintf(tmp, " %ld MB over-allocated on %s.", 330 330 amount_allocated - physical_drive_size, drive); 331 331 log_it(tmp); … … 349 349 /* Over-allocated the disk? Unallocated space on disk? */ 350 350 if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 351 mr_asprintf( &tmp, " %ld MB unallocated on %s.",351 mr_asprintf(tmp, " %ld MB unallocated on %s.", 352 352 physical_drive_size - amount_allocated, drive); 353 353 log_it(tmp); … … 389 389 assert_string_is_neither_NULL_nor_zerolength(drive); 390 390 assert(mountlist != NULL); 391 mr_asprintf( &flaws_str, "%s", "");391 mr_asprintf(flaws_str, "%s", ""); 392 392 393 393 malloc_string(device); … … 398 398 if (physical_drive_size < 0) { 399 399 if (strstr(drive,"/dev/dm-") == NULL) { 400 mr_asprintf( &tmp, " %s does not exist.", drive);400 mr_asprintf(tmp, " %s does not exist.", drive); 401 401 log_it(tmp); 402 402 mr_strcat(flaws_str, "%s", tmp); … … 405 405 goto endoffunc; 406 406 } else { 407 mr_asprintf( &tmp, " %s (dm) will be setup later on", drive);407 mr_asprintf(tmp, " %s (dm) will be setup later on", drive); 408 408 log_it(tmp); 409 409 mr_free(tmp); 410 410 } 411 411 } else { 412 mr_asprintf( &tmp, "%s is %ld MB", drive, physical_drive_size);412 mr_asprintf(tmp, "%s is %ld MB", drive, physical_drive_size); 413 413 log_it(tmp); 414 414 mr_free(tmp); … … 425 425 if (curr_part_no - prev_part_no > 1) { 426 426 if (prev_part_no == 0) { 427 mr_asprintf( &tmp, " Gap prior to %s.", device);427 mr_asprintf(tmp, " Gap prior to %s.", device); 428 428 log_it(tmp); 429 429 mr_strcat(flaws_str, "%s", tmp); … … 432 432 } else if (curr_part_no > 5 433 433 || (curr_part_no <= 4 && prev_part_no > 0)) { 434 mr_asprintf( &tmp, " Gap on %s between %d and %d.", drive,434 mr_asprintf(tmp, " Gap on %s between %d and %d.", drive, 435 435 prev_part_no, curr_part_no); 436 436 log_it(tmp); … … 445 445 if ((curr_part_no >= 5 && prev_part_no == 4) 446 446 && (strcmp(part_table_fmt, "MBR") == 0)) { 447 mr_asprintf( &tmp, " Partition 4 of %s is occupied.", drive);447 mr_asprintf(tmp, " Partition 4 of %s is occupied.", drive); 448 448 log_it(tmp); 449 449 mr_strcat(flaws_str, "%s", tmp); … … 459 459 } 460 460 if (device_copies > 1) { 461 mr_asprintf( &tmp, " %s %s's.", number_to_text(device_copies),461 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), 462 462 device); 463 463 if (!strstr(flaws_str, tmp)) { … … 471 471 if (mountlist->el[pos].size < 8192 472 472 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 473 mr_asprintf( &tmp, " %s is tiny!", device);473 mr_asprintf(tmp, " %s is tiny!", device); 474 474 log_it(tmp); 475 475 mr_strcat(flaws_str, "%s", tmp); … … 483 483 && strcmp(mountlist->el[pos].mountpoint, "image") 484 484 && mountlist->el[pos].mountpoint[0] != '/') { 485 mr_asprintf( &tmp, " %s has a weird mountpoint.", device);485 mr_asprintf(tmp, " %s has a weird mountpoint.", device); 486 486 log_it(tmp); 487 487 mr_strcat(flaws_str, "%s", tmp); … … 491 491 /* is format sensible? */ 492 492 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 493 mr_asprintf( &tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);493 mr_asprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 494 494 log_it(tmp); 495 495 mr_strcat(flaws_str, "%s", tmp); … … 504 504 /* Over-allocated the disk? Unallocated space on disk? */ 505 505 if (amount_allocated > physical_drive_size + 1) { 506 mr_asprintf( &tmp, " %ld MB over-allocated on %s.",506 mr_asprintf(tmp, " %ld MB over-allocated on %s.", 507 507 amount_allocated - physical_drive_size, drive); 508 508 log_it(tmp); … … 511 511 res++; 512 512 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 513 mr_asprintf( &tmp, " %ld MB unallocated on %s.",513 mr_asprintf(tmp, " %ld MB unallocated on %s.", 514 514 physical_drive_size - amount_allocated, drive); 515 515 log_it(tmp); … … 570 570 (drivelist->el[i].device, 571 571 DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) { 572 mr_asprintf( &tmp, " Not evaluating %s (I don't know how yet)", drivelist->el[i].device);572 mr_asprintf(tmp, " Not evaluating %s (I don't know how yet)", drivelist->el[i].device); 573 573 log_it(tmp); 574 574 paranoid_free(tmp); … … 588 588 /* Look for duplicate mountpoints in mountlist. */ 589 589 for (currline = 0; currline < mountlist->entries; currline++) { 590 mr_asprintf( &curr_mountpoint, "%s", mountlist->el[currline].mountpoint);590 mr_asprintf(curr_mountpoint, "%s", mountlist->el[currline].mountpoint); 591 591 for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries; i++) { 592 592 if (!strcmp(mountlist->el[i].mountpoint, curr_mountpoint) … … 599 599 if (copies > 1 && last_copy == currline 600 600 && strcmp(curr_mountpoint, "raid")) { 601 mr_asprintf( &tmp, " %s %s's.", number_to_text(copies), curr_mountpoint);601 mr_asprintf(tmp, " %s %s's.", number_to_text(copies), curr_mountpoint); 602 602 mr_strcat(flaws_str, "%s", tmp); 603 603 log_msg(8,"Adding: %s to flaws_str", tmp); … … 666 666 for (lino = 0, noof_drives = 0; lino < mountlist->entries; lino++) { 667 667 668 mr_asprintf( &drive, "%s", mountlist->el[lino].device);668 mr_asprintf(drive, "%s", mountlist->el[lino].device); 669 669 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { 670 670 log_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive); … … 753 753 (void *) &mountlist->el[i], 754 754 sizeof(struct mountlist_line)); 755 mr_asprintf( &tmp, "%s is available; user may choose to add it to raid device", output_list->el[items - 1].device);755 mr_asprintf(tmp, "%s is available; user may choose to add it to raid device", output_list->el[items - 1].device); 756 756 log_it(tmp); 757 757 paranoid_free(tmp); … … 874 874 if (j < items) { 875 875 strcat(mountlist->el[items].device, "_dup"); 876 mr_asprintf( &tmp, "Duplicate entry in mountlist - renaming to %s", mountlist->el[items].device);876 mr_asprintf(tmp, "Duplicate entry in mountlist - renaming to %s", mountlist->el[items].device); 877 877 log_it(tmp); 878 878 paranoid_free(tmp); 879 879 } 880 mr_asprintf( &tmp, "%s", mountlist->el[items].device);880 mr_asprintf(tmp, "%s", mountlist->el[items].device); 881 881 if (strstr(tmp, "/dev/md/")) { 882 882 log_it("format_device() --- Contracting %s", tmp); … … 1033 1033 assert(b >= 0); 1034 1034 1035 mr_asprintf( &device, "%s", mountlist->el[a].device);1036 mr_asprintf( &mountpoint, "%s", mountlist->el[a].mountpoint);1037 mr_asprintf( &format, "%s", mountlist->el[a].format);1035 mr_asprintf(device, "%s", mountlist->el[a].device); 1036 mr_asprintf(mountpoint, "%s", mountlist->el[a].mountpoint); 1037 mr_asprintf(format, "%s", mountlist->el[a].format); 1038 1038 1039 1039 size = mountlist->el[a].size;
Note:
See TracChangeset
for help on using the changeset viewer.