Changeset 783 in MondoRescue for trunk/mondo/mondo/common/libmondo-archive.c
- Timestamp:
- Aug 31, 2006, 5:09:20 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-archive.c
r729 r783 10 10 */ 11 11 12 #include " ../common/my-stuff.h"12 #include "my-stuff.h" 13 13 #include "../common/mondostructures.h" 14 #include "mr_conf.h" 14 15 #include "libmondo-string-EXT.h" 15 16 #include "libmondo-stream-EXT.h" … … 80 81 */ 81 82 t_bkptype g_backup_media_type = none; 83 char *g_backup_media_string = NULL; 82 84 83 85 /** … … 231 233 log_msg(5, "command='%s'", command); 232 234 res = system(command); 233 tmp = last_line_of_file(MONDO_LOGFILE) );235 tmp = last_line_of_file(MONDO_LOGFILE); 234 236 log_msg(1, "res=%d; tmp='%s'", res, tmp); 235 237 if (bkpinfo->use_star && (res == 254 || res == 65024) … … 390 392 } 391 393 392 if (g_tmpfs_mountpt [0] != '\0') {394 if (g_tmpfs_mountpt != NULL) { 393 395 tmp = call_program_and_get_last_line_of_output 394 396 ("df -m -P | grep dev/shm | grep -v none | tr -s ' ' '\t' | cut -f4"); … … 424 426 * @ingroup archiveGroup 425 427 */ 426 int backup_data(struct s_bkpinfo *bkpinfo , struct s_mrconf *mrconf)428 int backup_data(struct s_bkpinfo *bkpinfo) 427 429 { 428 430 int retval = 0, res = 0; … … 651 653 else 652 654 ch = 'U'; 655 653 656 if (bkpinfo->boot_loader != '\0') { 654 657 asprintf(&tmp, "User specified boot loader. It is '%c'.", … … 743 746 } 744 747 paranoid_free(tmp); 748 /* BERLIOS: Use bkptype_to_string without LANG */ 745 749 switch (bkpinfo->backup_media_type) { 746 750 case cdr: … … 1106 1110 * @ingroup MLarchiveGroup 1107 1111 */ 1108 int do_that_final_phase(struct s_bkpinfo *bkpinfo , struct s_mrconf *mrconf)1112 int do_that_final_phase(struct s_bkpinfo *bkpinfo) 1109 1113 { 1110 1114 … … 1125 1129 } else { 1126 1130 /* write final ISO */ 1127 res = write_final_iso_if_necessary(bkpinfo , mrconf);1131 res = write_final_iso_if_necessary(bkpinfo); 1128 1132 retval += res; 1129 1133 if (res) { … … 1178 1182 g_serial_string = call_program_and_get_last_line_of_output("dd \ 1179 1183 if=/dev/urandom bs=16 count=1 2> /dev/null | \ 1180 hexdump | tr -s ' ' '0' | head -n1") );1184 hexdump | tr -s ' ' '0' | head -n1"); 1181 1185 asprintf(&tmp, "%s...word.", g_serial_string); 1182 1186 paranoid_free(g_serial_string); … … 1269 1273 } 1270 1274 /* if not Debian then go ahead & use fdformat */ 1271 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX") );1275 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX"); 1272 1276 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, 1273 1277 tempfile, tempfile); … … 1294 1298 if (trackno <= 5 && last_trkno > 40) { 1295 1299 close_evalcall_form(); 1296 strcpy(title, "Verifying format"); 1297 open_evalcall_form(title); 1300 open_evalcall_form("Verifying format"); 1298 1301 } 1299 1302 last_trkno = trackno; … … 1401 1404 * @return The number of errors encountered (0 for success) 1402 1405 */ 1403 int make_afioballs_and_images(struct s_bkpinfo *bkpinfo , struct s_mrconf *mrconf)1406 int make_afioballs_and_images(struct s_bkpinfo *bkpinfo) 1404 1407 { 1405 1408 … … 1544 1547 } else { 1545 1548 res = 1546 move_files_to_cd(bkpinfo, mrconf,storing_filelist_fname,1549 move_files_to_cd(bkpinfo, storing_filelist_fname, 1547 1550 curr_xattr_list_fname, 1548 1551 curr_acl_list_fname, … … 1624 1627 * @return The number of errors encountered (0 for success) 1625 1628 */ 1626 int make_iso_fs(struct s_bkpinfo *bkpinfo, struct s_mrconf *mrconf,char *destfile)1629 int make_iso_fs(struct s_bkpinfo *bkpinfo, char *destfile) 1627 1630 { 1628 1631 /*@ int ********************************************** */ … … 1667 1670 /* BERLIOS: Do not ignore getcwd result */ 1668 1671 (void) getcwd(old_pwd, MAX_STR_LEN - 1); 1669 asprintf(&tmp, "chmod 7 44%s", bkpinfo->scratchdir);1672 asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir); 1670 1673 run_program_and_log_output(tmp, FALSE); 1671 1674 paranoid_free(tmp); 1672 1675 chdir(bkpinfo->scratchdir); 1673 1676 1674 if (bkpinfo->call_before_iso [0] != '\0') {1677 if (bkpinfo->call_before_iso != NULL) { 1675 1678 asprintf(&message_to_screen, "Running pre-ISO call for CD#%d", 1676 1679 g_current_media_number); … … 1687 1690 } 1688 1691 1689 if (bkpinfo->call_make_iso [0] != '\0') {1692 if (bkpinfo->call_make_iso != NULL) { 1690 1693 log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso); 1691 1694 asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir); 1692 1695 asprintf(&message_to_screen, "Making an ISO (%s #%d)", 1693 media_descriptor_string(bkpinfo->backup_media_type),1696 bkpinfo->backup_media_string, 1694 1697 g_current_media_number); 1695 1698 … … 1789 1792 } else { 1790 1793 asprintf(&message_to_screen, "Running mkisofs to make %s #%d", 1791 media_descriptor_string(bkpinfo->backup_media_type),1794 bkpinfo->backup_media_string, 1792 1795 g_current_media_number); 1793 1796 log_msg(1, message_to_screen); 1794 1797 asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ", 1795 media_descriptor_string(bkpinfo->backup_media_type),1798 bkpinfo->backup_media_string, 1796 1799 g_current_media_number); 1797 1800 if (bkpinfo->nonbootable_backup) { … … 1818 1821 #ifdef __IA64__ 1819 1822 log_msg(1, "IA64 --> elilo"); 1820 asprintf(&tmp2,"mkisofs -no-emul-boot -b images/mindi-bootroot.%s.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", mrconf->ia64_boot_size);1823 asprintf(&tmp2,"mkisofs -no-emul-boot -b images/mindi-bootroot.%s.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", bkpinfo->mrconf->mindi_ia64_boot_size); 1821 1824 res = eval_call_to_make_ISO(bkpinfo, 1822 1825 tmp2, … … 1870 1873 } 1871 1874 1872 if (bkpinfo->call_burn_iso [0] != '\0') {1875 if (bkpinfo->call_burn_iso != NULL) { 1873 1876 log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso); 1874 1877 asprintf(&message_to_screen, "Burning %s #%d", 1875 media_descriptor_string(bkpinfo->backup_media_type),1878 bkpinfo->backup_media_string, 1876 1879 g_current_media_number); 1877 1880 pause_and_ask_for_cdr(2, &cd_is_mountable); … … 1888 1891 } 1889 1892 1890 if (bkpinfo->call_after_iso [0] != '\0') {1893 if (bkpinfo->call_after_iso != NULL) { 1891 1894 asprintf(&message_to_screen, "Running post-ISO call (%s #%d)", 1892 media_descriptor_string(bkpinfo->backup_media_type),1895 bkpinfo->backup_media_string, 1893 1896 g_current_media_number); 1894 1897 res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_after_iso, … … 1922 1925 bigfile_fname); 1923 1926 log_msg(1, "command = '%s'", command); 1924 tmp = call_program_and_get_last_line_of_output(command) );1927 tmp = call_program_and_get_last_line_of_output(command); 1925 1928 log_msg(1, "--> tmp = '%s'", tmp); 1926 1929 paranoid_free(command); … … 1951 1954 */ 1952 1955 int 1953 make_slices_and_images(struct s_bkpinfo *bkpinfo, struct s_mrconf *mrconf,char *biggielist_fname)1956 make_slices_and_images(struct s_bkpinfo *bkpinfo, char *biggielist_fname) 1954 1957 { 1955 1958 … … 2070 2073 } 2071 2074 res = 2072 slice_up_file_etc(bkpinfo, mrconf,bigfile_fname,2075 slice_up_file_etc(bkpinfo, bigfile_fname, 2073 2076 ntfsprog_fifo, biggie_file_number, 2074 2077 noof_biggie_files, use_ntfsprog); … … 2119 2122 * @see make_afioballs_and_images 2120 2123 */ 2121 int make_afioballs_and_images_OLD(struct s_bkpinfo *bkpinfo , struct s_mrconf *mrconf)2124 int make_afioballs_and_images_OLD(struct s_bkpinfo *bkpinfo) 2122 2125 { 2123 2126 … … 2193 2196 } else { 2194 2197 res = 2195 move_files_to_cd(bkpinfo, mrconf,curr_filelist_fname,2198 move_files_to_cd(bkpinfo, curr_filelist_fname, 2196 2199 curr_xattr_list_fname, 2197 2200 curr_acl_list_fname, curr_afioball_fname, … … 2241 2244 * @ingroup MLarchiveGroup 2242 2245 */ 2243 int make_those_afios_phase(struct s_bkpinfo *bkpinfo , struct s_mrconf *mrconf)2246 int make_those_afios_phase(struct s_bkpinfo *bkpinfo) 2244 2247 { 2245 2248 /*@ int ******************************************* */ … … 2258 2261 log_msg(1, 2259 2262 "Using single-threaded make_afioballs_and_images() to suit b0rken FreeBSD 5.0"); 2260 res = make_afioballs_and_images_OLD(bkpinfo , mrconf);2263 res = make_afioballs_and_images_OLD(bkpinfo); 2261 2264 #else 2262 res = make_afioballs_and_images_OLD(bkpinfo , mrconf);2265 res = make_afioballs_and_images_OLD(bkpinfo); 2263 2266 #endif 2264 2267 write_header_block_to_stream((off_t)0, "stop-afioballs", 2265 2268 BLK_STOP_AFIOBALLS); 2266 2269 } else { 2267 res = make_afioballs_and_images(bkpinfo , mrconf);2270 res = make_afioballs_and_images(bkpinfo); 2268 2271 } 2269 2272 … … 2371 2374 * transfer files over the network) or leave it as is. 2372 2375 */ 2373 int (*move_files_to_cd) (struct s_bkpinfo *, struct s_mrconf *mrconf,char *, ...) =2376 int (*move_files_to_cd) (struct s_bkpinfo *, char *, ...) = 2374 2377 _move_files_to_cd; 2375 2378 … … 2392 2395 * @return The number of errors encountered (0 for success) 2393 2396 */ 2394 int _move_files_to_cd(struct s_bkpinfo *bkpinfo, struct s_mrconf *mrconf,char *files_to_add, ...)2397 int _move_files_to_cd(struct s_bkpinfo *bkpinfo, char *files_to_add, ...) 2395 2398 { 2396 2399 … … 2431 2434 if (would_occupy / 1024 > bkpinfo->media_size[g_current_media_number]) { 2432 2435 /* FALSE because this is not the last CD we'll write */ 2433 res = write_iso_and_go_on(bkpinfo, mrconf,FALSE);2436 res = write_iso_and_go_on(bkpinfo, FALSE); 2434 2437 retval += res; 2435 2438 if (res) { … … 2823 2826 2824 2827 asprintf(&szmsg, "I am about to burn %s #%d", 2825 media_descriptor_string(g_backup_media_type),2828 g_backup_media_string, 2826 2829 g_current_media_number); 2827 2830 log_to_screen(szmsg); … … 2860 2863 log_to_screen 2861 2864 ("%s has data on it but it's probably not a Mondo CD.", 2862 media_descriptor_string(g_backup_media_type));2865 g_backup_media_string); 2863 2866 asprintf(&our_serial_str, "%s", ""); 2864 2867 } else { 2865 2868 log_to_screen("%s found in drive. It's a Mondo disk.", 2866 media_descriptor_string(g_backup_media_type));2869 g_backup_media_string); 2867 2870 tmp1 = last_line_of_file(szcdno); 2868 2871 cd_number = atoi(tmp1); … … 2885 2888 if (cd_number > 0 && !strcmp(our_serial_str, g_serial_string)) { 2886 2889 log_msg(2, "This %s is part of this backup set!", 2887 media_descriptor_string(g_backup_media_type));2890 g_backup_media_string); 2888 2891 ok_go_ahead_burn_it = FALSE; 2889 2892 if (cd_number == g_current_media_number - 1) { 2890 2893 log_to_screen 2891 2894 ("I think you've left the previous %s in the drive.", 2892 media_descriptor_string(g_backup_media_type));2895 g_backup_media_string); 2893 2896 } else { 2894 2897 log_to_screen 2895 2898 ("Please remove this %s. It is part of the backup set you're making now.", 2896 media_descriptor_string(g_backup_media_type));2899 g_backup_media_string); 2897 2900 } 2898 2901 } else { … … 2903 2906 log_msg(2, 2904 2907 "paafcd: Can't find CD-ROM drive. Perhaps it has a blank %s in it?", 2905 media_descriptor_string(g_backup_media_type));2908 g_backup_media_string); 2906 2909 if ((cdrw_device = interrogate_disk_currently_in_cdrw_drive(cdrw_device)) != NULL) { 2907 2910 ok_go_ahead_burn_it = FALSE; 2908 2911 log_to_screen("There isn't a writable %s in the drive.", 2909 media_descriptor_string(g_backup_media_type));2912 g_backup_media_string); 2910 2913 } 2911 2914 paranoid_free(cdrw_device); … … 2917 2920 asprintf(&tmp, 2918 2921 "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", 2919 media_descriptor_string(g_backup_media_type),2922 g_backup_media_string, 2920 2923 g_current_media_number, 2921 media_descriptor_string(g_backup_media_type));2924 g_backup_media_string); 2922 2925 popup_and_OK(tmp); 2923 2926 paranoid_free(tmp); … … 2930 2933 log_msg(2, 2931 2934 "paafcd: OK, I assume I have a blank/reusable %s in the drive...", 2932 media_descriptor_string(g_backup_media_type));2935 g_backup_media_string); 2933 2936 2934 2937 log_to_screen("Proceeding w/ %s in drive.", 2935 media_descriptor_string(g_backup_media_type));2938 g_backup_media_string); 2936 2939 if (pmountable) { 2937 2940 if (attempt_to_mount_returned_this) { … … 2994 2997 */ 2995 2998 int 2996 slice_up_file_etc(struct s_bkpinfo *bkpinfo, struct s_mrconf *mrconf,char *biggie_filename,2999 slice_up_file_etc(struct s_bkpinfo *bkpinfo, char *biggie_filename, 2997 3000 char *ntfsprog_fifo, long biggie_file_number, 2998 3001 long noof_biggie_files, bool use_ntfsprog) … … 3092 3095 } 3093 3096 lstat(biggie_filename, &biggiestruct.properties); 3094 strcpy(biggiestruct.filename, biggie_filename); 3097 if (strlen(checksum_line) <= MAX_STR_LEN) { 3098 strcpy(biggiestruct.filename, biggie_filename); 3099 } else { 3100 fatal_error("biggie_filename too big"); 3101 } 3095 3102 pB = strchr(checksum_line, ' '); 3096 3103 if (!pB) { … … 3100 3107 *pB = '\0'; 3101 3108 } 3102 strcpy(biggiestruct.checksum, checksum_line); 3109 if (strlen(checksum_line) <= 64) { 3110 strcpy(biggiestruct.checksum, checksum_line); 3111 } else { 3112 fatal_error("checksum_line too big"); 3113 } 3103 3114 paranoid_free(checksum_line); 3104 3115 … … 3125 3136 res = move_files_to_stream(bkpinfo,tmp,NULL); 3126 3137 } else { 3127 res = move_files_to_cd(bkpinfo, mrconf,tmp, NULL);3138 res = move_files_to_cd(bkpinfo, tmp, NULL); 3128 3139 } 3129 3140 paranoid_free(tmp); … … 3131 3142 for (slice_num = 1; !finished; slice_num++) { 3132 3143 curr_slice_fname_uncompressed = slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, ""); 3133 curr_slice_fname_compressed = slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, suffix) );3144 curr_slice_fname_compressed = slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, suffix); 3134 3145 3135 3146 tmp = percent_media_full_comment(bkpinfo); … … 3236 3247 res = move_files_to_stream(bkpinfo, file_to_archive, NULL); 3237 3248 } else { 3238 res = move_files_to_cd(bkpinfo, mrconf,file_to_archive, NULL);3249 res = move_files_to_cd(bkpinfo, file_to_archive, NULL); 3239 3250 } 3240 3251 paranoid_free(file_to_archive); … … 3332 3343 * however, this occurs rarely. 3333 3344 */ 3334 int write_final_iso_if_necessary(struct s_bkpinfo *bkpinfo , struct s_mrconf *mrconf)3345 int write_final_iso_if_necessary(struct s_bkpinfo *bkpinfo) 3335 3346 { 3336 3347 /*@ int ***************************************************** */ … … 3355 3366 #endif 3356 3367 paranoid_free(tmp); 3357 res = write_iso_and_go_on(bkpinfo, mrconf,TRUE);3368 res = write_iso_and_go_on(bkpinfo, TRUE); 3358 3369 #ifndef _XWIN 3359 3370 if (!g_text_mode) { … … 3383 3394 * @see make_iso_fs 3384 3395 */ 3385 int write_iso_and_go_on(struct s_bkpinfo *bkpinfo, struct s_mrconf *mrconf,bool last_cd)3396 int write_iso_and_go_on(struct s_bkpinfo *bkpinfo, bool last_cd) 3386 3397 { 3387 3398 /*@ pointers **************************************************** */ … … 3414 3425 } 3415 3426 log_msg(1, "OK, time to make %s #%d", 3416 media_descriptor_string(bkpinfo->backup_media_type),3427 bkpinfo->backup_media_string, 3417 3428 g_current_media_number); 3418 3429 … … 3461 3472 g_current_media_number); 3462 3473 for (that_one_was_ok = FALSE; !that_one_was_ok;) { 3463 res = make_iso_fs(bkpinfo, mrconf,isofile);3474 res = make_iso_fs(bkpinfo, isofile); 3464 3475 if (g_current_media_number == 1 && !res 3465 3476 && (bkpinfo->backup_media_type == cdr … … 3478 3489 log_to_screen 3479 3490 ("Please reboot from the 1st %s in Compare Mode, as a precaution.", 3480 media_descriptor_string(g_backup_media_type));3491 g_backup_media_string); 3481 3492 chdir("/"); 3482 3493 iamhere("Before calling verify_cd_image()"); … … 3488 3499 } else { 3489 3500 asprintf(&tmp, "Failed to burn %s #%d. Retry?", 3490 media_descriptor_string(bkpinfo->backup_media_type),3501 bkpinfo->backup_media_string, 3491 3502 g_current_media_number); 3492 3503 res = ask_me_yes_or_no(tmp); … … 3577 3588 g_current_media_number = cdno; 3578 3589 if (bkpinfo->backup_media_type != iso) { 3579 bkpinfo->media_device = find_cdrom_device(FALSE) );3590 bkpinfo->media_device = find_cdrom_device(FALSE); 3580 3591 } 3581 3592 chdir("/"); … … 3595 3606 asprintf(&tmp, 3596 3607 "Warnings/errors were reported while checking %s #%d", 3597 media_descriptor_string(bkpinfo-> 3598 backup_media_type), 3608 bkpinfo->backup_media_string, 3599 3609 g_current_media_number); 3600 3610 log_to_screen(tmp); … … 3745 3755 } 3746 3756 3747 void mr archive_init_conf(struct s_mrconf *mrconf) {3757 void mr_archive_init_conf(struct s_mr_conf *mr_conf) { 3748 3758 char *command = NULL; 3749 FILE *conffd = NULL;3750 3759 FILE *fin = NULL; 3751 int n = 0;3760 size_t n = 0; 3752 3761 char *param = NULL; 3753 3762 3754 mr conf = (struct s_mrconf *)malloc(sizeof(struct s_mrconf));3755 if (mr conf == NULL) {3756 fatal_error("Unable to malloc mr conf");3763 mr_conf = (struct s_mr_conf *)malloc(sizeof(struct s_mr_conf)); 3764 if (mr_conf == NULL) { 3765 fatal_error("Unable to malloc mr_conf"); 3757 3766 } 3758 3767 /* Default for everything int : 0 char * : NULL */ 3759 3768 3760 3769 /* mindi conf parameters also needed in mondo */ 3761 mr conf->ia64_boot_size = 0;3770 mr_conf->mindi_ia64_boot_size = 0; 3762 3771 3763 3772 asprintf(&command, "mindi -printvar IA64_BOOT_SIZE"); … … 3766 3775 pclose(fin); 3767 3776 paranoid_free(command); 3768 mr conf->ia64_boot_size = atoi(param);3777 mr_conf->mindi_ia64_boot_size = atoi(param); 3769 3778 paranoid_free(param); 3770 3779 3771 mr conf->iso_creation_cmd = NULL;3780 mr_conf->mondo_iso_creation_cmd = NULL; 3772 3781 3773 3782 /* Finds mondo conf file */ 3774 mr conf_open(MONDO_CONF_DIR"/mondo.conf");3783 mr_conf_open(MONDO_CONF_DIR"/mondo.conf"); 3775 3784 3776 3785 /* mondo conf parameters needed */ 3777 mrconf->iso_creation_cmd = mrconf_sread(iso_creation_cmd); 3778 3779 mrconf_close(); 3786 mr_conf->mondo_iso_creation_cmd = mr_conf_sread("mondo_iso_creation_cmd"); 3787 3788 mr_conf_close(); 3789 }
Note:
See TracChangeset
for help on using the changeset viewer.