Changeset 3158 in MondoRescue for branches/3.0/mondo/src/mondorestore/mondo-rstr-tools.c
- Timestamp:
- Jun 24, 2013, 10:20:16 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/mondorestore/mondo-rstr-tools.c
r3157 r3158 41 41 extern char *g_tmpfs_mountpt; 42 42 */ 43 extern char *g_isodir_device; 44 extern char *g_isodir_format; 43 44 /** 45 * The device to mount to get at the ISO images. Ignored unless @p g_ISO_restore_mode. 46 */ 47 char *g_isodir_device; 48 49 50 /** 51 * The format of @p g_isodir_device. Ignored unless @p g_ISO_restore_mode. 52 */ 53 char *g_isodir_format; 54 45 55 extern long g_current_progress, g_maximum_progress; 46 56 extern char *g_biggielist_txt; // where 'biggielist.txt' is stored, on ramdisk / tempdir; … … 264 274 **************************************************************************/ 265 275 276 /** 277 * Get information about the location of ISO images from the user. 278 * @param isodir_device Where to put the device (e.g. /dev/hda4) the user enters. 279 * @param isodir_format Where to put the format (e.g. ext2) the user enters. 280 * @param nuke_me_please Whether we're planning on nuking or not. 281 * @return TRUE if OK was pressed, FALSE otherwise. 282 */ 283 bool 284 get_isodir_info(char *isodir_device, char *isodir_format, 285 struct s_bkpinfo *bkpinfo, bool nuke_me_please) 286 { 287 288 bool HDD = FALSE; 289 /** initialize ********************************************************/ 290 291 assert(isodir_device != NULL); 292 assert(isodir_format != NULL); 293 assert(bkpinfo->isodir != NULL); 294 295 log_it("bkpinfo->isodir = %s", bkpinfo->isodir); 296 isodir_format[0] = '\0'; 297 if (isodir_device[0] == '\0') { 298 strcpy(isodir_device, "/dev/"); 299 } 300 if (bkpinfo->isodir[0] == '\0') { 301 strcpy(bkpinfo->isodir, "/"); 302 } 303 if (does_file_exist("/tmp/NETFS-SERVER-PATH")) { 304 strcpy(isodir_device, last_line_of_file("/tmp/NETFS-SERVER-MOUNT")); 305 strcpy(isodir_format, "netfs"); 306 strcpy(bkpinfo->isodir, last_line_of_file("/tmp/NETFS-SERVER-PATH")); 307 } 308 if (nuke_me_please) { 309 return (TRUE); 310 } 311 312 if (popup_and_get_string 313 ("ISO Mode - device", "On what device do the ISO files live?", 314 isodir_device, MAX_STR_LEN / 4)) { 315 if (popup_and_get_string 316 ("ISO Mode - format", 317 "What is the disk format of the device? (Hit ENTER if you don't know.)", 318 isodir_format, 16)) { 319 if (popup_with_buttons("Are you restoring from an external hard drive ?", "Yes", "No")) { 320 HDD = TRUE; 321 } 322 if (popup_and_get_string 323 ("ISO Mode - path", 324 "At what path on this device can the ISO files be found ?", 325 bkpinfo->isodir, MAX_STR_LEN / 4)) { 326 strip_spaces(isodir_device); 327 strip_spaces(isodir_format); 328 strip_spaces(bkpinfo->isodir); 329 log_it("isodir_device = %s - isodir_format = %s - bkpinfo->isodir = %s", isodir_device, isodir_format, bkpinfo->isodir); 330 if (HDD) { 331 /* We need an additional param */ 332 mr_asprintf(&(bkpinfo->subdir), "%s", bkpinfo->isodir); 333 strcpy(bkpinfo->isodir, "/tmp/isodir"); 334 log_it("Now bkpinfo->isodir = %s and subdir = ", bkpinfo->isodir, bkpinfo->subdir); 335 } 336 return (TRUE); 337 } 338 } 339 } 340 return (FALSE); 341 } 266 342 267 343 … … 299 375 } 300 376 301 if (!get_isodir_info(g_isodir_device, g_isodir_format, bkpinfo ->isodir, bkpinfo->subdir, nuke_me_please)) {377 if (!get_isodir_info(g_isodir_device, g_isodir_format, bkpinfo, nuke_me_please)) { 302 378 return (1); 303 379 } … … 643 719 // assert_string_is_neither_NULL_nor_zerolength(cfg_file); 644 720 assert(bkpinfo != NULL); 721 log_it("Entering read_cfg_file_into_bkpinfo"); 645 722 646 723 if (!cfgf) { … … 665 742 bkpinfo->please_dont_eject = TRUE; 666 743 } else if (!strcmp(value, "iso")) { 667 668 // Patch by Conor Daly - 2004/07/12669 744 bkpinfo->backup_media_type = iso; 670 745 if (am_I_in_disaster_recovery_mode()) { 671 746 /* Check to see if CD is already mounted before mounting it... */ 672 747 if (!is_this_device_mounted("/dev/cdrom")) { 673 log_msg(2, 674 "NB: CDROM device not mounted, mounting..."); 675 run_program_and_log_output("mount /dev/cdrom " 676 MNT_CDROM, 1); 748 log_msg(2, "NB: CDROM device not mounted, mounting..."); 749 run_program_and_log_output("mount /dev/cdrom " MNT_CDROM, 1); 677 750 } 678 751 if (does_file_exist(MNT_CDROM "/archives/filelist.0")) { 679 752 bkpinfo->backup_media_type = cdr; 680 753 run_program_and_log_output("umount -d " MNT_CDROM, 1); 681 log_it 682 ("Re-jigging configuration AGAIN. CD-R, not ISO."); 754 log_it("Re-jigging configuration AGAIN. CD-R, not ISO."); 683 755 } 684 756 } 685 757 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 686 758 strcpy(bkpinfo->prefix,value); 687 759 } else { 688 strcpy(bkpinfo->prefix,STD_PREFIX); 689 } 760 strcpy(bkpinfo->prefix,STD_PREFIX); 761 } 762 log_it("Setting Prefix to %s", bkpinfo->prefix); 690 763 } else if ((!strcmp(value, "netfs")) || (!strcmp(value, "nfs"))) { 691 764 /* Stay compatible with previous versions by allowing nfs as an entry here */ … … 757 830 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* we don't really need this var */ 758 831 bkpinfo->media_size = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ 759 log_msg(2, "Backup medium is CD-R[W]");832 log_msg(2, "Backup medium is similar to CD-R[W]"); 760 833 } 761 834 } else { … … 843 916 844 917 read_cfg_var(g_mondo_cfg_file, "please-dont-eject", tmp); 845 if (tmp[0] 846 || 847 strstr(call_program_and_get_last_line_of_output 848 ("cat /proc/cmdline"), "donteject")) { 849 bkpinfo->please_dont_eject = TRUE; 850 log_msg(2, "Ok, I shan't eject when restoring! Groovy."); 918 if (tmp[0] || strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "donteject")) { 919 bkpinfo->please_dont_eject = TRUE; 920 log_msg(2, "Ok, I shan't eject when restoring! Groovy."); 851 921 } 852 922 … … 897 967 strcpy(bkpinfo->isodir, old_isodir); 898 968 } 899 if ( !bkpinfo->disaster_recovery) {969 if ((!bkpinfo->disaster_recovery) || (g_isodir_device[0] != '\0')) { 900 970 if (strcmp(old_isodir, bkpinfo->isodir)) { 901 971 log_it … … 905 975 } 906 976 } 907 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 908 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, 909 g_isodir_device); 977 if (g_isodir_device[0] == '\0') { 978 /* We don't want to loose our conf made earlier in iso_fiddly_bits 979 * so go here only if job not done already */ 980 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 981 } 982 983 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device); 910 984 if (bkpinfo->disaster_recovery) { 911 985 if (is_this_device_mounted(g_isodir_device)) { 912 986 log_msg(2, "NB: isodir is already mounted"); 913 987 /* Find out where it's mounted */ 914 sprintf(command, 915 "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", 916 g_isodir_device); 988 sprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device); 917 989 log_it("command = %s", command); 918 990 log_it("res of it = %s", … … 941 1013 } 942 1014 /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */ 943 if (bkpinfo->backup_media_type == iso) { 1015 /* except when already done is iso_fiddly_bits */ 1016 if ((bkpinfo->backup_media_type == iso) && (g_isodir_device[0] == '\0')) { 944 1017 sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 945 1018 } … … 950 1023 if (g_restoring_live_from_cd) { 951 1024 if (bkpinfo->backup_media_type != media_specified_by_user) { 952 log_msg(2, 953 "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)"); 1025 log_msg(2, "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)"); 954 1026 interactively_obtain_media_parameters_from_user(FALSE); 955 1027 media_specified_by_user = bkpinfo->backup_media_type;
Note:
See TracChangeset
for help on using the changeset viewer.