Changeset 900 in MondoRescue for trunk/mondo/src/common/libmondo-mountlist.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-mountlist.c
r783 r900 16 16 #include "libmondo-string-EXT.h" 17 17 #include "newt-specific-EXT.h" 18 #include "mr_mem.h" 18 19 19 20 /*@unused@*/ … … 81 82 82 83 if (physical_drive_size < 0) { 83 asprintf(&tmp, " %s does not exist.", drive);84 mr_asprintf(&tmp, " %s does not exist.", drive); 84 85 flaws_str = tmp; 85 86 } else { 86 asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);87 mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size); 87 88 flaws_str = NULL; 88 89 } 89 90 log_it(tmp); 90 paranoid_free(tmp);91 mr_free(tmp); 91 92 92 93 93 94 /* check DD */ 94 95 for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) { 95 asprintf(&device, "%s%c", drive, cur_sp_no);96 mr_asprintf(&device, "%s%c", drive, cur_sp_no); 96 97 if (find_device_in_mountlist(mountlist, device) >= 0) 97 98 foundsome = TRUE; 98 paranoid_free(device);99 mr_free(device); 99 100 } 100 101 if (foundsome) { 101 102 for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) { 102 asprintf(&device, "%s%c", drive, cur_sp_no);103 mr_asprintf(&device, "%s%c", drive, cur_sp_no); 103 104 pos = find_device_in_mountlist(mountlist, device); 104 105 if (pos < 0) { 105 106 continue; 106 107 } 107 // BERLIOS : useless ? asprintf(&mountpoint, mountlist->el[pos].mountpoint);108 // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint); 108 109 /* is it too big? */ 109 110 if (curr_part_no > 'h') { 110 asprintf(&tmp, " Can only have up to 'h' in disklabel.");111 mr_asprintf(&tmp, " Can only have up to 'h' in disklabel."); 111 112 log_it(tmp); 112 113 if (flaws_str) { 113 asprintf(&tmp1, "%s%s",flaws_str, tmp);114 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 114 115 } else { 115 asprintf(&tmp1, "%s", tmp);116 } 117 paranoid_free(flaws_str);116 mr_asprintf(&tmp1, "%s", tmp); 117 } 118 mr_free(flaws_str); 118 119 flaws_str = tmp1; 119 paranoid_free(tmp);120 mr_free(tmp); 120 121 res++; 121 122 } … … 128 129 } 129 130 if (device_copies > 1) { 130 asprintf(&tmp, " %s %s's.", number_to_text(device_copies),131 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), 131 132 device); 132 133 if (!strstr(flaws_str, tmp)) { 133 134 log_it(tmp); 134 135 if (flaws_str) { 135 asprintf(&tmp1, "%s%s",flaws_str, tmp);136 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 136 137 } else { 137 asprintf(&tmp1, "%s", tmp);138 mr_asprintf(&tmp1, "%s", tmp); 138 139 } 139 paranoid_free(flaws_str);140 mr_free(flaws_str); 140 141 flaws_str = tmp1; 141 142 res++; 142 143 } 143 paranoid_free(tmp);144 mr_free(tmp); 144 145 } 145 146 /* silly partition size? */ 146 147 if (mountlist->el[pos].size < 8192 147 148 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 148 asprintf(&tmp, " %s is tiny!", device);149 mr_asprintf(&tmp, " %s is tiny!", device); 149 150 log_it(tmp); 150 151 if (flaws_str) { 151 asprintf(&tmp1, "%s%s",flaws_str, tmp);152 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 152 153 } else { 153 asprintf(&tmp1, "%s", tmp);154 } 155 paranoid_free(flaws_str);154 mr_asprintf(&tmp1, "%s", tmp); 155 } 156 mr_free(flaws_str); 156 157 flaws_str = tmp1; 157 paranoid_free(tmp);158 mr_free(tmp); 158 159 res++; 159 160 } … … 165 166 && strcmp(mountlist->el[pos].mountpoint, "none") 166 167 && mountlist->el[pos].mountpoint[0] != '/') { 167 asprintf(&tmp, " %s has a weird mountpoint.", device);168 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 168 169 log_it(tmp); 169 170 if (flaws_str) { 170 asprintf(&tmp1, "%s%s",flaws_str, tmp);171 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 171 172 } else { 172 asprintf(&tmp1, "%s", tmp);173 } 174 paranoid_free(flaws_str);173 mr_asprintf(&tmp1, "%s", tmp); 174 } 175 mr_free(flaws_str); 175 176 flaws_str = tmp1; 176 paranoid_free(tmp);177 mr_free(tmp); 177 178 res++; 178 179 } 179 180 /* is format sensible? */ 180 181 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 181 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);182 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 182 183 log_it(tmp); 183 184 if (flaws_str) { 184 asprintf(&tmp1, "%s%s",flaws_str, tmp);185 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 185 186 } else { 186 asprintf(&tmp1, "%s", tmp);187 } 188 paranoid_free(flaws_str);187 mr_asprintf(&tmp1, "%s", tmp); 188 } 189 mr_free(flaws_str); 189 190 flaws_str = tmp1; 190 paranoid_free(tmp);191 mr_free(tmp); 191 192 res++; 192 193 } … … 194 195 prev_sp_no = cur_sp_no; 195 196 196 paranoid_free(device);197 mr_free(device); 197 198 } 198 199 } … … 200 201 npos = pos = 0; 201 202 for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) { 202 asprintf(&device, "%ss%d", drive, curr_part_no);203 mr_asprintf(&device, "%ss%d", drive, curr_part_no); 203 204 pos = find_device_in_mountlist(mountlist, device); 204 205 npos = 0; 205 206 for (cur_sp_no = 'a'; cur_sp_no <= 'h'; cur_sp_no++) { 206 asprintf(&ndevice, "%ss%d%c", device, curr_part_no, cur_sp_no);207 mr_asprintf(&ndevice, "%ss%d%c", device, curr_part_no, cur_sp_no); 207 208 if (find_device_in_mountlist(mountlist, ndevice) >= 0) 208 209 npos++; 209 paranoid_free(ndevice);210 } 211 paranoid_free(device);210 mr_free(ndevice); 211 } 212 mr_free(device); 212 213 213 214 if (((pos >= 0) || npos) && foundsome) { 214 asprintf(&tmp, " %s has both DD and PC-style partitions.", drive);215 mr_asprintf(&tmp, " %s has both DD and PC-style partitions.", drive); 215 216 if (flaws_str) { 216 asprintf(&tmp1, "%s%s",flaws_str, tmp);217 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 217 218 } else { 218 asprintf(&tmp1, "%s", tmp);219 } 220 paranoid_free(flaws_str);219 mr_asprintf(&tmp1, "%s", tmp); 220 } 221 mr_free(flaws_str); 221 222 flaws_str = tmp1; 222 paranoid_free(tmp);223 mr_free(tmp); 223 224 return ++res; // fatal error 224 225 } 225 // BERLIOS : useless ? asprintf(&mountpoint, mountlist->el[pos].mountpoint);226 // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint); 226 227 if (pos > 0 && !npos) { 227 asprintf(&device, "%ss%d", drive, curr_part_no);228 mr_asprintf(&device, "%ss%d", drive, curr_part_no); 228 229 /* gap in the partition list? */ 229 230 if (curr_part_no - prev_part_no > 1) { 230 231 if (prev_part_no == 0) { 231 asprintf(&tmp, " Gap prior to %s.", device);232 mr_asprintf(&tmp, " Gap prior to %s.", device); 232 233 log_it(tmp); 233 234 if (flaws_str) { 234 asprintf(&tmp1, "%s%s",flaws_str, tmp);235 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 235 236 } else { 236 asprintf(&tmp1, "%s", tmp);237 mr_asprintf(&tmp1, "%s", tmp); 237 238 } 238 paranoid_free(flaws_str);239 mr_free(flaws_str); 239 240 flaws_str = tmp1; 240 paranoid_free(tmp);241 mr_free(tmp); 241 242 res++; 242 243 } else if (curr_part_no > 5 243 244 || (curr_part_no <= 4 && prev_part_no > 0)) { 244 asprintf(&tmp, " Gap between %ss%d and %d.", drive,245 mr_asprintf(&tmp, " Gap between %ss%d and %d.", drive, 245 246 prev_part_no, curr_part_no); 246 247 log_it(tmp); 247 248 if (flaws_str) { 248 asprintf(&tmp1, "%s%s",flaws_str, tmp);249 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 249 250 } else { 250 asprintf(&tmp1, "%s", tmp);251 mr_asprintf(&tmp1, "%s", tmp); 251 252 } 252 paranoid_free(flaws_str);253 mr_free(flaws_str); 253 254 flaws_str = tmp1; 254 paranoid_free(tmp);255 mr_free(tmp); 255 256 res++; 256 257 } … … 261 262 if ((curr_part_no >= 5 && prev_part_no == 4) 262 263 && (strcmp(part_table_fmt, "MBR") == 0)) { 263 asprintf(&tmp, " Partition %ss4 is occupied.", drive);264 mr_asprintf(&tmp, " Partition %ss4 is occupied.", drive); 264 265 log_it(tmp); 265 266 if (flaws_str) { 266 asprintf(&tmp1, "%s%s",flaws_str, tmp);267 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 267 268 } else { 268 asprintf(&tmp1, "%s", tmp);269 } 270 paranoid_free(flaws_str);269 mr_asprintf(&tmp1, "%s", tmp); 270 } 271 mr_free(flaws_str); 271 272 flaws_str = tmp1; 272 paranoid_free(tmp);273 mr_free(tmp); 273 274 res++; 274 275 } … … 281 282 } 282 283 if (device_copies > 1) { 283 asprintf(&tmp, " %s %s's.", number_to_text(device_copies),284 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), 284 285 device); 285 286 if (!strstr(flaws_str, tmp)) { 286 287 log_it(tmp); 287 288 if (flaws_str) { 288 asprintf(&tmp1, "%s%s",flaws_str, tmp);289 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 289 290 } else { 290 asprintf(&tmp1, "%s", tmp);291 mr_asprintf(&tmp1, "%s", tmp); 291 292 } 292 paranoid_free(flaws_str);293 mr_free(flaws_str); 293 294 flaws_str = tmp1; 294 295 res++; 295 296 } 296 paranoid_free(tmp);297 mr_free(tmp); 297 298 } 298 299 /* silly partition size? */ 299 300 if (mountlist->el[pos].size < 8192 300 301 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 301 asprintf(&tmp, " %s is tiny!", device);302 mr_asprintf(&tmp, " %s is tiny!", device); 302 303 log_it(tmp); 303 304 if (flaws_str) { 304 asprintf(&tmp1, "%s%s",flaws_str, tmp);305 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 305 306 } else { 306 asprintf(&tmp1, "%s", tmp);307 } 308 paranoid_free(flaws_str);307 mr_asprintf(&tmp1, "%s", tmp); 308 } 309 mr_free(flaws_str); 309 310 flaws_str = tmp1; 310 paranoid_free(tmp);311 mr_free(tmp); 311 312 res++; 312 313 } … … 318 319 && strcmp(mountlist->el[pos].mountpoint, "none") 319 320 && mountlist->el[pos].mountpoint[0] != '/') { 320 asprintf(&tmp, " %s has a weird mountpoint.", device);321 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 321 322 log_it(tmp); 322 323 if (flaws_str) { 323 asprintf(&tmp1, "%s%s",flaws_str, tmp);324 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 324 325 } else { 325 asprintf(&tmp1, "%s", tmp);326 } 327 paranoid_free(flaws_str);326 mr_asprintf(&tmp1, "%s", tmp); 327 } 328 mr_free(flaws_str); 328 329 flaws_str = tmp1; 329 paranoid_free(tmp);330 mr_free(tmp); 330 331 res++; 331 332 } 332 333 /* is format sensible? */ 333 334 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 334 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);335 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 335 336 log_it(tmp); 336 337 if (flaws_str) { 337 asprintf(&tmp1, "%s%s",flaws_str, tmp);338 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 338 339 } else { 339 asprintf(&tmp1, "%s", tmp);340 } 341 paranoid_free(flaws_str);340 mr_asprintf(&tmp1, "%s", tmp); 341 } 342 mr_free(flaws_str); 342 343 flaws_str = tmp1; 343 paranoid_free(tmp);344 mr_free(tmp); 344 345 res++; 345 346 } 346 paranoid_free(device);347 mr_free(device); 347 348 } else { 348 349 /* Check subpartitions */ 349 350 for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) { 350 asprintf(&device, "%ss%d%c", drive, curr_part_no,351 mr_asprintf(&device, "%ss%d%c", drive, curr_part_no, 351 352 cur_sp_no); 352 353 pos = find_device_in_mountlist(mountlist, device); … … 354 355 continue; 355 356 } 356 // BERLIOS : useless ? asprintf(&mountpoint, mountlist->el[pos].mountpoint);357 // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint); 357 358 /* is it too big? */ 358 359 if (curr_part_no > 'h') { 359 asprintf(&tmp,360 mr_asprintf(&tmp, 360 361 " Can only have up to 'h' in disklabel."); 361 362 log_it(tmp); 362 363 if (flaws_str) { 363 asprintf(&tmp1, "%s%s",flaws_str, tmp);364 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 364 365 } else { 365 asprintf(&tmp1, "%s", tmp);366 mr_asprintf(&tmp1, "%s", tmp); 366 367 } 367 paranoid_free(flaws_str);368 mr_free(flaws_str); 368 369 flaws_str = tmp1; 369 paranoid_free(tmp);370 mr_free(tmp); 370 371 res++; 371 372 } … … 378 379 } 379 380 if (device_copies > 1) { 380 asprintf(&tmp, " %s %s's.",381 mr_asprintf(&tmp, " %s %s's.", 381 382 number_to_text(device_copies), device); 382 383 if (!strstr(flaws_str, tmp)) { 383 384 log_it(tmp); 384 385 if (flaws_str) { 385 asprintf(&tmp1, "%s%s",flaws_str, tmp);386 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 386 387 } else { 387 asprintf(&tmp1, "%s", tmp);388 mr_asprintf(&tmp1, "%s", tmp); 388 389 } 389 paranoid_free(flaws_str);390 mr_free(flaws_str); 390 391 flaws_str = tmp1; 391 392 res++; 392 393 } 393 paranoid_free(tmp);394 mr_free(tmp); 394 395 } 395 396 /* silly partition size? */ 396 397 if (mountlist->el[pos].size < 8192 397 398 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 398 asprintf(&tmp, " %s is tiny!", device);399 mr_asprintf(&tmp, " %s is tiny!", device); 399 400 log_it(tmp); 400 401 if (flaws_str) { 401 asprintf(&tmp1, "%s%s",flaws_str, tmp);402 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 402 403 } else { 403 asprintf(&tmp1, "%s", tmp);404 mr_asprintf(&tmp1, "%s", tmp); 404 405 } 405 paranoid_free(flaws_str);406 mr_free(flaws_str); 406 407 flaws_str = tmp1; 407 paranoid_free(tmp);408 mr_free(tmp); 408 409 res++; 409 410 } … … 415 416 && strcmp(mountlist->el[pos].mountpoint, "none") 416 417 && mountlist->el[pos].mountpoint[0] != '/') { 417 asprintf(&tmp, " %s has a weird mountpoint.", device);418 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 418 419 log_it(tmp); 419 420 if (flaws_str) { 420 asprintf(&tmp1, "%s%s",flaws_str, tmp);421 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 421 422 } else { 422 asprintf(&tmp1, "%s", tmp);423 mr_asprintf(&tmp1, "%s", tmp); 423 424 } 424 paranoid_free(flaws_str);425 mr_free(flaws_str); 425 426 flaws_str = tmp1; 426 paranoid_free(tmp);427 mr_free(tmp); 427 428 res++; 428 429 } … … 430 431 if (!is_this_a_valid_disk_format 431 432 (mountlist->el[pos].format)) { 432 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);433 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 433 434 log_it(tmp); 434 435 if (flaws_str) { 435 asprintf(&tmp1, "%s%s",flaws_str, tmp);436 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 436 437 } else { 437 asprintf(&tmp1, "%s", tmp);438 mr_asprintf(&tmp1, "%s", tmp); 438 439 } 439 paranoid_free(flaws_str);440 mr_free(flaws_str); 440 441 flaws_str = tmp1; 441 paranoid_free(tmp);442 mr_free(tmp); 442 443 res++; 443 444 } 444 445 amount_allocated += mountlist->el[pos].size / 1024; 445 446 prev_sp_no = cur_sp_no; 446 paranoid_free(device);447 mr_free(device); 447 448 } 448 449 } … … 456 457 if (amount_allocated > physical_drive_size) // Used to be +1, but what if you're 1 MB too high? 457 458 { 458 asprintf(&tmp, " %ld MB over-allocated on %s.",459 mr_asprintf(&tmp, " %ld MB over-allocated on %s.", 459 460 amount_allocated - physical_drive_size, drive); 460 461 log_it(tmp); 461 462 if (flaws_str) { 462 asprintf(&tmp1, "%s%s",flaws_str, tmp);463 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 463 464 } else { 464 asprintf(&tmp1, "%s", tmp);465 } 466 paranoid_free(flaws_str);465 mr_asprintf(&tmp1, "%s", tmp); 466 } 467 mr_free(flaws_str); 467 468 flaws_str = tmp1; 468 paranoid_free(tmp);469 mr_free(tmp); 469 470 res++; 470 471 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 471 asprintf(&tmp, " %ld MB unallocated on %s.",472 mr_asprintf(&tmp, " %ld MB unallocated on %s.", 472 473 physical_drive_size - amount_allocated, drive); 473 474 log_it(tmp); 474 475 if (flaws_str) { 475 asprintf(&tmp1, "%s%s",flaws_str, tmp);476 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 476 477 } else { 477 asprintf(&tmp1, "%s", tmp);478 } 479 paranoid_free(flaws_str);478 mr_asprintf(&tmp1, "%s", tmp); 479 } 480 mr_free(flaws_str); 480 481 flaws_str = tmp1; 481 paranoid_free(tmp);482 mr_free(tmp); 482 483 } 483 484 if (res) { … … 525 526 526 527 if (physical_drive_size < 0) { 527 asprintf(&tmp, " %s does not exist.", drive);528 mr_asprintf(&tmp, " %s does not exist.", drive); 528 529 if (flaws_str) { 529 asprintf(&tmp1, "%s%s",flaws_str, tmp);530 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 530 531 } else { 531 asprintf(&tmp1, "%s", tmp);532 } 533 paranoid_free(flaws_str);532 mr_asprintf(&tmp1, "%s", tmp); 533 } 534 mr_free(flaws_str); 534 535 flaws_str = tmp1; 535 536 res++; 536 537 log_msg(1, tmp); 537 paranoid_free(tmp);538 mr_free(tmp); 538 539 return (FALSE); 539 540 } else { 540 asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);541 mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size); 541 542 log_it(tmp); 542 paranoid_free(tmp);543 mr_free(tmp); 543 544 } 544 545 545 546 for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) { 546 asprintf(&device, "%s%d", drive, curr_part_no);547 mr_asprintf(&device, "%s%d", drive, curr_part_no); 547 548 pos = find_device_in_mountlist(mountlist, device); 548 549 if (pos < 0) { … … 550 551 } 551 552 if (physical_drive_size < 0) { 552 asprintf(&tmp, " %s refers to non-existent hardware.", device);553 mr_asprintf(&tmp, " %s refers to non-existent hardware.", device); 553 554 if (flaws_str) { 554 asprintf(&tmp1, "%s%s",flaws_str, tmp);555 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 555 556 } else { 556 asprintf(&tmp1, "%s", tmp);557 } 558 paranoid_free(flaws_str);557 mr_asprintf(&tmp1, "%s", tmp); 558 } 559 mr_free(flaws_str); 559 560 flaws_str = tmp1; 560 561 res++; 561 paranoid_free(tmp);562 mr_free(tmp); 562 563 continue; 563 564 } … … 566 567 if (curr_part_no - prev_part_no > 1) { 567 568 if (prev_part_no == 0) { 568 asprintf(&tmp, " Gap prior to %s.", device);569 mr_asprintf(&tmp, " Gap prior to %s.", device); 569 570 log_it(tmp); 570 571 if (flaws_str) { 571 asprintf(&tmp1, "%s%s",flaws_str, tmp);572 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 572 573 } else { 573 asprintf(&tmp1, "%s", tmp);574 } 575 paranoid_free(flaws_str);574 mr_asprintf(&tmp1, "%s", tmp); 575 } 576 mr_free(flaws_str); 576 577 flaws_str = tmp1; 577 paranoid_free(tmp);578 mr_free(tmp); 578 579 res++; 579 580 } else if (curr_part_no > 5 580 581 || (curr_part_no <= 4 && prev_part_no > 0)) { 581 asprintf(&tmp, " Gap between %s%d and %d.", drive,582 mr_asprintf(&tmp, " Gap between %s%d and %d.", drive, 582 583 prev_part_no, curr_part_no); 583 584 log_it(tmp); 584 585 if (flaws_str) { 585 asprintf(&tmp1, "%s%s",flaws_str, tmp);586 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 586 587 } else { 587 asprintf(&tmp1, "%s", tmp);588 } 589 paranoid_free(flaws_str);588 mr_asprintf(&tmp1, "%s", tmp); 589 } 590 mr_free(flaws_str); 590 591 flaws_str = tmp1; 591 paranoid_free(tmp);592 mr_free(tmp); 592 593 res++; 593 594 } … … 598 599 if ((curr_part_no >= 5 && prev_part_no == 4) 599 600 && (strcmp(part_table_fmt, "MBR") == 0)) { 600 asprintf(&tmp, " Partition %s4 is occupied.", drive);601 mr_asprintf(&tmp, " Partition %s4 is occupied.", drive); 601 602 log_it(tmp); 602 603 if (flaws_str) { 603 asprintf(&tmp1, "%s%s",flaws_str, tmp);604 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 604 605 } else { 605 asprintf(&tmp1, "%s", tmp);606 } 607 paranoid_free(flaws_str);606 mr_asprintf(&tmp1, "%s", tmp); 607 } 608 mr_free(flaws_str); 608 609 flaws_str = tmp1; 609 paranoid_free(tmp);610 mr_free(tmp); 610 611 res++; 611 612 } 612 paranoid_free(part_table_fmt);613 mr_free(part_table_fmt); 613 614 614 615 /* does partition /dev/hdNX exist more than once in the mountlist? */ … … 620 621 } 621 622 if (device_copies > 1) { 622 asprintf(&tmp, " %s %s's.", number_to_text(device_copies),623 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), 623 624 device); 624 625 if (!strstr(flaws_str, tmp)) { 625 626 log_it(tmp); 626 627 if (flaws_str) { 627 asprintf(&tmp1, "%s%s",flaws_str, tmp);628 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 628 629 } else { 629 asprintf(&tmp1, "%s", tmp);630 } 631 paranoid_free(flaws_str);630 mr_asprintf(&tmp1, "%s", tmp); 631 } 632 mr_free(flaws_str); 632 633 flaws_str = tmp1; 633 634 res++; 634 635 } 635 paranoid_free(tmp);636 mr_free(tmp); 636 637 } 637 638 /* silly partition size? */ 638 639 if (mountlist->el[pos].size < 8192 639 640 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 640 asprintf(&tmp, " %s is tiny!", device);641 mr_asprintf(&tmp, " %s is tiny!", device); 641 642 log_it(tmp); 642 643 if (flaws_str) { 643 asprintf(&tmp1, "%s%s",flaws_str, tmp);644 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 644 645 } else { 645 asprintf(&tmp1, "%s", tmp);646 } 647 paranoid_free(flaws_str);646 mr_asprintf(&tmp1, "%s", tmp); 647 } 648 mr_free(flaws_str); 648 649 flaws_str = tmp1; 649 paranoid_free(tmp);650 mr_free(tmp); 650 651 res++; 651 652 } … … 656 657 && strcmp(mountlist->el[pos].mountpoint, "image") 657 658 && mountlist->el[pos].mountpoint[0] != '/') { 658 asprintf(&tmp, " %s has a weird mountpoint.", device);659 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 659 660 log_it(tmp); 660 661 if (flaws_str) { 661 asprintf(&tmp1, "%s%s",flaws_str, tmp);662 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 662 663 } else { 663 asprintf(&tmp1, "%s", tmp);664 } 665 paranoid_free(flaws_str);664 mr_asprintf(&tmp1, "%s", tmp); 665 } 666 mr_free(flaws_str); 666 667 flaws_str = tmp1; 667 paranoid_free(tmp);668 mr_free(tmp); 668 669 res++; 669 670 } 670 671 /* is format sensible? */ 671 672 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 672 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);673 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 673 674 log_it(tmp); 674 675 if (flaws_str) { 675 asprintf(&tmp1, "%s%s",flaws_str, tmp);676 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 676 677 } else { 677 asprintf(&tmp1, "%s", tmp);678 } 679 paranoid_free(flaws_str);678 mr_asprintf(&tmp1, "%s", tmp); 679 } 680 mr_free(flaws_str); 680 681 flaws_str = tmp1; 681 paranoid_free(tmp);682 mr_free(tmp); 682 683 res++; 683 684 } … … 685 686 amount_allocated += mountlist->el[pos].size / 1024; 686 687 prev_part_no = curr_part_no; 687 paranoid_free(device);688 mr_free(device); 688 689 } 689 690 690 691 /* Over-allocated the disk? Unallocated space on disk? */ 691 692 if (amount_allocated > physical_drive_size + 1) { 692 asprintf(&tmp, " %ld MB over-allocated on %s.",693 mr_asprintf(&tmp, " %ld MB over-allocated on %s.", 693 694 amount_allocated - physical_drive_size, drive); 694 695 log_it(tmp); 695 696 if (flaws_str) { 696 asprintf(&tmp1, "%s%s",flaws_str, tmp);697 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 697 698 } else { 698 asprintf(&tmp1, "%s", tmp);699 } 700 paranoid_free(flaws_str);699 mr_asprintf(&tmp1, "%s", tmp); 700 } 701 mr_free(flaws_str); 701 702 flaws_str = tmp1; 702 paranoid_free(tmp);703 mr_free(tmp); 703 704 res++; 704 705 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 705 asprintf(&tmp, " %ld MB unallocated on %s.",706 mr_asprintf(&tmp, " %ld MB unallocated on %s.", 706 707 physical_drive_size - amount_allocated, drive); 707 708 log_it(tmp); 708 709 if (flaws_str) { 709 asprintf(&tmp1, "%s%s",flaws_str, tmp);710 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 710 711 } else { 711 asprintf(&tmp1, "%s", tmp);712 } 713 paranoid_free(flaws_str);712 mr_asprintf(&tmp1, "%s", tmp); 713 } 714 mr_free(flaws_str); 714 715 flaws_str = tmp1; 715 paranoid_free(tmp);716 mr_free(tmp); 716 717 } 717 718 … … 755 756 assert(mountlist != NULL); 756 757 757 asprintf(&flaws_str, " ");758 mr_asprintf(&flaws_str, " "); 758 759 759 760 make_list_of_drives_in_mountlist(mountlist, drivelist); … … 765 766 (drivelist->el[i].device, 766 767 DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) { 767 asprintf(&tmp, " Not evaluating %s (I don't know how yet)",768 mr_asprintf(&tmp, " Not evaluating %s (I don't know how yet)", 768 769 drivelist->el[i].device); 769 770 log_it(tmp); … … 775 776 } 776 777 } 777 asprintf(&tmp1, "%s%s", flaws_str, tmp);778 paranoid_free(tmp);779 paranoid_free(flaws_str);778 mr_asprintf(&tmp1, "%s%s", flaws_str, tmp); 779 mr_free(tmp); 780 mr_free(flaws_str); 780 781 flaws_str = tmp1; 781 782 } … … 841 842 842 843 for (currline = 0; currline < mountlist->entries; currline++) { 843 asprintf(&curr_mountpoint, mountlist->el[currline].mountpoint);844 mr_asprintf(&curr_mountpoint, mountlist->el[currline].mountpoint); 844 845 for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries; 845 846 i++) { … … 853 854 if (copies > 1 && last_copy == currline 854 855 && strcmp(curr_mountpoint, "raid")) { 855 asprintf(&tmp, " %s %s's.", number_to_text(copies),856 mr_asprintf(&tmp, " %s %s's.", number_to_text(copies), 856 857 curr_mountpoint); 857 858 log_it(tmp); 858 asprintf(&tmp1, "%s%s",flaws_str, tmp);859 paranoid_free(flaws_str);859 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 860 mr_free(flaws_str); 860 861 flaws_str = tmp1; 861 paranoid_free(tmp);862 mr_free(tmp); 862 863 res++; 863 864 } 864 paranoid_free(curr_mountpoint);865 mr_free(curr_mountpoint); 865 866 } 866 867 return (res); … … 895 896 for (lino = 0, noof_drives = 0; lino < mountlist->entries; lino++) { 896 897 897 asprintf(&drive, mountlist->el[lino].device);898 mr_asprintf(&drive, mountlist->el[lino].device); 898 899 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { 899 asprintf(&tmp,900 mr_asprintf(&tmp, 900 901 "Not putting %s in list of drives: it's a virtual drive", 901 902 drive); 902 903 log_msg(8, tmp); 903 paranoid_free(tmp);904 mr_free(tmp); 904 905 continue; 905 906 } … … 907 908 size = mountlist->el[lino].size; 908 909 if (size == 0) { 909 asprintf(&tmp,910 mr_asprintf(&tmp, 910 911 "Not putting %s in list of drives: it has zero size (maybe an LVM volume)", 911 912 drive); 912 913 log_msg(8, tmp); 913 paranoid_free(tmp);914 mr_free(tmp); 914 915 continue; 915 916 } … … 926 927 */ 927 928 928 asprintf(&tmp,929 mr_asprintf(&tmp, 929 930 "Putting %s with size %lli in list of drives", 930 931 drive, size); 931 932 log_msg(8, tmp); 932 paranoid_free(tmp);933 mr_free(tmp); 933 934 934 935 (void) truncate_to_drive_name(drive); … … 940 941 strcpy(drivelist->el[noof_drives++].device, drive); 941 942 } 942 paranoid_free(drive);943 mr_free(drive); 943 944 944 945 } … … 988 989 (void *) &mountlist->el[i], 989 990 sizeof(struct mountlist_line)); 990 asprintf(&tmp,991 mr_asprintf(&tmp, 991 992 "%s is available; user may choose to add it to raid device", 992 993 output_list->el[items - 1].device); 993 994 log_it(tmp); 994 paranoid_free(tmp);995 mr_free(tmp); 995 996 } 996 997 } … … 1058 1059 log_it("Unable to open mountlist - '%s'", fname); 1059 1060 log_to_screen(_("Cannot open mountlist")); 1060 paranoid_free(siz);1061 mr_free(siz); 1061 1062 return (1); 1062 1063 } 1063 1064 items = 0; 1064 (void)getline(&incoming, &n, fin);1065 mr_getline(&incoming, &n, fin); 1065 1066 log_it("Loading mountlist..."); 1066 1067 while (!feof(fin)) { … … 1091 1092 "Ignoring %s in mountlist - not loading that line :) ", 1092 1093 mountlist->el[items].device); 1093 (void)getline(&incoming, &n, fin);1094 mr_getline(&incoming, &n, fin); 1094 1095 continue; 1095 1096 } … … 1107 1108 if (j < items) { 1108 1109 strcat(mountlist->el[items].device, "_dup"); 1109 asprintf(&tmp,1110 mr_asprintf(&tmp, 1110 1111 "Duplicate entry in mountlist - renaming to %s", 1111 1112 mountlist->el[items].device); 1112 1113 log_it(tmp); 1113 paranoid_free(tmp);1114 } 1115 asprintf(&tmp, mountlist->el[items].device);1114 mr_free(tmp); 1115 } 1116 mr_asprintf(&tmp, mountlist->el[items].device); 1116 1117 if (strstr(tmp, "/dev/md/")) { 1117 1118 log_it("format_device() --- Contracting %s", tmp); … … 1126 1127 strcpy(mountlist->el[items].device, tmp); 1127 1128 } 1128 paranoid_free(tmp);1129 1130 asprintf(&tmp,1129 mr_free(tmp); 1130 1131 mr_asprintf(&tmp, 1131 1132 "%s %s %s %lld %s", 1132 1133 mountlist->el[items].device, … … 1137 1138 1138 1139 log_it(tmp); 1139 paranoid_free(tmp);1140 mr_free(tmp); 1140 1141 items++; 1141 1142 } 1142 (void)getline(&incoming, &n, fin);1143 mr_getline(&incoming, &n, fin); 1143 1144 } 1144 1145 paranoid_fclose(fin); 1145 paranoid_free(incoming);1146 mr_free(incoming); 1146 1147 mountlist->entries = items; 1147 1148 1148 1149 log_it("Mountlist loaded successfully."); 1149 asprintf(&tmp, "%d entries in mountlist", items);1150 mr_asprintf(&tmp, "%d entries in mountlist", items); 1150 1151 log_it(tmp); 1151 paranoid_free(tmp);1152 1153 paranoid_free(siz);1152 mr_free(tmp); 1153 1154 mr_free(siz); 1154 1155 return (0); 1155 1156 } … … 1264 1265 assert(b >= 0); 1265 1266 1266 asprintf(&device, mountlist->el[a].device);1267 asprintf(&mountpoint, mountlist->el[a].mountpoint);1268 asprintf(&format, mountlist->el[a].format);1267 mr_asprintf(&device, mountlist->el[a].device); 1268 mr_asprintf(&mountpoint, mountlist->el[a].mountpoint); 1269 mr_asprintf(&format, mountlist->el[a].format); 1269 1270 1270 1271 size = mountlist->el[a].size;
Note:
See TracChangeset
for help on using the changeset viewer.