Changeset 2321 in MondoRescue
- Timestamp:
- Aug 18, 2009, 2:37:55 PM (16 years ago)
- Location:
- branches/2.2.10/mondo/src
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2320 r2321 436 436 mr_free(tmp); 437 437 438 mr_asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, 439 bkpinfo->tmpdir); 438 mr_asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir); 440 439 if (run_program_and_log_output(tmp, 2)) { 441 440 mr_free(tmp); … … 1431 1430 register_in_tape_catalog(fileset, storing_set_no, -1, 1432 1431 storing_afioball_fname); 1433 maintain_collection_of_recent_archives(bkpinfo->tmpdir, 1434 storing_afioball_fname); 1432 maintain_collection_of_recent_archives(storing_afioball_fname); 1435 1433 log_it("Writing EXAT files"); 1436 1434 res += … … 2204 2202 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2205 2203 register_in_tape_catalog(fileset, curr_set_no, -1, curr_afioball_fname); 2206 maintain_collection_of_recent_archives( bkpinfo->tmpdir,curr_afioball_fname);2204 maintain_collection_of_recent_archives(curr_afioball_fname); 2207 2205 log_it("Writing EXAT files"); 2208 2206 res += … … 3107 3105 register_in_tape_catalog(biggieslice, biggie_file_number, 3108 3106 slice_num, file_to_archive); 3109 maintain_collection_of_recent_archives(bkpinfo->tmpdir, 3110 file_to_archive); 3107 maintain_collection_of_recent_archives(file_to_archive); 3111 3108 res = move_files_to_stream(file_to_archive, NULL); 3112 3109 } else { -
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2320 r2321 548 548 DSFptr->check = 1; 549 549 } 550 mr_free(token); 550 551 } 551 mr_free(token);552 552 mr_free(mount_list); 553 553 } else { … … 791 791 /* Fatal error; exit */ 792 792 case 1: 793 mr_free(token); 793 794 fatal_error("Error processing -I option"); 794 795 /* Everything is OK; process to archive data */ … … 1509 1510 if (opt == '?') { 1510 1511 bad_switches = TRUE; 1511 /*log_it("Invalid option: %c\n",optopt); */1512 1512 } else { 1513 1513 if (flag_set[opt]) { -
branches/2.2.10/mondo/src/common/libmondo-devices-EXT.h
r1647 r2321 49 49 extern char *list_of_NFS_mounts_only(void); 50 50 51 extern void sensibly_set_ tmpdir_and_scratchdir();51 extern void sensibly_set_scratchdir(); 52 52 53 53 -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2320 r2321 42 42 extern char *MONDO_LOGFILE; 43 43 44 extern void setup_tmpdir(char *path);45 46 44 static char g_cdrw_drive_is_here[MAX_STR_LEN / 4] = ""; 47 45 static char g_cdrom_drive_is_here[MAX_STR_LEN / 4] = ""; … … 111 109 bool is_this_a_ramdisk = FALSE; 112 110 113 malloc_string(comment);114 111 mr_asprintf(&tmp, "%s", where_is_root_mounted()); 115 mr_asprintf(&comment, "root is mounted at %s\n", tmp);112 mr_asprintf(&comment, "root is currently mounted at %s\n", tmp); 116 113 log_msg(0, comment); 117 114 mr_free(comment); 118 log_msg(0,119 "No, Schlomo, that doesn't mean %s is the root partition. It's just a debugging message. Relax. It's part of am_I_in_disaster_recovery_mode().",120 tmp);121 115 122 116 #ifdef __FreeBSD__ … … 138 132 if (is_this_a_ramdisk) { 139 133 if (!does_file_exist("/THIS-IS-A-RAMDISK")) { 140 log_to_screen 141 ("Using /dev/root is stupid of you but I'll forgive you."); 134 log_to_screen("Using /dev/root is stupid of you but I'll forgive you."); 142 135 is_this_a_ramdisk = FALSE; 143 136 } … … 146 139 is_this_a_ramdisk = TRUE; 147 140 } 148 log_msg(1, "Is this a ramdisk? result = % d", is_this_a_ramdisk);141 log_msg(1, "Is this a ramdisk? result = %s", (is_this_a_ramdisk) ? "TRUE" : "FALSE"); 149 142 return (is_this_a_ramdisk); 150 143 } … … 1374 1367 mr_asprintf(&tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want); 1375 1368 if (does_file_exist(tmp)) { 1376 log_msg(1, 1377 "FIXME - hacking bkpinfo->isodir from '%s' to %s/isodir", 1378 bkpinfo->isodir, bkpinfo->tmpdir); 1369 log_msg(1, "FIXME - hacking bkpinfo->isodir from '%s' to %s/isodir", bkpinfo->isodir, bkpinfo->tmpdir); 1379 1370 sprintf(bkpinfo->isodir, "%s/isodir", bkpinfo->tmpdir); 1380 1371 } … … 1474 1465 } 1475 1466 */ 1476 log_msg(3, "media type = %s", 1477 bkptype_to_string(bkpinfo->backup_media_type)); 1478 if (archiving_to_media) { 1479 sensibly_set_tmpdir_and_scratchdir(); 1480 } 1467 log_msg(3, "media type = %s", bkptype_to_string(bkpinfo->backup_media_type)); 1481 1468 bkpinfo->cdrw_speed = (bkpinfo->backup_media_type == cdstream) ? 2 : 4; 1482 1469 bkpinfo->compression_level = … … 1971 1958 finish(1); 1972 1959 } 1973 strcpy(bkpinfo->tmpdir, p);1974 mr_free(p);1960 mr_free(bkpinfo->tmpdir); 1961 bkpinfo->tmpdir = p; 1975 1962 1976 1963 p = popup_and_get_string("Scratch directory", "Please enter your scratch directory.", bkpinfo->scratchdir); … … 2140 2127 * @ingroup utilityGroup 2141 2128 */ 2142 void sensibly_set_ tmpdir_and_scratchdir()2129 void sensibly_set_scratchdir() 2143 2130 { 2144 2131 char *tmp = NULL; 2145 2132 char *command = NULL; 2146 2133 char *sz = NULL; 2147 2148 assert(bkpinfo != NULL);2149 2134 2150 2135 #ifdef __FreeBSD__ … … 2161 2146 } 2162 2147 if (!tmp[0]) { 2163 fatal_error("I couldn't figure out the tempdir!"); 2164 } 2165 setup_tmpdir(tmp); 2166 log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir); 2167 2148 fatal_error("I couldn't figure out the scratchdir!"); 2149 } 2168 2150 mr_asprintf(&sz, "%s/mondo.scratch.%d", tmp, (int) (random() % 32768)); 2169 2151 mr_free(bkpinfo->scratchdir); … … 2171 2153 log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir); 2172 2154 2173 mr_asprintf(&command, "rm -Rf %s/ tmp.mondo.* %s/mondo.scratch.*", tmp, tmp);2155 mr_asprintf(&command, "rm -Rf %s/mondo.scratch.*", tmp); 2174 2156 mr_free(tmp); 2175 2157 -
branches/2.2.10/mondo/src/common/libmondo-devices.h
r1647 r2321 41 41 char *list_of_NFS_mounts_only(); 42 42 43 void sensibly_set_ tmpdir_and_scratchdir();43 void sensibly_set_scratchdir(); 44 44 45 45 -
branches/2.2.10/mondo/src/common/libmondo-filelist-EXT.h
r1647 r2321 1 1 /* libmondo-filelist-EXT.h */ 2 2 3 extern int chop_filelist(char *filelist, char *outdir,long maxsetsizeK);3 extern int chop_filelist(char *filelist, long maxsetsizeK); 4 4 extern int call_filelist_chopper(); 5 5 extern void free_filelist(struct s_node *filelist); -
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2320 r2321 36 36 37 37 38 int mondo_makefilelist(char *logfile, char *tmpdir, char *scratchdir, 39 char *include_paths, char *excp, int differential, 40 char *userdef_filelist); 38 int mondo_makefilelist(char *logfile, char *include_paths, char *excp, int differential, char *userdef_filelist); 41 39 42 40 … … 106 104 } 107 105 108 noof_sets = chop_filelist(filelist, bkpinfo-> tmpdir, bkpinfo->optimal_set_size);106 noof_sets = chop_filelist(filelist, bkpinfo->optimal_set_size); 109 107 mr_free(filelist); 110 108 estimate_noof_media_required(noof_sets); // for cosmetic purposes … … 194 192 * 195 193 * @param filelist The big filelist (filelist.full) to chop up. 196 * @param outdir The directory to place the files (filelist.N where N is197 * an integer, biggielist.txt, and LAST-FILELIST-NUMBER) created198 194 * @param maxsetsizeK Optimal size of a fileset (X above). 199 195 * @return number of errors encountered (0 for success). 200 196 */ 201 int chop_filelist(char *filelist, char *outdir,long maxsetsizeK)197 int chop_filelist(char *filelist, long maxsetsizeK) 202 198 { 203 199 /*@ long ****************************************/ … … 228 224 229 225 assert_string_is_neither_NULL_nor_zerolength(filelist); 230 assert_string_is_neither_NULL_nor_zerolength(outdir);231 226 assert(maxsetsizeK > 0); 232 227 … … 245 240 curr_set_no = 0; 246 241 curr_set_size = 0; 247 mr_asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no);248 mr_asprintf(&biggie_fname, "%s/biggielist.txt", outdir);242 mr_asprintf(&outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no); 243 mr_asprintf(&biggie_fname, "%s/biggielist.txt", bkpinfo->tmpdir); 249 244 log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname); 250 245 if (!(fbig = fopen(biggie_fname, "w"))) { … … 298 293 curr_set_size = 0; 299 294 300 mr_asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no);295 mr_asprintf(&outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no); 301 296 if (!(fout = fopen(outfname, "w"))) { 302 297 log_OS_error("Unable to openout outfname"); … … 328 323 mr_free(biggie_fname); 329 324 330 mr_asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", outdir);325 mr_asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir); 331 326 mr_asprintf(&tmp, "%ld", curr_set_no); 332 327 if (write_one_liner_data_file(outfname, tmp)) { … … 1307 1302 if (bkpinfo->make_filelist) { 1308 1303 res = 1309 mondo_makefilelist(MONDO_LOGFILE, bkpinfo-> tmpdir, bkpinfo->scratchdir, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);1304 mondo_makefilelist(MONDO_LOGFILE, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL); 1310 1305 } else { 1311 1306 res = 1312 mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir,NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);1307 mondo_makefilelist(MONDO_LOGFILE, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths); 1313 1308 } 1314 1309 … … 1377 1372 while((token = mr_strtok(sth, delims, &lastpos))) { 1378 1373 mr_strcat(find_excludes," -path %s -prune -o", token); 1374 mr_free(token); 1379 1375 } 1380 1376 } … … 1542 1538 * Create the filelist for the backup. It will be stored in [scratchdir]/archives/filelist.full. 1543 1539 * @param logfile Unused. 1544 * @param tmpdir The tmpdir of the backup.1545 * @param scratchdir The scratchdir of the backup.1546 1540 * @param include_paths The paths to back up, or NULL if you're using a user-defined filelist. 1547 1541 * @param excp The paths to NOT back up. … … 1552 1546 * @bug Return value is meaningless. 1553 1547 */ 1554 int mondo_makefilelist(char *logfile, char *tmpdir, char *scratchdir, 1555 char *include_paths, char *excp, int differential, 1556 char *userdef_filelist) 1548 int mondo_makefilelist(char *logfile, char *include_paths, char *excp, int differential, char *userdef_filelist) 1557 1549 { 1558 1550 char *p, *q; … … 1577 1569 } 1578 1570 // make hole for filelist 1579 mr_asprintf(&command, "mkdir -p %s/archives", scratchdir);1571 mr_asprintf(&command, "mkdir -p %s/archives", bkpinfo->scratchdir); 1580 1572 paranoid_system(command); 1581 1573 mr_free(command); 1582 1574 1583 mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);1575 mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 1584 1576 make_hole_for_file(sz_filelist); 1585 1577 … … 1640 1632 mr_free(tmp1); 1641 1633 1642 mr_asprintf(&exclude_paths, " %s %s %s %s %s . .. " MNT_CDROM " " MNT_FLOPPY " /media /tmp /proc /sys " MINDI_CACHE, MONDO_CACHE, (excp == NULL) ? "" : excp, tmp2, ( tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) :scratchdir);1634 mr_asprintf(&exclude_paths, " %s %s %s %s %s . .. " MNT_CDROM " " MNT_FLOPPY " /media /tmp /proc /sys " MINDI_CACHE, MONDO_CACHE, (excp == NULL) ? "" : excp, tmp2, (bkpinfo->tmpdir[0] == '/' && bkpinfo->tmpdir[1] == '/') ? (bkpinfo->tmpdir + 1) : bkpinfo->tmpdir, (bkpinfo->scratchdir[0] == '/' && bkpinfo->scratchdir[1] == '/') ? (bkpinfo->scratchdir + 1) : bkpinfo->scratchdir); 1643 1635 mr_free(tmp2); 1644 1636 1645 1637 log_msg(2, "Excluding paths = '%s'", exclude_paths); 1646 1638 log_msg(2, "Generating skeleton filelist so that we can track our progress"); 1647 sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);1639 sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", bkpinfo->tmpdir); 1648 1640 make_hole_for_file(g_skeleton_filelist); 1649 1641 log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries); … … 1675 1667 } 1676 1668 log_msg(2, "Copying new filelist to scratchdir"); 1677 mr_asprintf(&command, "mkdir -p %s/archives", scratchdir);1669 mr_asprintf(&command, "mkdir -p %s/archives", bkpinfo->scratchdir); 1678 1670 paranoid_system(command); 1679 1671 mr_free(command); 1680 1672 1681 mr_asprintf(&command, "cp -f %s %s/archives/", sz_filelist, scratchdir);1673 mr_asprintf(&command, "cp -f %s %s/archives/", sz_filelist, bkpinfo->scratchdir); 1682 1674 paranoid_system(command); 1683 1675 mr_free(command); 1684 1676 1685 mr_asprintf(&command, "mv -f %s %s", sz_filelist, tmpdir);1677 mr_asprintf(&command, "mv -f %s %s", sz_filelist, bkpinfo->tmpdir); 1686 1678 paranoid_system(command); 1687 1679 mr_free(command); -
branches/2.2.10/mondo/src/common/libmondo-filelist.h
r1647 r2321 3 3 */ 4 4 5 int chop_filelist(char *filelist, char *outdir,long maxsetsizeK);5 int chop_filelist(char *filelist, long maxsetsizeK); 6 6 int call_filelist_chopper(); 7 7 void free_filelist(struct s_node *filelist); -
branches/2.2.10/mondo/src/common/libmondo-raid.c
r2260 r2321 1025 1025 } 1026 1026 // tokenise string 1027 token = mr_strtok 1027 token = mr_strtok(string, delims, &lastpos); 1028 1028 // get RAID device name 1029 1029 mr_asprintf(&strtmp,"%s%s", device_prefix, token); … … 1032 1032 mr_free(token); 1033 1033 // skip ':' and status 1034 token = mr_strtok 1034 token = mr_strtok(string, delims, &lastpos); 1035 1035 mr_free(token); 1036 token = mr_strtok 1036 token = mr_strtok(string, delims, &lastpos); 1037 1037 if (!strcmp(token, "inactive")) { 1038 1038 log_msg(1, "RAID device '%s' inactive.\n", … … 1045 1045 1046 1046 // get RAID level 1047 token = mr_strtok 1047 token = mr_strtok(string, delims, &lastpos); 1048 1048 if (!strcmp(token, "multipath")) { 1049 1049 raidlist->el[raidlist->entries].raid_level = -2; -
branches/2.2.10/mondo/src/common/libmondo-stream-EXT.h
r2303 r2321 8 8 extern void insist_on_this_tape_number(int tapeno); 9 9 extern void log_tape_pos(void); 10 extern int maintain_collection_of_recent_archives(char *td, 11 char *latest_fname); 10 extern int maintain_collection_of_recent_archives(char *latest_fname); 12 11 extern int openin_cdstream(); 13 12 extern int openin_tape(); -
branches/2.2.10/mondo/src/common/libmondo-stream.c
r2316 r2321 513 513 * assumed to be a fileset, otherwise if it contains "slice" it's a slice, 514 514 * otherwise we generate a fatal_error(). 515 * @param td The current @c bkpinfo->tempdir (file will be placed in <tt>td</tt>/tmpfs/backcatalog/).516 515 * @param latest_fname The file to place in the collection. 517 516 * @return 0, always. … … 519 518 * @bug The detection won't work for uncompressed afioballs (they end in ".afio", no dot afterwards). // Not true. They end in '.' -Hugo 520 519 */ 521 int maintain_collection_of_recent_archives(char * td, char *latest_fname)520 int maintain_collection_of_recent_archives(char *latest_fname) 522 521 { 523 522 long long final_alleged_writeK, final_projected_certain_writeK, … … 543 542 } else { 544 543 log_it("fname = %s", latest_fname); 545 fatal_error 546 ("Unknown type. Internal error in maintain_collection_of_recent_archives()"); 547 } 548 mr_asprintf(&tmpdir, "%s/tmpfs/backcatalog", td); 544 fatal_error("Unknown type. Internal error in maintain_collection_of_recent_archives()"); 545 } 546 mr_asprintf(&tmpdir, "%s/tmpfs/backcatalog", bkpinfo->tmpdir); 549 547 mkdir(tmpdir, 0x700); 550 548 mr_asprintf(&command, "cp -f %s %s", latest_fname, tmpdir); -
branches/2.2.10/mondo/src/common/libmondo-stream.h
r2303 r2321 10 10 void insist_on_this_tape_number(int tapeno); 11 11 void log_tape_pos(void); 12 int maintain_collection_of_recent_archives(char * td, char *latest_fname);12 int maintain_collection_of_recent_archives(char *latest_fname); 13 13 int openin_cdstream(); 14 14 int openin_tape(); -
branches/2.2.10/mondo/src/common/libmondo-string.c
r2318 r2321 513 513 mr_asprintf(&output, "%s%s", q, value); 514 514 } 515 p+ +;515 p+= strlen(token); 516 516 q = p; 517 517 } … … 692 692 numA = atol(stringA + start_of_numbers_in_A); 693 693 numB = atol(stringB + start_of_numbers_in_B); 694 /*695 sprintf(tmp,"Comparing %s and %s --> %ld,%ld\n",stringA,stringB,numA,numB);696 log_to_screen(tmp);697 */698 694 return ((int) (numA - numB)); 699 695 } -
branches/2.2.10/mondo/src/common/libmondo-tools-EXT.h
r1917 r2321 12 12 extern int read_cfg_var(char *config_file, char *label, char *value); 13 13 extern int write_cfg_var(char *config_file, char *label, char *value); 14 extern void reset_bkpinfo();14 extern void init_bkpinfo(); 15 15 #ifdef __FreeBSD__ 16 16 extern void initialize_raidrec(struct vinum_volume *vv); -
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2320 r2321 429 429 430 430 assert(bkpinfo != NULL); 431 432 if (!bkpinfo->tmpdir) { 433 fatal_error("Tmpdir set to NULL !"); 434 } 435 431 436 malloc_string(mtpt); 432 437 malloc_string(hostname); … … 435 440 (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) * 436 441 1024; 442 443 if (strlen(bkpinfo->tmpdir) < 2) { 444 log_it("tmpdir is blank/missing"); 445 retval++; 446 } 437 447 438 448 log_msg(1, "Foo"); … … 685 695 fprintf(stderr, "Type 'man mondoarchive' for help.\n"); 686 696 } 687 if (strlen(bkpinfo->tmpdir) < 2) {688 log_it("tmpdir is blank/missing");689 retval++;690 }691 697 if (bkpinfo->include_paths == NULL) { 692 698 mr_asprintf(&p, "/"); … … 751 757 if ((bkpinfo->tmpdir != NULL) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) { 752 758 /* purging a potential old tmpdir */ 759 log_it("Purging old tmpdir %s", bkpinfo->tmpdir); 753 760 mr_asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir); 754 system(tmp); 755 paranoid_free(tmp); 761 mr_free(bkpinfo->tmpdir); 762 (void)system(tmp); 763 mr_free(tmp); 756 764 } 757 765 … … 768 776 if (p == NULL) { 769 777 log_it("Failed to create global tmp directory %s for Mondo.",tmp); 778 mr_free(tmp); 770 779 finish(-1); 771 780 } 772 strcpy(bkpinfo->tmpdir,p); 773 paranoid_free(tmp); 774 } 775 781 782 bkpinfo->tmpdir = p; 783 log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir); 784 } 785 786 /* Free all memory allocated into bkpinfo */ 787 void mr_free_bkpinfo() { 788 789 mr_free(bkpinfo->scratchdir); 790 mr_free(bkpinfo->tmpdir); 791 mr_free(bkpinfo->include_paths); 792 mr_free(bkpinfo->exclude_paths); 793 mr_free(bkpinfo->nfs_user); 794 795 /* Then free the structure */ 796 mr_free(bkpinfo); 797 } 776 798 777 799 /** … … 779 801 * @param bkpinfo The @c bkpinfo to reset. 780 802 */ 781 void reset_bkpinfo()803 void init_bkpinfo() 782 804 { 783 805 int i; 784 806 785 807 log_msg(1, "Hi"); 786 assert(bkpinfo != NULL); 787 memset((void *) bkpinfo, 0, sizeof(struct s_bkpinfo)); 788 808 809 /* Initialized in same order as in the structure declaration to detect errors more easily */ 789 810 bkpinfo->media_device[0] = '\0'; 790 811 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { … … 805 826 bkpinfo->use_star = FALSE; 806 827 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 807 bkpinfo->disaster_recovery = 808 (am_I_in_disaster_recovery_mode()? TRUE : FALSE); 828 bkpinfo->disaster_recovery = (am_I_in_disaster_recovery_mode()? TRUE : FALSE); 809 829 if (bkpinfo->disaster_recovery) { 810 830 strcpy(bkpinfo->isodir, "/"); … … 813 833 } 814 834 strcpy(bkpinfo->prefix, STD_PREFIX); 815 sensibly_set_tmpdir_and_scratchdir();816 835 bkpinfo->scratchdir = NULL; 836 bkpinfo->tmpdir = NULL; 817 837 bkpinfo->optimal_set_size = 0; 838 bkpinfo->backup_media_type = none; 818 839 bkpinfo->make_filelist = TRUE; // unless -J supplied to mondoarchive 840 bkpinfo->include_paths = NULL; 841 bkpinfo->exclude_paths = NULL; 819 842 bkpinfo->restore_path[0] = '\0'; 820 843 bkpinfo->call_before_iso[0] = '\0'; … … 824 847 bkpinfo->kernel_path[0] = '\0'; 825 848 bkpinfo->nfs_mount[0] = '\0'; 849 bkpinfo->nfs_remote_dir[0] = '\0'; 826 850 bkpinfo->nfs_user = NULL; 827 bkpinfo->exclude_paths = NULL;828 bkpinfo->include_paths = NULL;829 bkpinfo->nfs_remote_dir[0] = '\0';830 851 bkpinfo->postnuke_tarball[0] = '\0'; 831 852 bkpinfo->wipe_media_first = FALSE; … … 838 859 bkpinfo->use_obdr = FALSE; 839 860 bkpinfo->restore_mode = interactive; 861 862 setup_tmpdir(NULL); 863 sensibly_set_scratchdir(); 840 864 } 841 865 … … 1339 1363 if (!(fout = fopen(MONDO_LOGFILE, "a"))) { 1340 1364 return; 1341 } // fatal_error("Failed to openout to logfile - sheesh..."); }1365 } 1342 1366 1343 1367 // add tabs to distinguish log levels -
branches/2.2.10/mondo/src/common/libmondo-tools.h
r1917 r2321 15 15 int read_cfg_var(char *config_file, char *label, char *value); 16 16 int write_cfg_var(char *config_file, char *label, char *value); 17 void reset_bkpinfo();17 void init_bkpinfo(); 18 18 #ifdef __FreeBSD__ 19 19 void initialize_raidrec(struct vinum_volume *vv); -
branches/2.2.10/mondo/src/common/libmondo-verify.c
r2296 r2321 312 312 bkpinfo->restore_path, 313 313 biggiestruct.filename); 314 mr_asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", 315 bkpinfo->restore_path, 316 biggiestruct.filename, 317 bkpinfo->tmpdir); 314 mr_asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir); 318 315 system(tmp); 319 316 mr_free(tmp); -
branches/2.2.10/mondo/src/common/mondostructures.h
r2320 r2321 25 25 26 26 /** @def MAX_NOOF_MEDIA The maximum number of media that can be used in any one backup. */ 27 28 27 ///* So we can override it in config.h: */ 29 28 //#ifndef MAX_NOOF_MEDIA … … 327 326 * that function may in turn pass the bkpinfo to other functions which use other fields. 328 327 * 329 * To fill out the bkpinfo first call reset_bkpinfo() and pre_param_configuration(). Then set328 * To fill out the bkpinfo first call init_bkpinfo() and pre_param_configuration(). Then set 330 329 * the backup-specific parameters (see mondo/mondoarchive/mondo-cli.c-\>process_switches for 331 330 * an example). After that, you should call post_param_configuration() to set some final … … 488 487 * of space here. 489 488 */ 490 char tmpdir[MAX_STR_LEN / 4];489 char *tmpdir; 491 490 492 491 /** … … 501 500 */ 502 501 t_bkptype backup_media_type; 503 // bool blank_dvd_first;504 502 505 503 /** … … 667 665 */ 668 666 bool expanded; 669 };670 671 672 673 /**674 * A structure to wrap a FIFO device for writing to a tape/CD stream.675 * @bug Is this structure used (w/the move to a standalone @c buffer and all)?676 */677 struct s_wrapfifo {678 /**679 * The device we write to or read from (a FIFO).680 */681 char public_device[MAX_STR_LEN / 4];682 683 /**684 * The actual device that data from the FIFO should be buffered and written to.685 */686 char private_device[MAX_STR_LEN / 4];687 688 /**689 * A buffer for holding data read from the FIFO.690 */691 char internal_buffer_IN_fifo[MAX_STR_LEN / 4];692 693 /**694 * A buffer for holding data to be written to the FIFO.695 */696 char internal_buffer_OUT_fifo[MAX_STR_LEN / 4];697 698 /**699 * If TRUE, then we're writing directly to the tape streamer; if FALSE, we're writing to the FIFO.700 */701 bool writing_to_private_device;702 667 }; 703 668 -
branches/2.2.10/mondo/src/common/newt-specific.c
r2320 r2321 33 33 34 34 extern struct s_bkpinfo *bkpinfo; 35 extern void mr_free_bkpinfo(); 35 36 36 37 /*@unused@*/ … … 280 281 mr_asprintf(&tmp1,"kill `%s`", tmp); 281 282 run_program_and_log_output(tmp1, TRUE); 282 paranoid_free(tmp1);283 } 284 paranoid_free(tmp);283 mr_free(tmp1); 284 } 285 mr_free(tmp); 285 286 } 286 287 … … 423 424 } 424 425 /* Free all allocated strings in bkpinfo */ 425 mr_free(bkpinfo->nfs_user); 426 mr_free(bkpinfo->exclude_paths); 427 mr_free(bkpinfo->include_paths); 428 mr_free(bkpinfo->scratchdir); 429 430 /* Then free the structure */ 431 mr_free(bkpinfo); 426 mr_free_bkpinfo(); 432 427 free_libmondo_global_strings(); 433 428 free_newt_stuff(); … … 601 596 strcpy(title, ttl); 602 597 strcpy(g_isoform_header_str, title); 603 // center_string (title, 80);604 598 if (g_text_mode) { 605 599 log_msg(0, title); … … 922 916 newtInit(); 923 917 newtCls(); 924 newtPushHelpLine 925 ("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed."); 926 /* newtDrawRootText(28,0,"Welcome to Mondo Rescue"); */ 918 newtPushHelpLine("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed."); 927 919 newtDrawRootText(18, 0, WELCOME_STRING); 928 920 newtRefresh(); -
branches/2.2.10/mondo/src/mondoarchive/mondoarchive.c
r2320 r2321 170 170 char *say_at_end = NULL; 171 171 172 /* Make sure I'm root; abort if not */173 if (getuid() != 0) {174 fprintf(stderr, "Please run as root.\r\n");175 exit(127);176 }177 178 /* If -V, -v or --version then echo version no. and quit */179 if (argc == 2180 && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")181 || !strcmp(argv[argc - 1], "--version"))) {182 printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION);183 exit(0);184 }185 186 172 /* Initialize variables */ 187 188 printf("Initializing...\n");189 if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {190 fatal_error("Cannot malloc bkpinfo");191 }192 reset_bkpinfo();193 173 194 174 res = 0; 195 175 retval = 0; 196 176 diffs = 0; 197 malloc_libmondo_global_strings(); 177 178 printf("Initializing...\n"); 179 180 bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo)); 181 init_bkpinfo(); 198 182 199 183 /* initialize log file with time stamp */ … … 201 185 log_msg(0, "Time started: %s", mr_date()); 202 186 187 /* Memory allocation is done in those functions */ 188 malloc_libmondo_global_strings(); 189 if (argc == 1) { 190 g_text_mode = FALSE; 191 } else { 192 g_text_mode = TRUE; 193 } 194 setup_newt_stuff(); 195 196 /* Make sure I'm root; abort if not */ 197 if (getuid() != 0) { 198 fatal_error("Please run as root.\n"); 199 } 200 201 /* If -V, -v or --version then echo version no. and quit */ 202 if (argc == 2 && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V") || !strcmp(argv[argc - 1], "--version"))) { 203 printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION); 204 finish(0); 205 } 206 207 203 208 /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */ 204 209 mr_asprintf(&tmp1,"%s:/sbin:/usr/sbin:/usr/local/sbin",getenv("PATH")); 205 210 setenv("PATH", tmp1, 1); 206 paranoid_free(tmp1);211 mr_free(tmp1); 207 212 208 213 /* Add the ARCH environment variable for ia64 purposes */ 209 214 mr_asprintf(&tmp1,"%s",get_architecture()); 210 215 setenv("ARCH", tmp1, 1); 211 paranoid_free(tmp1);216 mr_free(tmp1); 212 217 213 218 /* Add MONDO_SHARE environment variable for mindi */ … … 231 236 g_loglevel = 10; 232 237 g_text_mode = TRUE; 233 setup_newt_stuff();234 238 if (!strstr(argv[2], "filelist")) { 235 239 printf("Sorry - filelist goes first\n"); … … 242 246 if (argc == 4 && !strcmp(argv[1], "setfattr")) { 243 247 g_loglevel = 10; 244 g_text_mode = TRUE;245 setup_newt_stuff();246 248 finish(set_fattr_list(argv[2], argv[3])); 247 249 } … … 249 251 if (argc == 3 && !strcmp(argv[1], "wildcards")) { 250 252 g_loglevel = 10; 251 g_text_mode = TRUE;252 setup_newt_stuff();253 253 malloc_string(tmp); 254 254 turn_wildcard_chars_into_literal_chars(tmp, argv[2]); … … 260 260 if (argc == 4 && !strcmp(argv[1], "getfacl")) { 261 261 g_loglevel = 10; 262 g_text_mode = TRUE;263 setup_newt_stuff();264 262 if (!strstr(argv[2], "filelist")) { 265 263 printf("Sorry - filelist goes first\n"); … … 272 270 if (argc == 4 && !strcmp(argv[1], "setfacl")) { 273 271 g_loglevel = 10; 274 g_text_mode = TRUE;275 setup_newt_stuff();276 272 finish(set_acl_list(argv[2], argv[3])); 277 273 } … … 279 275 if (argc > 2 && !strcmp(argv[1], "find-cd")) { 280 276 g_loglevel = 10; 281 g_text_mode = TRUE;282 setup_newt_stuff();283 277 malloc_string(tmp); 284 278 if (find_cdrw_device(tmp)) { … … 299 293 if (argc > 2 && !strcmp(argv[1], "find-dvd")) { 300 294 g_loglevel = 10; 301 g_text_mode = TRUE;302 setup_newt_stuff();303 295 malloc_string(tmp); 304 296 if (find_dvd_device(tmp, atoi(argv[2]))) { … … 331 323 /* Process command line, if there is one. If not, ask user for info. */ 332 324 if (argc == 1) { 333 g_text_mode = FALSE;334 setup_newt_stuff();335 325 res = interactively_obtain_media_parameters_from_user(TRUE); /* yes, archiving */ 336 326 if (res) { … … 347 337 finish(1); 348 338 } 349 setup_newt_stuff();350 339 } 351 340 352 341 /* Finish configuring global structures */ 353 342 if (post_param_configuration()) { 354 fatal_error 355 ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting..."); 356 } 357 358 log_to_screen 359 ("BusyBox's sources are available from http://www.busybox.net"); 343 fatal_error("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting..."); 344 } 345 346 log_to_screen("BusyBox's sources are available from http://www.busybox.net"); 360 347 361 348 /* If we're meant to backup then backup */ … … 412 399 if (say_at_end != NULL) { 413 400 log_to_screen(say_at_end); 414 paranoid_free(say_at_end);401 mr_free(say_at_end); 415 402 } 416 403 mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir); -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c
r2296 r2321 675 675 0, "Verifying archives against filesystem"); 676 676 677 if (bkpinfo->disaster_recovery 678 && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 677 if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 679 678 strcpy(bkpinfo->media_device, 680 679 last_line_of_file("/tmp/CDROM-LIVES-HERE")); -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2316 r2321 1841 1841 void setup_MR_global_filenames() 1842 1842 { 1843 char *temppath;1844 1845 1843 assert(bkpinfo != NULL); 1846 1844 … … 1854 1852 malloc_string(g_isodir_device); 1855 1853 1856 temppath = bkpinfo->tmpdir; 1857 1858 sprintf(g_biggielist_txt, "%s/%s", temppath, BIGGIELIST_TXT_STUB); 1859 sprintf(g_filelist_full, "%s/%s", temppath, FILELIST_FULL_STUB); 1860 sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", temppath); 1861 sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", temppath); 1854 sprintf(g_biggielist_txt, "%s/%s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB); 1855 sprintf(g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB); 1856 sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir); 1857 sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", bkpinfo->tmpdir); 1862 1858 if (bkpinfo->disaster_recovery) { 1863 1859 sprintf(g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB); 1864 1860 sprintf(g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB); 1865 1861 } else { 1866 sprintf(g_mondo_cfg_file, "%s/%s", temppath, MONDO_CFG_FILE_STUB);1867 sprintf(g_mountlist_fname, "%s/%s", temppath, MOUNTLIST_FNAME_STUB);1862 sprintf(g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 1863 sprintf(g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 1868 1864 } 1869 1865 } -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2320 r2321 2720 2720 exit(127); 2721 2721 } 2722 if (! 2723 (bkpinfo = malloc(sizeof(struct s_bkpinfo)))) { 2724 fatal_error("Cannot malloc bkpinfo"); 2725 } 2726 reset_bkpinfo(); 2722 bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo)); 2723 init_bkpinfo(); 2727 2724 2728 2725 g_loglevel = DEFAULT_MR_LOGLEVEL; 2729 2726 2730 /* Configure global variables */ 2727 /* Configure global variables */ 2728 malloc_libmondo_global_strings(); 2731 2729 #ifdef __FreeBSD__ 2732 if (strstr 2733 (call_program_and_get_last_line_of_output("cat /tmp/cmdline"), 2734 "textonly")) 2730 if (strstr(call_program_and_get_last_line_of_output("cat /tmp/cmdline"), "textonly")) 2735 2731 #else 2736 if (strstr 2737 (call_program_and_get_last_line_of_output("cat /proc/cmdline"), 2738 "textonly")) 2732 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "textonly")) 2739 2733 #endif 2740 2734 { … … 2744 2738 g_text_mode = FALSE; 2745 2739 } // newt :-) 2746 if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) { 2747 fatal_error("Cannot malloc mountlist"); 2748 } 2749 if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) { 2750 fatal_error("Cannot malloc raidlist"); 2751 } 2752 2753 malloc_libmondo_global_strings(); 2754 2755 strcpy(g_mondo_home, 2756 call_program_and_get_last_line_of_output("which mondorestore")); 2740 2741 /* Init GUI */ 2742 setup_newt_stuff(); /* call newtInit and setup screen log */ 2743 2744 strcpy(g_mondo_home, call_program_and_get_last_line_of_output("which mondorestore")); 2757 2745 g_current_media_number = 1; // precaution 2758 2746 … … 2774 2762 log_msg(1, "FYI - g_mountlist_fname = %s", g_mountlist_fname); 2775 2763 if (strlen(g_mountlist_fname) < 3) { 2776 fatal_error 2777 ("Serious error in malloc()'ing. Could be a bug in your glibc."); 2764 fatal_error("Serious error in malloc()'ing. Could be a bug in your glibc."); 2778 2765 } 2779 2766 mkdir(MNT_CDROM, 0x770); … … 2783 2770 mr_asprintf(&tmp, "%s.orig", g_mountlist_fname); 2784 2771 if (!does_file_exist(g_mountlist_fname)) { 2785 log_msg(2, 2786 "%ld: Warning - g_mountlist_fname (%s) does not exist yet", 2787 __LINE__, g_mountlist_fname); 2772 log_msg(2, "%ld: Warning - g_mountlist_fname (%s) does not exist yet", __LINE__, g_mountlist_fname); 2788 2773 } else if (!does_file_exist(tmp)) { 2789 2774 mr_free(tmp); … … 2797 2782 make_hole_for_dir("/tmp/tmpfs"); /* just in case... */ 2798 2783 run_program_and_log_output("umount " MNT_CDROM, FALSE); 2799 /*2800 run_program_and_log_output("ln -sf /var/log/mondo-archive.log /tmp/mondorestore.log",2801 FALSE);2802 */2803 2784 2804 2785 run_program_and_log_output("rm -Rf /tmp/tmpfs/mondo.tmp.*", FALSE); 2805 2786 2806 /* Init GUI */2807 setup_newt_stuff(); /* call newtInit and setup screen log */2808 2787 welcome_to_mondorestore(); 2809 2788 if (bkpinfo->disaster_recovery) { … … 2814 2793 2815 2794 log_it("what time is it"); 2795 2796 mountlist = (struct mountlist_itself *)mr_malloc(sizeof(struct mountlist_itself)); 2797 raidlist = (struct raidlist_itself *)mr_malloc(sizeof(struct raidlist_itself)); 2816 2798 2817 2799 /* Process command-line parameters */ -
branches/2.2.10/mondo/src/mondorestore/mr-externs.h
r2316 r2321 61 61 extern char *popup_and_get_string(char *, char *, char *); 62 62 extern void setup_newt_stuff(void); 63 extern void reset_bkpinfo();63 extern void init_bkpinfo(); 64 64 extern int read_cfg_var(char *, char *, char *); 65 65 extern int read_file_from_stream_to_file(char *,
Note:
See TracChangeset
for help on using the changeset viewer.