Changeset 900 in MondoRescue for trunk/mondo/src/mondorestore/mondo-rstr-tools.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.