Changeset 1663 in MondoRescue for branches/stable/mondo/src/common/libmondo-tools.c
- Timestamp:
- Sep 27, 2007, 12:21:18 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-tools.c
r1639 r1663 23 23 #include <sys/socket.h> 24 24 #include <netdb.h> 25 #include <stdlib.h> 25 26 #include <netinet/in.h> 26 27 #include <arpa/inet.h> … … 39 40 40 41 extern struct mr_ar_conf *mr_conf; 42 43 /* Reference to global bkpinfo */ 44 extern struct s_bkpinfo *bkpinfo; 41 45 42 46 /** … … 347 351 * do not exist. 348 352 */ 349 int post_param_configuration( struct s_bkpinfo *bkpinfo)353 int post_param_configuration() 350 354 { 351 355 char *extra_cdrom_params = NULL; … … 383 387 } 384 388 make_hole_for_dir(bkpinfo->scratchdir); 385 make_hole_for_dir(bkpinfo->tmpdir);386 389 if (bkpinfo->backup_media_type == iso) 387 390 make_hole_for_dir(bkpinfo->isodir); … … 620 623 } 621 624 } 622 store_nfs_config( bkpinfo);625 store_nfs_config(); 623 626 mr_free(hostname); 624 627 } … … 638 641 } 639 642 chmod(bkpinfo->scratchdir, 0700); 640 chmod(bkpinfo->tmpdir, 0700);641 643 g_backup_media_type = bkpinfo->backup_media_type; 642 644 g_backup_media_string = bkpinfo->backup_media_string; … … 652 654 * @return number of errors (0 for success) 653 655 */ 654 int pre_param_configuration( struct s_bkpinfo *bkpinfo)656 int pre_param_configuration() 655 657 { 656 658 int res = 0; 659 char *tmp = NULL; 657 660 658 661 make_hole_for_dir(MNT_CDROM); … … 660 663 srandom((unsigned long) (time(NULL))); 661 664 insmod_crucial_modules(); 662 reset_bkpinfo(bkpinfo); // also sets defaults ('/'=backup path, 3=compression level)663 665 if (bkpinfo->disaster_recovery) { 664 666 if (!does_nonMS_partition_exist()) { … … 668 670 } 669 671 670 run_program_and_log_output("rm -Rf /tmp/changed.files*", FALSE); 672 asprintf(&tmp,"rm -Rf %s/changed.files*",MINDI_CACHE); 673 run_program_and_log_output(tmp, FALSE); 674 paranoid_free(tmp); 671 675 res += some_basic_system_sanity_checks(); 672 676 if (res) { … … 678 682 } 679 683 680 684 void setup_tmpdir(char *path) { 685 686 char *tmp = NULL; 687 char *p = NULL; 688 689 if (bkpinfo->tmpdir != NULL) { 690 /* purging a potential old tmpdir */ 691 asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir); 692 system(tmp); 693 paranoid_free(tmp); 694 } 695 696 if (path != NULL) { 697 asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path); 698 } else if (getenv("TMPDIR")) { 699 asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMPDIR")); 700 } else if (getenv("TMP")) { 701 asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMP")); 702 } else { 703 asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX"); 704 } 705 p = mkdtemp(tmp); 706 if (p == NULL) { 707 log_it("Failed to create global tmp directory %s for Mondo.",tmp); 708 finish(-1); 709 } 710 strcpy(bkpinfo->tmpdir,p); 711 paranoid_free(tmp); 712 713 //sprintf(bkpinfo->tmpdir, "%s/tmpfs/mondo.tmp.%d", "/tmp", (int) (random() % 32768)); // for mondorestore 714 } 681 715 682 716 … … 685 719 * @param bkpinfo The @c bkpinfo to reset. 686 720 */ 687 void reset_bkpinfo( struct s_bkpinfo *bkpinfo)721 void reset_bkpinfo() 688 722 { 689 723 char *tmp = NULL; … … 694 728 /* BERLIOS : Useless ?? */ 695 729 memset((void *) bkpinfo, 0, sizeof(struct s_bkpinfo)); 730 731 /* special case for tmpdir as used eveywhere after */ 732 setup_tmpdir(NULL); 696 733 697 734 bkpinfo->manual_tray = mr_conf->manual_tray; … … 726 763 bkpinfo->scratchdir[0] = '\0'; 727 764 bkpinfo->make_filelist = TRUE; // unless -J supplied to mondoarchive 728 sprintf(bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768)); // for mondorestore729 765 bkpinfo->optimal_set_size = 0; 730 766 bkpinfo->backup_media_type = none; … … 952 988 fatal_error("Please reinstall Mondo and Mindi."); 953 989 } 954 if (run_program_and_log_output 955 ("mindi --makemountlist /tmp/mountlist.txt.test", 5)) { 990 mr_asprintf(&tmp, "mindi --makemountlist %s/mountlist.txt.test", bkpinfo->tmpdir); 991 if (run_program_and_log_output(tmp, 5)) { 992 log_to_screen(tmp); 956 993 log_to_screen 957 (_(" Mindi --makemountlist /tmp/mountlist.txt.testfailed for some reason."));994 (_("failed for some reason.")); 958 995 log_to_screen 959 996 (_("Please run that command by hand and examine /var/log/mindi.log")); … … 964 1001 retval++; 965 1002 } 1003 mr_free(tmp); 966 1004 967 1005 if (!run_program_and_log_output("parted2fdisk -l | grep -i raid", 1) … … 1156 1194 return (1); 1157 1195 } 1158 mr_asprintf(&tempfile, 1159 call_program_and_get_last_line_of_output 1160 ("mktemp -q /tmp/mojo-jojo.blah.XXXXXX")); 1196 mr_asprintf(&tempfile, "%s/mojo-jojo.blah", bkpinfo->tmpdir); 1161 1197 if (does_file_exist(config_file)) { 1162 1198 mr_asprintf(&command, "grep -vE '^%s .*$' %s > %s", … … 1185 1221 { 1186 1222 if (mal) { 1187 iamhere("Malloc'ing globals");1188 1223 malloc_string(g_boot_mountpt); 1189 1224 malloc_string(g_tmpfs_mountpt); … … 1192 1227 malloc_string(g_magicdev_command); 1193 1228 } else { 1194 iamhere("Freeing globals");1195 1229 mr_free(g_boot_mountpt); 1196 1230 mr_free(g_tmpfs_mountpt);
Note:
See TracChangeset
for help on using the changeset viewer.