Changeset 1176 in MondoRescue for trunk/mondo/src/common/libmondo-mountlist.c
- Timestamp:
- Feb 16, 2007, 2:16:14 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-mountlist.c
r1161 r1176 2 2 $Id$ 3 3 */ 4 4 5 5 6 /** … … 21 22 /*@unused@*/ 22 23 //static char cvsid[] = "$Id$"; 23 24 /**25 * A global copy of @c bkpinfo, to aid in debugging. As the name implies, <em>don't use this</em>.26 * @ingroup globalGroup27 */28 struct s_bkpinfo *g_bkpinfo_DONTUSETHIS = NULL;29 24 30 25 /** … … 77 72 /*@ initialize ***************************************************** */ 78 73 prev_part_no = 0; 79 // BERLIOS: tmp[0] = '\0';80 74 81 75 … … 83 77 84 78 if (physical_drive_size < 0) { 85 mr_asprintf(&tmp, " %s does not exist.", drive); 79 mr_asprintf(&tmp, "%s %s does not exist.", flaw_str, drive); 80 mr_free(flaw_str); 86 81 flaws_str = tmp; 87 82 } else { … … 225 220 return ++res; // fatal error 226 221 } 222 223 mr_asprintf(&device, "%ss%d", drive, curr_part_no); 227 224 // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint); 228 225 if (pos > 0 && !npos) { 229 mr_asprintf(&device, "%ss%d", drive, curr_part_no);230 226 /* gap in the partition list? */ 231 227 if (curr_part_no - prev_part_no > 1) { … … 346 342 res++; 347 343 } 348 mr_free(device);349 344 } else { 350 345 /* Check subpartitions */ 351 346 for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) { 352 mr_asprintf(&device, "%ss%d%c", drive, curr_part_no, 353 cur_sp_no); 347 mr_asprintf(&device, "%ss%d%c", drive, curr_part_no, cur_sp_no); 354 348 pos = find_device_in_mountlist(mountlist, device); 355 349 if (pos < 0) { … … 446 440 amount_allocated += mountlist->el[pos].size / 1024; 447 441 prev_sp_no = cur_sp_no; 448 mr_free(device);449 450 }442 } 443 } 444 mr_free(device); 451 445 452 446 /* OK, continue with main loop */ … … 482 476 flaws_str = tmp1; 483 477 mr_free(tmp); 478 /* BERLIOS: Flawed since rev 1 !! */ 479 res++; 484 480 } 485 481 if (res) { … … 521 517 522 518 prev_part_no = 0; 523 // BERLIOS : useless ? tmp[0] = '\0';524 525 519 526 520 physical_drive_size = get_phys_size_of_drive(drive); … … 582 576 || (curr_part_no <= 4 && prev_part_no > 0)) { 583 577 mr_asprintf(&tmp, " Gap between %s%d and %d.", drive, 584 578 prev_part_no, curr_part_no); 585 579 log_it(tmp); 586 580 if (flaws_str) { … … 716 710 flaws_str = tmp1; 717 711 mr_free(tmp); 712 /* BERLIOS: Flawed since rev 1 !! - Is it sure ?? */ 713 res++; 718 714 } 719 715 … … 743 739 744 740 /*@ buffer *********************************************************** */ 745 struct list_of_disks *drivelist ;746 char *tmp ;747 char *tmp1 ;748 char *flaws_str ;741 struct list_of_disks *drivelist = NULL; 742 char *tmp = NULL; 743 char *tmp1 = NULL; 744 char *flaws_str = NULL; 749 745 750 746 /*@ int ************************************************************** */ … … 856 852 && strcmp(curr_mountpoint, "raid")) { 857 853 mr_asprintf(&tmp, " %s %s's.", number_to_text(copies), 858 854 curr_mountpoint); 859 855 log_it(tmp); 860 856 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); … … 887 883 888 884 /*@ buffers ********************************************************* */ 889 char *drive; 890 char *tmp; 885 char *drive = NULL; 891 886 892 887 long long size; … … 899 894 mr_asprintf(&drive, mountlist->el[lino].device); 900 895 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { 901 mr_asprintf(&tmp, 902 "Not putting %s in list of drives: it's a virtual drive", 903 drive); 904 mr_msg(8, tmp); 905 mr_free(tmp); 896 mr_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive); 906 897 continue; 907 898 } … … 909 900 size = mountlist->el[lino].size; 910 901 if (size == 0) { 911 mr_asprintf(&tmp, 912 "Not putting %s in list of drives: it has zero size (maybe an LVM volume)", 913 drive); 914 mr_msg(8, tmp); 915 mr_free(tmp); 902 mr_msg(8, "Not putting %s in list of drives: it has zero size (maybe an LVM volume)", drive); 916 903 continue; 917 904 } 918 905 919 /* 920 for (i = strlen (drive); isdigit (drive[i - 1]); i--); 921 drive[i] = '\0'; 922 if (get_phys_size_of_drive (drive) <= 0 && drive[i - 1] == 'p') 923 { 924 i--; 925 drive[i] = '\0'; 926 } 927 for (j = 0; j < noof_drives && strcmp (drivelist[j], drive) != 0; j++); 928 */ 929 930 mr_asprintf(&tmp, 931 "Putting %s with size %lli in list of drives", 932 drive, size); 933 mr_msg(8, tmp); 934 mr_free(tmp); 906 mr_msg(8, "Putting %s with size %lli in list of drives", drive, size); 935 907 936 908 (void) truncate_to_drive_name(drive); … … 960 932 */ 961 933 void make_list_of_unallocated_raid_partitions(struct mountlist_itself 962 *output_list, struct mountlist_itself 963 *mountlist, struct raidlist_itself 934 *output_list, 935 struct mountlist_itself 936 *mountlist, 937 struct raidlist_itself 964 938 *raidlist) 965 939 { … … 971 945 972 946 /*@ buffers ********************************************************* */ 973 char *tmp ;947 char *tmp = NULL; 974 948 975 949 assert(output_list != NULL); … … 1043 1017 int load_mountlist(struct mountlist_itself *mountlist, char *fname) 1044 1018 { 1045 FILE *fin ;1019 FILE *fin = NULL; 1046 1020 /* malloc ** */ 1047 1021 char *incoming = NULL; 1048 char *siz ;1049 char *tmp ;1050 char *p ;1051 1052 int items ;1053 int j ;1022 char *siz = NULL; 1023 char *tmp = NULL; 1024 char *p = NULL; 1025 1026 int items = 0; 1027 int j = 0; 1054 1028 size_t n = 0; 1055 1029 1056 1030 assert(mountlist != NULL); 1057 1031 assert_string_is_neither_NULL_nor_zerolength(fname); 1058 malloc_string(siz); 1032 1059 1033 if (!(fin = fopen(fname, "r"))) { 1060 1034 log_it("Unable to open mountlist - '%s'", fname); 1061 1035 log_to_screen(_("Cannot open mountlist")); 1062 mr_free(siz);1063 1036 return (1); 1064 1037 } 1065 items = 0;1038 malloc_string(siz); 1066 1039 mr_getline(&incoming, &n, fin); 1067 1040 log_it("Loading mountlist..."); … … 1130 1103 mr_free(tmp); 1131 1104 1132 mr_asprintf(&tmp, 1133 "%s %s %s %lld %s", 1105 log_it("%s %s %s %lld %s", 1134 1106 mountlist->el[items].device, 1135 1107 mountlist->el[items].mountpoint, … … 1137 1109 mountlist->el[items].size, 1138 1110 mountlist->el[items].label); 1139 1140 log_it(tmp);1141 mr_free(tmp);1142 1111 items++; 1143 1112 } … … 1149 1118 1150 1119 log_it("Mountlist loaded successfully."); 1151 mr_asprintf(&tmp, "%d entries in mountlist", items); 1152 log_it(tmp); 1153 mr_free(tmp); 1120 log_it("%d entries in mountlist", items); 1154 1121 1155 1122 mr_free(siz); 1156 1123 return (0); 1157 1124 } 1158 1159 1125 1160 1126 … … 1256 1222 { 1257 1223 /*@ mallocs *** */ 1258 char *device ;1259 char *mountpoint ;1260 char *format ;1224 char *device = NULL; 1225 char *mountpoint = NULL; 1226 char *format = NULL; 1261 1227 1262 1228 long long size; … … 1283 1249 1284 1250 mountlist->el[b].size = size; 1251 mr_free(device); 1252 mr_free(mountpoint); 1253 mr_free(format); 1285 1254 } 1286 1255
Note:
See TracChangeset
for help on using the changeset viewer.