Changeset 2323 in MondoRescue for branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
- Timestamp:
- Aug 18, 2009, 3:05:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2322 r2323 144 144 } 145 145 146 mr_asprintf( &question_ptr, "Should I restore the image of %s ?", incoming_ptr);146 mr_asprintf(question_ptr, "Should I restore the image of %s ?", incoming_ptr); 147 147 148 148 if (ask_me_yes_or_no(question_ptr)) { … … 228 228 } 229 229 log_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles", f, file); 230 mr_asprintf( &command, "grep -E '^%s$' %s", file, list_fname);230 mr_asprintf(command, "grep -E '^%s$' %s", file, list_fname); 231 231 res = run_program_and_log_output(command, FALSE); 232 232 mr_free(command); … … 260 260 char *command = NULL; 261 261 char *mds = NULL; 262 char *p = NULL; 262 263 int retval = 0, i; 263 264 bool already_mounted = FALSE; 264 265 char *isodir_format = NULL; 265 266 266 assert(bkpinfo != NULL);267 267 g_ISO_restore_mode = TRUE; 268 268 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); … … 271 271 * Don't let this clobber an existing bkpinfo->isodir */ 272 272 if (!bkpinfo->isodir[0]) { 273 strcpy(bkpinfo->isodir, "/tmp/isodir"); 273 mr_free(bkpinfo->isodir); 274 mr_asprintf(p, "/tmp/isodir"); 275 bkpinfo->isodir = p; 274 276 } 275 277 /* End patch */ 276 mr_asprintf( &command, "mkdir -p %s", bkpinfo->isodir);278 mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir); 277 279 run_program_and_log_output(command, 5); 278 280 mr_free(command); … … 290 292 already_mounted = TRUE; 291 293 } else { 292 mr_asprintf( &mount_isodir_command, "mount %s", g_isodir_device);294 mr_asprintf(mount_isodir_command, "mount %s", g_isodir_device); 293 295 if (isodir_format) { 294 296 mr_strcat(mount_isodir_command, " -t %s", isodir_format); … … 320 322 log_msg(1, "%s #%d has been mounted via loopback mount", mds, i); 321 323 if (i < 0) { 322 popup_and_OK 323 ("Cannot find ISO images in the directory you specified."); 324 retval = 1; 325 } 326 log_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__, 327 bkpinfo->isodir); 324 popup_and_OK("Cannot find ISO images in the directory you specified."); 325 retval = 1; 326 } 327 log_msg(2, "bkpinfo->isodir is now %s", bkpinfo->isodir); 328 328 return (retval); 329 329 } … … 368 368 369 369 if (!strcmp(mpt, "/1")) { 370 mr_asprintf( &mountpoint, "/");370 mr_asprintf(mountpoint, "/"); 371 371 log_msg(3, "Mommm! SME is being a dildo!"); 372 372 } else { 373 mr_asprintf( &mountpoint, "%s", mpt);373 mr_asprintf(mountpoint, "%s", mpt); 374 374 } 375 375 … … 380 380 return (0); 381 381 } 382 mr_asprintf( &tmp, "Mounting device %s ", device);382 mr_asprintf(tmp, "Mounting device %s ", device); 383 383 log_msg(1, tmp); 384 384 /* Deal with additional params only if not /proc or /sys */ 385 mr_asprintf( &additional_parameters, "");385 mr_asprintf(additional_parameters, ""); 386 386 if (strcmp(format, "proc") && strcmp(format, "sys")) { 387 387 if (writeable) { … … 399 399 400 400 if (!strcmp(mountpoint, "swap")) { 401 mr_asprintf( &command, "swapon %s", device);402 mr_asprintf( &mountdir, "swap");401 mr_asprintf(command, "swapon %s", device); 402 mr_asprintf(mountdir, "swap"); 403 403 } else { 404 404 if (!strcmp(mountpoint, "/")) { 405 mr_asprintf( &mountdir, "%s", MNT_RESTORING);405 mr_asprintf(mountdir, "%s", MNT_RESTORING); 406 406 } else { 407 mr_asprintf( &mountdir, "%s%s", MNT_RESTORING, mountpoint);408 } 409 mr_asprintf( &command, "mkdir -p %s", mountdir);407 mr_asprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint); 408 } 409 mr_asprintf(command, "mkdir -p %s", mountdir); 410 410 run_program_and_log_output(command, FALSE); 411 411 mr_free(command); 412 412 413 mr_asprintf( &command, "mount -t %s %s %s %s 2>> %s", format, device, additional_parameters, mountdir, MONDO_LOGFILE);413 mr_asprintf(command, "mount -t %s %s %s %s 2>> %s", format, device, additional_parameters, mountdir, MONDO_LOGFILE); 414 414 log_msg(2, "command='%s'", command); 415 415 } … … 420 420 log_msg(1, "Re-trying without the fancy extra parameters"); 421 421 mr_free(command); 422 mr_asprintf( &command, "mount -t %s %s %s 2>> %s", format, device, mountdir, MONDO_LOGFILE);422 mr_asprintf(command, "mount -t %s %s %s 2>> %s", format, device, mountdir, MONDO_LOGFILE); 423 423 res = run_program_and_log_output(command, TRUE); 424 424 } … … 432 432 log_msg(2, "Retrying w/o the '-t' switch"); 433 433 mr_free(command); 434 mr_asprintf( &command, "mount %s %s 2>> %s", device, mountdir, MONDO_LOGFILE);434 mr_asprintf(command, "mount %s %s 2>> %s", device, mountdir, MONDO_LOGFILE); 435 435 log_msg(2, "2nd command = '%s'", command); 436 436 res = run_program_and_log_output(command, TRUE); … … 492 492 "", mountlist->entries); 493 493 494 mr_asprintf( &these_failed, "");494 mr_asprintf(these_failed, ""); 495 495 for (lino = 0; lino < mountlist->entries; lino++) { 496 496 if (!strcmp(mountlist->el[lino].device, "/proc")) { … … 498 498 "Again with the /proc - why is this in your mountlist?"); 499 499 } else if (is_this_device_mounted(mountlist->el[lino].device)) { 500 mr_asprintf( &tmp, "%s is already mounted", mountlist->el[lino].device);500 mr_asprintf(tmp, "%s is already mounted", mountlist->el[lino].device); 501 501 log_to_screen(tmp); 502 502 mr_free(tmp); … … 505 505 && strcmp(mountlist->el[lino].mountpoint, "raid") 506 506 && strcmp(mountlist->el[lino].mountpoint, "image")) { 507 mr_asprintf( &tmp, "Mounting %s", mountlist->el[lino].device);507 mr_asprintf(tmp, "Mounting %s", mountlist->el[lino].device); 508 508 update_progress_form(tmp); 509 509 mr_free(tmp); … … 529 529 ("format and restore *without* partitioning first. Sorry for the inconvenience."); 530 530 } 531 mr_asprintf( &tmp, "Could not mount device(s) %s- shall I abort?", these_failed);531 mr_asprintf(tmp, "Could not mount device(s) %s- shall I abort?", these_failed); 532 532 533 533 if (!ask_me_yes_or_no(tmp)) { … … 570 570 * @return 0 for success, nonzero for failure. 571 571 */ 572 int mount_media() 573 { 574 char *mount_cmd = NULL; 575 int i, res; 572 int mount_media() { 573 574 char *mount_cmd = NULL; 575 char *p = NULL; 576 int i, res; 576 577 #ifdef __FreeBSD__ 577 char mdd[32];578 char *mddev = mdd;578 char mdd[32]; 579 char *mddev = mdd; 579 580 #endif 580 581 581 assert(bkpinfo != NULL); 582 583 if (bkpinfo->backup_media_type == tape 584 || bkpinfo->backup_media_type == udev) { 582 if (bkpinfo->backup_media_type == tape || bkpinfo->backup_media_type == udev) { 585 583 log_msg(8, "Tape/udev. Therefore, no need to mount a media."); 586 584 return 0; … … 595 593 log_msg(2, "Mounting for NFS thingy"); 596 594 log_msg(2, "isodir = %s", bkpinfo->isodir); 597 if ((!bkpinfo->isodir[0] || !strcmp(bkpinfo->isodir, "/")) 598 && am_I_in_disaster_recovery_mode()) { 599 strcpy(bkpinfo->isodir, "/tmp/isodir"); 595 if (!strcmp(bkpinfo->isodir, "/") && am_I_in_disaster_recovery_mode()) { 596 mr_free(bkpinfo->isodir); 597 mr_asprintf(p, "/tmp/isodir"); 598 bkpinfo->isodir = p; 600 599 log_msg(1, "isodir is being set to %s", bkpinfo->isodir); 601 600 } 602 601 #ifdef __FreeBSD__ 603 mr_asprintf( &mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);602 mr_asprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number); 604 603 mddev = make_vn(mount_cmd); 605 604 mr_free(mount_cmd); 606 605 607 mr_asprintf( &mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);606 mr_asprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev); 608 607 #else 609 mr_asprintf( &mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);608 mr_asprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 610 609 #endif 611 610 612 611 } else if (bkpinfo->backup_media_type == iso) { 613 612 #ifdef __FreeBSD__ 614 mr_asprintf( &mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number);613 mr_asprintf(mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number); 615 614 mddev = make_vn(mount_cmd); 616 615 mr_free(mount_cmd); 617 616 618 mr_asprintf( &mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);617 mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM); 619 618 #else 620 mr_asprintf( &mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);619 mr_asprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 621 620 #endif 622 621 } else if (bkpinfo->backup_media_type == usb) { 623 mr_asprintf( &mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);622 mr_asprintf(mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM); 624 623 } else if (strstr(bkpinfo->media_device, "/dev/")) { 625 624 #ifdef __FreeBSD__ 626 mr_asprintf( &mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);625 mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM); 627 626 #else 628 mr_asprintf( &mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);627 mr_asprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM); 629 628 #endif 630 629 } else { … … 638 637 639 638 #ifdef __FreeBSD__ 640 mr_asprintf( &mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);639 mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM); 641 640 #else 642 mr_asprintf( &mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);641 mr_asprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM); 643 642 #endif 644 643 } … … 727 726 malloc_string(iso_mnt); 728 727 malloc_string(iso_path); 729 malloc_string(old_isodir);730 728 malloc_string(value); 731 729 malloc_string(tmp); … … 774 772 mr_free(bkpinfo->prefix); 775 773 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 776 mr_asprintf( &tmp1, "%s", value);774 mr_asprintf(tmp1, "%s", value); 777 775 } else { 778 mr_asprintf( &tmp1, "%s", STD_PREFIX);776 mr_asprintf(tmp1, "%s", STD_PREFIX); 779 777 } 780 778 bkpinfo->prefix = tmp1; … … 784 782 mr_free(bkpinfo->prefix); 785 783 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 786 mr_asprintf( &tmp1, "%s", value);784 mr_asprintf(tmp1, "%s", value); 787 785 } else { 788 mr_asprintf( &tmp1, "%s", STD_PREFIX);786 mr_asprintf(tmp1, "%s", STD_PREFIX); 789 787 } 790 788 bkpinfo->prefix = tmp1; … … 798 796 } 799 797 mr_free(bkpinfo->prefix); 800 mr_asprintf( &tmp1, "%s", envtmp1);798 mr_asprintf(tmp1, "%s", envtmp1); 801 799 bkpinfo->prefix = tmp1; 802 800 } … … 863 861 read_cfg_var(cfg_file, "acl", value); 864 862 if (strstr(value, "TRUE")) { 865 mr_asprintf( &g_getfacl,"setfacl");863 mr_asprintf(g_getfacl,"setfacl"); 866 864 log_msg(1, "We will restore ACLs"); 867 865 if (! find_home_of_exe("setfacl")) { … … 871 869 read_cfg_var(cfg_file, "xattr", value); 872 870 if (strstr(value, "TRUE")) { 873 mr_asprintf( &g_getfattr,"setfattr");871 mr_asprintf(g_getfattr,"setfattr"); 874 872 log_msg(1, "We will restore XATTRs"); 875 873 if (! find_home_of_exe("setfattr")) { … … 968 966 * isodir in disaster recovery mode 969 967 */ 970 strcpy(old_isodir, bkpinfo->isodir);968 mr_asprintf(old_isodir, "%s", bkpinfo->isodir); 971 969 read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt); 972 970 read_cfg_var(g_mondo_cfg_file, "isodir", iso_path); 973 sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 971 mr_free(bkpinfo->isodir); 972 mr_asprintf(tmp1, "%s%s", iso_mnt, iso_path); 973 bkpinfo->isodir = tmp1; 974 974 if (!bkpinfo->isodir[0]) { 975 strcpy(bkpinfo->isodir, old_isodir); 975 mr_free(bkpinfo->isodir); 976 bkpinfo->isodir = old_isodir; 977 } else { 978 mr_free(old_isodir); 976 979 } 977 980 if (!bkpinfo->disaster_recovery) { 978 981 if (strcmp(old_isodir, bkpinfo->isodir)) { 979 log_it 980 ("user nominated isodir differs from archive, keeping user's choice: %s %s\n", 981 old_isodir, bkpinfo->isodir); 982 strcpy(bkpinfo->isodir, old_isodir); 982 log_it("user nominated isodir %s differs from archive, keeping user's choice: %s\n", bkpinfo->isodir, old_isodir ); 983 mr_free(bkpinfo->isodir); 984 bkpinfo->isodir = old_isodir; 985 } else { 986 mr_free(old_isodir); 983 987 } 984 988 } 985 989 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 986 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, 987 g_isodir_device); 990 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device); 991 988 992 if (bkpinfo->disaster_recovery) { 989 993 if (is_this_device_mounted(g_isodir_device)) { 990 994 log_msg(2, "NB: isodir is already mounted"); 991 995 /* Find out where it's mounted */ 992 mr_asprintf( &command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);996 mr_asprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device); 993 997 log_it("command = %s", command); 994 998 log_it("res of it = %s", call_program_and_get_last_line_of_output(command)); … … 997 1001 } else { 998 1002 sprintf(iso_mnt, "/tmp/isodir"); 999 mr_asprintf( &tmp1, "mkdir -p %s", iso_mnt);1003 mr_asprintf(tmp1, "mkdir -p %s", iso_mnt); 1000 1004 run_program_and_log_output(tmp1, 5); 1001 1005 mr_free(tmp1); 1002 1006 1003 mr_asprintf( &tmp1, "mount %s %s", g_isodir_device, iso_mnt);1007 mr_asprintf(tmp1, "mount %s %s", g_isodir_device, iso_mnt); 1004 1008 if (run_program_and_log_output(tmp1, 3)) { 1005 1009 log_msg(1, … … 1007 1011 bkpinfo->backup_media_type = cdr; 1008 1012 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* superfluous */ 1009 bkpinfo->isodir[0] =iso_mnt[0] = iso_path[0] = '\0';1013 iso_mnt[0] = iso_path[0] = '\0'; 1010 1014 if (mount_media()) { 1011 1015 mr_free(tmp1); 1012 fatal_error 1013 ("Unable to mount isodir. Failed to mount CD-ROM as well."); 1016 fatal_error("Unable to mount isodir. Failed to mount CD-ROM as well."); 1014 1017 } else { 1015 log_msg(1, 1016 "You backed up to disk, then burned some CDs."); 1018 log_msg(1, "You backed up to disk, then burned some CDs."); 1017 1019 } 1018 1020 } … … 1021 1023 /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */ 1022 1024 if (bkpinfo->backup_media_type == iso) { 1023 sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 1025 mr_free(bkpinfo->isodir); 1026 mr_asprintf(tmp1, "%s%s", iso_mnt, iso_path); 1027 bkpinfo->isodir = tmp1; 1024 1028 } 1025 1029 } … … 1047 1051 paranoid_free(iso_mnt); 1048 1052 paranoid_free(iso_path); 1049 paranoid_free(old_isodir);1050 1053 return (0); 1051 1054 … … 1105 1108 unlink(FILELIST_FULL_STUB); 1106 1109 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1107 mr_asprintf( &command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);1110 mr_asprintf(command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1108 1111 log_msg(1, "tarcommand = %s", command); 1109 1112 run_program_and_log_output(command, 1); … … 1113 1116 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 1114 1117 log_msg(2, "pre-2.2.4 compatible mode on"); 1115 mr_asprintf( &command, "tar -b %ld -zxf %s %s %s %s %s %s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);1118 mr_asprintf(command, "tar -b %ld -zxf %s %s %s %s %s %s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1116 1119 log_msg(1, "tarcommand = %s", command); 1117 1120 run_program_and_log_output(command, 1); … … 1119 1122 } 1120 1123 } else { 1121 log_msg(2, 1122 "Calling insist_on_this_cd_number; bkpinfo->isodir=%s", 1123 bkpinfo->isodir); 1124 log_msg(2, "Calling insist_on_this_cd_number; bkpinfo->isodir=%s", bkpinfo->isodir); 1124 1125 insist_on_this_cd_number(1); 1125 1126 log_msg(2, "Back from iotcn"); 1126 1127 run_program_and_log_output("mount", 1); 1127 mr_asprintf( &command, "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);1128 mr_asprintf(command, "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1128 1129 1129 1130 log_msg(1, "tarcommand = %s", command); … … 1134 1135 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 1135 1136 log_msg(2, "pre-2.2.4 compatible mode on"); 1136 mr_asprintf( &command, "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);1137 mr_asprintf(command, "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1137 1138 1138 1139 log_msg(1, "tarcommand = %s", command); … … 1149 1150 } 1150 1151 } 1151 mr_asprintf( &command, "cp -f %s %s", MONDO_CFG_FILE_STUB, g_mondo_cfg_file);1152 mr_asprintf(command, "cp -f %s %s", MONDO_CFG_FILE_STUB, g_mondo_cfg_file); 1152 1153 run_program_and_log_output(command, FALSE); 1153 1154 mr_free(command); 1154 1155 1155 mr_asprintf( &command, "cp -f %s/%s %s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB, g_biggielist_txt);1156 mr_asprintf(command, "cp -f %s/%s %s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB, g_biggielist_txt); 1156 1157 log_msg(1, "command = %s", command); 1157 1158 paranoid_system(command); 1158 1159 mr_free(command); 1159 1160 1160 mr_asprintf( &command, "ln -sf %s/%s %s", bkpinfo->tmpdir, FILELIST_FULL_STUB, g_filelist_full);1161 mr_asprintf(command, "ln -sf %s/%s %s", bkpinfo->tmpdir, FILELIST_FULL_STUB, g_filelist_full); 1161 1162 log_msg(1, "command = %s", command); 1162 1163 paranoid_system(command); … … 1170 1171 && 1171 1172 ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) { 1172 mr_asprintf( &command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir);1173 mr_asprintf(command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir); 1173 1174 paranoid_system(command); 1174 1175 mr_free(command); … … 1195 1196 log_to_screen("Pre-processing filelist"); 1196 1197 if (!does_file_exist(g_biggielist_txt)) { 1197 mr_asprintf( &command, "echo -n > %s", g_biggielist_txt);1198 mr_asprintf(command, "echo -n > %s", g_biggielist_txt); 1198 1199 paranoid_system(command); 1199 1200 mr_free(command); 1200 1201 } 1201 mr_asprintf( &command, "grep -E '^/dev/.*' %s > %s", g_biggielist_txt, g_filelist_imagedevs);1202 mr_asprintf(command, "grep -E '^/dev/.*' %s > %s", g_biggielist_txt, g_filelist_imagedevs); 1202 1203 paranoid_system(command); 1203 1204 mr_free(command); … … 1276 1277 assert_string_is_neither_NULL_nor_zerolength(filename); 1277 1278 1278 mr_asprintf( &tmp, "%s/%s", path_root, filename);1279 mr_asprintf( &command, "cp -f %s %s.pristine", tmp, tmp);1279 mr_asprintf(tmp, "%s/%s", path_root, filename); 1280 mr_asprintf(command, "cp -f %s %s.pristine", tmp, tmp); 1280 1281 mr_free(tmp); 1281 1282 … … 1334 1335 * the current /dev location 1335 1336 */ 1336 mr_asprintf( &cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING);1337 mr_asprintf(cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING); 1337 1338 run_program_and_log_output(cmd, 3); 1338 1339 paranoid_free(cmd); … … 1361 1362 #ifdef __FreeBSD__ 1362 1363 else if (!strcmp(name, "BOOT0")) { 1363 mr_asprintf( &tmp, "boot0cfg -B %s", device);1364 mr_asprintf(tmp, "boot0cfg -B %s", device); 1364 1365 res = run_program_and_log_output(tmp, FALSE); 1365 1366 paranoid_free(tmp); 1366 1367 } else { 1367 mr_asprintf( &tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);1368 mr_asprintf(tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device); 1368 1369 if (!system(tmp)) { 1369 1370 mr_free(tmp); 1370 mr_asprintf( &tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);1371 mr_asprintf(tmp, MNT_RESTORING "/sbin/fdisk -B %s", device); 1371 1372 res = run_program_and_log_output(tmp, 3); 1372 1373 } else { … … 1452 1453 assert_string_is_neither_NULL_nor_zerolength(bd); 1453 1454 strcpy(editor, find_my_editor()); 1454 mr_asprintf( &boot_device, "%s", bd);1455 mr_asprintf(boot_device, "%s", bd); 1455 1456 1456 1457 if (offer_to_run_stabgrub … … 1469 1470 continue; 1470 1471 } 1471 mr_asprintf( &command, "stabgrub-me %s", p);1472 mr_asprintf(command, "stabgrub-me %s", p); 1472 1473 mr_free(p); 1473 1474 … … 1489 1490 newtSuspend(); 1490 1491 } 1491 mr_asprintf( &tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);1492 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1492 1493 paranoid_system(tmp); 1493 1494 mr_free(tmp); 1494 1495 1495 mr_asprintf( &tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);1496 mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor); 1496 1497 paranoid_system(tmp); 1497 1498 mr_free(tmp); 1498 1499 1499 mr_asprintf( &tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);1500 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor); 1500 1501 paranoid_system(tmp); 1501 1502 mr_free(tmp); 1502 1503 1503 mr_asprintf( &tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);1504 mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor); 1504 1505 paranoid_system(tmp); 1505 1506 mr_free(tmp); … … 1513 1514 if (!run_program_and_log_output("which grub-MR", FALSE)) { 1514 1515 log_msg(1, "Yay! grub-MR found..."); 1515 mr_asprintf( &command, "grub-MR %s /tmp/mountlist.txt", boot_device);1516 mr_asprintf(command, "grub-MR %s /tmp/mountlist.txt", boot_device); 1516 1517 log_msg(1, "command = %s", command); 1517 1518 } else { 1518 mr_asprintf( &command, "chroot " MNT_RESTORING " grub-install %s", boot_device);1519 mr_asprintf(command, "chroot " MNT_RESTORING " grub-install %s", boot_device); 1519 1520 log_msg(1, "WARNING - grub-MR not found; using grub-install"); 1520 1521 } … … 1591 1592 0, 1592 1593 "Modifying fstab and elilo.conf... "); 1593 mr_asprintf( &command, "stabelilo-me");1594 mr_asprintf(command, "stabelilo-me"); 1594 1595 res = run_program_and_log_output(command, 3); 1595 1596 mr_free(command); … … 1602 1603 newtSuspend(); 1603 1604 } 1604 mr_asprintf( &tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);1605 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1605 1606 paranoid_system(tmp); 1606 1607 mr_free(tmp); 1607 1608 1608 mr_asprintf( &tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor);1609 mr_asprintf(tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor); 1609 1610 paranoid_system(tmp); 1610 1611 mr_free(tmp); … … 1667 1668 0, 1668 1669 "Modifying fstab and lilo.conf, and running LILO... "); 1669 mr_asprintf( &command, "stablilo-me");1670 mr_asprintf(command, "stablilo-me"); 1670 1671 res = run_program_and_log_output(command, 3); 1671 1672 mr_free(command); … … 1678 1679 newtSuspend(); 1679 1680 } 1680 mr_asprintf( &tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1681 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1681 1682 paranoid_system(tmp); 1682 1683 mr_free(tmp); 1683 1684 1684 mr_asprintf( &tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);1685 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1685 1686 paranoid_system(tmp); 1686 1687 mr_free(tmp); … … 1770 1771 1771 1772 strcpy(editor, find_my_editor()); 1772 mr_asprintf( &boot_device, "%s", bd);1773 mr_asprintf(boot_device, "%s", bd); 1773 1774 1774 1775 if (offer_to_hack_scripts … … 1783 1784 newtSuspend(); 1784 1785 } 1785 mr_asprintf( &tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1786 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1786 1787 paranoid_system(tmp); 1787 1788 mr_free(tmp); … … 1798 1799 continue; 1799 1800 } 1800 mr_asprintf( &command, "stabraw-me %s", p);1801 mr_asprintf(command, "stabraw-me %s", p); 1801 1802 mr_free(p); 1802 1803 … … 1812 1813 } else { 1813 1814 /* nuke mode */ 1814 mr_asprintf( &command, "raw-MR %s /tmp/mountlist.txt", boot_device);1815 mr_asprintf(command, "raw-MR %s /tmp/mountlist.txt", boot_device); 1815 1816 log_msg(2, "run_raw_mbr() --- command='%s'", command); 1816 1817 … … 1939 1940 for (i = 0; i < 20; i++) { 1940 1941 g_current_progress = i; 1941 mr_asprintf( &tmp, "You have %d seconds left to abort.", 20 - i);1942 mr_asprintf(tmp, "You have %d seconds left to abort.", 20 - i); 1942 1943 update_progress_form(tmp); 1943 1944 mr_free(tmp); … … 1991 1992 paranoid_system("sync"); 1992 1993 1993 mr_asprintf( &tmp, "cp -f %s " MNT_RESTORING "/var/log", MONDO_LOGFILE);1994 mr_asprintf(tmp, "cp -f %s " MNT_RESTORING "/var/log", MONDO_LOGFILE); 1994 1995 if (run_program_and_log_output(tmp, FALSE)) { 1995 1996 log_msg(1, … … 2010 2011 continue; 2011 2012 } 2012 mr_asprintf( &tmp, "Unmounting device %s ", mountlist->el[lino].device);2013 mr_asprintf(tmp, "Unmounting device %s ", mountlist->el[lino].device); 2013 2014 2014 2015 update_progress_form(tmp); … … 2016 2017 if (is_this_device_mounted(mountlist->el[lino].device)) { 2017 2018 if (!strcmp(mountlist->el[lino].mountpoint, "swap")) { 2018 mr_asprintf( &command, "swapoff %s", mountlist->el[lino].device);2019 mr_asprintf(command, "swapoff %s", mountlist->el[lino].device); 2019 2020 } else { 2020 2021 if (!strcmp(mountlist->el[lino].mountpoint, "/1")) { 2021 mr_asprintf( &command, "umount %s/", MNT_RESTORING);2022 mr_asprintf(command, "umount %s/", MNT_RESTORING); 2022 2023 log_msg(3, 2023 2024 "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight..."); 2024 2025 } else { 2025 mr_asprintf( &command, "umount " MNT_RESTORING "%s", mountlist->el[lino].mountpoint);2026 mr_asprintf(command, "umount " MNT_RESTORING "%s", mountlist->el[lino].mountpoint); 2026 2027 2027 2028 /* To support latest Ubuntu where /var is a separate FS … … 2090 2091 } 2091 2092 2092 mr_asprintf( &command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);2093 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2093 2094 log_msg(2, "command = '%s'", command); 2094 2095 res = run_program_and_log_output(command, -1); … … 2101 2102 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 2102 2103 log_msg(2, "pre-2.2.4 compatible mode on"); 2103 mr_asprintf( &command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);2104 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2104 2105 log_msg(2, "command = '%s'", command); 2105 2106 res = run_program_and_log_output(command, -1); … … 2148 2149 log_msg(2, "gcffa --- starting"); 2149 2150 log_to_screen("I'm thinking..."); 2150 mr_asprintf( &mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);2151 mr_asprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 2151 2152 device[0] = '\0'; 2152 2153 chdir(bkpinfo->tmpdir); 2153 mr_asprintf( &cfg_file, "%s", MONDO_CFG_FILE_STUB);2154 mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB); 2154 2155 unlink(cfg_file); // cfg_file[] is missing the '/' at the start, FYI, by intent 2155 2156 mr_free(cfg_file); … … 2157 2158 unlink(FILELIST_FULL_STUB); 2158 2159 unlink(BIGGIELIST_TXT_STUB); 2159 mr_asprintf( &command, "mkdir -p %s", mountpt);2160 mr_asprintf(command, "mkdir -p %s", mountpt); 2160 2161 run_program_and_log_output(command, FALSE); 2161 2162 mr_free(command); 2162 2163 2163 mr_asprintf( &cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);2164 mr_asprintf( &mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);2164 mr_asprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 2165 mr_asprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2165 2166 log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file); 2166 2167 mr_free(mountpt); … … 2192 2193 log_msg(2, "media_device is blank; assuming %s"); 2193 2194 } 2194 mr_asprintf( &tmp, "%s", bkpinfo->media_device);2195 mr_asprintf(tmp, "%s", bkpinfo->media_device); 2195 2196 if (extract_cfg_file_and_mountlist_from_tape_dev 2196 2197 (bkpinfo->media_device)) { … … 2231 2232 log_msg(2, 2232 2233 "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz"); 2233 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, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2234 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, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 2234 2235 run_program_and_log_output(command, TRUE); 2235 2236 mr_free(command); … … 2238 2239 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 2239 2240 log_msg(2, "pre-2.2.4 compatible mode on"); 2240 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, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2241 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, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 2241 2242 run_program_and_log_output(command, TRUE); 2242 2243 mr_free(command); … … 2251 2252 if (does_file_exist(MONDO_CFG_FILE_STUB)) { 2252 2253 log_msg(1, "gcffa --- great! We've got the config file"); 2253 mr_asprintf( &tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB);2254 mr_asprintf( &command, "cp -f %s %s", tmp, cfg_file);2254 mr_asprintf(tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB); 2255 mr_asprintf(command, "cp -f %s %s", tmp, cfg_file); 2255 2256 log_it("%s",command); 2256 2257 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) { … … 2261 2262 mr_free(command); 2262 2263 2263 mr_asprintf( &command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"),2264 mr_asprintf(command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"), 2264 2265 MOUNTLIST_FNAME_STUB, mountlist_file); 2265 2266 log_it("%s",command); … … 2271 2272 2272 2273 mr_free(command); 2273 mr_asprintf( &command, "cp -f %s %s", mountlist_file, g_mountlist_fname);2274 mr_asprintf(command, "cp -f %s %s", mountlist_file, g_mountlist_fname); 2274 2275 if (run_program_and_log_output(command, 1)) { 2275 2276 log_msg(1, "Failed to copy mountlist to /tmp"); … … 2277 2278 log_msg(1, "Copied mountlist to /tmp as well OK"); 2278 2279 mr_free(command); 2279 mr_asprintf( &command, "cp -f %s /tmp/",IWANTMYLVM_STUB);2280 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 2280 2281 run_program_and_log_output(command, 1); 2281 2282 } … … 2301 2302 /* Is this code really useful ??? */ 2302 2303 if (extract_mountlist_stub) { 2303 mr_asprintf( &command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);2304 mr_asprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2304 2305 run_program_and_log_output(command, FALSE); 2305 2306 mr_free(command); … … 2307 2308 } 2308 2309 2309 mr_asprintf( &command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);2310 mr_asprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 2310 2311 mr_free(cfg_file); 2311 2312 … … 2314 2315 2315 2316 if (extract_mountlist_stub) { 2316 mr_asprintf( &command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);2317 mr_asprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 2317 2318 run_program_and_log_output(command, FALSE); 2318 2319 mr_free(command); … … 2320 2321 mr_free(mountlist_file); 2321 2322 2322 mr_asprintf( &command, "cp -f etc/raidtab /etc/");2323 mr_asprintf(command, "cp -f etc/raidtab /etc/"); 2323 2324 run_program_and_log_output(command, FALSE); 2324 2325 mr_free(command); 2325 2326 2326 2327 if (extract_i_want_my_lvm) { 2327 mr_asprintf( &command, "cp -f %s /tmp/",IWANTMYLVM_STUB);2328 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 2328 2329 run_program_and_log_output(command, FALSE); 2329 2330 mr_free(command); … … 2382 2383 } 2383 2384 log_msg(1,"Sync'ing %s (i=%d)", raidlist->el[i].raid_device, i); 2384 mr_asprintf( &screen_message, "Sync'ing %s", raidlist->el[i].raid_device);2385 mr_asprintf(screen_message, "Sync'ing %s", raidlist->el[i].raid_device); 2385 2386 open_evalcall_form(screen_message); 2386 2387 mr_free(screen_message);
Note:
See TracChangeset
for help on using the changeset viewer.