Changeset 3190 in MondoRescue for branches/3.1/mondo/src/common/libmondo-tools.c
- Timestamp:
- Sep 25, 2013, 8:55:43 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/mondo/src/common/libmondo-tools.c
r3161 r3190 57 57 */ 58 58 char *g_mondo_home = NULL; 59 60 /** 61 * The serial string (used to differentiate between backups) of the current backup. 62 */ 63 char *g_serial_string = NULL; 59 64 60 65 /** … … 363 368 assert(bkpinfo != NULL); 364 369 365 if (!bkpinfo->tmpdir) {366 fatal_error("Tmpdir set to NULL !");367 }368 369 370 bkpinfo->optimal_set_size = 370 371 (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) * 371 372 1024; 372 373 if (strlen(bkpinfo->tmpdir) < 2) {374 log_it("tmpdir is blank/missing");375 retval++;376 }377 373 378 374 log_msg(1, "Post-param"); … … 393 389 } 394 390 mr_free(tmp); 395 }396 if (bkpinfo->scratchdir) {397 make_hole_for_dir(bkpinfo->scratchdir);398 chmod(bkpinfo->scratchdir, 0700);399 } else {400 fatal_error("Scratchdir set to NULL !");401 391 } 402 392 if (bkpinfo->backup_media_type == iso) … … 461 451 } 462 452 #endif 463 else 464 { 453 else { 465 454 mr_asprintf(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX); 466 455 } 467 456 if (bkpinfo->manual_cd_tray) { 468 paranoid_free(mondo_mkisofs_sz);469 457 fatal_error("Manual CD tray + DVD not supported yet."); 470 458 // -m isn't supported by growisofs, BTW... 471 } else { 472 if (bkpinfo->media_device == NULL) { 473 return(1); 474 } 459 } else {} 475 460 mr_free(bkpinfo->call_make_iso); 476 461 mr_asprintf(bkpinfo->call_make_iso, "%s %s -Z %s . 2>> _ERR_", mondo_mkisofs_sz, "", bkpinfo->media_device); 477 paranoid_free(mondo_mkisofs_sz);478 }462 } 463 mr_free(mondo_mkisofs_sz); 479 464 if (getenv ("SUDO_COMMAND")) { 480 465 mr_asprintf(command, "strings `which growisofs` | grep -c SUDO_COMMAND"); … … 506 491 } 507 492 if (find_home_of_exe("cdrecord")) { 508 strcpy(cdr_exe, "cdrecord");493 mr_asprintf(cdr_exe, "cdrecord"); 509 494 } else if (find_home_of_exe("dvdrecord")) { 510 strcpy(cdr_exe, "dvdrecord");495 mr_asprintf(cdr_exe, "dvdrecord"); 511 496 } else { 512 497 mr_free(tmp); … … 569 554 } 570 555 mr_free(cdr_exe); 571 paranoid_free(mondo_mkisofs_sz);572 paranoid_free(extra_cdrom_params);556 mr_free(mondo_mkisofs_sz); 557 mr_free(extra_cdrom_params); 573 558 } // end of CD code 574 559 … … 587 572 iso_dev = call_program_and_get_last_line_of_output(command,TRUE); 588 573 log_it("res of it = %s", iso_dev); 574 mr_asprintf(tmp, "%s/ISO-DEV", bkpinfo->tmpdir); 575 write_one_liner_data_file(tmp, iso_dev); 576 mr_free(tmp); 589 577 mr_free(command); 590 578 … … 595 583 iso_mnt = call_program_and_get_last_line_of_output(command,TRUE); 596 584 log_it("res of it = %s", iso_mnt); 585 mr_asprintf(tmp, "%s/ISO-MNT", bkpinfo->tmpdir); 586 write_one_liner_data_file(tmp, iso_mnt); 587 mr_free(tmp); 597 588 mr_free(command); 598 589 … … 602 593 mr_asprintf(iso_path, "%s", ""); 603 594 } else { 604 // If iso_mnt is only / then iso_path is the full dir 595 // If iso_mnt is only / then iso_path is the full dir 605 596 // (the formula bellow doesn't work in this case) 606 597 if (strcmp(iso_mnt, "/") == 0) { … … 614 605 mr_free(iso_tmp); 615 606 607 mr_asprintf(tmp, "%s/ISODIR", bkpinfo->tmpdir); 608 write_one_liner_data_file(tmp, iso_path); 609 mr_free(tmp); 610 616 611 log_it("isodir: %s", iso_path); 617 612 mr_free(iso_path); 613 614 mr_asprintf(tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir); 615 write_one_liner_data_file(tmp, bkpinfo->prefix); 616 mr_free(tmp); 618 617 619 618 log_it("iso-prefix: %s", bkpinfo->prefix); … … 666 665 } 667 666 if (bkpinfo->include_paths == NULL) { 668 mr_asprintf(p, "/"); 669 bkpinfo->include_paths = p; 667 mr_asprintf(bkpinfo->include_paths, "/"); 670 668 } 671 669 g_backup_media_type = bkpinfo->backup_media_type; … … 731 729 if ((bkpinfo->tmpdir != NULL) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) { 732 730 /* purging a potential old tmpdir */ 733 log_it("Purging old tmpdir %s", bkpinfo->tmpdir);734 731 if (chdir("/tmp")) { 735 732 // FIXME … … 757 754 finish(-1); 758 755 } 759 760 756 bkpinfo->tmpdir = p; 761 757 log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir); 758 759 mr_asprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir); 760 paranoid_system(tmp); 761 mr_free(tmp); 762 } 763 764 765 void setup_scratchdir(char *path) { 766 767 char *tmp = NULL; 768 char *p = NULL; 769 770 if (bkpinfo->scratchdir != NULL) { 771 /* purging a potential old scratchdir */ 772 if (chdir("/tmp")) { 773 // FIXME 774 } 775 if (strstr(bkpinfo->scratchdir,"mondo.scratch.") != NULL) { 776 log_it("Purging old scratchdir %s", bkpinfo->scratchdir); 777 mr_asprintf(tmp,"rm -Rf %s",bkpinfo->scratchdir); 778 } else { 779 log_it("Purging old scratchdir %s/mondo.scratch.*", bkpinfo->scratchdir); 780 mr_asprintf(tmp,"rm -Rf %s/mondo.scratch.*",bkpinfo->scratchdir); 781 } 782 paranoid_system(tmp); 783 mr_free(tmp); 784 } 785 786 /* Always take in account arg first, then env, then default */ 787 if (path != NULL) { 788 mr_asprintf(tmp, "%s/mondo.scratch.XXXXXX", path); 789 } else if (getenv("MRSCRATCH")) { 790 mr_asprintf(tmp, "%s/mondo.scratch.XXXXXX", getenv("MRSCRATCH")); 791 } else { 792 mr_asprintf(tmp, "/tmp/mondo.scratch.XXXXXX"); 793 } 794 p = mkdtemp(tmp); 795 if (p == NULL) { 796 log_it("Failed to create global scratch directory %s for Mondo.",tmp); 797 finish(-1); 798 } 799 strcpy(bkpinfo->scratchdir,p); 800 log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir); 801 paranoid_free(tmp); 802 803 mr_asprintf(tmp, "mkdir -p %s", bkpinfo->scratchdir); 804 paranoid_system(tmp); 805 mr_free(tmp); 762 806 } 763 807 … … 805 849 bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo)); 806 850 807 /* We need tmpdir as early as possible for further function calls */808 bkpinfo->tmpdir = NULL; // Really setup after809 setup_tmpdir(NULL);810 811 851 /* Initialized in same order as in the structure declaration to detect errors more easily */ 812 852 bkpinfo->media_device = NULL; 813 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { 814 bkpinfo->media_size[i] = -1; 815 } 853 bkpinfo->media_size = -1; 816 854 bkpinfo->boot_loader = '\0'; 817 855 bkpinfo->boot_device = NULL; … … 828 866 bkpinfo->use_star = FALSE; 829 867 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 868 869 /* We need tmpdir as early as possible for further function calls */ 870 bkpinfo->tmpdir = NULL; // Really setup after 871 setup_tmpdir(NULL); 872 setup_scratchdir(NULL); 873 830 874 bkpinfo->disaster_recovery = am_I_in_disaster_recovery_mode(); 831 875 if (bkpinfo->disaster_recovery) { … … 835 879 } 836 880 mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX); 837 /* bkpinfo->tmpdir is here in the struct */838 bkpinfo->scratchdir = NULL; // Really setup after839 881 bkpinfo->optimal_set_size = 0; 840 882 bkpinfo->backup_media_type = none; 841 883 bkpinfo->make_filelist = TRUE; // unless -J supplied to mondoarchive 884 bkpinfo->exclude_paths = NULL; 842 885 bkpinfo->include_paths = NULL; 843 bkpinfo->exclude_paths = NULL;844 886 bkpinfo->exclude_devs = NULL; 845 887 bkpinfo->restore_path = NULL; … … 850 892 bkpinfo->kernel_path = NULL; 851 893 bkpinfo->netfs_mount = NULL; 894 bkpinfo->netfs_proto = NULL; 895 bkpinfo->netfs_user = NULL; 852 896 bkpinfo->netfs_remote_dir = NULL; 853 bkpinfo->netfs_user = NULL;854 bkpinfo->netfs_proto = NULL;855 897 bkpinfo->postnuke_tarball = NULL; 856 898 bkpinfo->subdir = NULL; … … 864 906 bkpinfo->use_obdr = FALSE; 865 907 bkpinfo->restore_mode = interactive; 866 867 sensibly_set_scratchdir(); 868 } 869 870 908 } 871 909 872 910 … … 1218 1256 mr_asprintf(command, "mount | grep -Ew '/boot'"); 1219 1257 mr_free(tmp); 1258 1220 1259 tmp = call_program_and_get_last_line_of_output(command,TRUE); 1221 1260 mr_free(command); 1222 1261 1223 1262 if (!strcmp(tmp,"")) { 1224 if ((strstr(tmp, "LABEL=") != NULL) || (strstr(tmp,"UUID=") != NULL)) {1263 if ((strstr(tmp, "LABEL=") != NULL) || (strstr(tmp,"UUID=") != NULL)) { 1225 1264 if (!run_program_and_log_output("mount /boot", 5)) { 1226 1265 strcpy(g_boot_mountpt, "/boot");
Note:
See TracChangeset
for help on using the changeset viewer.