Changeset 900 in MondoRescue for trunk/mondo/src/mondorestore/mondo-prep.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/mondorestore/mondo-prep.c
r783 r900 19 19 #include <math.h> 20 20 #include <unistd.h> 21 #include "mr_mem.h" 21 22 22 23 … … 63 64 make_list_of_drives_in_mountlist(mountlist, drivelist); 64 65 for (lino = 0; lino < drivelist->entries; lino++) { 65 asprintf(&command,66 mr_asprintf(&command, 66 67 "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", 67 68 drivelist->el[lino].device, MONDO_WAS_HERE); … … 69 70 log_msg(1, "Found MONDO_WAS_HERE marker on drive#%d (%s)", 70 71 lino, drivelist->el[lino].device); 71 paranoid_free(command);72 mr_free(command); 72 73 break; 73 74 } 74 paranoid_free(command);75 mr_free(command); 75 76 } 76 77 … … 86 87 log_to_screen("Please hit 'Enter' to reboot."); 87 88 for (lino = 0; lino < drivelist->entries; lino++) { 88 asprintf(&buf, "%s\n", MONDO_WAS_HERE);89 mr_asprintf(&buf, "%s\n", MONDO_WAS_HERE); 89 90 fout = fopen(drivelist->el[lino].device, "w+"); 90 91 if (!fout) { … … 101 102 fclose(fout); 102 103 } 103 paranoid_free(buf);104 mr_free(buf); 104 105 } 105 106 sync(); … … 201 202 if (tmp) // found it :) cool 202 203 { 203 asprintf(&lvscan_sz, "lvm lvscan");204 asprintf(&lvremove_sz, "lvm lvremove");205 asprintf(&vgscan_sz, "lvm vgscan");206 asprintf(&pvscan_sz, "lvm pvscan");207 asprintf(&vgchange_sz, "lvm vgchange");208 asprintf(&vgremove_sz, "lvm vgremove");204 mr_asprintf(&lvscan_sz, "lvm lvscan"); 205 mr_asprintf(&lvremove_sz, "lvm lvremove"); 206 mr_asprintf(&vgscan_sz, "lvm vgscan"); 207 mr_asprintf(&pvscan_sz, "lvm pvscan"); 208 mr_asprintf(&vgchange_sz, "lvm vgchange"); 209 mr_asprintf(&vgremove_sz, "lvm vgremove"); 209 210 } else { 210 asprintf(&lvscan_sz, "lvscan");211 asprintf(&lvremove_sz, "lvremove");212 asprintf(&vgscan_sz, "vgscan");213 asprintf(&pvscan_sz, "pvscan");214 asprintf(&vgchange_sz, "vgchange");215 asprintf(&vgremove_sz, "vgremove");216 } 217 paranoid_free(tmp);218 219 asprintf(&command,211 mr_asprintf(&lvscan_sz, "lvscan"); 212 mr_asprintf(&lvremove_sz, "lvremove"); 213 mr_asprintf(&vgscan_sz, "vgscan"); 214 mr_asprintf(&pvscan_sz, "pvscan"); 215 mr_asprintf(&vgchange_sz, "vgchange"); 216 mr_asprintf(&vgremove_sz, "vgremove"); 217 } 218 mr_free(tmp); 219 220 mr_asprintf(&command, 220 221 "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> " 221 222 MONDO_LOGFILE "; %s -f $i; done", lvscan_sz, lvremove_sz); 222 paranoid_free(lvscan_sz);223 paranoid_free(lvremove_sz);223 mr_free(lvscan_sz); 224 mr_free(lvremove_sz); 224 225 225 226 run_program_and_log_output(command, 5); 226 paranoid_free(command);227 mr_free(command); 227 228 228 229 sleep(1); 229 asprintf(&command,230 mr_asprintf(&command, 230 231 "for i in `%s | grep -i lvm | cut -d'\"' -f2` ; do %s -a n $i ; %s $i; echo \"Shutting down vg $i\" >> " 231 232 MONDO_LOGFILE "; done", vgscan_sz, vgchange_sz, vgremove_sz); 232 paranoid_free(vgchange_sz);233 paranoid_free(vgremove_sz);233 mr_free(vgchange_sz); 234 mr_free(vgremove_sz); 234 235 235 236 run_program_and_log_output(command, 5); 236 paranoid_free(command);237 mr_free(command); 237 238 238 239 if (just_erase_existing_volumes) { … … 250 251 log_msg(1, "OK, rewound i-want-my-lvm. Doing funky stuff..."); 251 252 rewind(fin); 252 for ( getline(&incoming, &n1, fin); !feof(fin);getline(&incoming, &n1, fin)) {253 for (mr_getline(&incoming, &n1, fin); !feof(fin); mr_getline(&incoming, &n1, fin)) { 253 254 fgetpos(fin, &orig_pos); 254 255 /* we want to execute lines begining with a # */ … … 264 265 if ((p = strstr(incoming, "vgcreate"))) { 265 266 // include next line(s) if they end in /dev (cos we've got a broken i-want-my-lvm) 266 for ( getline(&tmp, &n, fin); !feof(fin);getline(&tmp, &n, fin)) {267 for (mr_getline(&tmp, &n, fin); !feof(fin); mr_getline(&tmp, &n, fin)) { 267 268 if (tmp[0] == '#') { 268 269 fsetpos(fin, &orig_pos); … … 270 271 } else { 271 272 fgetpos(fin, &orig_pos); 272 asprintf(&tmp1, "%s%s", incoming, tmp);273 paranoid_free(incoming);273 mr_asprintf(&tmp1, "%s%s", incoming, tmp); 274 mr_free(incoming); 274 275 incoming = tmp1; 275 276 } 276 277 } 277 paranoid_free(tmp);278 mr_free(tmp); 278 279 279 280 for (q = incoming; *q != '\0'; q++) { … … 282 283 } 283 284 } 284 asprintf(&tmp1, p + strlen("vgcreate") + 1);285 mr_asprintf(&tmp1, p + strlen("vgcreate") + 1); 285 286 for (q = tmp1; *q > 32; q++); 286 287 *q = '\0'; 287 288 log_msg(1, "Deleting old entries at /dev/%s", tmp1); 288 asprintf(&tmp, "rm -Rf /dev/%s", tmp1);289 paranoid_free(tmp1);289 mr_asprintf(&tmp, "rm -Rf /dev/%s", tmp1); 290 mr_free(tmp1); 290 291 291 292 run_program_and_log_output(tmp, 1); 292 paranoid_free(tmp);293 mr_free(tmp); 293 294 294 295 run_program_and_log_output(vgscan_sz, 1); … … 299 300 } 300 301 for (p = incoming + 1; *p == ' '; p++); 301 paranoid_alloc(command,p);302 mr_allocstr(command,p); 302 303 for (p = command; *p != '\0'; p++); 303 304 for (; *(p - 1) < 32; p--); … … 333 334 extents = atol(p); 334 335 log_msg(5, "p='%s' --> extents=%ld", p, extents); 335 paranoid_free(tmp);336 mr_free(tmp); 336 337 337 338 p = strstr(command, "-L"); … … 384 385 retval++; 385 386 } 386 asprintf(&tmp, "echo \"%s\" >> /tmp/out.sh", command);387 mr_asprintf(&tmp, "echo \"%s\" >> /tmp/out.sh", command); 387 388 system(tmp); 388 paranoid_free(tmp);389 mr_free(tmp); 389 390 sleep(1); 390 391 } 391 392 paranoid_fclose(fin); 392 paranoid_free(vgscan_sz);393 paranoid_free(pvscan_sz);394 paranoid_free(command);395 paranoid_free(incoming);393 mr_free(vgscan_sz); 394 mr_free(pvscan_sz); 395 mr_free(command); 396 mr_free(incoming); 396 397 397 398 log_msg(1, "Closed i-want-my-lvm. Finished doing funky stuff."); … … 460 461 finish(1); 461 462 } 462 for ( getline(&incoming, &n, fin); !feof(fin)463 for (mr_getline(&incoming, &n, fin); !feof(fin) 463 464 && !strstr(incoming, old_mountlist->el[lino].device); 464 getline(&incoming, &n, fin));465 mr_getline(&incoming, &n, fin)); 465 466 if (!feof(fin)) { 466 asprintf(&tmp, "Investigating %s",467 mr_asprintf(&tmp, "Investigating %s", 467 468 old_mountlist->el[lino].device); 468 469 log_it(tmp); 469 paranoid_free(tmp);470 471 for ( getline(&incoming, &n, fin); !feof(fin)470 mr_free(tmp); 471 472 for (mr_getline(&incoming, &n, fin); !feof(fin) 472 473 && !strstr(incoming, "raiddev"); 473 getline(&incoming, &n, fin)) {474 mr_getline(&incoming, &n, fin)) { 474 475 if (strstr(incoming, OSSWAP("device", "drive")) 475 476 && !strchr(incoming, '#')) { … … 478 479 *p = '\0'; 479 480 for (p--; p > incoming && *(p - 1) > 32; p--); 480 asprintf(&tmp, "Extrapolating %s", p);481 mr_asprintf(&tmp, "Extrapolating %s", p); 481 482 log_it(tmp); 482 paranoid_free(tmp);483 mr_free(tmp); 483 484 484 485 for (j = 0; … … 499 500 new_mountlist->entries++; 500 501 } else { 501 asprintf(&tmp,502 mr_asprintf(&tmp, 502 503 "Not adding %s to mountlist: it's already there", p); 503 504 log_it(tmp); 504 paranoid_free(tmp);505 mr_free(tmp); 505 506 } 506 507 } 507 508 } 508 509 } 509 paranoid_free(incoming);510 mr_free(incoming); 510 511 paranoid_fclose(fin); 511 512 } else { … … 566 567 } 567 568 // create device list from normal disks followed by spare ones 568 asprintf(&devices, raidlist->el[i].data_disks.el[0].device);569 mr_asprintf(&devices, raidlist->el[i].data_disks.el[0].device); 569 570 for (j = 1; j < raidlist->el[i].data_disks.entries; j++) { 570 asprintf(&strtmp, "%s", devices);571 paranoid_free(devices);572 asprintf(&devices, "%s %s", strtmp,571 mr_asprintf(&strtmp, "%s", devices); 572 mr_free(devices); 573 mr_asprintf(&devices, "%s %s", strtmp, 573 574 raidlist->el[i].data_disks.el[j].device); 574 paranoid_free(strtmp);575 mr_free(strtmp); 575 576 } 576 577 for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) { 577 asprintf(&strtmp, "%s", devices);578 paranoid_free(devices);579 asprintf(&devices, "%s %s", strtmp,578 mr_asprintf(&strtmp, "%s", devices); 579 mr_free(devices); 580 mr_asprintf(&devices, "%s %s", strtmp, 580 581 raidlist->el[i].spare_disks.el[j].device); 581 paranoid_free(strtmp);582 mr_free(strtmp); 582 583 } 583 584 // translate RAID level 584 585 if (raidlist->el[i].raid_level == -2) { 585 asprintf(&level, "multipath");586 mr_asprintf(&level, "multipath"); 586 587 } else if (raidlist->el[i].raid_level == -1) { 587 asprintf(&level, "linear");588 mr_asprintf(&level, "linear"); 588 589 } else { 589 asprintf(&level, "raid%d", raidlist->el[i].raid_level);590 mr_asprintf(&level, "raid%d", raidlist->el[i].raid_level); 590 591 } 591 592 // create RAID device: … … 594 595 // - faulty devices ignored 595 596 // - persistent superblock always used as this is recommended 596 asprintf(&program,597 mr_asprintf(&program, 597 598 "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", 598 599 raidlist->el[i].raid_device, level, 599 600 raidlist->el[i].data_disks.entries); 600 601 if (raidlist->el[i].parity != -1) { 601 asprintf(&strtmp, "%s", program);602 paranoid_free(program);602 mr_asprintf(&strtmp, "%s", program); 603 mr_free(program); 603 604 switch (raidlist->el[i].parity) { 604 605 case 0: 605 asprintf(&program, "%s --parity=%s", strtmp, "la");606 mr_asprintf(&program, "%s --parity=%s", strtmp, "la"); 606 607 break; 607 608 case 1: 608 asprintf(&program, "%s --parity=%s", strtmp, "ra");609 mr_asprintf(&program, "%s --parity=%s", strtmp, "ra"); 609 610 break; 610 611 case 2: 611 asprintf(&program, "%s --parity=%s", strtmp, "ls");612 mr_asprintf(&program, "%s --parity=%s", strtmp, "ls"); 612 613 break; 613 614 case 3: 614 asprintf(&program, "%s --parity=%s", strtmp, "rs");615 mr_asprintf(&program, "%s --parity=%s", strtmp, "rs"); 615 616 break; 616 617 default: … … 618 619 break; 619 620 } 620 paranoid_free(strtmp);621 mr_free(strtmp); 621 622 } 622 623 if (raidlist->el[i].chunk_size != -1) { 623 asprintf(&strtmp, "%s", program);624 paranoid_free(program);625 asprintf(&program, "%s --chunk=%d", strtmp,624 mr_asprintf(&strtmp, "%s", program); 625 mr_free(program); 626 mr_asprintf(&program, "%s --chunk=%d", strtmp, 626 627 raidlist->el[i].chunk_size); 627 paranoid_free(strtmp);628 mr_free(strtmp); 628 629 } 629 630 if (raidlist->el[i].spare_disks.entries > 0) { 630 asprintf(&strtmp, "%s", program);631 paranoid_free(program);632 asprintf(&program, "%s --spare-devices=%d", strtmp,631 mr_asprintf(&strtmp, "%s", program); 632 mr_free(program); 633 mr_asprintf(&program, "%s --spare-devices=%d", strtmp, 633 634 raidlist->el[i].spare_disks.entries); 634 paranoid_free(strtmp);635 } 636 asprintf(&strtmp, "%s", program);637 paranoid_free(program);638 asprintf(&program, "%s %s", strtmp, devices);639 paranoid_free(strtmp);635 mr_free(strtmp); 636 } 637 mr_asprintf(&strtmp, "%s", program); 638 mr_free(program); 639 mr_asprintf(&program, "%s %s", strtmp, devices); 640 mr_free(strtmp); 640 641 res = run_program_and_log_output(program, 1); 641 642 // free memory 642 paranoid_free(devices);643 paranoid_free(level);644 paranoid_free(program);643 mr_free(devices); 644 mr_free(level); 645 mr_free(program); 645 646 // return to calling instance 646 647 return res; … … 687 688 688 689 if (strstr(format, "raid")) { // do not form RAID disks; do it to /dev/md* instead 689 asprintf(&tmp, "Not formatting %s (it is a RAID disk)", device);690 mr_asprintf(&tmp, "Not formatting %s (it is a RAID disk)", device); 690 691 log_it(tmp); 691 paranoid_free(tmp);692 mr_free(tmp); 692 693 return (0); 693 694 } … … 699 700 #endif 700 701 if (strlen(format) <= 2) { 701 asprintf(&tmp,702 mr_asprintf(&tmp, 702 703 "%s has a really small format type ('%s') - this is probably a hexadecimal string, which would suggest the partition is an image --- I shouldn't format it", 703 704 device, format); 704 705 log_it(tmp); 705 paranoid_free(tmp);706 mr_free(tmp); 706 707 return (0); 707 708 } 708 709 if (is_this_device_mounted(device)) { 709 asprintf(&tmp, _("%s is mounted - cannot format it "), device);710 mr_asprintf(&tmp, _("%s is mounted - cannot format it "), device); 710 711 log_to_screen(tmp); 711 paranoid_free(tmp);712 mr_free(tmp); 712 713 return (1); 713 714 } … … 736 737 737 738 if (vinum_started_yet) { 738 asprintf(&tmp,739 mr_asprintf(&tmp, 739 740 _ 740 741 ("Initializing Vinum device %s (this may take a *long* time)"), 741 742 device); 742 743 log_to_screen(tmp); 743 paranoid_free(tmp);744 mr_free(tmp); 744 745 745 746 /* format raid partition */ 746 asprintf(&program,747 mr_asprintf(&program, 747 748 "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", 748 749 basename(device)); … … 752 753 fprintf(g_fprep, "%s\n", program); 753 754 } 754 paranoid_free(program);755 mr_free(program); 755 756 756 757 fin = fopen("/tmp/plexes", "r"); 757 while ( getline(&line, &n, fin)) {758 while (mr_getline(&line, &n, fin)) { 758 759 if (strchr(line, '\n')) 759 760 *(strchr(line, '\n')) = '\0'; // get rid of the \n on the end 760 761 761 asprintf(&tmp, "Initializing plex: %s", line);762 mr_asprintf(&tmp, "Initializing plex: %s", line); 762 763 open_evalcall_form(tmp); 763 paranoid_free(tmp);764 765 asprintf(&tmp, "vinum init %s", line);764 mr_free(tmp); 765 766 mr_asprintf(&tmp, "vinum init %s", line); 766 767 system(tmp); 767 paranoid_free(tmp);768 mr_free(tmp); 768 769 769 770 while (1) { 770 asprintf(&tmp,771 mr_asprintf(&tmp, 771 772 "vinum lp -r %s | grep '^S' | head -1 | tr -s ' ' | cut -d: -f2 | cut -f1 | sed 's/^ //' | sed 's/I //' | sed 's/%%//'", 772 773 line); 773 774 pin = popen(tmp, "r"); 774 paranoid_free(tmp);775 776 getline(&status, &n1, pin);775 mr_free(tmp); 776 777 mr_getline(&status, &n1, pin); 777 778 pclose(pin); 778 779 … … 782 783 update_evalcall_form(atoi(status)); 783 784 usleep(250000); 784 paranoid_free(status);785 mr_free(status); 785 786 } 786 787 close_evalcall_form(); 787 788 } 788 paranoid_free(line);789 mr_free(line); 789 790 fclose(fin); 790 791 unlink("/tmp/plexes"); … … 792 793 } 793 794 #else 794 asprintf(&tmp, _("Initializing RAID device %s"), device);795 mr_asprintf(&tmp, _("Initializing RAID device %s"), device); 795 796 log_to_screen(tmp); 796 paranoid_free(tmp);797 mr_free(tmp); 797 798 798 799 // Shouldn't be necessary. … … 814 815 device, res); 815 816 } else { 816 asprintf(&program, "mkraid --really-force %s", device);817 mr_asprintf(&program, "mkraid --really-force %s", device); 817 818 res = run_program_and_log_output(program, 1); 818 819 log_msg(1, "%s returned %d", program, res); … … 823 824 fprintf(g_fprep, "%s\n", program); 824 825 } 825 paranoid_free(program);826 mr_free(program); 826 827 } 827 828 sync(); … … 842 843 res = which_format_command_do_i_need(format, program); 843 844 if (strstr(program, "kludge")) { 844 asprintf(&tmp, "%s %s /", program, device);845 mr_asprintf(&tmp, "%s %s /", program, device); 845 846 } else { 846 asprintf(&tmp, "%s %s", program, device);847 } 848 paranoid_free(program);849 850 asprintf(&program, "sh -c 'echo -en \"y\\ny\\ny\\n\" | %s'", tmp);851 paranoid_free(tmp);852 853 asprintf(&tmp, "Formatting %s as %s", device, format);847 mr_asprintf(&tmp, "%s %s", program, device); 848 } 849 mr_free(program); 850 851 mr_asprintf(&program, "sh -c 'echo -en \"y\\ny\\ny\\n\" | %s'", tmp); 852 mr_free(tmp); 853 854 mr_asprintf(&tmp, "Formatting %s as %s", device, format); 854 855 update_progress_form(tmp); 855 856 … … 857 858 if (res && strstr(program, "kludge")) { 858 859 #ifdef __FreeBSD__ 859 paranoid_free(program);860 asprintf(&program, "newfs_msdos -F 32 %s", device);860 mr_free(program); 861 mr_asprintf(&program, "newfs_msdos -F 32 %s", device); 861 862 #else 862 863 #ifdef __IA64__ 863 864 /* For EFI partitions take fat16 864 865 * as we want to make small ones */ 865 paranoid_free(program);866 asprintf(&program, "mkfs -t %s -F 16 %s", format, device);866 mr_free(program); 867 mr_asprintf(&program, "mkfs -t %s -F 16 %s", format, device); 867 868 #else 868 paranoid_free(program);869 asprintf(&program, "mkfs -t %s -F 32 %s", format, device);869 mr_free(program); 870 mr_asprintf(&program, "mkfs -t %s -F 32 %s", format, device); 870 871 #endif 871 872 #endif … … 875 876 } 876 877 } 877 paranoid_free(program);878 mr_free(program); 878 879 879 880 retval += res; 880 881 if (retval) { 881 asprintf(&tmp1, "%s%s",tmp, _("...failed"));882 mr_asprintf(&tmp1, "%s%s",tmp, _("...failed")); 882 883 } else { 883 asprintf(&tmp1, "%s%s",tmp, _("...OK"));884 } 885 paranoid_free(tmp);884 mr_asprintf(&tmp1, "%s%s",tmp, _("...OK")); 885 } 886 mr_free(tmp); 886 887 887 888 log_to_screen(tmp1); 888 paranoid_free(tmp1);889 mr_free(tmp1); 889 890 sync(); 890 891 sleep(1); … … 923 924 924 925 assert(mountlist != NULL); 925 asprintf(&tmp, "format_everything (mountlist, interactively = %s",926 mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s", 926 927 (interactively) ? "true" : "false"); 927 928 log_it(tmp); 928 paranoid_free(tmp);929 mr_free(tmp); 929 930 930 931 mvaddstr_and_log_it(g_currentY, 0, _("Formatting partitions ")); … … 952 953 if (interactively) { 953 954 // ask user if we should format the current device 954 asprintf(&tmp, "Shall I format %s (%s) ?", me->device,955 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, 955 956 me->mountpoint); 956 957 do_it = ask_me_yes_or_no(tmp); 957 paranoid_free(tmp);958 mr_free(tmp); 958 959 } else { 959 960 do_it = TRUE; … … 1003 1004 me = &mountlist->el[lino]; // the current mountlist entry 1004 1005 if (!strcmp(me->mountpoint, "image")) { 1005 asprintf(&tmp, "Not formatting %s - it's an image", me->device);1006 mr_asprintf(&tmp, "Not formatting %s - it's an image", me->device); 1006 1007 log_it(tmp); 1007 paranoid_free(tmp);1008 mr_free(tmp); 1008 1009 } else if (!strcmp(me->format, "raid")) { 1009 asprintf(&tmp, "Not formatting %s - it's a raid-let",1010 mr_asprintf(&tmp, "Not formatting %s - it's a raid-let", 1010 1011 me->device); 1011 1012 log_it(tmp); 1012 paranoid_free(tmp);1013 mr_free(tmp); 1013 1014 continue; 1014 1015 } else if (!strcmp(me->format, "lvm")) { 1015 asprintf(&tmp, "Not formatting %s - it's an LVM", me->device);1016 mr_asprintf(&tmp, "Not formatting %s - it's an LVM", me->device); 1016 1017 log_it(tmp); 1017 paranoid_free(tmp);1018 mr_free(tmp); 1018 1019 continue; 1019 1020 } else if (!strncmp(me->device, "/dev/md", 7)) { 1020 asprintf(&tmp, "Already formatted %s - it's a soft-RAID dev",1021 mr_asprintf(&tmp, "Already formatted %s - it's a soft-RAID dev", 1021 1022 me->device); 1022 1023 log_it(tmp); 1023 paranoid_free(tmp);1024 mr_free(tmp); 1024 1025 continue; 1025 1026 } else if (!does_file_exist(me->device) 1026 1027 && strncmp(me->device, "/dev/hd", 7) 1027 1028 && strncmp(me->device, "/dev/sd", 7)) { 1028 asprintf(&tmp,1029 mr_asprintf(&tmp, 1029 1030 "Not formatting %s yet - doesn't exist - probably an LVM", 1030 1031 me->device); 1031 1032 log_it(tmp); 1032 paranoid_free(tmp);1033 mr_free(tmp); 1033 1034 continue; 1034 1035 } else { 1035 1036 if (interactively) { 1036 1037 // ask user if we should format the current device 1037 asprintf(&tmp, "Shall I format %s (%s) ?", me->device,1038 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, 1038 1039 me->mountpoint); 1039 1040 do_it = ask_me_yes_or_no(tmp); 1040 paranoid_free(tmp);1041 mr_free(tmp); 1041 1042 } else { 1042 1043 do_it = TRUE; … … 1068 1069 } 1069 1070 1070 asprintf(&tmp, "format_everything () - %s",1071 mr_asprintf(&tmp, "format_everything () - %s", 1071 1072 (retval) ? "failed!" : "finished successfully"); 1072 1073 log_it(tmp); 1073 paranoid_free(tmp);1074 mr_free(tmp); 1074 1075 1075 1076 if (g_partition_table_locked_up > 0) { … … 1135 1136 1136 1137 if (devno_we_must_allow_for >= 5) { 1137 asprintf(&tmp, "Making dummy primary %s%d", drivename, 1);1138 mr_asprintf(&tmp, "Making dummy primary %s%d", drivename, 1); 1138 1139 log_it(tmp); 1139 paranoid_free(tmp);1140 mr_free(tmp); 1140 1141 1141 1142 g_maximum_progress++; … … 1151 1152 } 1152 1153 for (; current_devno < devno_we_must_allow_for; current_devno++) { 1153 asprintf(&tmp, "Creating dummy partition %s%d", drivename,1154 mr_asprintf(&tmp, "Creating dummy partition %s%d", drivename, 1154 1155 current_devno); 1155 1156 log_it(tmp); 1156 paranoid_free(tmp);1157 mr_free(tmp); 1157 1158 1158 1159 g_maximum_progress++; … … 1301 1302 off_t mediasize; 1302 1303 1303 asprintf(&lnamebuf, "%s", dkname);1304 mr_asprintf(&lnamebuf, "%s", dkname); 1304 1305 if ((f = open(lnamebuf, O_RDONLY)) == -1) { 1305 1306 warn("cannot open %s", lnamebuf); 1306 paranoid_free(lnamebuf);1307 mr_free(lnamebuf); 1307 1308 return (NULL); 1308 1309 } 1309 paranoid_free(lnamebuf);1310 mr_free(lnamebuf); 1310 1311 1311 1312 /* New world order */ … … 1389 1390 for (c = 'a'; c <= 'z'; ++c) { 1390 1391 int idx; 1391 asprintf(&subdev_str, "%s%c", drivename, c);1392 mr_asprintf(&subdev_str, "%s%c", drivename, c); 1392 1393 if ((idx = find_device_in_mountlist(mountlist, subdev_str)) < 0) { 1393 1394 lp->d_partitions[c - 'a'].p_size = 0; … … 1414 1415 lp->d_partitions[c - 'a'].p_fstype = FS_OTHER; 1415 1416 } 1416 paranoid_free(subdev_str);1417 mr_free(subdev_str); 1417 1418 } 1418 1419 … … 1445 1446 display_disklabel(ftmp, lp); 1446 1447 fclose(ftmp); 1447 asprintf(&command, "disklabel -wr %s auto", canonical_name(drivename));1448 mr_asprintf(&command, "disklabel -wr %s auto", canonical_name(drivename)); 1448 1449 retval += run_program_and_log_output(command, TRUE); 1449 paranoid_free(command);1450 1451 asprintf(&command, "disklabel -R %s /tmp/disklabel",1450 mr_free(command); 1451 1452 mr_asprintf(&command, "disklabel -R %s /tmp/disklabel", 1452 1453 canonical_name(drivename)); 1453 1454 retval += run_program_and_log_output(command, TRUE); 1454 paranoid_free(command);1455 mr_free(command); 1455 1456 if (ret) 1456 1457 *ret = *lp; … … 1495 1496 assert_string_is_neither_NULL_nor_zerolength(drivename); 1496 1497 1497 asprintf(&tmp, "Partitioning drive %s", drivename);1498 mr_asprintf(&tmp, "Partitioning drive %s", drivename); 1498 1499 log_it(tmp); 1499 paranoid_free(tmp);1500 mr_free(tmp); 1500 1501 1501 1502 #if __FreeBSD__ … … 1504 1505 #else 1505 1506 make_hole_for_file(FDISK_LOG); 1506 asprintf(&tmp, "parted2fdisk %s >> %s 2>> %s", drivename, FDISK_LOG,1507 mr_asprintf(&tmp, "parted2fdisk %s >> %s 2>> %s", drivename, FDISK_LOG, 1507 1508 FDISK_LOG); 1508 1509 pout_to_fdisk = popen(tmp, "w"); 1509 paranoid_free(tmp);1510 mr_free(tmp); 1510 1511 1511 1512 if (!pout_to_fdisk) { … … 1531 1532 // try DangerouslyDedicated mode 1532 1533 for (c = 'a'; c <= 'z'; c++) { 1533 asprintf(&subdev_str, "%s%c", drivename, c);1534 mr_asprintf(&subdev_str, "%s%c", drivename, c); 1534 1535 if (find_device_in_mountlist(mountlist, subdev_str) > 0) { 1535 1536 fbsd_part = TRUE; 1536 1537 } 1537 paranoid_free(subdev_str);1538 mr_free(subdev_str); 1538 1539 } 1539 1540 if (fbsd_part) { … … 1541 1542 drivename, 1542 1543 0); 1543 asprintf(&command, "disklabel -B %s",1544 mr_asprintf(&command, "disklabel -B %s", 1544 1545 basename(drivename)); 1545 1546 if (system(command)) { … … 1548 1549 ("Warning! Unable to make the drive bootable.")); 1549 1550 } 1550 paranoid_free(command);1551 paranoid_free(device_str);1551 mr_free(command); 1552 mr_free(device_str); 1552 1553 1553 1554 return r; … … 1555 1556 } 1556 1557 for (c = 'a'; c <= 'z'; c++) { 1557 asprintf(&subdev_str, "%s%c", device_str, c);1558 mr_asprintf(&subdev_str, "%s%c", device_str, c); 1558 1559 if (find_device_in_mountlist(mountlist, subdev_str) > 0) { 1559 1560 fbsd_part = TRUE; 1560 1561 } 1561 paranoid_free(subdev_str);1562 mr_free(subdev_str); 1562 1563 } 1563 1564 // Now we check the subpartitions of the current partition. … … 1565 1566 int i, line; 1566 1567 1567 asprintf(&format, "ufs");1568 mr_asprintf(&format, "ufs"); 1568 1569 partsize = 0; 1569 1570 for (i = 'a'; i < 'z'; ++i) { 1570 asprintf(&subdev_str, "%s%c", device_str, i);1571 mr_asprintf(&subdev_str, "%s%c", device_str, i); 1571 1572 line = find_device_in_mountlist(mountlist, subdev_str); 1572 paranoid_free(subdev_str);1573 mr_free(subdev_str); 1573 1574 1574 1575 if (line > 0) { … … 1596 1597 file = open(drivename, O_WRONLY); 1597 1598 if (!file) { 1598 asprintf(&tmp,1599 mr_asprintf(&tmp, 1599 1600 _("Warning - unable to open %s for wiping it's partition table"), 1600 1601 drivename); 1601 1602 log_to_screen(tmp); 1602 paranoid_free(tmp);1603 mr_free(tmp); 1603 1604 } 1604 1605 1605 1606 for (i = 0; i < 512; i++) { 1606 1607 if (!write(file, "\0", 1)) { 1607 asprintf(&tmp, _("Warning - unable to write to %s"),1608 mr_asprintf(&tmp, _("Warning - unable to write to %s"), 1608 1609 drivename); 1609 1610 log_to_screen(tmp); 1610 paranoid_free(tmp);1611 mr_free(tmp); 1611 1612 } 1612 1613 } … … 1629 1630 #endif 1630 1631 1631 asprintf(&format, mountlist->el[lino].format);1632 mr_asprintf(&format, mountlist->el[lino].format); 1632 1633 partsize = mountlist->el[lino].size; 1633 1634 … … 1640 1641 (_ 1641 1642 ("You must leave at least one partition spare as the Extended partition.")); 1642 paranoid_free(device_str);1643 paranoid_free(format);1643 mr_free(device_str); 1644 mr_free(format); 1644 1645 1645 1646 return (1); … … 1652 1653 #ifdef __FreeBSD__ 1653 1654 if ((current_devno <= 4) && fbsd_part) { 1654 asprintf(&tmp, "disklabel -B %s", basename(device_str));1655 mr_asprintf(&tmp, "disklabel -B %s", basename(device_str)); 1655 1656 retval += label_drive_or_slice(mountlist, device_str, 0); 1656 1657 if (system(tmp)) { … … 1658 1659 (_("Warning! Unable to make the slice bootable.")); 1659 1660 } 1660 paranoid_free(tmp);1661 mr_free(tmp); 1661 1662 } 1662 1663 #endif … … 1664 1665 previous_devno = current_devno; 1665 1666 } 1666 paranoid_free(device_str);1667 paranoid_free(format);1667 mr_free(device_str); 1668 mr_free(format); 1668 1669 1669 1670 if (pout_to_fdisk) { … … 1671 1672 tmp1 = call_program_and_get_last_line_of_output 1672 1673 ("make-me-bootable /tmp/mountlist.txt dummy"); 1673 asprintf(&tmp, "a\n%s\n", tmp1);1674 paranoid_free(tmp1);1674 mr_asprintf(&tmp, "a\n%s\n", tmp1); 1675 mr_free(tmp1); 1675 1676 1676 1677 fput_string_one_char_at_a_time(pout_to_fdisk, tmp); 1677 paranoid_free(tmp);1678 mr_free(tmp); 1678 1679 1679 1680 // close fdisk … … 1683 1684 log_msg(0, 1684 1685 "------------------- fdisk.log looks like this ------------------"); 1685 asprintf(&tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);1686 mr_asprintf(&tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE); 1686 1687 system(tmp); 1687 paranoid_free(tmp);1688 mr_free(tmp); 1688 1689 1689 1690 log_msg(0, 1690 1691 "------------------- end of fdisk.log... word! ------------------"); 1691 asprintf(&tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG);1692 mr_asprintf(&tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG); 1692 1693 if (!run_program_and_log_output(tmp, 5)) { 1693 1694 g_partition_table_locked_up++; … … 1696 1697 ("A flaw in the Linux kernel has locked the partition table.")); 1697 1698 } 1698 paranoid_free(tmp);1699 mr_free(tmp); 1699 1700 } 1700 1701 return (retval); … … 1739 1740 1740 1741 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { 1741 asprintf(&tmp, "Not partitioning %s - it is a virtual drive", drive);1742 mr_asprintf(&tmp, "Not partitioning %s - it is a virtual drive", drive); 1742 1743 log_it(tmp); 1743 paranoid_free(tmp);1744 mr_free(tmp); 1744 1745 return (0); 1745 1746 } 1746 1747 partition_name = build_partition_name(drive, partno); 1747 1748 if (partsize <= 0) { 1748 asprintf(&tmp, "Partitioning device %s (max size)", partition_name);1749 mr_asprintf(&tmp, "Partitioning device %s (max size)", partition_name); 1749 1750 } else { 1750 asprintf(&tmp, "Partitioning device %s (%lld MB)", partition_name,1751 mr_asprintf(&tmp, "Partitioning device %s (%lld MB)", partition_name, 1751 1752 (long long) partsize / 1024); 1752 1753 } 1753 1754 update_progress_form(tmp); 1754 1755 log_it(tmp); 1755 paranoid_free(tmp);1756 mr_free(tmp); 1756 1757 1757 1758 if (is_this_device_mounted(partition_name)) { 1758 asprintf(&tmp, _("%s is mounted, and should not be partitioned"),1759 mr_asprintf(&tmp, _("%s is mounted, and should not be partitioned"), 1759 1760 partition_name); 1760 paranoid_free(partition_name);1761 mr_free(partition_name); 1761 1762 1762 1763 log_to_screen(tmp); 1763 paranoid_free(tmp);1764 mr_free(tmp); 1764 1765 return (1); 1765 1766 } 1766 1767 1767 1768 p = (char *) strrchr(partition_name, '/'); 1768 asprintf(&program, "parted2fdisk %s >> %s 2>> %s", drive, MONDO_LOGFILE,1769 mr_asprintf(&program, "parted2fdisk %s >> %s 2>> %s", drive, MONDO_LOGFILE, 1769 1770 MONDO_LOGFILE); 1770 1771 … … 1773 1774 /* make it a primary/extended/logical */ 1774 1775 if (partno <= 4) { 1775 asprintf(&output,"n\np\n%d\n", partno);1776 mr_asprintf(&output,"n\np\n%d\n", partno); 1776 1777 } else { 1777 1778 /* MBR needs an extended partition if more than 4 partitions */ … … 1782 1783 (_ 1783 1784 ("You need to leave at least one partition free, for 'extended/logical'")); 1784 paranoid_free(partition_name);1785 paranoid_free(program);1786 1787 paranoid_free(output);1785 mr_free(partition_name); 1786 mr_free(program); 1787 1788 mr_free(output); 1788 1789 return (1); 1789 1790 } else { 1790 asprintf(&output,"n\ne\n%d\n\n\n",prev_partno + 1);1791 mr_asprintf(&output,"n\ne\n%d\n\n\n",prev_partno + 1); 1791 1792 } 1792 1793 } 1793 asprintf(&tmp,"%sn\nl\n",output);1794 paranoid_free(output);1794 mr_asprintf(&tmp,"%sn\nl\n",output); 1795 mr_free(output); 1795 1796 output = tmp; 1796 1797 } else { 1797 1798 /* GPT allows more than 4 primary partitions */ 1798 asprintf(&output,"n\np\n%d\n",partno);1799 } 1800 } 1801 paranoid_free(part_table_fmt);1799 mr_asprintf(&output,"n\np\n%d\n",partno); 1800 } 1801 } 1802 mr_free(part_table_fmt); 1802 1803 /*start block (ENTER for next free blk */ 1803 asprintf(&tmp,"%s\n",output);1804 paranoid_free(output);1804 mr_asprintf(&tmp,"%s\n",output); 1805 mr_free(output); 1805 1806 output = tmp; 1806 1807 … … 1810 1811 partsize += 512; 1811 1812 } 1812 asprintf(&tmp,"%s+%lldK", output, (long long) (partsize));1813 paranoid_free(output);1813 mr_asprintf(&tmp,"%s+%lldK", output, (long long) (partsize)); 1814 mr_free(output); 1814 1815 output = tmp; 1815 1816 } 1816 asprintf(&tmp,"%s\n",output);1817 paranoid_free(output);1817 mr_asprintf(&tmp,"%s\n",output); 1818 mr_free(output); 1818 1819 output = tmp; 1819 1820 #if 0 1820 1821 /* 1821 1822 #endif 1822 asprintf(&tmp,"PARTSIZE = +%ld",(long)partsize);1823 mr_asprintf(&tmp,"PARTSIZE = +%ld",(long)partsize); 1823 1824 log_it(tmp); 1824 paranoid_free(tmp);1825 mr_free(tmp); 1825 1826 1826 1827 log_it("---fdisk command---"); … … 1845 1846 partno); 1846 1847 } 1847 paranoid_free(tmp);1848 mr_free(tmp); 1848 1849 1849 1850 if (!retval) { … … 1864 1865 } 1865 1866 } else { 1866 asprintf(&tmp,"%sw\n\n",output);1867 paranoid_free(output);1867 mr_asprintf(&tmp,"%sw\n\n",output); 1868 mr_free(output); 1868 1869 output = tmp; 1869 1870 … … 1885 1886 format, -1); 1886 1887 if (res) { 1887 asprintf(&tmp, "Failed to vacuum-pack %s", partition_name);1888 mr_asprintf(&tmp, "Failed to vacuum-pack %s", partition_name); 1888 1889 log_it(tmp); 1889 paranoid_free(tmp);1890 mr_free(tmp); 1890 1891 1891 1892 retval++; … … 1899 1900 partsize); 1900 1901 if (retval) { 1901 asprintf(&tmp, "Partitioned %s but failed to set its type",1902 mr_asprintf(&tmp, "Partitioned %s but failed to set its type", 1902 1903 partition_name); 1903 1904 log_it(tmp); 1904 paranoid_free(tmp);1905 mr_free(tmp); 1905 1906 } else { 1906 1907 if (partsize > 0) { 1907 asprintf(&tmp, "Partition %s created+configured OK",1908 mr_asprintf(&tmp, "Partition %s created+configured OK", 1908 1909 partition_name); 1909 1910 log_to_screen(tmp); 1910 paranoid_free(tmp);1911 mr_free(tmp); 1911 1912 } else { 1912 1913 log_it("Returning from a successful vacuum-pack"); … … 1914 1915 } 1915 1916 } else { 1916 asprintf(&tmp, "Failed to partition %s", partition_name);1917 mr_asprintf(&tmp, "Failed to partition %s", partition_name); 1917 1918 if (partsize > 0) { 1918 1919 log_to_screen(tmp); … … 1920 1921 log_it(tmp); 1921 1922 } 1922 paranoid_free(tmp);1923 mr_free(tmp); 1923 1924 retval++; 1924 1925 } … … 1926 1927 g_current_progress++; 1927 1928 log_it("partition_device() --- leaving"); 1928 paranoid_free(partition_name);1929 paranoid_free(program);1930 paranoid_free(output);1929 mr_free(partition_name); 1930 mr_free(program); 1931 mr_free(output); 1931 1932 return (retval); 1932 1933 } … … 2014 2015 system("clear"); 2015 2016 newtResume(); 2016 paranoid_free(drivelist);2017 mr_free(drivelist); 2017 2018 return (retval); 2018 2019 } … … 2058 2059 p = (char *) strrchr(partition, '/'); 2059 2060 if (strcmp(format, "swap") == 0) { 2060 asprintf(&partcode, "82");2061 mr_asprintf(&partcode, "82"); 2061 2062 } else if (strcmp(format, "vfat") == 0) { 2062 2063 if (partsize / 1024 > 8192) { 2063 asprintf(&partcode, "c");2064 mr_asprintf(&partcode, "c"); 2064 2065 } else { 2065 asprintf(&partcode, "b");2066 mr_asprintf(&partcode, "b"); 2066 2067 } 2067 2068 } else if (strcmp(format, "ext2") == 0 … … 2069 2070 || strcmp(format, "ext3") == 0 || strcmp(format, "xfs") == 0 2070 2071 || strcmp(format, "jfs") == 0) { 2071 asprintf(&partcode, "83");2072 mr_asprintf(&partcode, "83"); 2072 2073 } else if (strcmp(format, "minix") == 0) { 2073 asprintf(&partcode, "81");2074 mr_asprintf(&partcode, "81"); 2074 2075 } else if (strcmp(format, "raid") == 0) { 2075 asprintf(&partcode, "fd");2076 mr_asprintf(&partcode, "fd"); 2076 2077 } else if ((strcmp(format, "ufs") == 0) 2077 2078 || (strcmp(format, "ffs") == 0)) { /* raid autodetect */ 2078 asprintf(&partcode, "a5");2079 mr_asprintf(&partcode, "a5"); 2079 2080 } else if (strcmp(format, "lvm") == 0) { 2080 asprintf(&partcode, "8e");2081 mr_asprintf(&partcode, "8e"); 2081 2082 } else if (format[0] == '\0') { /* LVM physical partition */ 2082 asprintf(&partcode, "%s", "");2083 mr_asprintf(&partcode, "%s", ""); 2083 2084 } else if (strlen(format) >= 1 && strlen(format) <= 2) { 2084 asprintf(&partcode, format);2085 mr_asprintf(&partcode, format); 2085 2086 } else { 2086 2087 /* probably an image */ 2087 asprintf(&tmp,2088 mr_asprintf(&tmp, 2088 2089 "Unknown format ('%s') - using supplied string anyway", 2089 2090 format); 2090 2091 mvaddstr_and_log_it(g_currentY++, 0, tmp); 2091 paranoid_free(tmp);2092 mr_free(tmp); 2092 2093 #ifdef __FreeBSD__ 2093 asprintf(&partcode, format); // was a52094 mr_asprintf(&partcode, format); // was a5 2094 2095 #else 2095 asprintf(&partcode, format); // was 832096 #endif 2097 } 2098 asprintf(&tmp, "Setting %s's type to %s (%s)", partition, format,2096 mr_asprintf(&partcode, format); // was 83 2097 #endif 2098 } 2099 mr_asprintf(&tmp, "Setting %s's type to %s (%s)", partition, format, 2099 2100 partcode); 2100 paranoid_free(partition);2101 mr_free(partition); 2101 2102 2102 2103 log_msg(1, tmp); 2103 paranoid_free(tmp);2104 mr_free(tmp); 2104 2105 if (partcode[0] != '\0' && strcmp(partcode, "83")) { /* no need to set type if 83: 83 is default */ 2105 2106 … … 2111 2112 || strstr(tmp1, " (1-4)")) { 2112 2113 log_msg(5, "Specifying partno (%d) - yay", partno); 2113 asprintf(&tmp, "%d\n", partno);2114 mr_asprintf(&tmp, "%d\n", partno); 2114 2115 fput_string_one_char_at_a_time(pout_to_fdisk, tmp); 2115 paranoid_free(tmp);2116 paranoid_free(tmp1);2116 mr_free(tmp); 2117 mr_free(tmp1); 2117 2118 tmp1 = last_line_of_file(FDISK_LOG); 2118 2119 log_msg(5, "A - last line = '%s'", tmp1); 2119 2120 } 2120 paranoid_free(tmp1);2121 2122 asprintf(&tmp, "%s\n", partcode);2121 mr_free(tmp1); 2122 2123 mr_asprintf(&tmp, "%s\n", partcode); 2123 2124 fput_string_one_char_at_a_time(pout_to_fdisk, tmp); 2124 paranoid_free(tmp);2125 mr_free(tmp); 2125 2126 tmp1 = last_line_of_file(FDISK_LOG); 2126 2127 log_msg(5, "B - last line = '%s'",tmp1); 2127 paranoid_free(tmp1);2128 mr_free(tmp1); 2128 2129 2129 2130 fput_string_one_char_at_a_time(pout_to_fdisk, "\n"); 2130 2131 tmp1 = last_line_of_file(FDISK_LOG); 2131 2132 log_msg(5, "C - last line = '%s'",tmp1); 2132 paranoid_free(tmp1);2133 mr_free(tmp1); 2133 2134 2134 2135 tmp = last_line_of_file(FDISK_LOG); … … 2138 2139 fput_string_one_char_at_a_time(pout_to_fdisk, "\n"); 2139 2140 } 2140 paranoid_free(tmp);2141 mr_free(tmp); 2141 2142 fput_string_one_char_at_a_time(pout_to_fdisk, "p\n"); 2142 2143 } else { 2143 asprintf(&output, "t\n%d\n%s\nw\n", partno, partcode);2144 asprintf(&command, "parted2fdisk %s >> %s 2>> %s", drive,2144 mr_asprintf(&output, "t\n%d\n%s\nw\n", partno, partcode); 2145 mr_asprintf(&command, "parted2fdisk %s >> %s 2>> %s", drive, 2145 2146 MONDO_LOGFILE, MONDO_LOGFILE); 2146 2147 log_msg(5, "output = '%s'", output); … … 2156 2157 paranoid_pclose(fout); 2157 2158 } 2158 paranoid_free(command);2159 paranoid_free(output);2159 mr_free(command); 2160 mr_free(output); 2160 2161 } 2161 2162 /* BERLIOS: Useless as command not initialized in all cases … … 2165 2166 */ 2166 2167 } 2167 paranoid_free(partcode);2168 mr_free(partcode); 2168 2169 2169 2170 … … 2190 2191 return 1; 2191 2192 } 2192 asprintf(&program, "vinum start -f %s", raid_device);2193 mr_asprintf(&program, "vinum start -f %s", raid_device); 2193 2194 #else 2194 asprintf(&program, "raidstart %s", raid_device);2195 mr_asprintf(&program, "raidstart %s", raid_device); 2195 2196 #endif 2196 2197 log_msg(1, "program = %s", program); … … 2199 2200 fprintf(g_fprep, "%s\n", program); 2200 2201 } 2201 paranoid_free(program);2202 mr_free(program); 2202 2203 2203 2204 if (res) { … … 2234 2235 return 1; 2235 2236 } 2236 asprintf(&program, "vinum stop -f %s", raid_device);2237 mr_asprintf(&program, "vinum stop -f %s", raid_device); 2237 2238 #else 2238 2239 // use raidstop if it exists, otherwise use mdadm 2239 2240 if (run_program_and_log_output("which raidstop", FALSE)) { 2240 asprintf(&program, "mdadm -S %s", raid_device);2241 mr_asprintf(&program, "mdadm -S %s", raid_device); 2241 2242 } else { 2242 asprintf(&program, "raidstop %s", raid_device);2243 mr_asprintf(&program, "raidstop %s", raid_device); 2243 2244 } 2244 2245 #endif … … 2248 2249 fprintf(g_fprep, "%s\n", program); 2249 2250 } 2250 paranoid_free(program);2251 mr_free(program); 2251 2252 2252 2253 if (res) { … … 2322 2323 return (1); 2323 2324 } 2324 for ( getline(&incoming, &n, fin); !feof(fin);2325 getline(&incoming, &n, fin)) {2325 for (mr_getline(&incoming, &n, fin); !feof(fin); 2326 mr_getline(&incoming, &n, fin)) { 2326 2327 retval += stop_raid_device(incoming); 2327 2328 } … … 2332 2333 return (1); 2333 2334 } 2334 for ( getline(&incoming, &n, fin); !feof(fin);2335 getline(&incoming, &n, fin)) {2335 for (mr_getline(&incoming, &n, fin); !feof(fin); 2336 mr_getline(&incoming, &n, fin)) { 2336 2337 for (p = incoming; 2337 2338 *p != '\0' && (*p != 'm' || *(p + 1) != 'd' 2338 2339 || !isdigit(*(p + 2))); p++); 2339 2340 if (*p != '\0') { 2340 asprintf(&dev, "/dev/%s", p);2341 mr_asprintf(&dev, "/dev/%s", p); 2341 2342 /* BERLIOS : 32 Hard coded value */ 2342 2343 for (p = dev; *p > 32; p++); 2343 2344 *p = '\0'; 2344 2345 res = stop_raid_device(dev); 2345 paranoid_free(dev);2346 } 2347 } 2348 #endif 2349 paranoid_free(incoming);2346 mr_free(dev); 2347 } 2348 } 2349 #endif 2350 mr_free(incoming); 2350 2351 } 2351 2352 paranoid_fclose(fin); … … 2381 2382 if (strcmp(format, "swap") == 0) { 2382 2383 #ifdef __FreeBSD__ 2383 asprintf(&program, "true");2384 mr_asprintf(&program, "true"); 2384 2385 #else 2385 asprintf(&program, "mkswap");2386 mr_asprintf(&program, "mkswap"); 2386 2387 #endif 2387 2388 } else if (strcmp(format, "vfat") == 0) { 2388 asprintf(&program, "format-and-kludge-vfat");2389 mr_asprintf(&program, "format-and-kludge-vfat"); 2389 2390 #ifndef __FreeBSD__ 2390 2391 } else if (strcmp(format, "reiserfs") == 0) { 2391 asprintf(&program, "mkreiserfs -ff");2392 mr_asprintf(&program, "mkreiserfs -ff"); 2392 2393 } else if (strcmp(format, "xfs") == 0) { 2393 asprintf(&program, "mkfs.xfs -f -q");2394 mr_asprintf(&program, "mkfs.xfs -f -q"); 2394 2395 } else if (strcmp(format, "jfs") == 0) { 2395 asprintf(&program, "mkfs.jfs");2396 mr_asprintf(&program, "mkfs.jfs"); 2396 2397 } else if (strcmp(format, "ext3") == 0) { 2397 asprintf(&program, "mkfs -t ext2 -F -j -q");2398 mr_asprintf(&program, "mkfs -t ext2 -F -j -q"); 2398 2399 } else if (strcmp(format, "minix") == 0) { 2399 asprintf(&program, "mkfs.minix");2400 mr_asprintf(&program, "mkfs.minix"); 2400 2401 #endif 2401 2402 } else if (strcmp(format, "ext2") == 0) { 2402 asprintf(&program, "mke2fs -F -q");2403 mr_asprintf(&program, "mke2fs -F -q"); 2403 2404 } else { 2404 2405 #ifdef __FreeBSD__ 2405 asprintf(&program, "newfs_%s", format);2406 mr_asprintf(&program, "newfs_%s", format); 2406 2407 #else 2407 asprintf(&program, "mkfs -t %s -c", format); // -c checks for bad blocks2408 #endif 2409 asprintf(&tmp, "Unknown format (%s) - assuming '%s' will do", format,2408 mr_asprintf(&program, "mkfs -t %s -c", format); // -c checks for bad blocks 2409 #endif 2410 mr_asprintf(&tmp, "Unknown format (%s) - assuming '%s' will do", format, 2410 2411 program); 2411 2412 log_it(tmp); 2412 paranoid_free(tmp);2413 mr_free(tmp); 2413 2414 res = 0; 2414 2415 } … … 2448 2449 original_size_of_drive += mountlist->el[partno].size; 2449 2450 } else { 2450 asprintf(&tmp, "Skipping %s", mountlist->el[partno].device);2451 mr_asprintf(&tmp, "Skipping %s", mountlist->el[partno].device); 2451 2452 // log_to_screen(tmp); 2452 paranoid_free(tmp);2453 mr_free(tmp); 2453 2454 } 2454 2455 } … … 2512 2513 return; 2513 2514 } 2514 asprintf(&tmp, _("Expanding entries to suit drive %s (%ld MB)"),2515 mr_asprintf(&tmp, _("Expanding entries to suit drive %s (%ld MB)"), 2515 2516 drive_name, current_size_of_drive); 2516 2517 log_to_screen(tmp); 2517 paranoid_free(tmp);2518 mr_free(tmp); 2518 2519 2519 2520 drivemntlist = malloc(sizeof(struct mountlist_reference)); … … 2532 2533 2533 2534 if (original_size_of_drive <= 0) { 2534 asprintf(&tmp, _("Cannot resize %s's entries. Drive not found."),2535 mr_asprintf(&tmp, _("Cannot resize %s's entries. Drive not found."), 2535 2536 drive_name); 2536 2537 log_to_screen(tmp); 2537 paranoid_free(tmp);2538 mr_free(tmp); 2538 2539 return; 2539 2540 } 2540 2541 factor = 2541 2542 (float) (current_size_of_drive) / (float) (original_size_of_drive); 2542 asprintf(&tmp, "Disk %s was %ld MB; is now %ld MB; factor = %f",2543 mr_asprintf(&tmp, "Disk %s was %ld MB; is now %ld MB; factor = %f", 2543 2544 drive_name, original_size_of_drive, current_size_of_drive, 2544 2545 factor); 2545 2546 log_to_screen(tmp); 2546 paranoid_free(tmp);2547 mr_free(tmp); 2547 2548 2548 2549 lastpart = drivemntlist->entries - 1; … … 2563 2564 newsizL = (long) new_size; 2564 2565 } 2565 asprintf(&tmp, _("Changing %s from %lld KB to %ld KB"),2566 mr_asprintf(&tmp, _("Changing %s from %lld KB to %ld KB"), 2566 2567 drivemntlist->el[partno]->device, 2567 2568 drivemntlist->el[partno]->size, newsizL); 2568 2569 log_to_screen(tmp); 2569 paranoid_free(tmp);2570 mr_free(tmp); 2570 2571 drivemntlist->el[partno]->size = newsizL; 2571 2572 } 2572 2573 final_size = get_phys_size_of_drive(drive_name); 2573 asprintf(&tmp, _("final_size = %ld MB"), final_size);2574 mr_asprintf(&tmp, _("final_size = %ld MB"), final_size); 2574 2575 log_to_screen(tmp); 2575 paranoid_free(tmp);2576 mr_free(tmp); 2576 2577 } 2577 2578 … … 2613 2614 } 2614 2615 log_to_screen(_("Mountlist adjusted to suit current hard drive(s)")); 2615 paranoid_free(drivelist);2616 mr_free(drivelist); 2616 2617 } 2617 2618 … … 2637 2638 log_msg(1, "Creating list of partitions for drive %s", drive_name); 2638 2639 2639 asprintf(&tmp_drive_name,drive_name);2640 mr_asprintf(&tmp_drive_name,drive_name); 2640 2641 if (!tmp_drive_name) 2641 2642 fatal_error("Out of memory"); … … 2657 2658 } 2658 2659 } 2659 paranoid_free(tmp_drive_name);2660 mr_free(tmp_drive_name); 2660 2661 } 2661 2662
Note:
See TracChangeset
for help on using the changeset viewer.