Changeset 3191 in MondoRescue for branches/3.2/mondo/src/common/libmondo-mountlist.c
- Timestamp:
- Sep 25, 2013, 8:55:45 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mondo/src/common/libmondo-mountlist.c
r3185 r3191 59 59 char tmp = NULL; 60 60 char device[MAX_STR_LEN]; 61 char mountpoint[MAX_STR_LEN];62 61 63 62 char *flaws_str = NULL; … … 100 99 continue; 101 100 } 102 strcpy(mountpoint, mountlist->el[pos].mountpoint);103 101 /* is it too big? */ 104 102 if (curr_part_no > 'h') { … … 176 174 177 175 build_partition_name(device, drive, curr_part_no); 178 strcpy(mountpoint, mountlist->el[pos].mountpoint);179 176 if (pos > 0 && !npos) { 180 177 /* gap in the partition list? */ … … 260 257 continue; 261 258 } 262 strcpy(mountpoint, mountlist->el[pos].mountpoint);263 259 /* is it too big? */ 264 260 if (curr_part_no > 'h') { … … 327 323 if (amount_allocated > physical_drive_size) { 328 324 // Used to be +1, but what if you're 1 MB too high? 329 mr_asprintf(tmp, " %ld MB over-allocated on %s.", 330 amount_allocated - physical_drive_size, drive); 325 mr_asprintf(tmp, " %ld MB over-allocated on %s.",amount_allocated - physical_drive_size, drive); 331 326 log_it(tmp); 332 327 … … 348 343 349 344 /* Over-allocated the disk? Unallocated space on disk? */ 350 if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 351 mr_asprintf(tmp, " %ld MB unallocated on %s.", 352 physical_drive_size - amount_allocated, drive); 345 if (amount_allocated > physical_drive_size) // Used to be +1, but what if you're 1 MB too high? 346 { 347 mr_asprintf(tmp, " %ld MB over-allocated on %s.", amount_allocated - physical_drive_size, drive); 348 log_it(tmp); 349 mr_strcat(flaws_str, "%s", tmp); 350 mr_free(tmp); 351 res++; 352 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 353 mr_asprintf(tmp, " %ld MB unallocated on %s.", physical_drive_size - amount_allocated, drive); 353 354 log_it(tmp); 354 355 mr_strcat(flaws_str, "%s", tmp); … … 405 406 goto endoffunc; 406 407 } else { 407 mr_asprintf(tmp, " %s (dm) will be setup later on", drive); 408 log_it(tmp); 409 mr_free(tmp); 408 log_it(" %s (dm) will be setup later on", drive); 410 409 } 411 410 } else { 412 mr_asprintf(tmp, "%s is %ld MB", drive, physical_drive_size); 413 log_it(tmp); 414 mr_free(tmp); 411 log_it("%s is %ld MB", drive, physical_drive_size); 415 412 } 416 413 … … 432 429 } else if (curr_part_no > 5 433 430 || (curr_part_no <= 4 && prev_part_no > 0)) { 434 mr_asprintf(tmp, " Gap on %s between %d and %d.", drive, 435 prev_part_no, curr_part_no); 431 mr_asprintf(tmp, " Gap on %s between %d and %d.", drive, prev_part_no, curr_part_no); 436 432 log_it(tmp); 437 433 mr_strcat(flaws_str, "%s", tmp); … … 443 439 part_table_fmt = which_partition_format(drive); 444 440 /* no spare primary partitions to help accommodate the logical(s)? */ 445 if ((curr_part_no >= 5 && prev_part_no == 4) 446 && (strcmp(part_table_fmt, "MBR") == 0)) { 441 if ((curr_part_no >= 5 && prev_part_no == 4) && (strcmp(part_table_fmt, "MBR") == 0)) { 447 442 mr_asprintf(tmp, " Partition 4 of %s is occupied.", drive); 448 443 log_it(tmp); … … 451 446 res++; 452 447 } 448 mr_free(part_table_fmt); 449 453 450 /* does partition /dev/hdNX exist more than once in the mountlist? */ 454 451 for (i = 0, device_copies = 0; … … 459 456 } 460 457 if (device_copies > 1) { 461 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), 462 device); 458 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device); 463 459 if (!strstr(flaws_str, tmp)) { 464 460 log_it(tmp); … … 504 500 /* Over-allocated the disk? Unallocated space on disk? */ 505 501 if (amount_allocated > physical_drive_size + 1) { 506 mr_asprintf(tmp, " %ld MB over-allocated on %s.", 507 amount_allocated - physical_drive_size, drive); 502 mr_asprintf(tmp, " %ld MB over-allocated on %s.", amount_allocated - physical_drive_size, drive); 508 503 log_it(tmp); 509 504 mr_strcat(flaws_str, "%s", tmp); … … 511 506 res++; 512 507 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 513 mr_asprintf(tmp, " %ld MB unallocated on %s.", 514 physical_drive_size - amount_allocated, drive); 508 mr_asprintf(tmp, " %ld MB unallocated on %s.", physical_drive_size - amount_allocated, drive); 515 509 log_it(tmp); 516 510 mr_strcat(flaws_str, "%s", tmp); … … 570 564 (drivelist->el[i].device, 571 565 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); 573 log_it(tmp); 574 paranoid_free(tmp); 566 log_it(" Not evaluating %s (I don't know how yet)", drivelist->el[i].device); 575 567 } else { 576 568 log_msg(8, "Evaluating drive #%d (%s) within mountlist", i, drivelist->el[i].device); … … 582 574 log_msg(8,"Adding: %s to flaws_str", tmp); 583 575 mr_strcat(flaws_str, "%s", tmp); 584 paranoid_free(tmp);576 mr_free(tmp); 585 577 } 586 578 } … … 602 594 mr_strcat(flaws_str, "%s", tmp); 603 595 log_msg(8,"Adding: %s to flaws_str", tmp); 604 paranoid_free(tmp);605 } 606 paranoid_free(curr_mountpoint);596 mr_free(tmp); 597 } 598 mr_free(curr_mountpoint); 607 599 } 608 600 … … 669 661 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { 670 662 log_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive); 671 paranoid_free(drive);663 mr_free(drive); 672 664 continue; 673 665 } … … 676 668 if (size == 0) { 677 669 log_msg(8, "Not putting %s in list of drives: it has zero size (maybe an LVM volume)", drive); 678 paranoid_free(drive);670 mr_free(drive); 679 671 continue; 680 672 } … … 684 676 /* memory allocation */ 685 677 truncdrive = truncate_to_drive_name(drive); 686 paranoid_free(drive);678 mr_free(drive); 687 679 688 680 log_msg(8, "drive truncated to %s", truncdrive); … … 733 725 int used_by = 0; 734 726 735 /*@ buffers ********************************************************* */736 char *tmp = NULL;737 738 727 assert(output_list != NULL); 739 728 assert(mountlist != NULL); … … 745 734 for (i = 0; i < mountlist->entries; i++) { 746 735 if (strstr(mountlist->el[i].mountpoint, "raid")) { 747 used_by = 748 which_raid_device_is_using_this_partition(raidlist, 749 mountlist->el[i]. 750 device); 736 used_by = which_raid_device_is_using_this_partition(raidlist, mountlist->el[i].device); 751 737 if (used_by < 0) { 752 738 memcpy((void *) &output_list->el[items++], 753 739 (void *) &mountlist->el[i], 754 740 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); 756 log_it(tmp); 757 paranoid_free(tmp); 741 log_it("%s is available; user may choose to add it to raid device", output_list->el[items - 1].device); 758 742 } 759 743 } … … 810 794 char *tmp = NULL; 811 795 char *p = NULL; 812 char *q = NULL;813 796 814 797 int items = 0; … … 824 807 return (1); 825 808 } 826 malloc_string(incoming);827 809 malloc_string(siz); 828 q = fgets(incoming, MAX_STR_LEN - 1, fin);829 810 log_it("Loading mountlist..."); 830 while (!feof(fin) && (q != NULL)) { 811 mr_getline(incoming, fin); 812 while (!feof(fin)) { 831 813 #if linux 832 res = sscanf(incoming, 833 "%s %s %s %s %s", 834 mountlist->el[items].device, 835 mountlist->el[items].mountpoint, 836 mountlist->el[items].format, 837 siz, mountlist->el[items].label); 814 res = sscanf(incoming, "%s %s %s %s %s", mountlist->el[items].device, mountlist->el[items].mountpoint, mountlist->el[items].format, siz, mountlist->el[items].label); 838 815 if (res < 5) { 839 816 /* no label found */ … … 842 819 } 843 820 #elif __FreeBSD__ 844 res = sscanf(incoming, 845 "%s %s %s %s", 846 mountlist->el[items].device, 847 mountlist->el[items].mountpoint, 848 mountlist->el[items].format, siz); 821 res = sscanf(incoming, "%s %s %s %s", mountlist->el[items].device, mountlist->el[items].mountpoint, mountlist->el[items].format, siz); 849 822 strcpy(mountlist->el[items].label,""); 850 823 #endif … … 859 832 !strcmp(mountlist->el[items].device, "devpts") 860 833 ) { 861 log_msg(1, 862 "Ignoring %s in mountlist - not loading that line :) ", 863 mountlist->el[items].device); 864 q = fgets(incoming, MAX_STR_LEN - 1, fin); 834 log_msg(1, "Ignoring %s in mountlist - not loading that line :) ", mountlist->el[items].device); 835 mr_free(incoming); 836 mr_getline(incoming, fin); 865 837 continue; 866 838 } … … 874 846 if (j < items) { 875 847 strcat(mountlist->el[items].device, "_dup"); 876 mr_asprintf(tmp, "Duplicate entry in mountlist - renaming to %s", mountlist->el[items].device); 877 log_it(tmp); 878 paranoid_free(tmp); 848 log_it("Duplicate entry in mountlist - renaming to %s", mountlist->el[items].device); 879 849 } 880 850 mr_asprintf(tmp, "%s", mountlist->el[items].device); … … 887 857 *(p + 2) = *(p + 3); 888 858 } 889 log_it("It was %s; it is now %s", 890 mountlist->el[items].device, tmp); 859 log_it("It was %s; it is now %s", mountlist->el[items].device, tmp); 891 860 strcpy(mountlist->el[items].device, tmp); 892 861 } 893 862 paranoid_free(tmp); 894 863 895 log_it("%s %s %s %lld %s", 896 mountlist->el[items].device, 897 mountlist->el[items].mountpoint, 898 mountlist->el[items].format, 899 mountlist->el[items].size, 900 mountlist->el[items].label); 864 log_it("%s %s %s %lld %s", mountlist->el[items].device, mountlist->el[items].mountpoint, mountlist->el[items].format, mountlist->el[items].size, mountlist->el[items].label); 901 865 items++; 902 866 if (items >= MAX_MOUNTLIST_ENTRIES) { … … 905 869 } 906 870 } 907 q = fgets(incoming, MAX_STR_LEN - 1, fin); 908 } 871 mr_free(incoming); 872 mr_getline(incoming, fin); 873 } 874 mr_free(incoming); 909 875 paranoid_fclose(fin); 910 876 mountlist->entries = items; … … 913 879 log_it("%d entries in mountlist", items); 914 880 915 paranoid_free(incoming);916 881 paranoid_free(siz); 917 882 return (0); … … 1050 1015 1051 1016 mountlist->el[b].size = size; 1052 paranoid_free(device);1053 paranoid_free(mountpoint);1054 paranoid_free(format);1017 mr_free(device); 1018 mr_free(mountpoint); 1019 mr_free(format); 1055 1020 } 1056 1021
Note:
See TracChangeset
for help on using the changeset viewer.