Changeset 900 in MondoRescue for trunk/mondo/src/mondorestore
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- Location:
- trunk/mondo/src/mondorestore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/mondorestore/Makefile.am
r867 r900 1 ## $Id$ 1 2 ## 2 3 ## Process with Automake to generate Makefile.in … … 14 15 mondorestore_SOURCES = mondo-prep.c mondo-restore.c mondo-rstr-newt.c \ 15 16 mondo-rstr-compare.c mondo-rstr-tools.c 16 mondorestore_LDADD = ${top_builddir}/src/common/libmondo.a ${top_builddir}/src/lib/libmr.a @MONDORESTORE_STATIC@ 17 18 17 mondorestore_LDADD = ${top_builddir}/src/common/libmondo.a ${top_builddir}/src/lib/libmr.a @MONDORESTORE_STATIC@ -
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 -
trunk/mondo/src/mondorestore/mondo-restore.c
r851 r900 23 23 #include <pthread.h> 24 24 #endif 25 #include "mr_mem.h" 25 26 26 27 extern void twenty_seconds_til_yikes(void); … … 160 161 assert(raidlist != NULL); 161 162 if (!bkpinfo->disaster_recovery) { 162 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");163 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 163 164 log_msg(2, "I guess you're testing edit_mountlist()"); 164 165 } … … 274 275 } 275 276 if (g_ISO_restore_mode) { 276 asprintf(&tmp, "umount %s", bkpinfo->isodir);277 mr_asprintf(&tmp, "umount %s", bkpinfo->isodir); 277 278 run_program_and_log_output(tmp, FALSE); 278 paranoid_free(tmp);279 mr_free(tmp); 279 280 } 280 281 paranoid_MR_finish(0); … … 386 387 save_mountlist_to_disk(mountlist, g_mountlist_fname); 387 388 tmp1 = find_my_editor(); 388 asprintf(&tmp, "%s %s", tmp1, g_mountlist_fname);389 paranoid_free(tmp1);389 mr_asprintf(&tmp, "%s %s", tmp1, g_mountlist_fname); 390 mr_free(tmp1); 390 391 391 392 res = system(tmp); 392 paranoid_free(tmp);393 mr_free(tmp); 393 394 load_mountlist(mountlist, g_mountlist_fname); 394 395 } else { … … 500 501 ask_me_yes_or_no 501 502 (_("Do you want me to restore _some_ of your data?")))) { 502 asprintf(&old_restpath,bkpinfo->restore_path);503 mr_asprintf(&old_restpath,bkpinfo->restore_path); 503 504 for (done = FALSE; !done;) { 504 505 unlink("/tmp/filelist.full"); … … 514 515 if (!strcmp(bkpinfo->restore_path, "/")) { 515 516 if (!ask_me_yes_or_no(_("Are you sure?"))) { 516 paranoid_alloc(bkpinfo->restore_path, old_restpath);517 mr_allocstr(bkpinfo->restore_path, old_restpath); 517 518 goto gotos_suck; 518 519 } 519 paranoid_alloc(bkpinfo->restore_path, ""); // so we restore to [blank]/file/name :)520 mr_allocstr(bkpinfo->restore_path, ""); // so we restore to [blank]/file/name :) 520 521 } 521 522 log_msg(1, "Restoring subset"); … … 523 524 free_filelist(filelist); 524 525 } else { 525 paranoid_alloc(bkpinfo->restore_path,old_restpath);526 mr_allocstr(bkpinfo->restore_path,old_restpath); 526 527 free_filelist(filelist); 527 528 } … … 534 535 } 535 536 } 536 paranoid_free(old_restpath);537 mr_free(old_restpath); 537 538 } else { 538 539 mvaddstr_and_log_it(g_currentY++, … … 567 568 ("Using e2label to label your ext2,3 partitions")); 568 569 if (does_file_exist("/tmp/fstab.new")) { 569 asprintf(&fstab_fname, "/tmp/fstab.new");570 mr_asprintf(&fstab_fname, "/tmp/fstab.new"); 570 571 } else { 571 asprintf(&fstab_fname, "/tmp/fstab");572 } 573 asprintf(&tmp,572 mr_asprintf(&fstab_fname, "/tmp/fstab"); 573 } 574 mr_asprintf(&tmp, 574 575 "label-partitions-as-necessary %s < %s >> %s 2>> %s", 575 576 g_mountlist_fname, fstab_fname, MONDO_LOGFILE, 576 577 MONDO_LOGFILE); 577 paranoid_free(fstab_fname);578 mr_free(fstab_fname); 578 579 579 580 res = system(tmp); 580 paranoid_free(tmp);581 mr_free(tmp); 581 582 if (res) { 582 583 log_to_screen … … 679 680 (strstr(tmp1,"RESTORE") == NULL)) { 680 681 /* -H option */ 681 asprintf(&tmp,682 mr_asprintf(&tmp, 682 683 _ 683 684 (" Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.")); 684 685 popup_and_OK(tmp); 685 paranoid_free(tmp);686 } 687 paranoid_free(tmp1);686 mr_free(tmp); 687 } 688 mr_free(tmp1); 688 689 689 690 log_to_screen(_ … … 739 740 resize_mountlist_proportionately_to_suit_new_drives(mountlist); 740 741 } 741 paranoid_free(tmp);742 mr_free(tmp); 742 743 743 744 if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) { 744 asprintf(&tmp,745 mr_asprintf(&tmp, 745 746 _ 746 747 ("Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?"), 747 748 tmpA, tmpB, tmpC); 748 749 if (ask_me_yes_or_no(tmp)) { 749 paranoid_free(tmp);750 mr_free(tmp); 750 751 retval = interactive_mode(bkpinfo, mountlist, raidlist); 751 752 goto after_the_nuke; 752 753 } else { 753 paranoid_free(tmp);754 mr_free(tmp); 754 755 fatal_error("Nuke Mode aborted. "); 755 756 } … … 787 788 } 788 789 } 789 paranoid_free(tmp);790 mr_free(tmp); 790 791 791 792 retval += res; … … 840 841 ("Using e2label to label your ext2,3 partitions")); 841 842 842 asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab",843 mr_asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab", 843 844 g_mountlist_fname); 844 845 res = run_program_and_log_output(tmp, TRUE); 845 paranoid_free(tmp);846 mr_free(tmp); 846 847 847 848 if (res) { … … 916 917 } 917 918 918 paranoid_alloc(bkpinfo->restore_path, "/");919 mr_allocstr(bkpinfo->restore_path, "/"); 919 920 if (!g_restoring_live_from_cd) { 920 921 popup_and_OK … … 945 946 if (filelist) { 946 947 save_filelist(filelist, "/tmp/selected-files.txt"); 947 asprintf(&old_restpath,bkpinfo->restore_path);948 mr_asprintf(&old_restpath,bkpinfo->restore_path); 948 949 if (popup_and_get_string(_("Restore path"), 949 950 _("Restore files to where? )"), … … 953 954 } 954 955 free_filelist(filelist); 955 paranoid_alloc(bkpinfo->restore_path,old_restpath);956 mr_allocstr(bkpinfo->restore_path,old_restpath); 956 957 } 957 958 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 1034 1035 if (!(fin = fopen(tmp,"r"))) { 1035 1036 log_to_screen(_("Cannot even open bigfile's info file")); 1036 paranoid_free(tmp);1037 mr_free(tmp); 1037 1038 return (pathname_of_last_file_restored); 1038 1039 } 1039 paranoid_free(tmp);1040 mr_free(tmp); 1040 1041 1041 1042 memset((void *) &biggiestruct, 0, sizeof(biggiestruct)); … … 1047 1048 paranoid_fclose(fin); 1048 1049 1049 asprintf(&checksum, biggiestruct.checksum);1050 mr_asprintf(&checksum, biggiestruct.checksum); 1050 1051 1051 1052 if (!checksum[0]) { 1052 asprintf(&tmp, "Warning - bigfile %ld does not have a checksum",1053 mr_asprintf(&tmp, "Warning - bigfile %ld does not have a checksum", 1053 1054 bigfileno + 1); 1054 1055 log_msg(3, tmp); 1055 paranoid_free(tmp);1056 mr_free(tmp); 1056 1057 /* BERLIOS : Useless ??? 1057 1058 p = checksum; 1058 1059 */ 1059 1060 } 1060 paranoid_free(checksum);1061 mr_free(checksum); 1061 1062 1062 1063 if (!strncmp(biggiestruct.filename, "/dev/", 5)) // Whether NTFS or not :) 1063 1064 { 1064 asprintf(&outfile_fname, biggiestruct.filename);1065 mr_asprintf(&outfile_fname, biggiestruct.filename); 1065 1066 } else { 1066 asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,1067 mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, 1067 1068 biggiestruct.filename); 1068 1069 } … … 1101 1102 "Calling ntfsclone in background because %s is an NTFS /dev entry", 1102 1103 outfile_fname); 1103 asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768),1104 mr_asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768), 1104 1105 (int) (random() % 32768)); 1105 1106 mkfifo(ntfsprog_fifo, 0x770); … … 1125 1126 } 1126 1127 // BERLIOS: Is it the right place ?? 1127 paranoid_free(ntfsprog_fifo);1128 mr_free(ntfsprog_fifo); 1128 1129 } else { 1129 1130 use_ntfsprog_hack = FALSE; … … 1135 1136 } 1136 1137 1137 asprintf(&tmp, "Reassembling big file %ld (%s)", bigfileno + 1,1138 mr_asprintf(&tmp, "Reassembling big file %ld (%s)", bigfileno + 1, 1138 1139 outfile_fname); 1139 1140 log_msg(2, tmp); 1140 paranoid_free(tmp);1141 mr_free(tmp); 1141 1142 1142 1143 /* … … 1146 1147 */ 1147 1148 1148 asprintf(&pathname_of_last_file_restored, biggiestruct.filename);1149 mr_asprintf(&pathname_of_last_file_restored, biggiestruct.filename); 1149 1150 1150 1151 log_msg(3, "file_to_openout = %s", file_to_openout); … … 1165 1166 g_current_media_number); 1166 1167 g_current_media_number++; 1167 asprintf(&tmp3,1168 mr_asprintf(&tmp3, 1168 1169 "Asking for %s #%d so that I may read slice #%ld\n", 1169 1170 bkpinfo->backup_media_string, 1170 1171 g_current_media_number, sliceno); 1171 1172 log_msg(2, tmp3); 1172 paranoid_free(tmp3);1173 1174 asprintf(&tmp3, _("Restoring from %s #%d"),1173 mr_free(tmp3); 1174 1175 mr_asprintf(&tmp3, _("Restoring from %s #%d"), 1175 1176 bkpinfo->backup_media_string, 1176 1177 g_current_media_number); 1177 1178 log_to_screen(tmp3); 1178 paranoid_free(tmp3);1179 mr_free(tmp3); 1179 1180 1180 1181 insist_on_this_cd_number(bkpinfo, g_current_media_number); … … 1189 1190 } else { 1190 1191 if (does_file_exist(tmp1)) { 1191 asprintf(&bzip2_command, "lzop -dc %s 2>> %s",tmp1, MONDO_LOGFILE);1192 mr_asprintf(&bzip2_command, "lzop -dc %s 2>> %s",tmp1, MONDO_LOGFILE); 1192 1193 } else if (does_file_exist(tmp2)) { 1193 asprintf(&bzip2_command, "bzip2 -dc %s 2>> %s",tmp2, MONDO_LOGFILE);1194 mr_asprintf(&bzip2_command, "bzip2 -dc %s 2>> %s",tmp2, MONDO_LOGFILE); 1194 1195 } else if (does_file_exist(tmp)) { 1195 asprintf(&bzip2_command, "%s", "");1196 mr_asprintf(&bzip2_command, "%s", ""); 1196 1197 } else { 1197 1198 log_to_screen(_("OK, that's pretty fsck0red...")); … … 1201 1202 1202 1203 if (bzip2_command == NULL) { 1203 asprintf(&bzip2_command, "cat %s 2>> %s", tmp, MONDO_LOGFILE);1204 } 1205 asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld ",1204 mr_asprintf(&bzip2_command, "cat %s 2>> %s", tmp, MONDO_LOGFILE); 1205 } 1206 mr_asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld ", 1206 1207 bkpinfo->backup_media_string, 1207 1208 g_current_media_number, bigfileno + 1, sliceno); … … 1212 1213 update_progress_form(tmp3); 1213 1214 } 1214 paranoid_free(tmp3);1215 mr_free(tmp3); 1215 1216 1216 1217 if (!(fbzip2 = popen(bzip2_command, "r"))) { 1217 1218 fatal_error("Can't run popen command"); 1218 1219 } 1219 paranoid_free(bzip2_command);1220 mr_free(bzip2_command); 1220 1221 1221 1222 while (!feof(fbzip2)) { … … 1223 1224 if (siz > 0) { 1224 1225 siz1 = fwrite(bigblk, 1, siz, fout); 1225 asprintf(&sz_msg, "Read %ld from fbzip2; written %ld to fout", siz, siz1);1226 mr_asprintf(&sz_msg, "Read %ld from fbzip2; written %ld to fout", siz, siz1); 1226 1227 log_it(sz_msg); 1227 paranoid_free(sz_msg);1228 mr_free(sz_msg); 1228 1229 } 1229 1230 } … … 1234 1235 g_current_progress++; 1235 1236 } 1236 paranoid_free(tmp);1237 paranoid_free(tmp1);1238 paranoid_free(tmp2);1237 mr_free(tmp); 1238 mr_free(tmp1); 1239 mr_free(tmp2); 1239 1240 } 1240 1241 paranoid_fclose(fout); … … 1243 1244 if (use_ntfsprog_hack) { 1244 1245 log_msg(3, "Waiting for ntfsclone to finish"); 1245 asprintf(&tmp,1246 mr_asprintf(&tmp, 1246 1247 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1247 1248 while (system(tmp) == 0) { 1248 1249 sleep(1); 1249 1250 } 1250 paranoid_free(tmp);1251 mr_free(tmp); 1251 1252 log_it("OK, ntfsclone has really finished"); 1252 1253 } … … 1260 1261 utime(outfile_fname, ubuf); 1261 1262 } 1262 paranoid_free(outfile_fname);1263 paranoid_free(bigblk);1263 mr_free(outfile_fname); 1264 mr_free(bigblk); 1264 1265 1265 1266 return (pathname_of_last_file_restored); … … 1329 1330 } 1330 1331 1331 asprintf(&pathname_of_last_file_restored, orig_bf_fname);1332 mr_asprintf(&pathname_of_last_file_restored, orig_bf_fname); 1332 1333 1333 1334 /* open out to biggiefile to be restored (or /dev/null if biggiefile is not to be restored) */ … … 1359 1360 if (use_ntfsprog) { 1360 1361 g_loglevel = 4; 1361 asprintf(&outfile_fname, orig_bf_fname);1362 mr_asprintf(&outfile_fname, orig_bf_fname); 1362 1363 use_ntfsprog_hack = TRUE; 1363 1364 log_msg(2, 1364 1365 "Calling ntfsclone in background because %s is a /dev entry", 1365 1366 outfile_fname); 1366 asprintf(&ntfsprog_fifo, "%s/%d.%d.000",1367 mr_asprintf(&ntfsprog_fifo, "%s/%d.%d.000", 1367 1368 bkpinfo->tmpdir, 1368 1369 (int) (random() % 32768), … … 1387 1388 (long int) (pid)); 1388 1389 } 1389 paranoid_free(ntfsprog_fifo);1390 mr_free(ntfsprog_fifo); 1390 1391 } else { 1391 1392 if (!strncmp(orig_bf_fname, "/dev/", 5)) // non-NTFS partition 1392 1393 { 1393 asprintf(&outfile_fname, orig_bf_fname);1394 mr_asprintf(&outfile_fname, orig_bf_fname); 1394 1395 } else // biggiefile 1395 1396 { 1396 asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,1397 mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, 1397 1398 orig_bf_fname); 1398 1399 } … … 1403 1404 make_hole_for_file(outfile_fname); 1404 1405 } 1405 asprintf(&tmp1, "Reassembling big file %ld (%s)",1406 mr_asprintf(&tmp1, "Reassembling big file %ld (%s)", 1406 1407 biggiefile_number + 1, orig_bf_fname); 1407 1408 log_msg(2, tmp1); 1408 paranoid_free(tmp1);1409 mr_free(tmp1); 1409 1410 } 1410 1411 1411 1412 if (dummy_restore) { 1412 paranoid_free(outfile_fname);1413 asprintf(&outfile_fname, "/dev/null");1413 mr_free(outfile_fname); 1414 mr_asprintf(&outfile_fname, "/dev/null"); 1414 1415 } 1415 1416 1416 1417 if (bkpinfo->zip_exe == NULL) { 1417 asprintf(&command, "cat > \"%s\"", file_to_openout);1418 mr_asprintf(&command, "cat > \"%s\"", file_to_openout); 1418 1419 } else { 1419 asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe,1420 mr_asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe, 1420 1421 file_to_openout, MONDO_LOGFILE); 1421 1422 } 1422 asprintf(&tmp1, "Pipe command = '%s'", command);1423 mr_asprintf(&tmp1, "Pipe command = '%s'", command); 1423 1424 log_msg(3, tmp1); 1424 paranoid_free(tmp1);1425 mr_free(tmp1); 1425 1426 1426 1427 /* restore biggiefile, one slice at a time */ … … 1428 1429 fatal_error("Cannot pipe out"); 1429 1430 } 1430 paranoid_free(command);1431 mr_free(command); 1431 1432 1432 1433 for (res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr); … … 1436 1437 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 1437 1438 } 1438 asprintf(&tmp1, "Working on file #%ld, slice #%ld ",1439 mr_asprintf(&tmp1, "Working on file #%ld, slice #%ld ", 1439 1440 biggiefile_number + 1, current_slice_number); 1440 1441 log_msg(2, tmp1); … … 1446 1447 strip_spaces(tmp1); 1447 1448 update_progress_form(tmp1); 1448 paranoid_free(tmp1);1449 mr_free(tmp1); 1449 1450 1450 1451 if (current_slice_number == 0) { … … 1477 1478 g_current_progress++; 1478 1479 } 1479 paranoid_free(tmp);1480 mr_free(tmp); 1480 1481 paranoid_pclose(pout); 1481 1482 … … 1485 1486 if (use_ntfsprog_hack) { 1486 1487 log_msg(3, "Waiting for ntfsclone to finish"); 1487 asprintf(&tmp,1488 mr_asprintf(&tmp, 1488 1489 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1489 1490 while (system(tmp) == 0) { 1490 1491 sleep(1); 1491 1492 } 1492 paranoid_free(tmp);1493 mr_free(tmp); 1493 1494 log_msg(3, "OK, ntfsclone has really finished"); 1494 1495 } … … 1505 1506 } 1506 1507 1507 paranoid_free(outfile_fname);1508 mr_free(outfile_fname); 1508 1509 g_loglevel = old_loglevel; 1509 1510 return (pathname_of_last_file_restored); … … 1551 1552 log_msg(5, "Entering"); 1552 1553 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 1553 asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING);1554 mr_asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING); 1554 1555 run_program_and_log_output(command, 9); 1555 paranoid_free(command);1556 1557 asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld",1556 mr_free(command); 1557 1558 mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld", 1558 1559 current_tarball_number); 1559 1560 if (length_of_file(filelist_name) <= 2) { … … 1572 1573 log_msg(3, "length_of_file(%s) = %llu", tarball_fname, 1573 1574 length_of_file(tarball_fname)); 1574 asprintf(&tmp, "Unable to restore fileset #%ld (CD I/O error)",1575 mr_asprintf(&tmp, "Unable to restore fileset #%ld (CD I/O error)", 1575 1576 current_tarball_number); 1576 1577 log_to_screen(tmp); 1577 paranoid_free(tmp);1578 mr_free(tmp); 1578 1579 retval = 1; 1579 1580 log_msg(5, "Leaving"); … … 1582 1583 1583 1584 if (filelist) { 1584 asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp",1585 mr_asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp", 1585 1586 current_tarball_number); 1586 1587 if ((matches = … … 1589 1590 use_star)) 1590 1591 <= 0) { 1591 asprintf(&tmp, "Skipping fileset %ld", current_tarball_number);1592 mr_asprintf(&tmp, "Skipping fileset %ld", current_tarball_number); 1592 1593 log_msg(1, tmp); 1593 paranoid_free(tmp);1594 mr_free(tmp); 1594 1595 } else { 1595 1596 log_msg(3, "Saved fileset %ld's subset to %s", 1596 1597 current_tarball_number, filelist_subset_fname); 1597 1598 } 1598 asprintf(&tmp, "Tarball #%ld --- %ld matches",1599 mr_asprintf(&tmp, "Tarball #%ld --- %ld matches", 1599 1600 current_tarball_number, matches); 1600 1601 log_to_screen(tmp); 1601 paranoid_free(tmp);1602 mr_free(tmp); 1602 1603 } else { 1603 1604 filelist_subset_fname = NULL; 1604 1605 } 1605 paranoid_free(filelist_name);1606 mr_free(filelist_name); 1606 1607 1607 1608 if (filelist == NULL || matches > 0) { 1608 asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ,1609 mr_asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ, 1609 1610 MNT_CDROM "/archives", current_tarball_number); 1610 asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives",1611 mr_asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives", 1611 1612 current_tarball_number); 1612 1613 if (strstr(tarball_fname, ".bz2")) { 1613 asprintf(&executable, "bzip2");1614 mr_asprintf(&executable, "bzip2"); 1614 1615 } else if (strstr(tarball_fname, ".lzo")) { 1615 asprintf(&executable, "lzop");1616 mr_asprintf(&executable, "lzop"); 1616 1617 } else { 1617 1618 executable = NULL; … … 1619 1620 1620 1621 if (executable == NULL) { 1621 asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable);1622 mr_asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable); 1622 1623 if (run_program_and_log_output(tmp, FALSE)) { 1623 1624 log_to_screen … … 1626 1627 paranoid_MR_finish(1); 1627 1628 } 1628 paranoid_free(tmp);1629 1630 asprintf(&tmp, executable);1631 asprintf(&executable, "-P %s -Z", tmp);1632 paranoid_free(tmp);1629 mr_free(tmp); 1630 1631 mr_asprintf(&tmp, executable); 1632 mr_asprintf(&executable, "-P %s -Z", tmp); 1633 mr_free(tmp); 1633 1634 } 1634 1635 #ifdef __FreeBSD__ … … 1638 1639 #endif 1639 1640 1640 asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768),1641 mr_asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768), 1641 1642 (int) (random() % 32768)); 1642 1643 1643 1644 if (use_star) { 1644 1645 if (strstr(tarball_fname, ".bz2")) { 1645 asprintf(&tmp, " -bz");1646 mr_asprintf(&tmp, " -bz"); 1646 1647 } else { 1647 asprintf(&tmp, "%s", "");1648 } 1649 asprintf(&command,1648 mr_asprintf(&tmp, "%s", ""); 1649 } 1650 mr_asprintf(&command, 1650 1651 "star -x -force-remove -U " STAR_ACL_SZ 1651 1652 " errctl= file=%s %s 2>> %s >> %s", tarball_fname, tmp, temp_log, temp_log); 1652 paranoid_free(tmp);1653 mr_free(tmp); 1653 1654 } else { 1654 1655 if (filelist_subset_fname != NULL) { 1655 asprintf(&command,1656 mr_asprintf(&command, 1656 1657 "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s 2>> %s >> %s", 1657 1658 TAPE_BLOCK_SIZE, … … 1660 1661 tarball_fname, temp_log, temp_log); 1661 1662 } else { 1662 asprintf(&command,1663 mr_asprintf(&command, 1663 1664 "afio -i -b %ld -c %ld -M 8m %s %s 2>> %s >> %s", 1664 1665 TAPE_BLOCK_SIZE, … … 1666 1667 } 1667 1668 } 1668 paranoid_free(executable);1669 mr_free(executable); 1669 1670 1670 1671 #undef BUFSIZE … … 1680 1681 } 1681 1682 } 1682 paranoid_free(command);1683 mr_free(command); 1683 1684 1684 1685 if (res && length_of_file(temp_log) < 5) { … … 1711 1712 } 1712 1713 if (retval) { 1713 asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE);1714 mr_asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE); 1714 1715 system(command); 1715 paranoid_free(command);1716 mr_free(command); 1716 1717 log_msg(2, "Errors occurred while processing fileset #%d", 1717 1718 current_tarball_number); … … 1720 1721 } 1721 1722 unlink(xattr_fname); 1722 paranoid_free(xattr_fname);1723 mr_free(xattr_fname); 1723 1724 } 1724 1725 if (does_file_exist("/PAUSE")) { … … 1731 1732 unlink(temp_log); 1732 1733 1733 paranoid_free(filelist_subset_fname);1734 paranoid_free(acl_fname);1735 paranoid_free(temp_log);1734 mr_free(filelist_subset_fname); 1735 mr_free(acl_fname); 1736 mr_free(temp_log); 1736 1737 1737 1738 log_msg(5, "Leaving"); … … 1785 1786 /* to do it with a file... */ 1786 1787 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 1787 asprintf(&tmp,1788 mr_asprintf(&tmp, 1788 1789 "Restoring from fileset #%ld (%ld KB) on %s #%d", 1789 1790 current_tarball_number, (long) size >> 10, … … 1791 1792 g_current_media_number); 1792 1793 log_msg(2, tmp); 1793 paranoid_free(tmp);1794 mr_free(tmp); 1794 1795 run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE); 1795 1796 … … 1799 1800 * in afio or someting; oh darn.. OK, use tmpfs :-) * 1800 1801 ****************************************************************************/ 1801 asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld",1802 mr_asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld", 1802 1803 current_tarball_number); 1803 asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir,1804 mr_asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir, 1804 1805 current_tarball_number); 1805 asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp",1806 mr_asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp", 1806 1807 bkpinfo->tmpdir, current_tarball_number); 1807 1808 res = read_file_from_stream_to_file(bkpinfo, afio_fname, size); … … 1814 1815 if (bkpinfo->compression_level != 0) { 1815 1816 if (bkpinfo->use_star) { 1816 asprintf(&executable, " -bz");1817 mr_asprintf(&executable, " -bz"); 1817 1818 } else { 1818 asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe);1819 mr_asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe); 1819 1820 } 1820 1821 } … … 1827 1828 if (strstr(tarball_fname, ".star.")) { 1828 1829 use_star = TRUE; 1829 asprintf(&command, "star -t file=%s %s > %s 2>> %s", afio_fname, executable, filelist_fname, MONDO_LOGFILE);1830 mr_asprintf(&command, "star -t file=%s %s > %s 2>> %s", afio_fname, executable, filelist_fname, MONDO_LOGFILE); 1830 1831 } else { 1831 1832 use_star = FALSE; 1832 asprintf(&command, "afio -t -M 8m -b %ld %s %s > %s 2>> %s", TAPE_BLOCK_SIZE,1833 mr_asprintf(&command, "afio -t -M 8m -b %ld %s %s > %s 2>> %s", TAPE_BLOCK_SIZE, 1833 1834 executable, afio_fname, filelist_fname, MONDO_LOGFILE); 1834 1835 } … … 1837 1838 log_msg(4, "Warning - error occurred while retrieving TOC"); 1838 1839 } 1839 paranoid_free(command);1840 mr_free(command); 1840 1841 if ((matches = 1841 1842 save_filelist_entries_in_common(filelist_fname, filelist, … … 1847 1848 current_tarball_number); 1848 1849 } 1849 asprintf(&tmp, "Skipping fileset %ld", current_tarball_number);1850 mr_asprintf(&tmp, "Skipping fileset %ld", current_tarball_number); 1850 1851 log_msg(2, tmp); 1851 paranoid_free(tmp);1852 mr_free(tmp); 1852 1853 restore_this_fileset = FALSE; 1853 1854 } else { … … 1859 1860 } 1860 1861 unlink(filelist_fname); 1861 paranoid_free(filelist_fname);1862 mr_free(filelist_fname); 1862 1863 1863 1864 // Concoct the call to star/afio to restore files … … 1865 1866 // star 1866 1867 if (filelist) { 1867 asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable,1868 mr_asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable, 1868 1869 filelist_subset_fname,MONDO_LOGFILE); 1869 1870 } else { 1870 asprintf(&command,"star -x file=%s %s 2>> %s", afio_fname, executable,MONDO_LOGFILE);1871 mr_asprintf(&command,"star -x file=%s %s 2>> %s", afio_fname, executable,MONDO_LOGFILE); 1871 1872 } 1872 1873 } else { 1873 1874 // afio 1874 1875 if (filelist) { 1875 asprintf(&command, "afio -i -M 8m -b %ld %s -w %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, filelist_subset_fname,afio_fname,MONDO_LOGFILE);1876 mr_asprintf(&command, "afio -i -M 8m -b %ld %s -w %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, filelist_subset_fname,afio_fname,MONDO_LOGFILE); 1876 1877 } else { 1877 asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable,afio_fname,MONDO_LOGFILE);1878 } 1879 } 1880 paranoid_free(executable);1878 mr_asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable,afio_fname,MONDO_LOGFILE); 1879 } 1880 } 1881 mr_free(executable); 1881 1882 1882 1883 // Call if IF there are files to restore (selectively/unconditionally) … … 1905 1906 log_msg(1, "NOT CALLING '%s'", command); 1906 1907 } 1907 paranoid_free(command);1908 mr_free(command); 1908 1909 1909 1910 if (does_file_exist("/PAUSE") && current_tarball_number >= 50) { … … 1915 1916 unlink(afio_fname); 1916 1917 1917 paranoid_free(filelist_subset_fname);1918 paranoid_free(afio_fname);1918 mr_free(filelist_subset_fname); 1919 mr_free(afio_fname); 1919 1920 return (retval); 1920 1921 } … … 1952 1953 assert(bkpinfo != NULL); 1953 1954 1954 asprintf(&biggies_whose_EXATs_we_should_set,1955 mr_asprintf(&biggies_whose_EXATs_we_should_set, 1955 1956 "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir); 1956 1957 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) { … … 1961 1962 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 1962 1963 total_slices = atol(tmp); 1963 paranoid_free(tmp);1964 1965 asprintf(&tmp, _("Reassembling large files "));1964 mr_free(tmp); 1965 1966 mr_asprintf(&tmp, _("Reassembling large files ")); 1966 1967 mvaddstr_and_log_it(g_currentY, 0, tmp); 1967 paranoid_free(tmp);1968 mr_free(tmp); 1968 1969 1969 1970 if (length_of_file(BIGGIELIST) < 6) { … … 1977 1978 return (0); 1978 1979 } 1979 asprintf(&tmp, "OK, there are %ld biggiefiles in the archives",1980 mr_asprintf(&tmp, "OK, there are %ld biggiefiles in the archives", 1980 1981 noof_biggiefiles); 1981 1982 log_msg(2, tmp); 1982 paranoid_free(tmp);1983 mr_free(tmp); 1983 1984 1984 1985 open_progress_form(_("Reassembling large files"), … … 1998 1999 tmp1 = slice_fname(bigfileno + 1, 0, ARCHIVES_PATH, ""); 1999 2000 log_msg(3, "Slicename would have been %s", tmp1); 2000 paranoid_free(tmp1);2001 mr_free(tmp1); 2001 2002 2002 2003 // I'm not positive 'just_changed_cds' is even necessary... … … 2008 2009 insist_on_this_cd_number(bkpinfo, 2009 2010 ++g_current_media_number); 2010 asprintf(&tmp, _("Restoring from %s #%d"),2011 mr_asprintf(&tmp, _("Restoring from %s #%d"), 2011 2012 bkpinfo->backup_media_string, 2012 2013 g_current_media_number); 2013 2014 log_to_screen(tmp); 2014 paranoid_free(tmp);2015 mr_free(tmp); 2015 2016 2016 2017 just_changed_cds = TRUE; … … 2023 2024 } else { 2024 2025 just_changed_cds = FALSE; 2025 asprintf(&tmp, _("Restoring big file %ld"), bigfileno + 1);2026 mr_asprintf(&tmp, _("Restoring big file %ld"), bigfileno + 1); 2026 2027 update_progress_form(tmp); 2027 paranoid_free(tmp);2028 mr_free(tmp); 2028 2029 2029 2030 pathname_of_last_biggie_restored = … … 2033 2034 fprintf(fbw, "%s\n", pathname_of_last_biggie_restored); 2034 2035 } 2035 paranoid_free(pathname_of_last_biggie_restored);2036 mr_free(pathname_of_last_biggie_restored); 2036 2037 retval += res; 2037 2038 bigfileno++; 2038 2039 2039 2040 } 2040 paranoid_free(tmp);2041 mr_free(tmp); 2041 2042 } 2042 2043 2043 2044 if (fbw) { 2044 2045 fclose(fbw); 2045 asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);2046 asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);2046 mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH); 2047 mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH); 2047 2048 tmp = find_home_of_exe("setfacl"); 2048 2049 if (length_of_file(acl_fname) > 0 && tmp) { 2049 2050 set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname); 2050 2051 } 2051 paranoid_free(tmp);2052 mr_free(tmp); 2052 2053 2053 2054 tmp = find_home_of_exe("setfattr"); … … 2055 2056 set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname); 2056 2057 } 2057 paranoid_free(tmp);2058 paranoid_free(acl_fname);2059 paranoid_free(xattr_fname);2060 } 2061 paranoid_free(biggies_whose_EXATs_we_should_set);2058 mr_free(tmp); 2059 mr_free(acl_fname); 2060 mr_free(xattr_fname); 2061 } 2062 mr_free(biggies_whose_EXATs_we_should_set); 2062 2063 2063 2064 if (does_file_exist("/PAUSE")) { … … 2117 2118 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2118 2119 max_val = atol(tmp) + 1; 2119 paranoid_free(tmp);2120 2121 asprintf(&progress_str, _("Restoring from %s #%d"),2120 mr_free(tmp); 2121 2122 mr_asprintf(&progress_str, _("Restoring from %s #%d"), 2122 2123 bkpinfo->backup_media_string, 2123 2124 g_current_media_number); … … 2131 2132 update_progress_form(progress_str); 2132 2133 2133 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2",2134 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2", 2134 2135 current_tarball_number); 2135 2136 if (!does_file_exist(tarball_fname)) { 2136 paranoid_free(tarball_fname);2137 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo",2137 mr_free(tarball_fname); 2138 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo", 2138 2139 current_tarball_number); 2139 2140 } 2140 2141 if (!does_file_exist(tarball_fname)) { 2141 paranoid_free(tarball_fname);2142 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.",2142 mr_free(tarball_fname); 2143 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.", 2143 2144 current_tarball_number); 2144 2145 } 2145 2146 if (!does_file_exist(tarball_fname)) { 2146 paranoid_free(tarball_fname);2147 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2",2147 mr_free(tarball_fname); 2148 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2", 2148 2149 current_tarball_number); 2149 2150 } 2150 2151 if (!does_file_exist(tarball_fname)) { 2151 paranoid_free(tarball_fname);2152 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.",2152 mr_free(tarball_fname); 2153 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.", 2153 2154 current_tarball_number); 2154 2155 } 2155 2156 if (!does_file_exist(tarball_fname)) { 2156 paranoid_free(tarball_fname);2157 mr_free(tarball_fname); 2157 2158 if (current_tarball_number == 0) { 2158 2159 log_to_screen … … 2168 2169 } 2169 2170 g_current_media_number++; 2170 paranoid_free(progress_str);2171 asprintf(&progress_str, _("Restoring from %s #%d"),2171 mr_free(progress_str); 2172 mr_asprintf(&progress_str, _("Restoring from %s #%d"), 2172 2173 bkpinfo->backup_media_string, 2173 2174 g_current_media_number); 2174 2175 log_to_screen(progress_str); 2175 2176 } else { 2176 paranoid_free(progress_str);2177 asprintf(&progress_str,2177 mr_free(progress_str); 2178 mr_asprintf(&progress_str, 2178 2179 _("Restoring from fileset #%ld on %s #%d"), 2179 2180 current_tarball_number, … … 2189 2190 } 2190 2191 if (res) { 2191 asprintf(&tmp1, _("reported errors"));2192 mr_asprintf(&tmp1, _("reported errors")); 2192 2193 } else { 2193 asprintf(&tmp1, _("succeeded"));2194 } 2195 asprintf(&tmp, _("%s #%d, fileset #%ld - restore %s"),2194 mr_asprintf(&tmp1, _("succeeded")); 2195 } 2196 mr_asprintf(&tmp, _("%s #%d, fileset #%ld - restore %s"), 2196 2197 bkpinfo->backup_media_string, 2197 2198 g_current_media_number, current_tarball_number,tmp1); 2198 paranoid_free(tmp1);2199 mr_free(tmp1); 2199 2200 2200 2201 if (attempts > 1) { 2201 asprintf(&tmp1, _(" (%d attempts) - review logs"), attempts);2202 } 2203 asprintf(&comment, "%s%s", tmp, tmp1);2204 paranoid_free(tmp);2205 paranoid_free(tmp1);2202 mr_asprintf(&tmp1, _(" (%d attempts) - review logs"), attempts); 2203 } 2204 mr_asprintf(&comment, "%s%s", tmp, tmp1); 2205 mr_free(tmp); 2206 mr_free(tmp1); 2206 2207 if (attempts > 1) { 2207 2208 log_to_screen(comment); 2208 2209 } 2209 paranoid_free(comment);2210 mr_free(comment); 2210 2211 2211 2212 retval += res; … … 2213 2214 g_current_progress++; 2214 2215 } 2215 paranoid_free(tarball_fname);2216 } 2217 paranoid_free(progress_str);2216 mr_free(tarball_fname); 2217 } 2218 mr_free(progress_str); 2218 2219 close_progress_form(); 2219 2220 … … 2265 2266 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 2266 2267 total_slices = atol(tmp); 2267 paranoid_free(tmp);2268 2269 asprintf(&tmp, "Reassembling large files ");2270 asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);2271 asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);2268 mr_free(tmp); 2269 2270 mr_asprintf(&tmp, "Reassembling large files "); 2271 mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2272 mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2272 2273 mvaddstr_and_log_it(g_currentY, 0, tmp); 2273 paranoid_free(tmp);2274 2275 asprintf(&biggies_whose_EXATs_we_should_set,2274 mr_free(tmp); 2275 2276 mr_asprintf(&biggies_whose_EXATs_we_should_set, 2276 2277 "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir); 2277 2278 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) { … … 2290 2291 2291 2292 noof_biggiefiles = atol(biggie_fname); 2292 asprintf(&tmp, "OK, there are %ld biggiefiles in the archives",2293 mr_asprintf(&tmp, "OK, there are %ld biggiefiles in the archives", 2293 2294 noof_biggiefiles); 2294 2295 log_msg(2, tmp); 2295 paranoid_free(tmp);2296 mr_free(tmp); 2296 2297 2297 2298 open_progress_form(_("Reassembling large files"), … … 2319 2320 } 2320 2321 */ 2321 asprintf(&tmp, _("Restoring big file %ld (%lld K)"),2322 mr_asprintf(&tmp, _("Restoring big file %ld (%lld K)"), 2322 2323 current_bigfile_number + 1, biggie_size / 1024); 2323 2324 update_progress_form(tmp); 2324 paranoid_free(tmp);2325 mr_free(tmp); 2325 2326 2326 2327 pathname_of_last_biggie_restored = restore_a_biggiefile_from_stream(bkpinfo, biggie_fname, … … 2332 2333 fprintf(fbw, "%s\n", pathname_of_last_biggie_restored); 2333 2334 } 2334 paranoid_free(pathname_of_last_biggie_restored);2335 mr_free(pathname_of_last_biggie_restored); 2335 2336 2336 2337 retval += res; … … 2340 2341 if (current_bigfile_number != noof_biggiefiles 2341 2342 && noof_biggiefiles != 0) { 2342 asprintf(&tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",2343 mr_asprintf(&tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n", 2343 2344 current_bigfile_number, noof_biggiefiles); 2344 2345 } else { 2345 asprintf(&tmp,2346 mr_asprintf(&tmp, 2346 2347 "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.", 2347 2348 noof_biggiefiles, current_bigfile_number); 2348 2349 } 2349 2350 log_msg(1, tmp); 2350 paranoid_free(tmp);2351 mr_free(tmp); 2351 2352 2352 2353 if (fbw) { … … 2370 2371 } 2371 2372 } 2372 paranoid_free(xattr_fname);2373 paranoid_free(acl_fname);2374 paranoid_free(biggies_whose_EXATs_we_should_set);2373 mr_free(xattr_fname); 2374 mr_free(acl_fname); 2375 mr_free(biggies_whose_EXATs_we_should_set); 2375 2376 2376 2377 if (does_file_exist("/PAUSE")) { … … 2386 2387 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2387 2388 } 2388 paranoid_free(biggie_fname);2389 mr_free(biggie_fname); 2389 2390 return (retval); 2390 2391 } … … 2428 2429 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2429 2430 max_val = atol(tmp) + 1; 2430 paranoid_free(tmp);2431 mr_free(tmp); 2431 2432 2432 2433 chdir(bkpinfo->restore_path); /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */ … … 2434 2435 run_program_and_log_output("pwd", 5); 2435 2436 2436 asprintf(&progress_str, _("Restoring from media #%d"),2437 mr_asprintf(&progress_str, _("Restoring from media #%d"), 2437 2438 g_current_media_number); 2438 2439 log_to_screen(progress_str); … … 2456 2457 while (ctrl_chr != BLK_STOP_AFIOBALLS) { 2457 2458 update_progress_form(progress_str); 2458 asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,2459 mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, 2459 2460 current_afioball_number); 2460 asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir,2461 mr_asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir, 2461 2462 current_afioball_number); 2462 2463 unlink(xattr_fname); … … 2473 2474 } 2474 2475 /* BERLIOS: useless ? 2475 asprintf(&tmp,2476 mr_asprintf(&tmp, 2476 2477 _("Restoring from fileset #%ld (name=%s, size=%ld K)"), 2477 2478 current_afioball_number, tmp_fname, (long) tmp_size >> 10); … … 2484 2485 retval += res; 2485 2486 if (res) { 2486 asprintf(&tmp, _("Fileset %ld - errors occurred"),2487 mr_asprintf(&tmp, _("Fileset %ld - errors occurred"), 2487 2488 current_afioball_number); 2488 2489 log_to_screen(tmp); 2489 paranoid_free(tmp);2490 mr_free(tmp); 2490 2491 } 2491 2492 res = … … 2498 2499 g_current_progress++; 2499 2500 2500 paranoid_free(progress_str);2501 asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"),2501 mr_free(progress_str); 2502 mr_asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"), 2502 2503 current_afioball_number, 2503 2504 bkpinfo->backup_media_string, … … 2507 2508 unlink(xattr_fname); 2508 2509 unlink(acl_fname); 2509 paranoid_free(xattr_fname);2510 paranoid_free(acl_fname);2510 mr_free(xattr_fname); 2511 mr_free(acl_fname); 2511 2512 } // next 2512 paranoid_free(progress_str);2513 paranoid_free(tmp_fname);2513 mr_free(progress_str); 2514 mr_free(tmp_fname); 2514 2515 2515 2516 log_msg(1, "All done with afioballs"); … … 2555 2556 /* BERLIOS: should test return value, or better change the function */ 2556 2557 getcwd(cwd, MAX_STR_LEN - 1); 2557 asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path);2558 mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path); 2558 2559 run_program_and_log_output(tmp, FALSE); 2559 paranoid_free(tmp);2560 mr_free(tmp); 2560 2561 2561 2562 log_msg(1, "Changing dir to %s", bkpinfo->restore_path); … … 2572 2573 newtRefresh(); 2573 2574 } 2574 paranoid_free(tmp);2575 mr_free(tmp); 2575 2576 2576 2577 mvaddstr_and_log_it(g_currentY, 0, … … 2613 2614 kill_petris(); 2614 2615 log_msg(2, "restore_everything() --- leaving"); 2615 paranoid_free(cwd);2616 paranoid_free(newpath);2616 mr_free(cwd); 2617 mr_free(newpath); 2617 2618 return (resA + resB); 2618 2619 } … … 2715 2716 g_text_mode = FALSE; 2716 2717 } // newt :-) 2717 paranoid_free(tmp);2718 mr_free(tmp); 2718 2719 2719 2720 if (! … … 2732 2733 2733 2734 g_mondo_home = call_program_and_get_last_line_of_output("which mondorestore"); 2734 paranoid_alloc(g_tmpfs_mountpt, "/tmp/tmpfs");2735 mr_allocstr(g_tmpfs_mountpt, "/tmp/tmpfs"); 2735 2736 make_hole_for_dir(g_tmpfs_mountpt); 2736 2737 g_current_media_number = 1; // precaution … … 2757 2758 2758 2759 /* Backup original mountlist.txt */ 2759 asprintf(&tmp, "%s.orig", g_mountlist_fname);2760 mr_asprintf(&tmp, "%s.orig", g_mountlist_fname); 2760 2761 if (!does_file_exist(g_mountlist_fname)) { 2761 2762 log_msg(2, … … 2763 2764 __LINE__, g_mountlist_fname); 2764 2765 } else if (!does_file_exist(tmp)) { 2765 paranoid_free(tmp);2766 asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname,2766 mr_free(tmp); 2767 mr_asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname, 2767 2768 g_mountlist_fname); 2768 2769 run_program_and_log_output(tmp, FALSE); 2769 2770 } 2770 paranoid_free(tmp);2771 mr_free(tmp); 2771 2772 2772 2773 /* Init directories */ 2773 2774 make_hole_for_dir(bkpinfo->tmpdir); 2774 asprintf(&tmp, "mkdir -p %s", bkpinfo->tmpdir);2775 mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->tmpdir); 2775 2776 run_program_and_log_output(tmp, FALSE); 2776 paranoid_free(tmp);2777 mr_free(tmp); 2777 2778 2778 2779 make_hole_for_dir("/var/log"); … … 2805 2806 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2806 2807 if (!does_file_exist(g_mountlist_fname)) { 2807 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");2808 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 2808 2809 } 2809 2810 res = let_user_edit_the_mountlist(bkpinfo, mountlist, raidlist); … … 2832 2833 bkpinfo->compression_level = 1; 2833 2834 g_current_media_number = 2; 2834 paranoid_alloc(bkpinfo->restore_path, "/tmp/TESTING");2835 mr_allocstr(bkpinfo->restore_path, "/tmp/TESTING"); 2835 2836 bkpinfo->backup_media_type = dvd; 2836 paranoid_free(bkpinfo->backup_media_string);2837 mr_free(bkpinfo->backup_media_string); 2837 2838 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 2838 2839 open_progress_form(_("Reassembling /dev/hda1"), … … 2859 2860 // finish(0); 2860 2861 // toggle_path_selection (filelist, "/root/stuff", TRUE); 2861 asprintf(&a, argv[3]);2862 asprintf(&b, argv[4]);2862 mr_asprintf(&a, argv[3]); 2863 mr_asprintf(&b, argv[4]); 2863 2864 2864 2865 res = save_filelist_entries_in_common(a, filelist, b, FALSE); 2865 2866 free_filelist(filelist); 2866 paranoid_free(a);2867 paranoid_free(b);2867 mr_free(a); 2868 mr_free(b); 2868 2869 printf("res = %d", res); 2869 2870 finish(0); … … 2944 2945 log_msg(2, "Still here. Yay."); 2945 2946 if (strlen(bkpinfo->tmpdir) > 0) { 2946 asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir);2947 mr_asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir); 2947 2948 run_program_and_log_output(tmp, FALSE); 2948 paranoid_free(tmp);2949 mr_free(tmp); 2949 2950 } 2950 2951 unmount_boot_if_necessary(); /* for Gentoo users */ … … 2960 2961 2961 2962 iamhere("About to call load_mountlist and load_raidtab"); 2962 paranoid_alloc(bkpinfo->restore_path, MNT_RESTORING);2963 mr_allocstr(bkpinfo->restore_path, MNT_RESTORING); 2963 2964 read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo); 2964 2965 retval = load_mountlist(mountlist, g_mountlist_fname); … … 2973 2974 && !is_this_device_mounted(bkpinfo->nfs_mount)) { 2974 2975 log_msg(1, "Mounting nfs dir"); 2975 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");2976 mr_allocstr(bkpinfo->isodir, "/tmp/isodir"); 2976 2977 run_program_and_log_output("mkdir -p /tmp/isodir", 5); 2977 asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir",2978 mr_asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir", 2978 2979 bkpinfo->nfs_mount); 2979 2980 run_program_and_log_output(tmp, 1); 2980 paranoid_free(tmp);2981 mr_free(tmp); 2981 2982 } 2982 2983 } … … 2995 2996 log_msg(0, "Partitioning only."); 2996 2997 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2997 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");2998 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 2998 2999 load_mountlist(mountlist, g_mountlist_fname); 2999 3000 res = partition_everything(mountlist); … … 3004 3005 log_msg(0, "Formatting only."); 3005 3006 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 3006 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");3007 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 3007 3008 load_mountlist(mountlist, g_mountlist_fname); 3008 3009 res = format_everything(mountlist, FALSE, raidlist); … … 3013 3014 log_msg(0, "Stopping LVM and RAID"); 3014 3015 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 3015 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");3016 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 3016 3017 load_mountlist(mountlist, g_mountlist_fname); 3017 3018 res = do_my_funky_lvm_stuff(TRUE, FALSE); … … 3139 3140 unlink("/tmp/mondo-run-prog.tmp"); 3140 3141 set_signals(FALSE); 3141 asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir);3142 mr_asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir); 3142 3143 run_program_and_log_output(tmp, FALSE); 3143 paranoid_free(tmp);3144 mr_free(tmp); 3144 3145 3145 3146 log_to_screen 3146 3147 (_ 3147 3148 ("Restore log copied to /tmp/mondo-restore.log on your hard disk")); 3148 asprintf(&tmp,3149 mr_asprintf(&tmp, 3149 3150 _ 3150 3151 ("Mondo-restore is exiting (retval=%d) "), 3151 3152 retval); 3152 3153 log_to_screen(tmp); 3153 paranoid_free(tmp);3154 3155 asprintf(&tmp, "umount %s", bkpinfo->isodir);3154 mr_free(tmp); 3155 3156 mr_asprintf(&tmp, "umount %s", bkpinfo->isodir); 3156 3157 run_program_and_log_output(tmp, 5); 3157 paranoid_free(tmp);3158 3159 paranoid_free(mountlist);3160 paranoid_free(raidlist);3158 mr_free(tmp); 3159 3160 mr_free(mountlist); 3161 mr_free(raidlist); 3161 3162 if (am_I_in_disaster_recovery_mode()) { 3162 3163 run_program_and_log_output("mount / -o remount,rw", 2); -
trunk/mondo/src/mondorestore/mondo-rstr-compare.c
r783 r900 14 14 #include <pthread.h> 15 15 #endif 16 #include "mr_mem.h" 16 17 17 18 void popup_changelist_from_file(char *); … … 61 62 } 62 63 if (!(fin = fopen(tmp1, "r"))) { 63 asprintf(&tmp, _("Cannot open bigfile %ld (%s)'s info file"),64 mr_asprintf(&tmp, _("Cannot open bigfile %ld (%s)'s info file"), 64 65 bigfileno + 1, tmp); 65 66 log_to_screen(tmp); 66 paranoid_free(tmp);67 paranoid_free(tmp1);67 mr_free(tmp); 68 mr_free(tmp1); 68 69 return (1); 69 70 } 70 paranoid_free(tmp1);71 mr_free(tmp1); 71 72 72 73 fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin); 73 74 paranoid_fclose(fin); 74 75 75 asprintf(&checksum, biggiestruct.checksum);76 asprintf(&bigfile_fname, biggiestruct.filename);76 mr_asprintf(&checksum, biggiestruct.checksum); 77 mr_asprintf(&bigfile_fname, biggiestruct.filename); 77 78 78 79 log_msg(2, "biggiestruct.filename = %s", bigfile_fname); … … 80 81 81 82 if (!g_text_mode) { 82 asprintf(&tmp, _("Comparing %s"), bigfile_fname);83 mr_asprintf(&tmp, _("Comparing %s"), bigfile_fname); 83 84 newtDrawRootText(0, 22, tmp); 84 85 newtRefresh(); 85 paranoid_free(tmp);86 mr_free(tmp); 86 87 } 87 88 /* BERLIOS: Useless ? … … 93 94 return(0); 94 95 } else { 95 asprintf(&command,96 mr_asprintf(&command, 96 97 "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors.txt", 97 98 MNT_RESTORING, bigfile_fname); … … 101 102 if (system(command)) { 102 103 log_OS_error("Warning - command failed"); 103 paranoid_free(command);104 paranoid_free(bigfile_fname);104 mr_free(command); 105 mr_free(bigfile_fname); 105 106 return (1); 106 107 } else { 107 paranoid_free(command);108 mr_free(command); 108 109 if (!(fin = fopen("/tmp/md5sum.txt", "r"))) { 109 110 log_msg(2, "Unable to open /tmp/md5sum.txt; can't get live checksum"); 110 paranoid_free(bigfile_fname);111 mr_free(bigfile_fname); 111 112 return (1); 112 113 } else { 113 getline(&original_cksum, &n, fin);114 mr_getline(&original_cksum, &n, fin); 114 115 paranoid_fclose(fin); 115 116 for (i = strlen(original_cksum); … … 128 129 retval++; 129 130 } 130 paranoid_free(original_cksum);131 paranoid_free(checksum);131 mr_free(original_cksum); 132 mr_free(checksum); 132 133 133 134 if (retval) { … … 138 139 paranoid_fclose(fout); 139 140 } 140 paranoid_free(bigfile_fname);141 mr_free(bigfile_fname); 141 142 142 143 return (retval); … … 181 182 noof_biggiefiles); 182 183 for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) { 183 asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1);184 mr_asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1); 184 185 log_msg(1, tmp); 185 186 update_progress_form(tmp); 186 paranoid_free(tmp);187 mr_free(tmp); 187 188 res = compare_a_biggiefile(bkpinfo, bigfileno); 188 189 retval += res; … … 232 233 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 233 234 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 234 asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d",235 mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d", 235 236 current_tarball_number); 236 237 237 238 noof_lines = count_lines_in_file(filelist_name); 238 paranoid_free(filelist_name);239 mr_free(filelist_name); 239 240 240 241 if (strstr(tarball_fname, ".bz2")) { 241 asprintf(&compressor_exe, "bzip2");242 mr_asprintf(&compressor_exe, "bzip2"); 242 243 } else if (strstr(tarball_fname, ".lzo")) { 243 asprintf(&compressor_exe, "lzop");244 mr_asprintf(&compressor_exe, "lzop"); 244 245 } else { 245 246 compressor_exe = NULL; … … 247 248 248 249 if (use_star) { 249 asprintf(&archiver_exe, "star -bz");250 } else { 251 asprintf(&archiver_exe, "afio");250 mr_asprintf(&archiver_exe, "star -bz"); 251 } else { 252 mr_asprintf(&archiver_exe, "afio"); 252 253 } 253 254 … … 257 258 fatal_error("(compare_a_tarball) Compression program missing"); 258 259 } 259 paranoid_free(tmp);260 mr_free(tmp); 260 261 261 262 if (use_star) { … … 266 267 } else { 267 268 tmp = compressor_exe; 268 asprintf(&compressor_exe, "-P %s -Z", tmp);269 paranoid_free(tmp);269 mr_asprintf(&compressor_exe, "-P %s -Z", tmp); 270 mr_free(tmp); 270 271 } 271 272 } … … 278 279 #endif 279 280 280 asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number);281 mr_asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number); 281 282 if (use_star) // doesn't use compressor_exe 282 283 { 283 asprintf(&command,284 mr_asprintf(&command, 284 285 "%s -diff H=star file=%s >> %s 2>> %s", 285 286 archiver_exe, tarball_fname, logfile, logfile); 286 287 } else { 287 asprintf(&command,288 mr_asprintf(&command, 288 289 "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", 289 290 archiver_exe, … … 292 293 } 293 294 #undef BUFSIZE 294 paranoid_free(archiver_exe);295 paranoid_free(compressor_exe);295 mr_free(archiver_exe); 296 mr_free(compressor_exe); 296 297 297 298 res = system(command); … … 300 301 log_OS_error(command); 301 302 } 302 paranoid_free(command);303 mr_free(command); 303 304 304 305 if (length_of_file(logfile) > 5) { 305 asprintf(&command,306 mr_asprintf(&command, 306 307 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vx \"dev/.*\" >> /tmp/changed.txt", 307 308 logfile); 308 309 system(command); 309 paranoid_free(command);310 mr_free(command); 310 311 archiver_errors = count_lines_in_file(logfile); 311 312 } else { … … 314 315 315 316 if (archiver_errors) { 316 asprintf(&tmp,317 mr_asprintf(&tmp, 317 318 "Differences found while processing fileset #%d ", 318 319 current_tarball_number); 319 320 log_msg(1, tmp); 320 paranoid_free(tmp);321 mr_free(tmp); 321 322 } 322 323 unlink(logfile); 323 paranoid_free(logfile);324 mr_free(logfile); 324 325 return (retval); 325 326 } … … 353 354 354 355 max_val = atol(tmp); 355 paranoid_free(tmp);356 357 asprintf(&progress_str, _("Comparing with %s #%d "),356 mr_free(tmp); 357 358 mr_asprintf(&progress_str, _("Comparing with %s #%d "), 358 359 bkpinfo->backup_media_string, 359 360 g_current_media_number); … … 369 370 insist_on_this_cd_number(bkpinfo, g_current_media_number); 370 371 update_progress_form(progress_str); 371 asprintf(&tarball_fname,372 mr_asprintf(&tarball_fname, 372 373 MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number); 373 374 374 375 if (!does_file_exist(tarball_fname)) { 375 paranoid_free(tarball_fname);376 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",376 mr_free(tarball_fname); 377 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo", 377 378 current_tarball_number); 378 379 } 379 380 if (!does_file_exist(tarball_fname)) { 380 paranoid_free(tarball_fname);381 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.",381 mr_free(tarball_fname); 382 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.", 382 383 current_tarball_number); 383 384 } 384 385 if (!does_file_exist(tarball_fname)) { 385 paranoid_free(tarball_fname);386 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2",386 mr_free(tarball_fname); 387 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2", 387 388 current_tarball_number); 388 389 } 389 390 if (!does_file_exist(tarball_fname)) { 390 paranoid_free(tarball_fname);391 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.",391 mr_free(tarball_fname); 392 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.", 392 393 current_tarball_number); 393 394 } … … 398 399 == 0) { 399 400 log_msg(2, "OK, I think I'm done with tarballs..."); 400 paranoid_free(tarball_fname);401 mr_free(tarball_fname); 401 402 break; 402 403 } 403 404 log_msg(2, "OK, I think it's time for another CD..."); 404 405 g_current_media_number++; 405 paranoid_free(progress_str);406 asprintf(&progress_str, _("Comparing with %s #%d "),406 mr_free(progress_str); 407 mr_asprintf(&progress_str, _("Comparing with %s #%d "), 407 408 bkpinfo->backup_media_string, 408 409 g_current_media_number); … … 410 411 } else { 411 412 res = compare_a_tarball(tarball_fname, current_tarball_number); 412 paranoid_free(tarball_fname);413 mr_free(tarball_fname); 413 414 414 415 g_current_progress++; … … 416 417 } 417 418 } 418 paranoid_free(progress_str);419 mr_free(progress_str); 419 420 close_progress_form(); 420 421 … … 470 471 noof_changed_files = count_lines_in_file("/tmp/changed.txt"); 471 472 if (noof_changed_files) { 472 asprintf(&tmp, _("%ld files do not match the backup "),473 mr_asprintf(&tmp, _("%ld files do not match the backup "), 473 474 noof_changed_files); 474 475 // mvaddstr_and_log_it( g_currentY++, 0, tmp ); 475 476 log_to_screen(tmp); 476 paranoid_free(tmp);477 478 asprintf(&command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE);477 mr_free(tmp); 478 479 mr_asprintf(&command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE); 479 480 paranoid_system(command); 480 paranoid_free(command);481 } else { 482 asprintf(&tmp, _("All files match the backup "));481 mr_free(command); 482 } else { 483 mr_asprintf(&tmp, _("All files match the backup ")); 483 484 mvaddstr_and_log_it(g_currentY++, 0, tmp); 484 485 log_to_screen(tmp); 485 paranoid_free(tmp);486 } 487 488 paranoid_free(cwd);489 paranoid_free(new);486 mr_free(tmp); 487 } 488 489 mr_free(cwd); 490 mr_free(new); 490 491 491 492 return (resA + resB); … … 573 574 } else { 574 575 q = count_lines_in_file("/tmp/changed.files"); 575 asprintf(&tmp, _("%ld significant difference%s found."), q,576 mr_asprintf(&tmp, _("%ld significant difference%s found."), q, 576 577 (q != 1) ? "s" : ""); 577 578 mvaddstr_and_log_it(g_currentY++, 0, tmp); 578 579 log_to_screen(tmp); 579 paranoid_free(tmp);580 581 asprintf(&tmp,580 mr_free(tmp); 581 582 mr_asprintf(&tmp, 582 583 _("Type 'less /tmp/changed.files' for a list of non-matching files")); 583 584 mvaddstr_and_log_it(g_currentY++, 0, tmp); 584 585 log_to_screen(tmp); 585 paranoid_free(tmp);586 mr_free(tmp); 586 587 587 588 log_msg(2, "calling popup_changelist_from_file()"); … … 624 625 chdir(bkpinfo->restore_path); 625 626 626 asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",627 mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 627 628 bkpinfo->restore_path); 628 629 run_program_and_log_output(command, FALSE); 629 paranoid_free(command);630 mr_free(command); 630 631 mvaddstr_and_log_it(g_currentY, 631 632 0, _("Verifying archives against filesystem")); … … 633 634 if (bkpinfo->disaster_recovery 634 635 && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 635 paranoid_free(bkpinfo->media_device);636 mr_free(bkpinfo->media_device); 636 637 // last_line_of_file allocates the string 637 638 bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE"); 638 639 } else { 639 paranoid_free(bkpinfo->media_device);640 mr_free(bkpinfo->media_device); 640 641 // find_cdrom_device allocates the string 641 642 bkpinfo->media_device = find_cdrom_device(FALSE); … … 653 654 654 655 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 655 paranoid_free(dir);656 mr_free(dir); 656 657 return (res); 657 658 } … … 684 685 getcwd(dir, MAX_STR_LEN); 685 686 chdir(bkpinfo->restore_path); 686 asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",687 mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 687 688 bkpinfo->restore_path); 688 689 run_program_and_log_output(command, FALSE); 689 paranoid_free(command);690 mr_free(command); 690 691 691 692 mvaddstr_and_log_it(g_currentY, … … 698 699 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 699 700 } 700 paranoid_free(dir);701 mr_free(dir); 701 702 return (res); 702 703 } -
trunk/mondo/src/mondorestore/mondo-rstr-newt.c
r783 r900 16 16 17 17 #include "mondo-rstr-newt.h" 18 #include "mr_mem.h" 18 19 19 20 /** … … 78 79 (_ 79 80 (" Add one of the following unallocated RAID partitions to this RAID device.")); 80 asprintf(&tmp, "%-26s %s", _("Device"), _("Size"));81 mr_asprintf(&tmp, "%-26s %s", _("Device"), _("Size")); 81 82 headerMsg = newtLabel(1, 1, tmp); 82 paranoid_free(tmp);83 mr_free(tmp); 83 84 84 85 partitionsListbox = … … 167 168 assert(keylist != NULL); 168 169 169 asprintf(&device_str, "/dev/");170 asprintf(&mountpoint_str, "/");170 mr_asprintf(&device_str, "/dev/"); 171 mr_asprintf(&mountpoint_str, "/"); 171 172 #ifdef __FreeBSD__ 172 asprintf(&format_str, "ufs");173 mr_asprintf(&format_str, "ufs"); 173 174 #else 174 asprintf(&format_str, "ext2");175 mr_asprintf(&format_str, "ext2"); 175 176 #endif 176 177 newtOpenWindow(20, 5, 48, 10, _("Add entry")); … … 199 200 b_res = newtRunForm(myForm); 200 201 201 paranoid_free(device_str);202 asprintf(&device_str, device_here);202 mr_free(device_str); 203 mr_asprintf(&device_str, device_here); 203 204 strip_spaces(device_str); 204 205 205 paranoid_free(format_str);206 asprintf(&format_str, format_here);206 mr_free(format_str); 207 mr_asprintf(&format_str, format_here); 207 208 strip_spaces(format_str); 208 209 209 paranoid_free(mountpoint_str);210 asprintf(&mountpoint_str, mountpoint_here);210 mr_free(mountpoint_str); 211 mr_asprintf(&mountpoint_str, mountpoint_here); 211 212 strip_spaces(mountpoint_str); 212 213 213 paranoid_free(size_str);214 asprintf(&size_str, size_here);214 mr_free(size_str); 215 mr_asprintf(&size_str, size_here); 215 216 strip_spaces(size_str); 216 217 … … 234 235 return; 235 236 } 236 asprintf(&drive_to_add, device_str);237 mr_asprintf(&drive_to_add, device_str); 237 238 for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--); 238 239 num_to_add = atoi(drive_to_add + i); 239 240 drive_to_add[i] = '\0'; 240 paranoid_free(drive_to_add);241 mr_free(drive_to_add); 241 242 242 243 currline = mountlist->entries; 243 244 strcpy(mountlist->el[currline].device, device_str); 244 245 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 245 paranoid_free(mountpoint_str);246 mr_free(mountpoint_str); 246 247 247 248 strcpy(mountlist->el[currline].format, format_str); 248 paranoid_free(format_str);249 mr_free(format_str); 249 250 250 251 mountlist->el[currline].size = atol(size_str) * 1024; 251 paranoid_free(size_str);252 mr_free(size_str); 252 253 253 254 mountlist->entries++; … … 256 257 device_str); 257 258 } 258 paranoid_free(device_str);259 mr_free(device_str); 259 260 redraw_mountlist(mountlist, keylist, listbox); 260 261 } … … 296 297 } 297 298 } 298 paranoid_free(sz_out);299 mr_free(sz_out); 299 300 } 300 301 #endif … … 335 336 && strcmp(raidlist->el[i].volname, basename(raid_device)); i++); 336 337 if (i == raidlist->entries) { 337 asprintf(&tmp,338 mr_asprintf(&tmp, 338 339 "Cannot calc size of raid device %s - cannot find it in raidlist", 339 340 raid_device); 340 341 log_it(tmp); 341 paranoid_free(tmp);342 mr_free(tmp); 342 343 return (0); // Isn't this more sensible than 999999999? If the raid dev !exists, 343 344 // then it has no size, right? … … 351 352 int k = 0, l = 0; 352 353 for (k = 0; k < raidrec->plex[j].subdisks; ++k) { 353 asprintf(&devname, raidrec->plex[j].sd[k].which_device);354 mr_asprintf(&devname, raidrec->plex[j].sd[k].which_device); 354 355 for (l = 0; l < raidlist->disks.entries; ++l) { 355 356 if (!strcmp(devname, raidlist->disks.el[l].name)) { … … 379 380 } 380 381 } 381 paranoid_free(devname);382 mr_free(devname); 382 383 } 383 384 … … 400 401 } 401 402 402 asprintf(&tmp, "I have calculated %s's real size to be %ld",403 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", 403 404 raid_device, (long) smallest_plex); 404 405 log_it(tmp); 405 paranoid_free(tmp);406 mr_free(tmp); 406 407 return (smallest_plex); 407 408 #else … … 431 432 && strcmp(raidlist->el[i].raid_device, raid_device); i++); 432 433 if (i == raidlist->entries) { 433 asprintf(&tmp,434 mr_asprintf(&tmp, 434 435 "Cannot calc size of raid device %s - cannot find it in raidlist", 435 436 raid_device); 436 437 log_it(tmp); 437 paranoid_free(tmp);438 mr_free(tmp); 438 439 return (999999999); 439 440 } … … 458 459 total_size = smallest_partition * (noof_partitions - 1); 459 460 } 460 asprintf(&tmp, "I have calculated %s's real size to be %ld",461 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", 461 462 raid_device, (long) total_size); 462 463 log_it(tmp); 463 paranoid_free(tmp);464 mr_free(tmp); 464 465 return (total_size); 465 466 #endif … … 487 488 char *sz = NULL; 488 489 489 asprintf(&prompt,490 mr_asprintf(&prompt, 490 491 _ 491 492 ("Please enter the RAID level you want. (concat, striped, raid5)")); 492 493 if (raidrec->raidlevel == -1) { 493 asprintf(&tmp, "concat");494 mr_asprintf(&tmp, "concat"); 494 495 } else if (raidrec->raidlevel == 0) { 495 asprintf(&tmp, "striped");496 mr_asprintf(&tmp, "striped"); 496 497 } else { 497 asprintf(&tmp, "raid%i", raidrec->raidlevel);498 mr_asprintf(&tmp, "raid%i", raidrec->raidlevel); 498 499 } 499 500 for (out = 999; out == 999;) { … … 504 505 /* BERLIOS: Useless ??? 505 506 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 506 asprintf(&sz, tmp);507 mr_asprintf(&sz, tmp); 507 508 strncpy(tmp, sz + 1, strlen(sz) - 2); 508 509 tmp[strlen(sz) - 2] = '\0'; 509 paranoid_free(sz);510 mr_free(sz); 510 511 } 511 512 */ … … 518 519 } 519 520 log_it(tmp); 520 paranoid_free(tmp);521 mr_free(tmp); 521 522 if (is_this_raid_personality_registered(out)) { 522 523 log_it … … 530 531 } 531 532 } 532 paranoid_free(prompt);533 mr_free(prompt); 533 534 raidrec->raidlevel = out; 534 535 #else … … 544 545 ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null"); 545 546 personalities = last_line_of_file("/tmp/raid-personalities.txt"); 546 asprintf(&prompt, _("Please enter the RAID level you want. %s"),547 mr_asprintf(&prompt, _("Please enter the RAID level you want. %s"), 547 548 personalities); 548 paranoid_free(personalities);549 mr_free(personalities); 549 550 550 551 if (raidrec->raid_level == -1) { 551 asprintf(&tmp, "linear");552 mr_asprintf(&tmp, "linear"); 552 553 } else { 553 asprintf(&tmp, "%d", raidrec->raid_level);554 mr_asprintf(&tmp, "%d", raidrec->raid_level); 554 555 } 555 556 for (out = 999; … … 563 564 /* BERLIOS: Useless ??? 564 565 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 565 asprintf(&sz, tmp);566 paranoid_free(tmp);567 568 asprintf(&tmp, sz + 1);566 mr_asprintf(&sz, tmp); 567 mr_free(tmp); 568 569 mr_asprintf(&tmp, sz + 1); 569 570 tmp[strlen(sz) - 2] = '\0'; 570 paranoid_free(sz);571 mr_free(sz); 571 572 } 572 573 */ … … 591 592 } 592 593 } 593 paranoid_free(tmp);594 paranoid_free(prompt);594 mr_free(tmp); 595 mr_free(prompt); 595 596 raidrec->raid_level = out; 596 597 #endif … … 659 660 assert_string_is_neither_NULL_nor_zerolength(raid_device); 660 661 661 asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"),662 mr_asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"), 662 663 disklist->el[currline].device, raid_device); 663 664 if (!ask_me_yes_or_no(tmp)) { 664 paranoid_free(tmp);665 mr_free(tmp); 665 666 return; 666 667 } 667 paranoid_free(tmp);668 mr_free(tmp); 668 669 for (pos = currline; pos < disklist->entries - 1; pos++) { 669 670 /* memcpy((void*)&disklist->el[pos], (void*)&disklist->el[pos+1], sizeof(struct s_disk)); */ … … 707 708 device); 708 709 if (pos >= 0) { 709 asprintf(&tmp,710 mr_asprintf(&tmp, 710 711 _("Cannot delete %s: it is in use by RAID device %s"), 711 712 mountlist->el[currline].device, 712 713 raidlist->el[pos].OSSWAP(raid_device, volname)); 713 714 popup_and_OK(tmp); 714 paranoid_free(tmp);715 mr_free(tmp); 715 716 return; 716 717 } 717 asprintf(&tmp, _("Delete %s - are you sure?"),718 mr_asprintf(&tmp, _("Delete %s - are you sure?"), 718 719 mountlist->el[currline].device); 719 720 if (!ask_me_yes_or_no(tmp)) { 720 paranoid_free(tmp);721 mr_free(tmp); 721 722 return; 722 723 } 723 paranoid_free(tmp);724 mr_free(tmp); 724 725 725 726 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { 726 asprintf(&device, mountlist->el[currline].device);727 mr_asprintf(&device, mountlist->el[currline].device); 727 728 delete_raidlist_entry(mountlist, raidlist, device); 728 729 for (currline = 0; … … 732 733 if (currline == mountlist->entries) { 733 734 log_it("Dev is gone. I can't delete it. Ho-hum"); 734 paranoid_free(device);735 mr_free(device); 735 736 return; 736 737 } 737 paranoid_free(device);738 mr_free(device); 738 739 } 739 740 memcpy((void *) &mountlist->el[currline], … … 775 776 return; 776 777 } 777 asprintf(&tmp,778 mr_asprintf(&tmp, 778 779 _("Do you want me to delete %s's partitions, too?"), device); 779 780 delete_partitions_too = ask_me_yes_or_no(tmp); … … 820 821 items--; 821 822 } 822 paranoid_free(tmp);823 mr_free(tmp); 823 824 824 825 raidlist->entries = items; … … 845 846 846 847 av = &raidrec->additional_vars; 847 asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label);848 mr_asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label); 848 849 if (ask_me_yes_or_no(tmp)) { 849 850 if (!strcmp(av->el[lino].label, "persistent-superblock") 850 851 || !strcmp(av->el[lino].label, "chunk-size")) { 851 paranoid_free(tmp);852 asprintf(&tmp, _("%s must not be deleted. It would be bad."),852 mr_free(tmp); 853 mr_asprintf(&tmp, _("%s must not be deleted. It would be bad."), 853 854 av->el[lino].label); 854 855 popup_and_OK(tmp); 855 856 } else { 856 paranoid_free(av->el[lino].label);857 paranoid_free(av->el[lino].value);857 mr_free(av->el[lino].label); 858 mr_free(av->el[lino].value); 858 859 memcpy((void *) &av->el[lino], (void *) &av->el[av->entries--], 859 860 sizeof(struct raid_var_line)); … … 864 865 } 865 866 } 866 paranoid_free(tmp);867 mr_free(tmp); 867 868 } 868 869 #endif … … 924 925 if (!warned_already) { 925 926 warned_already = TRUE; 926 asprintf(&tmp,927 mr_asprintf(&tmp, 927 928 _ 928 929 ("Too many lines. Displaying first %d entries only. Close a directory to see more."), 929 930 ARBITRARY_MAXIMUM); 930 931 popup_and_OK(tmp); 931 paranoid_free(tmp);932 mr_free(tmp); 932 933 } 933 934 } else { … … 948 949 (g_strings_of_flist_window[i], 949 950 g_strings_of_flist_window[i - 1]) < 0) { 950 asprintf(&tmp, g_strings_of_flist_window[i]);951 mr_asprintf(&tmp, g_strings_of_flist_window[i]); 951 952 strcpy(g_strings_of_flist_window[i], 952 953 g_strings_of_flist_window[i - 1]); 953 954 strcpy(g_strings_of_flist_window[i - 1], tmp); 954 paranoid_free(tmp);955 mr_free(tmp); 955 956 956 957 dummybool = g_is_path_selected[i]; … … 963 964 newtListboxClear(listbox); 964 965 for (i = 0; i < lines_in_flist_window; i++) { 965 asprintf(&tmp, "%c%c %-80s",966 mr_asprintf(&tmp, "%c%c %-80s", 966 967 (g_is_path_selected[i] ? '*' : ' '), 967 968 (g_is_path_expanded[i] ? '+' : '-'), … … 973 974 keylist[i] = (void *) i; 974 975 newtListboxAppendEntry(listbox, tmp, keylist[i]); 975 paranoid_free(tmp);976 mr_free(tmp); 976 977 } 977 978 return (lines_in_flist_window); … … 1223 1224 memcpy((void *) &bkp_raidlist, (void *) raidlist, 1224 1225 sizeof(struct raidlist_itself)); 1225 asprintf(&device_str, mountlist->el[currline].device);1226 asprintf(&device_used_to_be, mountlist->el[currline].device);1227 asprintf(&mountpoint_str, mountlist->el[currline].mountpoint);1228 asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint);1229 asprintf(&format_str, mountlist->el[currline].format);1230 asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024);1226 mr_asprintf(&device_str, mountlist->el[currline].device); 1227 mr_asprintf(&device_used_to_be, mountlist->el[currline].device); 1228 mr_asprintf(&mountpoint_str, mountlist->el[currline].mountpoint); 1229 mr_asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint); 1230 mr_asprintf(&format_str, mountlist->el[currline].format); 1231 mr_asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024); 1231 1232 1232 1233 newtOpenWindow(20, 5, 48, 10, "Edit entry"); … … 1237 1238 deviceComp = 1238 1239 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 1239 paranoid_free(device_str);1240 mr_free(device_str); 1240 1241 1241 1242 mountpointComp = 1242 1243 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 1243 paranoid_free(mountpoint_str);1244 mr_free(mountpoint_str); 1244 1245 1245 1246 formatComp = 1246 1247 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 1247 paranoid_free(format_str);1248 mr_free(format_str); 1248 1249 1249 1250 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) … … 1253 1254 sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0); 1254 1255 } 1255 paranoid_free(size_str);1256 mr_free(size_str); 1256 1257 1257 1258 bOK = newtButton(2, 6, _(" OK ")); … … 1270 1271 b_res = newtRunForm(myForm); 1271 1272 1272 paranoid_free(device_str);1273 asprintf(&device_str, device_here);1273 mr_free(device_str); 1274 mr_asprintf(&device_str, device_here); 1274 1275 strip_spaces(device_str); 1275 1276 1276 paranoid_free(mountpoint_str);1277 asprintf(&mountpoint_str, mountpoint_here);1277 mr_free(mountpoint_str); 1278 mr_asprintf(&mountpoint_str, mountpoint_here); 1278 1279 strip_spaces(mountpoint_str); 1279 1280 1280 paranoid_free(format_str);1281 asprintf(&format_str, format_here);1282 paranoid_free(format_here);1281 mr_free(format_str); 1282 mr_asprintf(&format_str, format_here); 1283 mr_free(format_here); 1283 1284 strip_spaces(format_str); 1284 1285 if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB) … … 1295 1296 continue; 1296 1297 } 1297 paranoid_free(mountpt_used_to_be);1298 mr_free(mountpt_used_to_be); 1298 1299 1299 1300 if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1300 1301 && strcmp(mountlist->el[currline].mountpoint, "image")) { 1301 asprintf(&size_str, size_here);1302 mr_asprintf(&size_str, size_here); 1302 1303 strip_spaces(size_str); 1303 1304 } else { 1304 asprintf(&size_str, "%ld",1305 mr_asprintf(&size_str, "%ld", 1305 1306 calculate_raid_device_size(mountlist, raidlist, 1306 1307 mountlist->el[currline]. … … 1308 1309 newtLabelSetText(sizeComp, size_str); 1309 1310 } 1310 paranoid_free(size_here);1311 mr_free(size_here); 1311 1312 1312 1313 /* do not let user click RAID button if user has changed device_str */ … … 1325 1326 device); 1326 1327 if (j < 0) { 1327 asprintf(&tmp,1328 mr_asprintf(&tmp, 1328 1329 _ 1329 1330 ("/etc/raidtab does not have an entry for %s; please delete it and add it again"), 1330 1331 mountlist->el[currline].device); 1331 1332 popup_and_OK(tmp); 1332 paranoid_free(tmp);1333 mr_free(tmp); 1333 1334 } else { 1334 1335 log_it(_("edit_raidlist_entry - calling")); … … 1339 1340 } 1340 1341 } 1341 paranoid_free(device_here);1342 paranoid_free(mountpoint_here);1342 mr_free(device_here); 1343 mr_free(mountpoint_here); 1343 1344 1344 1345 newtFormDestroy(myForm); … … 1352 1353 strcpy(mountlist->el[currline].device, device_str); 1353 1354 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 1354 paranoid_free(mountpoint_str);1355 mr_free(mountpoint_str); 1355 1356 1356 1357 strcpy(mountlist->el[currline].format, format_str); 1357 paranoid_free(format_str);1358 mr_free(format_str); 1358 1359 1359 1360 if (strcmp(mountlist->el[currline].mountpoint, "image")) { … … 1366 1367 } 1367 1368 } 1368 paranoid_free(size_str);1369 mr_free(size_str); 1369 1370 1370 1371 newtListboxSetEntry(listbox, (long) keylist[currline], … … 1397 1398 #endif 1398 1399 redraw_mountlist(mountlist, keylist, listbox); 1399 paranoid_free(device_str);1400 paranoid_free(device_used_to_be);1400 mr_free(device_str); 1401 mr_free(device_used_to_be); 1401 1402 } 1402 1403 … … 1516 1517 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1517 1518 sizeof(struct vinum_volume)); 1518 asprintf(&title_of_editraidForm_window, _("Plexes on %s"),1519 mr_asprintf(&title_of_editraidForm_window, _("Plexes on %s"), 1519 1520 raidrec->volname); 1520 1521 newtPushHelpLine(_(" Please select a plex to edit")); 1521 1522 newtOpenWindow(13, 5, 54, 15, title_of_editraidForm_window); 1522 paranoid_free(title_of_editraidForm_window);1523 mr_free(title_of_editraidForm_window); 1523 1524 1524 1525 for (;;) { 1525 asprintf(&headerstr, "%-14s %-8s %11s %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks"));1526 mr_asprintf(&headerstr, "%-14s %-8s %11s %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks")); 1526 1527 1527 1528 bOK = newtCompactButton(2, 13, _(" OK ")); … … 1534 1535 newtListbox(2, 3, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); 1535 1536 plexesHeader = newtLabel(2, 2, headerstr); 1536 paranoid_free(headerstr);1537 mr_free(headerstr); 1537 1538 1538 1539 editraidForm = newtForm(NULL, NULL, 0); … … 1544 1545 switch (raidrec->plex[i].raidlevel) { 1545 1546 case -1: 1546 asprintf(&raidlevel, "concat");1547 mr_asprintf(&raidlevel, "concat"); 1547 1548 break; 1548 1549 case 0: 1549 asprintf(&raidlevel, "striped");1550 mr_asprintf(&raidlevel, "striped"); 1550 1551 break; 1551 1552 case 5: 1552 asprintf(&raidlevel, "raid5");1553 mr_asprintf(&raidlevel, "raid5"); 1553 1554 break; 1554 1555 default: 1555 asprintf(&raidlevel, "raid%i",1556 mr_asprintf(&raidlevel, "raid%i", 1556 1557 raidrec->plex[i].raidlevel); 1557 1558 break; … … 1559 1560 1560 1561 if (raidrec->plex[i].raidlevel == -1) { 1561 asprintf(&chunksize, "N/A");1562 mr_asprintf(&chunksize, "N/A"); 1562 1563 } else { 1563 asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize);1564 mr_asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize); 1564 1565 } 1565 asprintf(&pname, "%s.p%i", raidrec->volname, i);1566 asprintf(&entry, "%-14s %-8s %11s %8d",1566 mr_asprintf(&pname, "%s.p%i", raidrec->volname, i); 1567 mr_asprintf(&entry, "%-14s %-8s %11s %8d", 1567 1568 pname, raidlevel, chunksize, 1568 1569 raidrec->plex[i].subdisks); 1569 paranoid_free(pname);1570 paranoid_free(chunksize);1571 paranoid_free(raidlevel);1570 mr_free(pname); 1571 mr_free(chunksize); 1572 mr_free(raidlevel); 1572 1573 newtListboxAppendEntry(plexesListbox, entry, keylist[i]); 1573 paranoid_free(entry);1574 mr_free(entry); 1574 1575 } 1575 1576 } … … 1592 1593 1593 1594 if (b_res == bDelete) { 1594 asprintf(&msg, _("Are you sure you want to delete %s.p%i?"),1595 mr_asprintf(&msg, _("Are you sure you want to delete %s.p%i?"), 1595 1596 raidrec->volname, currline2); 1596 1597 if (ask_me_yes_or_no(msg)) { … … 1601 1602 raidrec->plexes--; 1602 1603 } 1603 paranoid_free(msg);1604 mr_free(msg); 1604 1605 continue; 1605 1606 } … … 1659 1660 memcpy((void *) bkp_raidrec, (void *) raidrec, 1660 1661 sizeof(struct raid_device_record)); 1661 asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device);1662 mr_asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device); 1662 1663 log_msg(2, "Opening newt window"); 1663 1664 newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window); 1664 paranoid_free(title_of_editraidForm_window);1665 mr_free(title_of_editraidForm_window); 1665 1666 1666 1667 for (;;) { 1667 1668 log_msg(2, "Main loop"); 1668 asprintf(&sz_raid_level,1669 mr_asprintf(&sz_raid_level, 1669 1670 turn_raid_level_number_to_string(raidrec->raid_level)); 1670 asprintf(&sz_data_disks,1671 mr_asprintf(&sz_data_disks, 1671 1672 number_of_disks_as_string(raidrec->data_disks.entries, 1672 1673 _("data"))); 1673 asprintf(&sz_spare_disks,1674 mr_asprintf(&sz_spare_disks, 1674 1675 number_of_disks_as_string(raidrec->spare_disks.entries, 1675 1676 _("spare"))); 1676 asprintf(&sz_parity_disks,1677 mr_asprintf(&sz_parity_disks, 1677 1678 number_of_disks_as_string(raidrec->parity_disks.entries, 1678 1679 _("parity"))); 1679 asprintf(&sz_failed_disks,1680 mr_asprintf(&sz_failed_disks, 1680 1681 number_of_disks_as_string(raidrec->failed_disks.entries, 1681 1682 _("failed"))); … … 1685 1686 bSelectFailed = newtButton(20, 5, sz_failed_disks); 1686 1687 bChangeRaid = newtButton(1, 9, sz_raid_level); 1687 paranoid_free(sz_raid_level);1688 paranoid_free(sz_data_disks);1689 paranoid_free(sz_spare_disks);1690 paranoid_free(sz_parity_disks);1691 paranoid_free(sz_failed_disks);1688 mr_free(sz_raid_level); 1689 mr_free(sz_data_disks); 1690 mr_free(sz_spare_disks); 1691 mr_free(sz_parity_disks); 1692 mr_free(sz_failed_disks); 1692 1693 1693 1694 bOK = newtButton(16 + (raidrec->raid_level == -1), 9, _(" OK ")); … … 1735 1736 calculate_raid_device_size(mountlist, raidlist, 1736 1737 raidrec->raid_device); 1737 paranoid_free(bkp_raidrec);1738 mr_free(bkp_raidrec); 1738 1739 #endif 1739 1740 } … … 1792 1793 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1793 1794 sizeof(struct vinum_plex)); 1794 asprintf(&title_of_editraidForm_window, "%s.p%i",1795 mr_asprintf(&title_of_editraidForm_window, "%s.p%i", 1795 1796 raidlist->el[currline].volname, currline2); 1796 1797 newtPushHelpLine … … 1798 1799 (" Please select a subdisk to edit, or edit this plex's parameters")); 1799 1800 newtOpenWindow(13, 3, 54, 18, title_of_editraidForm_window); 1800 paranoid_free(title_of_editraidForm_window);1801 mr_free(title_of_editraidForm_window); 1801 1802 1802 1803 for (;;) { 1803 1804 switch (raidrec->raidlevel) { 1804 1805 case -1: 1805 asprintf(&tmp, "concat");1806 mr_asprintf(&tmp, "concat"); 1806 1807 break; 1807 1808 case 0: 1808 asprintf(&tmp, "striped");1809 mr_asprintf(&tmp, "striped"); 1809 1810 break; 1810 1811 case 5: 1811 asprintf(&tmp, "raid5");1812 mr_asprintf(&tmp, "raid5"); 1812 1813 break; 1813 1814 default: 1814 asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel);1815 mr_asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel); 1815 1816 break; 1816 1817 } 1817 1818 bLevel = newtCompactButton(2, 2, _(" RAID level ")); 1818 1819 sLevel = newtLabel(19, 2, tmp); 1819 paranoid_free(tmp);1820 mr_free(tmp); 1820 1821 1821 1822 if (raidrec->raidlevel >= 0) { 1822 asprintf(&tmp, "%ik", raidrec->stripesize);1823 mr_asprintf(&tmp, "%ik", raidrec->stripesize); 1823 1824 bStripeSize = newtCompactButton(2, 4, _(" Stripe size ")); 1824 1825 } else { 1825 asprintf(&tmp, "N/A");1826 mr_asprintf(&tmp, "N/A"); 1826 1827 bStripeSize = newtLabel(2, 4, _("Stripe size:")); 1827 1828 } 1828 1829 sStripeSize = newtLabel(19, 4, tmp); 1829 paranoid_free(tmp);1830 mr_free(tmp); 1830 1831 1831 1832 bOK = newtCompactButton(2, 16, _(" OK ")); … … 1854 1855 keylist[i] = (void *) i; 1855 1856 if (i < raidrec->subdisks) { 1856 asprintf(&entry, "%-17s",1857 mr_asprintf(&entry, "%-17s", 1857 1858 find_dev_entry_for_raid_device_name(raidlist, 1858 1859 raidrec-> … … 1860 1861 which_device)); 1861 1862 newtListboxAppendEntry(allocListbox, entry, keylist[i]); 1862 paranoid_free(entry);1863 mr_free(entry); 1863 1864 } 1864 1865 if (i < unallocparts->entries) { 1865 asprintf(&entry, "%-17s", unallocparts->el[i].device);1866 mr_asprintf(&entry, "%-17s", unallocparts->el[i].device); 1866 1867 newtListboxAppendEntry(unallocListbox, entry, keylist[i]); 1867 paranoid_free(entry);1868 mr_free(entry); 1868 1869 } 1869 1870 } … … 1915 1916 choose_raid_level(raidrec); 1916 1917 } else if (b_res == bStripeSize) { 1917 asprintf(&tmp, "%i", raidrec->stripesize);1918 mr_asprintf(&tmp, "%i", raidrec->stripesize); 1918 1919 if (popup_and_get_string 1919 1920 (_("Stripe size"), … … 1921 1922 raidrec->stripesize = atoi(tmp); 1922 1923 } 1923 paranoid_free(tmp);1924 mr_free(tmp); 1924 1925 } else if ((b_res == bAlloc) || (b_res == unallocListbox)) { 1925 1926 if (currline_u <= unallocparts->entries) … … 1969 1970 assert(lino >= 0); 1970 1971 1971 asprintf(&sz_out, raidrec->additional_vars.el[lino].value);1972 asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label);1973 asprintf(&comment, _("Please set %s's value (currently '%s')"),1972 mr_asprintf(&sz_out, raidrec->additional_vars.el[lino].value); 1973 mr_asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label); 1974 mr_asprintf(&comment, _("Please set %s's value (currently '%s')"), 1974 1975 raidrec->additional_vars.el[lino].label, sz_out); 1975 1976 if (popup_and_get_string(header, comment, sz_out)) { 1976 paranoid_free(raidrec->additional_vars.el[lino].value);1977 mr_free(raidrec->additional_vars.el[lino].value); 1977 1978 raidrec->additional_vars.el[lino].value = sz_out; 1978 1979 } 1979 paranoid_free(header);1980 paranoid_free(comment);1980 mr_free(header); 1981 mr_free(comment); 1981 1982 } 1982 1983 #endif … … 2043 2044 bCancel = newtCompactButton(i += 12, 17, _("Cancel")); 2044 2045 bOK = newtCompactButton(i += 12, 17, _(" OK ")); 2045 asprintf(&tmp, "%-24s %-24s %-8s %s", _("Device"), _("Mountpoint"),2046 mr_asprintf(&tmp, "%-24s %-24s %-8s %s", _("Device"), _("Mountpoint"), 2046 2047 _("Format"), _("Size (MB)")); 2047 2048 headerMsg = newtLabel(2, 1, tmp); … … 2064 2065 newtLabelSetText(flawsLabelC, flaws_str_C); 2065 2066 2066 paranoid_free(flaws_str_A);2067 paranoid_free(flaws_str_B);2068 paranoid_free(flaws_str_C);2067 mr_free(flaws_str_A); 2068 mr_free(flaws_str_B); 2069 mr_free(flaws_str_C); 2069 2070 2070 2071 b_res = newtRunForm(myForm); … … 2196 2197 memcpy((void *) &bkp_raidrec, (void *) raidrec, 2197 2198 sizeof(struct raid_device_record)); 2198 asprintf(&title_of_window, "Additional variables");2199 mr_asprintf(&title_of_window, "Additional variables"); 2199 2200 newtPushHelpLine 2200 2201 (_ … … 2211 2212 bCancel = newtCompactButton(i += 9, 9, _("Cancel")); 2212 2213 newtOpenWindow(17, 7, 46, 10, title_of_window); 2213 paranoid_free(title_of_window);2214 mr_free(title_of_window); 2214 2215 2215 2216 myForm = newtForm(NULL, NULL, 0); … … 2306 2307 #ifdef __FreeBSD__ 2307 2308 for (i = 0; i < raidlist->entries; i++) { 2308 asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname);2309 mr_asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname); 2309 2310 if (!strcmp(device, vdev)) { 2310 paranoid_free(vdev);2311 mr_free(vdev); 2311 2312 break; 2312 2313 } 2313 paranoid_free(vdev);2314 mr_free(vdev); 2314 2315 } 2315 2316 #else … … 2344 2345 // log_it("%d - AAA - isodir_path = %s", isodir_path); 2345 2346 if (isodir_device == NULL) { 2346 asprintf(&isodir_device, "/dev/");2347 mr_asprintf(&isodir_device, "/dev/"); 2347 2348 } 2348 2349 if (isodir_path == NULL) { 2349 asprintf(&isodir_path, "/");2350 mr_asprintf(&isodir_path, "/"); 2350 2351 } 2351 2352 if (does_file_exist("/tmp/NFS-SERVER-PATH")) { 2352 paranoid_free(isodir_device);2353 mr_free(isodir_device); 2353 2354 isodir_device = last_line_of_file("/tmp/NFS-SERVER-MOUNT"); 2354 asprintf(&isodir_format, "nfs");2355 paranoid_free(isodir_path);2355 mr_asprintf(&isodir_format, "nfs"); 2356 mr_free(isodir_path); 2356 2357 isodir_path = last_line_of_file("/tmp/NFS-SERVER-PATH"); 2357 2358 } … … 2415 2416 raidrec = &raidlist->el[pos_in_raidlist]; 2416 2417 initialize_raidrec(raidrec); 2417 asprintf(&raidrec->OSSWAP(raid_device, volname),2418 mr_asprintf(&raidrec->OSSWAP(raid_device, volname), 2418 2419 OSSWAP(device, basename(device))); 2419 2420 #ifndef __FreeBSD__ … … 2573 2574 } 2574 2575 for (i = 0; i < unallocated_raid_partitions->entries; i++) { 2575 asprintf(&tmp, "%-22s %8lld",2576 mr_asprintf(&tmp, "%-22s %8lld", 2576 2577 unallocated_raid_partitions->el[i].device, 2577 2578 unallocated_raid_partitions->el[i].size / 1024); 2578 2579 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2579 paranoid_free(tmp);2580 mr_free(tmp); 2580 2581 } 2581 2582 } … … 2610 2611 } 2611 2612 for (i = 0; i < additional_vars->entries; i++) { 2612 asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label,2613 mr_asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label, 2613 2614 additional_vars->el[i].value); 2614 2615 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2615 paranoid_free(tmp);2616 mr_free(tmp); 2616 2617 } 2617 2618 } … … 2683 2684 pos = which_raid_device_is_using_this_partition(raidlist, old_dev); 2684 2685 if (pos < 0) { 2685 asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.",2686 mr_asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.", 2686 2687 old_dev); 2687 2688 log_it(tmp); 2688 paranoid_free(tmp);2689 mr_free(tmp); 2689 2690 } else { 2690 2691 if ((j = … … 2718 2719 #endif 2719 2720 else { 2720 asprintf(&tmp,2721 mr_asprintf(&tmp, 2721 2722 "%s is supposed to be listed in this raid dev but it's not...", 2722 2723 old_dev); 2723 2724 log_it(tmp); 2724 paranoid_free(tmp);2725 mr_free(tmp); 2725 2726 } 2726 2727 } … … 2833 2834 2834 2835 iamhere("Post-malloc"); 2835 asprintf(&help_text,2836 mr_asprintf(&help_text, 2836 2837 _ 2837 2838 (" Edit this RAID device's list of partitions. Choose OK or Cancel when done.")); 2838 asprintf(&header_text, "%-24s %s", _("Device"), _("Index"));2839 asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device);2839 mr_asprintf(&header_text, "%-24s %s", _("Device"), _("Index")); 2840 mr_asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device); 2840 2841 newtPushHelpLine(help_text); 2841 paranoid_free(help_text);2842 mr_free(help_text); 2842 2843 for (b_res = (newtComponent) 12345; b_res != bOK && b_res != bCancel;) { 2843 2844 headerMsg = newtLabel(1, 1, header_text); … … 2896 2897 redraw_disklist(disklist, keylist, partitionsListbox); 2897 2898 } else { 2898 asprintf(&tmp, _("%s's index is %d. What should it be?"),2899 mr_asprintf(&tmp, _("%s's index is %d. What should it be?"), 2899 2900 raidrec->raid_device, 2900 2901 disklist->el[currline].index); 2901 asprintf(&sz_res, "%d", disklist->el[currline].index);2902 mr_asprintf(&sz_res, "%d", disklist->el[currline].index); 2902 2903 if (popup_and_get_string 2903 2904 (_("Set index"), tmp, sz_res)) { 2904 2905 disklist->el[currline].index = atoi(sz_res); 2905 2906 } 2906 paranoid_free(tmp);2907 paranoid_free(sz_res);2907 mr_free(tmp); 2908 mr_free(sz_res); 2908 2909 redraw_disklist(disklist, keylist, partitionsListbox); 2909 2910 } … … 2913 2914 newtPopWindow(); 2914 2915 } 2915 paranoid_free(title_of_window);2916 paranoid_free(header_text);2916 mr_free(title_of_window); 2917 mr_free(header_text); 2917 2918 2918 2919 newtPopHelpLine(); … … 2925 2926 sizeof(struct list_of_disks)); 2926 2927 } 2927 paranoid_free(bkp_raidrec);2928 paranoid_free(bkp_disklist);2929 paranoid_free(bkp_raidlist);2930 paranoid_free(unallocated_raid_partitions);2928 mr_free(bkp_raidrec); 2929 mr_free(bkp_disklist); 2930 mr_free(bkp_raidlist); 2931 mr_free(unallocated_raid_partitions); 2931 2932 } 2932 2933 #endif … … 2960 2961 (_ 2961 2962 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> ")); 2962 getline(&tmp, &n, stdin);2963 } 2964 paranoid_free(tmp);2963 mr_getline(&tmp, &n, stdin); 2964 } 2965 mr_free(tmp); 2965 2966 return (output); 2966 2967 } -
trunk/mondo/src/mondorestore/mondo-rstr-tools.c
r808 r900 13 13 #include <pthread.h> 14 14 #endif 15 #include "mr_mem.h" 15 16 16 17 extern bool g_sigpipe_caught; … … 52 53 void free_MR_global_filenames() 53 54 { 54 paranoid_free(g_biggielist_txt);55 paranoid_free(g_filelist_full);56 paranoid_free(g_filelist_imagedevs);57 paranoid_free(g_imagedevs_restthese);58 paranoid_free(g_mondo_cfg_file);59 paranoid_free(g_mountlist_fname);60 paranoid_free(g_mondo_home);61 paranoid_free(g_tmpfs_mountpt);62 paranoid_free(g_isodir_device);63 paranoid_free(g_isodir_format);55 mr_free(g_biggielist_txt); 56 mr_free(g_filelist_full); 57 mr_free(g_filelist_imagedevs); 58 mr_free(g_imagedevs_restthese); 59 mr_free(g_mondo_cfg_file); 60 mr_free(g_mountlist_fname); 61 mr_free(g_mondo_home); 62 mr_free(g_tmpfs_mountpt); 63 mr_free(g_isodir_device); 64 mr_free(g_isodir_format); 64 65 65 66 } … … 94 95 fatal_error("Cannot openin outfname"); 95 96 } 96 for ( getline(&incoming, &n, fin);97 !feof(fin); getline(&incoming, &n, fin)) {97 for (mr_getline(&incoming, &n, fin); 98 !feof(fin); mr_getline(&incoming, &n, fin)) { 98 99 strip_spaces(incoming); 99 100 … … 102 103 } 103 104 104 asprintf(&question,105 mr_asprintf(&question, 105 106 _("Should I restore the image of %s ?"), incoming); 106 107 … … 108 109 fprintf(fout, "%s\n", incoming); 109 110 } 110 paranoid_free(question);111 mr_free(question); 111 112 } 112 113 113 114 /*** free memory ***********/ 114 paranoid_free(incoming);115 mr_free(incoming); 115 116 116 117 paranoid_fclose(fout); … … 147 148 assert_string_is_neither_NULL_nor_zerolength(output_cfg_file); 148 149 assert_string_is_neither_NULL_nor_zerolength(output_mountlist_file); 149 asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);150 asprintf(&command, "mkdir -p %s", mountpt);150 mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 151 mr_asprintf(&command, "mkdir -p %s", mountpt); 151 152 run_program_and_log_output(command, FALSE); 152 paranoid_free(command);153 154 asprintf(&command, "gzip -dc %s > %s/mindi.rd 2> /dev/null",153 mr_free(command); 154 155 mr_asprintf(&command, "gzip -dc %s > %s/mindi.rd 2> /dev/null", 155 156 ramdisk_fname, bkpinfo->tmpdir); 156 157 run_program_and_log_output(command, FALSE); 157 paranoid_free(command);158 159 asprintf(&command, "umount %s", mountpt);158 mr_free(command); 159 160 mr_asprintf(&command, "umount %s", mountpt); 160 161 run_program_and_log_output(command, FALSE); 161 paranoid_free(command);162 163 asprintf(&command, "mount -o loop %s/mindi.rd -t ext2 %s",162 mr_free(command); 163 164 mr_asprintf(&command, "mount -o loop %s/mindi.rd -t ext2 %s", 164 165 bkpinfo->tmpdir, mountpt); 165 166 run_program_and_log_output(command, FALSE); 166 paranoid_free(command);167 168 asprintf(&command, "mkdir -p %s/tmp", bkpinfo->tmpdir);167 mr_free(command); 168 169 mr_asprintf(&command, "mkdir -p %s/tmp", bkpinfo->tmpdir); 169 170 run_program_and_log_output(command, FALSE); 170 paranoid_free(command);171 172 asprintf(&command, "cp -f %s/%s %s", // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg171 mr_free(command); 172 173 mr_asprintf(&command, "cp -f %s/%s %s", // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg 173 174 mountpt, g_mondo_cfg_file, output_cfg_file); 174 175 run_program_and_log_output(command, FALSE); 175 paranoid_free(command);176 177 asprintf(&orig_fname, "%s/%s", mountpt, g_mountlist_fname);176 mr_free(command); 177 178 mr_asprintf(&orig_fname, "%s/%s", mountpt, g_mountlist_fname); 178 179 if (does_file_exist(orig_fname)) { 179 asprintf(&command, "cp -f %s %s", orig_fname, output_mountlist_file);180 mr_asprintf(&command, "cp -f %s %s", orig_fname, output_mountlist_file); 180 181 run_program_and_log_output(command, FALSE); 181 paranoid_free(command);182 } 183 asprintf(&command, "umount %s", mountpt);184 paranoid_free(mountpt);182 mr_free(command); 183 } 184 mr_asprintf(&command, "umount %s", mountpt); 185 mr_free(mountpt); 185 186 186 187 run_program_and_log_output(command, FALSE); 187 paranoid_free(command);188 mr_free(command); 188 189 189 190 if (!does_file_exist(output_cfg_file) … … 196 197 retval = 0; 197 198 } 198 paranoid_free(orig_fname);199 mr_free(orig_fname); 199 200 return (retval); 200 201 } … … 240 241 241 242 if (strncmp(preamble, f, strlen(preamble)) == 0) { 242 asprintf(&file, f + strlen(preamble));243 } else { 244 asprintf(&file, f);243 mr_asprintf(&file, f + strlen(preamble)); 244 } else { 245 mr_asprintf(&file, f); 245 246 } 246 247 if (file[0] == '/' && file[1] == '/') { 247 asprintf(&tmp, file);248 paranoid_free(file);249 asprintf(&file, tmp + 1);250 paranoid_free(tmp);251 } 252 asprintf(&tmp,248 mr_asprintf(&tmp, file); 249 mr_free(file); 250 mr_asprintf(&file, tmp + 1); 251 mr_free(tmp); 252 } 253 mr_asprintf(&tmp, 253 254 "Checking to see if f=%s, file=%s, is in the list of biggiefiles", 254 255 f, file); 255 256 log_msg(2, tmp); 256 paranoid_free(tmp);257 258 asprintf(&command, "grep -x \"%s\" %s", file, list_fname);259 paranoid_free(file);257 mr_free(tmp); 258 259 mr_asprintf(&command, "grep -x \"%s\" %s", file, list_fname); 260 mr_free(file); 260 261 261 262 res = run_program_and_log_output(command, FALSE); 262 paranoid_free(command);263 mr_free(command); 263 264 if (res) { 264 265 return (FALSE); … … 292 293 g_ISO_restore_mode = TRUE; 293 294 294 paranoid_free(g_isodir_device);295 mr_free(g_isodir_device); 295 296 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 296 297 if (bkpinfo->disaster_recovery) { … … 298 299 * Don't let this clobber an existing bkpinfo->isodir */ 299 300 if (!bkpinfo->isodir) { 300 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");301 mr_allocstr(bkpinfo->isodir, "/tmp/isodir"); 301 302 } 302 303 /* End patch */ 303 asprintf(&command, "mkdir -p %s", bkpinfo->isodir);304 mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir); 304 305 run_program_and_log_output(command, 5); 305 paranoid_free(command);306 mr_free(command); 306 307 log_msg(2, "Setting isodir to %s", bkpinfo->isodir); 307 308 } … … 319 320 } else { 320 321 if (g_isodir_format != NULL) { 321 asprintf(&mount_isodir_command, "mount %s -t %s -o ro %s", g_isodir_device, g_isodir_format, bkpinfo->isodir);322 mr_asprintf(&mount_isodir_command, "mount %s -t %s -o ro %s", g_isodir_device, g_isodir_format, bkpinfo->isodir); 322 323 } else { 323 asprintf(&mount_isodir_command, "mount %s -o ro %s", g_isodir_device, bkpinfo->isodir);324 mr_asprintf(&mount_isodir_command, "mount %s -o ro %s", g_isodir_device, bkpinfo->isodir); 324 325 } 325 326 run_program_and_log_output("df -m", FALSE); 326 asprintf(&tmp,327 mr_asprintf(&tmp, 327 328 "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?", 328 329 mount_isodir_command); 329 330 log_msg(1, tmp); 330 paranoid_free(tmp);331 mr_free(tmp); 331 332 332 333 if (run_program_and_log_output(mount_isodir_command, FALSE)) { … … 334 335 (_ 335 336 ("Cannot mount the device where the ISO files are stored.")); 336 paranoid_free(mount_isodir_command);337 mr_free(mount_isodir_command); 337 338 return (1); 338 339 } 339 paranoid_free(mount_isodir_command);340 mr_free(mount_isodir_command); 340 341 log_to_screen 341 342 (_ … … 346 347 } 347 348 i = what_number_cd_is_this(bkpinfo); /* has the side-effect of calling mount_cdrom() */ 348 asprintf(&tmp, "%s #%d has been mounted via loopback mount",349 mr_asprintf(&tmp, "%s #%d has been mounted via loopback mount", 349 350 bkpinfo->backup_media_string, i); 350 351 log_msg(1, tmp); 351 paranoid_free(tmp);352 mr_free(tmp); 352 353 353 354 if (i < 0) { … … 368 369 { 369 370 char *command; 370 asprintf(&command,371 mr_asprintf(&command, 371 372 "kill `ps 2> /dev/null | grep petris 2> /dev/null | grep -v grep | cut -d' ' -f2` 2> /dev/null"); 372 373 paranoid_system(command); 373 paranoid_free(command);374 mr_free(command); 374 375 } 375 376 … … 413 414 "Again with the /proc - why is this in your mountlist?"); 414 415 } else if (is_this_device_mounted(mountlist->el[lino].device)) { 415 asprintf(&tmp, _("%s is already mounted"),416 mr_asprintf(&tmp, _("%s is already mounted"), 416 417 mountlist->el[lino].device); 417 418 log_to_screen(tmp); 418 paranoid_free(tmp);419 mr_free(tmp); 419 420 } else if (strcmp(mountlist->el[lino].mountpoint, "none") 420 421 && strcmp(mountlist->el[lino].mountpoint, "lvm") 421 422 && strcmp(mountlist->el[lino].mountpoint, "raid") 422 423 && strcmp(mountlist->el[lino].mountpoint, "image")) { 423 asprintf(&tmp, "Mounting %s", mountlist->el[lino].device);424 mr_asprintf(&tmp, "Mounting %s", mountlist->el[lino].device); 424 425 update_progress_form(tmp); 425 paranoid_free(tmp);426 427 asprintf(&format, mountlist->el[lino].format);426 mr_free(tmp); 427 428 mr_asprintf(&format, mountlist->el[lino].format); 428 429 if (!strcmp(format, "ext3")) { 429 paranoid_free(format);430 asprintf(&format, "ext2");430 mr_free(format); 431 mr_asprintf(&format, "ext2"); 431 432 } 432 433 res = mount_device(mountlist->el[lino].device, … … 436 437 if (res) { 437 438 if (these_failed != NULL) { /* not the first time */ 438 asprintf(&tmp, "%s %s", these_failed, mountlist->el[lino].device);439 paranoid_free(these_failed);439 mr_asprintf(&tmp, "%s %s", these_failed, mountlist->el[lino].device); 440 mr_free(these_failed); 440 441 these_failed = tmp; 441 442 } else { /* The first time */ 442 asprintf(&these_failed, "%s ", mountlist->el[lino].device);443 mr_asprintf(&these_failed, "%s ", mountlist->el[lino].device); 443 444 } 444 445 } 445 paranoid_free(format);446 mr_free(format); 446 447 } 447 448 g_current_progress++; … … 459 460 ("format and restore *without* partitioning first. Sorry for the inconvenience.")); 460 461 } 461 asprintf(&tmp, _("Could not mount devices %s- shall I abort?"),462 mr_asprintf(&tmp, _("Could not mount devices %s- shall I abort?"), 462 463 these_failed); 463 paranoid_free(these_failed);464 mr_free(these_failed); 464 465 465 466 if (!ask_me_yes_or_no(tmp)) { … … 474 475 (_("Unable to mount some or all of your partitions.")); 475 476 } 476 paranoid_free(tmp);477 mr_free(tmp); 477 478 } else { 478 479 log_to_screen(_("All partitions were mounted OK.")); … … 480 481 } 481 482 run_program_and_log_output("df -m", 3); 482 paranoid_free(mountlist);483 mr_free(mountlist); 483 484 return (retval); 484 485 } … … 523 524 if ((!bkpinfo->isodir || !strcmp(bkpinfo->isodir, "/")) 524 525 && am_I_in_disaster_recovery_mode()) { 525 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");526 mr_allocstr(bkpinfo->isodir, "/tmp/isodir"); 526 527 log_msg(1, "isodir is being set to %s", bkpinfo->isodir); 527 528 } 528 529 #ifdef __FreeBSD__ 529 asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,530 mr_asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, 530 531 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 531 532 g_current_media_number); 532 533 mddev = make_vn(mount_cmd); 533 paranoid_free(mount_cmd);534 535 asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);536 paranoid_free(mddev);534 mr_free(mount_cmd); 535 536 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev); 537 mr_free(mddev); 537 538 #else 538 asprintf(&mount_cmd,539 mr_asprintf(&mount_cmd, 539 540 "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", 540 541 bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, … … 544 545 } else if (bkpinfo->backup_media_type == iso) { 545 546 #ifdef __FreeBSD__ 546 asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir,547 mr_asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, 547 548 bkpinfo->prefix, g_current_media_number); 548 549 mddev = make_vn(mount_cmd); 549 paranoid_free(mount_cmd);550 551 asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);552 paranoid_free(mddev);550 mr_free(mount_cmd); 551 552 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM); 553 mr_free(mddev); 553 554 #else 554 asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",555 mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", 555 556 bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, 556 557 MNT_CDROM); … … 559 560 #ifdef __FreeBSD__ 560 561 { 561 asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,562 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, 562 563 MNT_CDROM); 563 564 } 564 565 #else 565 566 { 566 asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",567 mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", 567 568 bkpinfo->media_device, MNT_CDROM); 568 569 } … … 572 573 if (bkpinfo->disaster_recovery 573 574 && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 574 paranoid_free(bkpinfo->media_device);575 mr_free(bkpinfo->media_device); 575 576 bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE"); 576 577 } else { 577 paranoid_free(bkpinfo->media_device);578 mr_free(bkpinfo->media_device); 578 579 bkpinfo->media_device = find_cdrom_device(TRUE); 579 580 } 580 581 581 582 #ifdef __FreeBSD__ 582 asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,583 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, 583 584 MNT_CDROM); 584 585 #else 585 asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",586 mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", 586 587 bkpinfo->media_device, MNT_CDROM); 587 588 #endif … … 599 600 } 600 601 } 601 paranoid_free(mount_cmd);602 mr_free(mount_cmd); 602 603 603 604 if (res) { … … 639 640 640 641 if (!strcmp(mpt, "/1")) { 641 asprintf(&mountpoint, "/");642 mr_asprintf(&mountpoint, "/"); 642 643 log_msg(3, "Mommm! SME is being a dildo!"); 643 644 } else { 644 asprintf(&mountpoint, mpt);645 mr_asprintf(&mountpoint, mpt); 645 646 } 646 647 647 648 if (!strcmp(mountpoint, "lvm")) { 648 paranoid_free(mountpoint);649 mr_free(mountpoint); 649 650 return (0); 650 651 } 651 652 if (!strcmp(mountpoint, "image")) { 652 paranoid_free(mountpoint);653 mr_free(mountpoint); 653 654 return (0); 654 655 } 655 asprintf(&tmp, "Mounting device %s ", device);656 mr_asprintf(&tmp, "Mounting device %s ", device); 656 657 log_msg(1, tmp); 657 658 658 659 if (writeable) { 659 asprintf(&p1, "-o rw");660 } else { 661 asprintf(&p1, "-o ro");660 mr_asprintf(&p1, "-o rw"); 661 } else { 662 mr_asprintf(&p1, "-o ro"); 662 663 } 663 664 tmp = find_home_of_exe("setfattr"); 664 665 if (tmp) { 665 asprintf(&p2, ",user_xattr");666 } else { 667 asprintf(&p2, "%s", "");668 } 669 paranoid_free(tmp);666 mr_asprintf(&p2, ",user_xattr"); 667 } else { 668 mr_asprintf(&p2, "%s", ""); 669 } 670 mr_free(tmp); 670 671 671 672 tmp = find_home_of_exe("setfacl"); 672 673 if (tmp) { 673 asprintf(&p3, ",acl");674 } else { 675 asprintf(&p3, "%s", "");676 } 677 paranoid_free(tmp);678 679 asprintf(&additional_parameters, "%s%s%s", p1, p2, p3);680 paranoid_free(p1);681 paranoid_free(p2);682 paranoid_free(p3);674 mr_asprintf(&p3, ",acl"); 675 } else { 676 mr_asprintf(&p3, "%s", ""); 677 } 678 mr_free(tmp); 679 680 mr_asprintf(&additional_parameters, "%s%s%s", p1, p2, p3); 681 mr_free(p1); 682 mr_free(p2); 683 mr_free(p3); 683 684 684 685 if (!strcmp(mountpoint, "swap")) { 685 asprintf(&command, "swapon %s", device);686 mr_asprintf(&command, "swapon %s", device); 686 687 } else { 687 688 if (!strcmp(mountpoint, "/")) { 688 asprintf(&mountdir, MNT_RESTORING);689 mr_asprintf(&mountdir, MNT_RESTORING); 689 690 } else { 690 asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint);691 } 692 asprintf(&command, "mkdir -p %s", mountdir);691 mr_asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint); 692 } 693 mr_asprintf(&command, "mkdir -p %s", mountdir); 693 694 run_program_and_log_output(command, FALSE); 694 paranoid_free(command);695 696 asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device,695 mr_free(command); 696 697 mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, 697 698 additional_parameters, mountdir, MONDO_LOGFILE); 698 699 log_msg(2, "command='%s'", command); 699 700 } 700 paranoid_free(additional_parameters);701 mr_free(additional_parameters); 701 702 702 703 res = run_program_and_log_output(command, TRUE); 703 704 if (res && (strstr(command, "xattr") || strstr(command, "acl"))) { 704 705 log_msg(1, "Re-trying without the fancy extra parameters"); 705 paranoid_free(command);706 707 asprintf(&command, "mount -t %s %s %s 2>> %s", format, device,706 mr_free(command); 707 708 mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, 708 709 mountdir, MONDO_LOGFILE); 709 710 res = run_program_and_log_output(command, TRUE); … … 717 718 } else { 718 719 log_msg(2, "Retrying w/o the '-t' switch"); 719 paranoid_free(command);720 721 asprintf(&command, "mount %s %s 2>> %s", device, mountdir,720 mr_free(command); 721 722 mr_asprintf(&command, "mount %s %s 2>> %s", device, mountdir, 722 723 MONDO_LOGFILE); 723 724 log_msg(2, "2nd command = '%s'", command); … … 731 732 } 732 733 } 733 paranoid_free(tmp);734 paranoid_free(command);735 paranoid_free(mountdir);734 mr_free(tmp); 735 mr_free(command); 736 mr_free(mountdir); 736 737 737 738 if (res && !strcmp(mountpoint, "swap")) { … … 740 741 res = 0; 741 742 } 742 paranoid_free(mountpoint);743 mr_free(mountpoint); 743 744 744 745 return (res); … … 836 837 } 837 838 } 838 paranoid_free(value);839 mr_free(value); 839 840 840 841 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 841 paranoid_alloc(bkpinfo->prefix,value);842 mr_allocstr(bkpinfo->prefix,value); 842 843 } else { 843 paranoid_alloc(bkpinfo->prefix, STD_PREFIX);844 mr_allocstr(bkpinfo->prefix, STD_PREFIX); 844 845 } 845 846 } else if (!strcmp(value, "nfs")) { 846 847 bkpinfo->backup_media_type = nfs; 847 paranoid_free(value);848 mr_free(value); 848 849 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 849 paranoid_alloc(bkpinfo->prefix,value);850 mr_allocstr(bkpinfo->prefix,value); 850 851 } else { 851 paranoid_alloc(bkpinfo->prefix, STD_PREFIX);852 mr_allocstr(bkpinfo->prefix, STD_PREFIX); 852 853 } 853 854 /* We need to override prefix value in PXE mode as it's … … 868 869 fatal_error("backup-media-type not specified!"); 869 870 } 870 paranoid_free(value);871 mr_free(value); 871 872 872 873 if (bkpinfo->disaster_recovery) { 873 874 if (bkpinfo->backup_media_type == cdstream) { 874 paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");875 mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); 875 876 bkpinfo->media_size[0] = 1999 * 1024; 876 877 bkpinfo->media_size[1] = 650; /* good guess */ 877 878 } else if (bkpinfo->backup_media_type == tape 878 879 || bkpinfo->backup_media_type == udev) { 879 paranoid_free(bkpinfo->media_device);880 mr_free(bkpinfo->media_device); 880 881 if (read_cfg_var(cfg_file, "media-dev", bkpinfo->media_device)) { 881 882 fatal_error("Cannot get tape device name from cfg file"); … … 883 884 read_cfg_var(cfg_file, "media-size", value); 884 885 bkpinfo->media_size[1] = atol(value); 885 paranoid_free(value);886 887 asprintf(&tmp, "Backup medium is TAPE --- dev=%s",886 mr_free(value); 887 888 mr_asprintf(&tmp, "Backup medium is TAPE --- dev=%s", 888 889 bkpinfo->media_device); 889 890 log_msg(2, tmp); 890 paranoid_free(tmp);891 mr_free(tmp); 891 892 } else { 892 paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");893 mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); 893 894 bkpinfo->media_size[0] = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ 894 895 bkpinfo->media_size[1] = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ … … 905 906 log_msg(1, "Goody! ... bkpinfo->use_star is now true."); 906 907 } 907 paranoid_free(value);908 mr_free(value); 908 909 909 910 if (0 == read_cfg_var(cfg_file, "internal-tape-block-size", value)) { … … 917 918 DEFAULT_INTERNAL_TAPE_BLOCK_SIZE); 918 919 } 919 paranoid_free(value);920 mr_free(value); 920 921 921 922 read_cfg_var(cfg_file, "use-lzo", value); 922 923 if (strstr(value, "yes")) { 923 924 bkpinfo->use_lzo = TRUE; 924 paranoid_alloc(bkpinfo->zip_exe, "lzop");925 paranoid_alloc(bkpinfo->zip_suffix, "lzo");926 } else { 927 paranoid_free(value);925 mr_allocstr(bkpinfo->zip_exe, "lzop"); 926 mr_allocstr(bkpinfo->zip_suffix, "lzo"); 927 } else { 928 mr_free(value); 928 929 read_cfg_var(cfg_file, "use-comp", value); 929 930 if (strstr(value, "yes")) { 930 931 bkpinfo->use_lzo = FALSE; 931 paranoid_alloc(bkpinfo->zip_exe, "bzip2");932 paranoid_alloc(bkpinfo->zip_suffix, "bz2");932 mr_allocstr(bkpinfo->zip_exe, "bzip2"); 933 mr_allocstr(bkpinfo->zip_suffix, "bz2"); 933 934 } else { 934 935 // Just to be sure … … 937 938 } 938 939 } 939 paranoid_free(value);940 mr_free(value); 940 941 941 942 read_cfg_var(cfg_file, "differential", value); … … 944 945 } 945 946 log_msg(2, "differential var = '%s'", value); 946 paranoid_free(value);947 mr_free(value); 947 948 948 949 if (bkpinfo->differential) { … … 962 963 log_msg(2, "Ok, I shan't eject when restoring! Groovy."); 963 964 } 964 paranoid_free(tmp);965 paranoid_free(tmp1);965 mr_free(tmp); 966 mr_free(tmp1); 966 967 967 968 if (bkpinfo->backup_media_type == nfs) { … … 973 974 "...cos it wouldn't make sense to abandon the values that GOT ME to this config file in the first place"); 974 975 } else { 975 paranoid_free(bkpinfo->nfs_mount);976 paranoid_free(bkpinfo->nfs_remote_dir);976 mr_free(bkpinfo->nfs_mount); 977 mr_free(bkpinfo->nfs_remote_dir); 977 978 read_cfg_var(g_mondo_cfg_file, "nfs-server-mount", 978 979 bkpinfo->nfs_mount); … … 994 995 * isodir in disaster recovery mode 995 996 */ 996 paranoid_alloc(old_isodir,bkpinfo->isodir);997 mr_allocstr(old_isodir,bkpinfo->isodir); 997 998 read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt); 998 999 read_cfg_var(g_mondo_cfg_file, "isodir", iso_path); 999 1000 if (iso_mnt && iso_path) { 1000 paranoid_free(bkpinfo->isodir);1001 asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path);1002 } 1003 paranoid_free(iso_mnt);1004 paranoid_free(iso_path);1001 mr_free(bkpinfo->isodir); 1002 mr_asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 1003 } 1004 mr_free(iso_mnt); 1005 mr_free(iso_path); 1005 1006 1006 1007 if (!bkpinfo->disaster_recovery) { … … 1011 1012 } 1012 1013 } 1013 paranoid_free(old_isodir);1014 1015 paranoid_free(g_isodir_device);1014 mr_free(old_isodir); 1015 1016 mr_free(g_isodir_device); 1016 1017 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 1017 1018 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device); … … 1020 1021 log_msg(2, "NB: isodir is already mounted"); 1021 1022 /* Find out where it's mounted */ 1022 asprintf(&command,1023 mr_asprintf(&command, 1023 1024 "mount | grep -w %s | tail -n1 | cut -d' ' -f3", 1024 1025 g_isodir_device); … … 1027 1028 log_it("res of it = %s", tmp); 1028 1029 iso_mnt = tmp; 1029 paranoid_free(command);1030 mr_free(command); 1030 1031 } else { 1031 asprintf(&iso_mnt, "/tmp/isodir");1032 asprintf(&tmp, "mkdir -p %s", iso_mnt);1032 mr_asprintf(&iso_mnt, "/tmp/isodir"); 1033 mr_asprintf(&tmp, "mkdir -p %s", iso_mnt); 1033 1034 run_program_and_log_output(tmp, 5); 1034 paranoid_free(tmp);1035 1036 asprintf(&tmp, "mount %s %s", g_isodir_device, iso_mnt);1035 mr_free(tmp); 1036 1037 mr_asprintf(&tmp, "mount %s %s", g_isodir_device, iso_mnt); 1037 1038 if (run_program_and_log_output(tmp, 3)) { 1038 1039 log_msg(1, 1039 1040 "Unable to mount isodir. Perhaps this is really a CD backup?"); 1040 1041 bkpinfo->backup_media_type = cdr; 1041 paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");1042 paranoid_free(bkpinfo->isodir);1043 paranoid_free(iso_mnt);1044 paranoid_free(iso_path);1045 asprintf(&iso_mnt, "%s", "");1046 asprintf(&iso_path, "%s", "");1042 mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); 1043 mr_free(bkpinfo->isodir); 1044 mr_free(iso_mnt); 1045 mr_free(iso_path); 1046 mr_asprintf(&iso_mnt, "%s", ""); 1047 mr_asprintf(&iso_path, "%s", ""); 1047 1048 1048 1049 if (mount_cdrom(bkpinfo)) { … … 1054 1055 } 1055 1056 } 1056 paranoid_free(tmp);1057 mr_free(tmp); 1057 1058 } 1058 1059 /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */ 1059 1060 if (bkpinfo->backup_media_type == iso) { 1060 paranoid_free(bkpinfo->isodir);1061 asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path);1062 } 1063 paranoid_free(iso_mnt);1064 paranoid_free(iso_path);1061 mr_free(bkpinfo->isodir); 1062 mr_asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 1063 } 1064 mr_free(iso_mnt); 1065 mr_free(iso_path); 1065 1066 } 1066 1067 } … … 1131 1132 unlink("/tmp/i-want-my-lvm"); 1132 1133 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1133 asprintf(&command,1134 mr_asprintf(&command, 1134 1135 "tar -zxf %s %s %s %s %s %s", 1135 1136 bkpinfo->media_device, … … 1140 1141 log_msg(1, "tarcommand = %s", command); 1141 1142 run_program_and_log_output(command, 1); 1142 paranoid_free(command);1143 mr_free(command); 1143 1144 } else { 1144 1145 log_msg(2, … … 1148 1149 log_msg(2, "Back from iotcn"); 1149 1150 run_program_and_log_output("mount", 1); 1150 asprintf(&command,1151 mr_asprintf(&command, 1151 1152 "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", 1152 1153 MNT_CDROM, … … 1158 1159 log_msg(1, "tarcommand = %s", command); 1159 1160 run_program_and_log_output(command, 1); 1160 paranoid_free(command);1161 mr_free(command); 1161 1162 1162 1163 if (!does_file_exist(BIGGIELIST_TXT_STUB)) { … … 1169 1170 } 1170 1171 } 1171 asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB,1172 mr_asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB, 1172 1173 g_mondo_cfg_file); 1173 1174 run_program_and_log_output(command, FALSE); 1174 paranoid_free(command);1175 1176 asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir,1175 mr_free(command); 1176 1177 mr_asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir, 1177 1178 BIGGIELIST_TXT_STUB, g_biggielist_txt); 1178 1179 log_msg(1, "command = %s", command); 1179 1180 paranoid_system(command); 1180 paranoid_free(command);1181 1182 asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir,1181 mr_free(command); 1182 1183 mr_asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir, 1183 1184 FILELIST_FULL_STUB, g_filelist_full); 1184 1185 log_msg(1, "command = %s", command); 1185 1186 paranoid_system(command); 1186 paranoid_free(command);1187 mr_free(command); 1187 1188 } 1188 1189 … … 1192 1193 ("Do you want to retrieve the mountlist as well?"))) 1193 1194 { 1194 asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,1195 mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, 1195 1196 bkpinfo->tmpdir); 1196 1197 paranoid_system(command); 1197 paranoid_free(command);1198 mr_free(command); 1198 1199 } 1199 1200 1200 1201 chdir(tmp); 1201 paranoid_free(tmp);1202 mr_free(tmp); 1202 1203 1203 1204 if (!does_file_exist(g_biggielist_txt)) { … … 1219 1220 log_to_screen(("Pre-processing filelist")); 1220 1221 if (!does_file_exist(g_biggielist_txt)) { 1221 asprintf(&command, "> %s", g_biggielist_txt);1222 mr_asprintf(&command, "> %s", g_biggielist_txt); 1222 1223 paranoid_system(command); 1223 paranoid_free(command);1224 } 1225 asprintf(&command, "grep -x \"/dev/.*\" %s > %s",1224 mr_free(command); 1225 } 1226 mr_asprintf(&command, "grep -x \"/dev/.*\" %s > %s", 1226 1227 g_biggielist_txt, g_filelist_imagedevs); 1227 1228 paranoid_system(command); 1228 paranoid_free(command);1229 mr_free(command); 1229 1230 exit(0); 1230 1231 break; … … 1245 1246 if (g_text_mode) { 1246 1247 printf(_("Restore which directory? --> ")); 1247 getline(&tmp, &n, stdin);1248 mr_getline(&tmp, &n, stdin); 1248 1249 toggle_path_selection(filelist, tmp, TRUE); 1249 1250 if (strlen(tmp) == 0) { … … 1252 1253 res = 0; 1253 1254 } 1254 paranoid_free(tmp);1255 mr_free(tmp); 1255 1256 } else { 1256 1257 res = edit_filelist(filelist); … … 1296 1297 assert_string_is_neither_NULL_nor_zerolength(filename); 1297 1298 1298 asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename);1299 mr_asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename); 1299 1300 res = run_program_and_log_output(command, 5); 1300 paranoid_free(command);1301 mr_free(command); 1301 1302 return (res); 1302 1303 } … … 1324 1325 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device); 1325 1326 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name); 1326 asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name);1327 mr_asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name); 1327 1328 log_msg(2, tmp); 1328 paranoid_free(tmp);1329 mr_free(tmp); 1329 1330 1330 1331 sync(); … … 1349 1350 #ifdef __FreeBSD__ 1350 1351 else if (!strcmp(name, "BOOT0")) { 1351 asprintf(&tmp, "boot0cfg -B %s", device);1352 mr_asprintf(&tmp, "boot0cfg -B %s", device); 1352 1353 res = run_program_and_log_output(tmp, FALSE); 1353 paranoid_free(tmp);1354 } else { 1355 asprintf(&tmp, "ls /dev | grep -xq %ss[1-4].*", device);1354 mr_free(tmp); 1355 } else { 1356 mr_asprintf(&tmp, "ls /dev | grep -xq %ss[1-4].*", device); 1356 1357 if (!system(tmp)) { 1357 paranoid_free(tmp);1358 asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);1358 mr_free(tmp); 1359 mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device); 1359 1360 res = run_program_and_log_output(tmp, 3); 1360 1361 } else { … … 1362 1363 "I'm not running any boot loader. You have a DD boot drive. It's already loaded up."); 1363 1364 } 1364 paranoid_free(tmp);1365 mr_free(tmp); 1365 1366 } 1366 1367 #else … … 1372 1373 } 1373 1374 #endif 1374 paranoid_free(device);1375 paranoid_free(name);1375 mr_free(device); 1376 mr_free(name); 1376 1377 1377 1378 retval += res; … … 1401 1402 tmp = find_home_of_exe("pico"); 1402 1403 if (tmp) { 1403 asprintf(&output, "pico");1404 mr_asprintf(&output, "pico"); 1404 1405 } else { 1405 1406 tmp = find_home_of_exe("nano"); 1406 1407 if (tmp) { 1407 asprintf(&output, "nano");1408 mr_asprintf(&output, "nano"); 1408 1409 } else { 1409 1410 tmp = find_home_of_exe("vi"); 1410 1411 if (tmp) { 1411 asprintf(&output, "vi");1412 mr_asprintf(&output, "vi"); 1412 1413 } else { 1413 asprintf(&output, "emacs");1414 } 1415 } 1416 } 1417 paranoid_free(tmp);1414 mr_asprintf(&output, "emacs"); 1415 } 1416 } 1417 } 1418 mr_free(tmp); 1418 1419 1419 1420 tmp = find_home_of_exe(output); … … 1421 1422 log_msg(2, " (find_my_editor) --- warning - %s not found", output); 1422 1423 } 1423 paranoid_free(tmp);1424 mr_free(tmp); 1424 1425 return (output); 1425 1426 } … … 1454 1455 popup_and_get_string(_("Boot device"), 1455 1456 _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd); 1456 asprintf(&command, "stabgrub-me %s", bd);1457 mr_asprintf(&command, "stabgrub-me %s", bd); 1457 1458 res = run_program_and_log_output(command, 1); 1458 paranoid_free(command);1459 mr_free(command); 1459 1460 1460 1461 if (res) { … … 1474 1475 } 1475 1476 editor = find_my_editor(); 1476 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1477 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1477 1478 paranoid_system(tmp); 1478 paranoid_free(tmp);1479 1480 asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor);1481 paranoid_free(editor);1479 mr_free(tmp); 1480 1481 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor); 1482 mr_free(editor); 1482 1483 1483 1484 paranoid_system(tmp); 1484 paranoid_free(tmp);1485 mr_free(tmp); 1485 1486 1486 1487 if (!g_text_mode) { … … 1492 1493 if (!run_program_and_log_output("which grub-MR", FALSE)) { 1493 1494 log_msg(1, "Yay! grub-MR found..."); 1494 asprintf(&command, "grub-MR %s /tmp/mountlist.txt", bd);1495 mr_asprintf(&command, "grub-MR %s /tmp/mountlist.txt", bd); 1495 1496 log_msg(1, "command = %s", command); 1496 1497 } else { 1497 asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", bd);1498 mr_asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", bd); 1498 1499 log_msg(1, "WARNING - grub-MR not found; using grub-install"); 1499 1500 } … … 1504 1505 iamhere(command); 1505 1506 res = run_program_and_log_output(command, 1); 1506 paranoid_free(command);1507 mr_free(command); 1507 1508 1508 1509 if (res) { … … 1563 1564 _ 1564 1565 ("Modifying fstab and elilo.conf... ")); 1565 asprintf(&command, "stabelilo-me");1566 mr_asprintf(&command, "stabelilo-me"); 1566 1567 res = run_program_and_log_output(command, 3); 1567 paranoid_free(command);1568 mr_free(command); 1568 1569 1569 1570 if (res) { … … 1576 1577 } 1577 1578 editor = find_my_editor(); 1578 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1579 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1579 1580 paranoid_system(tmp); 1580 paranoid_free(tmp);1581 1582 asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor);1583 paranoid_free(editor);1581 mr_free(tmp); 1582 1583 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor); 1584 mr_free(editor); 1584 1585 1585 1586 paranoid_system(tmp); 1586 paranoid_free(tmp);1587 mr_free(tmp); 1587 1588 1588 1589 if (!g_text_mode) { … … 1638 1639 _ 1639 1640 ("Modifying fstab and lilo.conf, and running LILO... ")); 1640 asprintf(&command, "stablilo-me");1641 mr_asprintf(&command, "stablilo-me"); 1641 1642 res = run_program_and_log_output(command, 3); 1642 paranoid_free(command);1643 mr_free(command); 1643 1644 1644 1645 if (res) { … … 1651 1652 } 1652 1653 editor = find_my_editor(); 1653 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1654 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1654 1655 paranoid_system(tmp); 1655 paranoid_free(tmp);1656 1657 asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);1658 paranoid_free(editor);1656 mr_free(tmp); 1657 1658 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1659 mr_free(editor); 1659 1660 1660 1661 paranoid_system(tmp); 1661 paranoid_free(tmp);1662 mr_free(tmp); 1662 1663 1663 1664 if (!g_text_mode) { … … 1753 1754 } 1754 1755 editor = find_my_editor(); 1755 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1756 paranoid_free(editor);1756 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1757 mr_free(editor); 1757 1758 1758 1759 paranoid_system(tmp); 1759 paranoid_free(tmp);1760 mr_free(tmp); 1760 1761 1761 1762 if (!g_text_mode) { … … 1767 1768 _ 1768 1769 ("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd); 1769 asprintf(&command, "stabraw-me %s", bd);1770 mr_asprintf(&command, "stabraw-me %s", bd); 1770 1771 res = run_program_and_log_output(command, 3); 1771 paranoid_free(command);1772 mr_free(command); 1772 1773 1773 1774 if (res) { … … 1783 1784 _ 1784 1785 ("Restoring MBR... ")); 1785 asprintf(&command, "raw-MR %s /tmp/mountlist.txt", bd);1786 mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", bd); 1786 1787 log_msg(2, "run_raw_mbr() --- command='%s'", command); 1787 1788 res = run_program_and_log_output(command, 3); 1788 paranoid_free(command);1789 mr_free(command); 1789 1790 } 1790 1791 if (res) { … … 1839 1840 assert(bkpinfo != NULL); 1840 1841 1841 asprintf(&g_biggielist_txt, "%s/%s",bkpinfo->tmpdir , BIGGIELIST_TXT_STUB);1842 asprintf(&g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB);1843 asprintf(&g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir);1844 asprintf(&g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these",1842 mr_asprintf(&g_biggielist_txt, "%s/%s",bkpinfo->tmpdir , BIGGIELIST_TXT_STUB); 1843 mr_asprintf(&g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB); 1844 mr_asprintf(&g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir); 1845 mr_asprintf(&g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", 1845 1846 bkpinfo->tmpdir); 1846 paranoid_free(g_mondo_cfg_file);1847 paranoid_free(g_mountlist_fname);1847 mr_free(g_mondo_cfg_file); 1848 mr_free(g_mountlist_fname); 1848 1849 if (bkpinfo->disaster_recovery) { 1849 asprintf(&g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB);1850 asprintf(&g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB);1851 } else { 1852 asprintf(&g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);1853 asprintf(&g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);1850 mr_asprintf(&g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB); 1851 mr_asprintf(&g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB); 1852 } else { 1853 mr_asprintf(&g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 1854 mr_asprintf(&g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 1854 1855 } 1855 1856 } … … 1882 1883 fatal_error("cannot open output_file"); 1883 1884 } 1884 for ( getline(&incoming, &n, fin); !feof(fin);1885 getline(&incoming, &n, fin)) {1885 for (mr_getline(&incoming, &n, fin); !feof(fin); 1886 mr_getline(&incoming, &n, fin)) { 1886 1887 if (strncmp(incoming, "etc/adjtime", 11) 1887 1888 && strncmp(incoming, "etc/mtab", 8) … … 1893 1894 fprintf(fout, "%s", incoming); /* don't need \n here, for some reason.. */ 1894 1895 } 1895 paranoid_free(incoming);1896 mr_free(incoming); 1896 1897 paranoid_fclose(fout); 1897 1898 paranoid_fclose(fin); … … 1936 1937 for (i = 0; i < 20; i++) { 1937 1938 g_current_progress = i; 1938 asprintf(&tmp, _("You have %d seconds left to abort."), 20 - i);1939 mr_asprintf(&tmp, _("You have %d seconds left to abort."), 20 - i); 1939 1940 update_progress_form(tmp); 1940 paranoid_free(tmp);1941 mr_free(tmp); 1941 1942 sleep(1); 1942 1943 } … … 2025 2026 continue; 2026 2027 } 2027 asprintf(&tmp, _("Unmounting device %s "),2028 mr_asprintf(&tmp, _("Unmounting device %s "), 2028 2029 mountlist->el[lino].device); 2029 2030 … … 2032 2033 if (is_this_device_mounted(mountlist->el[lino].device)) { 2033 2034 if (!strcmp(mountlist->el[lino].mountpoint, "swap")) { 2034 asprintf(&command, "swapoff %s", mountlist->el[lino].device);2035 mr_asprintf(&command, "swapoff %s", mountlist->el[lino].device); 2035 2036 } else { 2036 2037 if (!strcmp(mountlist->el[lino].mountpoint, "/1")) { 2037 asprintf(&command, "umount %s/", MNT_RESTORING);2038 mr_asprintf(&command, "umount %s/", MNT_RESTORING); 2038 2039 log_msg(3, 2039 2040 "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight..."); 2040 2041 } else { 2041 asprintf(&command, "umount " MNT_RESTORING "%s",2042 mr_asprintf(&command, "umount " MNT_RESTORING "%s", 2042 2043 mountlist->el[lino].mountpoint); 2043 2044 } … … 2045 2046 log_msg(10, "The 'umount' command is '%s'", command); 2046 2047 res = run_program_and_log_output(command, 3); 2047 paranoid_free(command);2048 mr_free(command); 2048 2049 } else { 2049 asprintf(&tmp1, "%s%s", tmp, _("...not mounted anyway :-) OK"));2050 paranoid_free(tmp);2050 mr_asprintf(&tmp1, "%s%s", tmp, _("...not mounted anyway :-) OK")); 2051 mr_free(tmp); 2051 2052 tmp = tmp1; 2052 2053 res = 0; … … 2054 2055 g_current_progress++; 2055 2056 if (res) { 2056 asprintf(&tmp1, "%s%s", tmp, _("...Failed"));2057 paranoid_free(tmp);2057 mr_asprintf(&tmp1, "%s%s", tmp, _("...Failed")); 2058 mr_free(tmp); 2058 2059 tmp = tmp1; 2059 2060 retval++; … … 2062 2063 log_msg(2, tmp); 2063 2064 } 2064 paranoid_free(tmp);2065 mr_free(tmp); 2065 2066 } 2066 2067 close_progress_form(); … … 2097 2098 2098 2099 // tar -zxvf- 2099 asprintf(&command,2100 mr_asprintf(&command, 2100 2101 "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", 2101 2102 dev, … … 2106 2107 log_msg(2, "command = '%s'", command); 2107 2108 res = run_program_and_log_output(command, -1); 2108 paranoid_free(command);2109 mr_free(command); 2109 2110 2110 2111 if (res != 0 && does_file_exist(MONDO_CFG_FILE_STUB)) { … … 2142 2143 log_msg(2, "gcffa --- starting"); 2143 2144 log_to_screen(_("I'm thinking...")); 2144 asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);2145 mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 2145 2146 chdir(bkpinfo->tmpdir); 2146 2147 // MONDO_CFG_FILE_STUB is missing the '/' at the start, FYI, by intent … … 2150 2151 unlink(BIGGIELIST_TXT_STUB); 2151 2152 unlink("tmp/i-want-my-lvm"); 2152 asprintf(&command, "mkdir -p %s", mountpt);2153 mr_asprintf(&command, "mkdir -p %s", mountpt); 2153 2154 run_program_and_log_output(command, FALSE); 2154 paranoid_free(command);2155 2156 asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);2157 asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir,2155 mr_free(command); 2156 2157 mr_asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 2158 mr_asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir, 2158 2159 MOUNTLIST_FNAME_STUB); 2159 2160 log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file); 2160 2161 2161 2162 /* Floppy? */ 2162 asprintf(&tmp, "mkdir -p %s", mountpt);2163 mr_asprintf(&tmp, "mkdir -p %s", mountpt); 2163 2164 run_program_and_log_output(tmp, FALSE); 2164 paranoid_free(tmp);2165 2166 asprintf(&tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir);2165 mr_free(tmp); 2166 2167 mr_asprintf(&tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir); 2167 2168 run_program_and_log_output(tmp, FALSE); 2168 paranoid_free(tmp);2169 2170 asprintf(&command, "mount /dev/fd0u1722 %s", mountpt);2171 asprintf(&tmp,2169 mr_free(tmp); 2170 2171 mr_asprintf(&command, "mount /dev/fd0u1722 %s", mountpt); 2172 mr_asprintf(&tmp, 2172 2173 "(sleep 15; kill `ps | grep \"%s\" | cut -d' ' -f1` 2> /dev/null) &", 2173 2174 command); 2174 2175 log_msg(1, "tmp = '%s'", tmp); 2175 2176 system(tmp); 2176 paranoid_free(tmp);2177 mr_free(tmp); 2177 2178 2178 2179 res = run_program_and_log_output(command, FALSE); 2179 paranoid_free(command);2180 mr_free(command); 2180 2181 2181 2182 if (res) { 2182 asprintf(&command, "mount /dev/fd0H1440 %s", mountpt);2183 mr_asprintf(&command, "mount /dev/fd0H1440 %s", mountpt); 2183 2184 res = run_program_and_log_output(command, FALSE); 2184 paranoid_free(command);2185 mr_free(command); 2185 2186 } 2186 2187 if (res) { … … 2192 2193 // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK. 2193 2194 log_msg(2, "Processing floppy (plan A?)"); 2194 asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt);2195 mr_asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt); 2195 2196 if (!does_file_exist(ramdisk_fname)) { 2196 paranoid_free(ramdisk_fname);2197 asprintf(&ramdisk_fname, "%s/initrd.img", mountpt);2197 mr_free(ramdisk_fname); 2198 mr_asprintf(&ramdisk_fname, "%s/initrd.img", mountpt); 2198 2199 } 2199 2200 if (!does_file_exist(ramdisk_fname)) { … … 2206 2207 "Warning - failed to extract config file from ramdisk. I think this boot disk is mangled."); 2207 2208 } 2208 asprintf(&command, "umount %s", mountpt);2209 mr_asprintf(&command, "umount %s", mountpt); 2209 2210 run_program_and_log_output(command, 5); 2210 paranoid_free(command);2211 mr_free(command); 2211 2212 2212 2213 unlink(ramdisk_fname); 2213 paranoid_free(ramdisk_fname);2214 mr_free(ramdisk_fname); 2214 2215 } 2215 2216 if (!does_file_exist(cfg_file)) { … … 2237 2238 2238 2239 if (bkpinfo->media_device == NULL) { 2239 asprintf(&bkpinfo->media_device, "/dev/st0");2240 mr_asprintf(&bkpinfo->media_device, "/dev/st0"); 2240 2241 log_msg(2, "media_device is blank; assuming %s", 2241 2242 bkpinfo->media_device); 2242 2243 } 2243 asprintf(&sav, bkpinfo->media_device);2244 mr_asprintf(&sav, bkpinfo->media_device); 2244 2245 if (extract_cfg_file_and_mountlist_from_tape_dev 2245 2246 (bkpinfo->media_device)) { 2246 paranoid_alloc(bkpinfo->media_device, "/dev/st0");2247 mr_allocstr(bkpinfo->media_device, "/dev/st0"); 2247 2248 if (extract_cfg_file_and_mountlist_from_tape_dev 2248 2249 (bkpinfo->media_device)) { 2249 paranoid_alloc(bkpinfo->media_device, "/dev/osst0");2250 mr_allocstr(bkpinfo->media_device, "/dev/osst0"); 2250 2251 if (extract_cfg_file_and_mountlist_from_tape_dev 2251 2252 (bkpinfo->media_device)) { 2252 paranoid_alloc(bkpinfo->media_device, "/dev/ht0");2253 mr_allocstr(bkpinfo->media_device, "/dev/ht0"); 2253 2254 if (extract_cfg_file_and_mountlist_from_tape_dev 2254 2255 (bkpinfo->media_device)) { 2255 2256 log_msg(3, 2256 2257 "I tried lots of devices but none worked."); 2257 paranoid_alloc(bkpinfo->media_device, sav);2258 mr_allocstr(bkpinfo->media_device, sav); 2258 2259 } 2259 2260 } 2260 2261 } 2261 2262 } 2262 paranoid_free(sav);2263 mr_free(sav); 2263 2264 2264 2265 if (!does_file_exist("tmp/mondo-restore.cfg")) { … … 2271 2272 "gcffa --- looking at mounted CD for mindi-boot.2880.img"); 2272 2273 /* BERLIOS : Useless ? 2273 asprintf(&command,2274 mr_asprintf(&command, 2274 2275 "mount " MNT_CDROM 2275 2276 "/images/mindi-boot.2880.img -o loop %s", mountpt); 2276 2277 */ 2277 asprintf(&mounted_cfgf_path, "%s/%s", mountpt, cfg_file);2278 mr_asprintf(&mounted_cfgf_path, "%s/%s", mountpt, cfg_file); 2278 2279 if (!does_file_exist(mounted_cfgf_path)) { 2279 2280 log_msg(2, 2280 2281 "gcffa --- Plan C, a.k.a. untarring some file from all.tar.gz"); 2281 asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2282 mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 2282 2283 run_program_and_log_output(command, TRUE); 2283 paranoid_free(command);2284 mr_free(command); 2284 2285 2285 2286 if (!does_file_exist(MONDO_CFG_FILE_STUB)) { … … 2288 2289 } 2289 2290 } 2290 paranoid_free(mounted_cfgf_path);2291 } 2292 } 2293 paranoid_free(mountpt);2291 mr_free(mounted_cfgf_path); 2292 } 2293 } 2294 mr_free(mountpt); 2294 2295 2295 2296 if (does_file_exist(MONDO_CFG_FILE_STUB)) { 2296 2297 log_msg(1, "gcffa --- great! We've got the config file"); 2297 2298 tmp1 = call_program_and_get_last_line_of_output("pwd"); 2298 asprintf(&tmp, "%s/%s", tmp1,MONDO_CFG_FILE_STUB);2299 asprintf(&command, "cp -f %s %s", tmp, cfg_file);2299 mr_asprintf(&tmp, "%s/%s", tmp1,MONDO_CFG_FILE_STUB); 2300 mr_asprintf(&command, "cp -f %s %s", tmp, cfg_file); 2300 2301 iamhere(command); 2301 2302 … … 2308 2309 log_msg(1, "... and I moved it successfully to %s", cfg_file); 2309 2310 } 2310 paranoid_free(command);2311 2312 asprintf(&command, "cp -f %s/%s %s",tmp1,2311 mr_free(command); 2312 2313 mr_asprintf(&command, "cp -f %s/%s %s",tmp1, 2313 2314 MOUNTLIST_FNAME_STUB, mountlist_file); 2314 paranoid_free(tmp1);2315 mr_free(tmp1); 2315 2316 2316 2317 iamhere(command); … … 2320 2321 } else { 2321 2322 log_msg(1, "Got mountlist too"); 2322 paranoid_free(command);2323 asprintf(&command, "cp -f %s %s", mountlist_file,2323 mr_free(command); 2324 mr_asprintf(&command, "cp -f %s %s", mountlist_file, 2324 2325 g_mountlist_fname); 2325 2326 if (run_program_and_log_output(command, 1)) { … … 2327 2328 } else { 2328 2329 log_msg(1, "Copied mountlist to /tmp as well OK"); 2329 paranoid_free(command);2330 asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");2330 mr_free(command); 2331 mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/"); 2331 2332 run_program_and_log_output(command, 1); 2332 2333 } 2333 2334 } 2334 paranoid_free(command);2335 paranoid_free(tmp);2335 mr_free(command); 2336 mr_free(tmp); 2336 2337 } 2337 2338 run_program_and_log_output("umount " MNT_CDROM, FALSE); … … 2351 2352 /* start SAH */ 2352 2353 else { 2353 asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,2354 mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, 2354 2355 bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2355 2356 run_program_and_log_output(command, FALSE); 2356 paranoid_free(command);2357 mr_free(command); 2357 2358 } 2358 2359 /* end SAH */ 2359 2360 2360 asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);2361 paranoid_free(cfg_file);2361 mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 2362 mr_free(cfg_file); 2362 2363 2363 2364 run_program_and_log_output(command, FALSE); 2364 paranoid_free(command);2365 2366 asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);2367 paranoid_free(mountlist_file);2365 mr_free(command); 2366 2367 mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 2368 mr_free(mountlist_file); 2368 2369 2369 2370 run_program_and_log_output(command, FALSE); 2370 paranoid_free(command);2371 2372 asprintf(&command, "cp -f etc/raidtab /etc/");2371 mr_free(command); 2372 2373 mr_asprintf(&command, "cp -f etc/raidtab /etc/"); 2373 2374 run_program_and_log_output(command, FALSE); 2374 paranoid_free(command);2375 2376 asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");2375 mr_free(command); 2376 2377 mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/"); 2377 2378 run_program_and_log_output(command, FALSE); 2378 paranoid_free(command);2379 mr_free(command); 2379 2380 2380 2381 g_backup_media_type = bkpinfo->backup_media_type; … … 2412 2413 log_msg(1, "Sync'ing %s (i=%d)", 2413 2414 raidlist->el[i].raid_device, i); 2414 asprintf(&screen_message, "Sync'ing %s",2415 mr_asprintf(&screen_message, "Sync'ing %s", 2415 2416 raidlist->el[i].raid_device); 2416 2417 open_evalcall_form(screen_message); 2417 paranoid_free(screen_message);2418 mr_free(screen_message); 2418 2419 2419 2420 if (raidlist->el[i].progress == -1) { // delayed while another partition inits … … 2434 2435 } 2435 2436 } 2436 paranoid_free(raidlist);2437 } 2437 mr_free(raidlist); 2438 }
Note:
See TracChangeset
for help on using the changeset viewer.