Changeset 2405 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-archive.c
- Timestamp:
- Sep 17, 2009, 3:45:24 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2383 r2405 979 979 void *create_afio_files_in_background(void *inbuf) 980 980 { 981 long int archiving_set_no ;982 char *archiving_filelist_fname ;983 char *archiving_afioball_fname ;981 long int archiving_set_no = 0L; 982 char *archiving_filelist_fname = NULL; 983 char *archiving_afioball_fname = NULL; 984 984 char *curr_xattr_list_fname = NULL; 985 985 char *curr_acl_list_fname = NULL; … … 994 994 int this_thread_no = g_current_thread_no++; 995 995 996 malloc_string(archiving_filelist_fname);997 malloc_string(archiving_afioball_fname);998 996 p_last_set_archived = (int *) inbuf; 999 997 p_archival_threads_running = (int *) (inbuf + 4); … … 1002 1000 bkpinfo_bis = (struct s_bkpinfo *) (inbuf + BKPINFO_LOC_OFFSET); 1003 1001 1004 sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L);1005 for (archiving_set_no = 0; does_file_exist(archiving_filelist_fname); 1006 sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no)) {1002 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L); 1003 1004 while (does_file_exist(archiving_filelist_fname)) { 1007 1005 if (g_exiting) { 1006 mr_free(archiving_filelist_fname); 1008 1007 fatal_error("Execution run aborted (pthread)"); 1009 1008 } 1010 1009 if (archiving_set_no >= MAX_NOOF_SETS_HERE) { 1010 mr_free(archiving_filelist_fname); 1011 1011 fatal_error("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please."); 1012 1012 } 1013 1013 if (!semaphore_p()) { 1014 1014 log_msg(3, "P sem failed (pid=%d)", (int) getpid()); 1015 mr_free(archiving_filelist_fname); 1015 1016 fatal_error("Cannot get semaphore P"); 1016 1017 } … … 1020 1021 *p_next_set_to_archive = *p_next_set_to_archive + 1; 1021 1022 if (!semaphore_v()) { 1023 mr_free(archiving_filelist_fname); 1022 1024 fatal_error("Cannot get semaphore V"); 1023 1025 } 1024 1026 1025 1027 /* backup this set of files */ 1026 sprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix); 1027 sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1028 mr_asprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix); 1029 mr_free(archiving_filelist_fname); 1030 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1028 1031 if (!does_file_exist(archiving_filelist_fname)) { 1029 log_msg(3, 1030 "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", 1031 FORTY_SPACES, getpid(), this_thread_no, 1032 archiving_set_no); 1032 log_msg(3, "[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", getpid(), this_thread_no, archiving_set_no); 1033 1033 break; 1034 1034 } … … 1036 1036 mr_asprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix); 1037 1037 if (does_file_exist(tmp)) { 1038 log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES, 1039 getpid(), this_thread_no); 1038 log_msg(4, "[%d:%d] - waiting for storer", getpid(), this_thread_no); 1040 1039 while (does_file_exist(tmp)) { 1041 1040 sleep(1); … … 1045 1044 mr_free(tmp); 1046 1045 1047 log_msg(4, " %s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),1048 this_thread_no, archiving_set_no); 1046 log_msg(4, "[%d:%d] - EXATing %d...", getpid(), this_thread_no, archiving_set_no); 1047 1049 1048 if (g_getfattr) { 1050 1049 mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); … … 1058 1057 } 1059 1058 1060 log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(), 1061 this_thread_no, archiving_set_no); 1062 res = 1063 archive_this_fileset(archiving_filelist_fname, 1064 archiving_afioball_fname, 1065 archiving_set_no); 1059 log_msg(4, "[%d:%d] - archiving %d...", getpid(), this_thread_no, archiving_set_no); 1060 res = archive_this_fileset(archiving_filelist_fname, archiving_afioball_fname, archiving_set_no); 1061 mr_free(archiving_afioball_fname); 1062 1066 1063 retval += res; 1067 1064 … … 1069 1066 log_to_screen("Errors occurred while archiving set %ld. Please review logs.", archiving_set_no); 1070 1067 } 1068 1071 1069 if (!semaphore_p()) { 1070 mr_free(archiving_filelist_fname); 1072 1071 fatal_error("Cannot get semaphore P"); 1073 1072 } … … 1080 1079 1081 1080 if (!semaphore_v()) { 1081 mr_free(archiving_filelist_fname); 1082 1082 fatal_error("Cannot get semaphore V"); 1083 1083 } 1084 log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(), 1085 this_thread_no, archiving_set_no); 1084 log_msg(4, "[%d:%d] - archived %d OK", getpid(), this_thread_no, archiving_set_no); 1086 1085 archiving_set_no++; 1087 } 1086 1087 mr_free(archiving_filelist_fname); 1088 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1089 } 1090 mr_free(archiving_filelist_fname); 1091 1088 1092 if (!semaphore_p()) { 1089 1093 fatal_error("Cannot get semaphore P"); … … 1093 1097 fatal_error("Cannot get semaphore V"); 1094 1098 } 1095 log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(), 1096 this_thread_no); 1097 paranoid_free(archiving_filelist_fname); 1098 paranoid_free(archiving_afioball_fname); 1099 log_msg(3, "[%d:%d] - exiting", getpid(), this_thread_no); 1099 1100 pthread_exit(NULL); 1100 1101 } … … 1327 1328 assert(bkpinfo != NULL); 1328 1329 malloc_string(result_str); 1329 transfer_block = 1330 malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1330 transfer_block = malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1331 1331 memset((void *) transfer_block, 0, 1332 1332 sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); … … 1638 1638 char *message_to_screen = NULL; 1639 1639 char *sz_blank_disk = NULL; 1640 char *fnam;1641 1640 char *tmp2 = NULL; 1642 1641 char *tmp3 = NULL; … … 1645 1644 1646 1645 malloc_string(old_pwd); 1647 malloc_string(fnam);1648 1646 assert(bkpinfo != NULL); 1649 1647 assert_string_is_neither_NULL_nor_zerolength(destfile); … … 1879 1877 } 1880 1878 paranoid_free(old_pwd); 1881 paranoid_free(fnam);1882 1879 return (retval); 1883 1880 } … … 2529 2526 /** 2530 2527 * Make sure the user has a valid CD-R(W) in the CD drive. 2531 * @param cdrw_dev Set to the CD-R(W) device checked. 2532 * @param keep_looping If TRUE, keep pestering user until they insist 2533 * or insert a correct CD; if FALSE, only check once. 2534 * @return 0 (there was an OK CD in the drive) or 1 (there wasn't). 2535 */ 2536 int interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev, bool keep_looping) { 2537 int res = 0; 2538 char *bkp = NULL; 2528 * @return the CD-R(W) device checked or NULL 2529 */ 2530 char *interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev) { 2539 2531 char *cdrecord = NULL; 2540 2541 mr_asprintf(bkp, "%s", cdrw_dev); 2542 if (find_cdrw_device(cdrw_dev)) { 2543 strcpy(cdrw_dev, bkp); 2544 } else { 2532 char *cdrw_dev = NULL; 2533 2534 cdrw_dev = find_cdrw_device(); 2535 if (cdrw_dev != NULL) { 2545 2536 if (!system("which cdrecord > /dev/null 2> /dev/null")) { 2546 2537 mr_asprintf(cdrecord, "cdrecord dev=%s -atip", cdrw_dev); … … 2551 2542 } 2552 2543 if (cdrecord != NULL) { 2553 if (!keep_looping) { 2554 retract_CD_tray_and_defeat_autorun(); 2555 res = run_program_and_log_output(cdrecord, 5); 2556 } else { 2557 while ((res = run_program_and_log_output(cdrecord, 5))) { 2558 retract_CD_tray_and_defeat_autorun(); 2559 if (ask_me_yes_or_no 2560 ("Unable to examine CD. Are you sure this is a valid CD-R(W) CD?")) 2561 { 2562 log_msg(1, "Well, he insisted..."); 2563 break; 2564 } 2565 } 2544 retract_CD_tray_and_defeat_autorun(); 2545 if (run_program_and_log_output(cdrecord, 5)) { 2546 /* As it didn't work, return NULL */ 2547 mr_free(cdrw_dev); 2566 2548 } 2567 2549 } 2568 } 2569 mr_free(bkp); 2570 2571 mr_free(cdrecord); 2572 return (res); 2550 mr_free(cdrecord); 2551 } 2552 return(cdrw_dev); 2573 2553 } 2574 2554 … … 2586 2566 char *tmp = NULL; 2587 2567 char *cdrom_dev = NULL; 2588 char *cdrw_dev ;2568 char *cdrw_dev = NULL; 2589 2569 char *our_serial_str = NULL; 2590 2570 bool ok_go_ahead_burn_it; … … 2592 2572 int attempt_to_mount_returned_this = 999; 2593 2573 char *mtpt = NULL; 2594 char *szcdno ;2595 char *szserfname ;2596 char *szunmount ;2574 char *szcdno = NULL; 2575 char *szserfname = NULL; 2576 char *szunmount = NULL; 2597 2577 char *mds = NULL; 2598 2599 malloc_string(cdrw_dev);2600 malloc_string(szcdno);2601 malloc_string(szserfname);2602 malloc_string(szunmount);2603 2578 2604 2579 mds = media_descriptor_string(g_backup_media_type); … … 2621 2596 mr_asprintf(tmp, "umount %s", cdrom_dev); 2622 2597 run_program_and_log_output(tmp, 1); 2623 sprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);2624 sprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);2625 sprintf(szunmount, "umount %s", mtpt);2598 mr_asprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt); 2599 mr_asprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt); 2600 mr_asprintf(szunmount, "umount %s", mtpt); 2626 2601 cd_number = -1; 2627 2602 mr_asprintf(tmp, "mount %s %s", cdrom_dev, mtpt); … … 2629 2604 attempt_to_mount_returned_this = run_program_and_log_output(tmp, 1); 2630 2605 mr_free(tmp); 2606 2631 2607 if (attempt_to_mount_returned_this) { 2632 2608 log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt); 2633 2609 log_to_screen("If there's a CD/DVD in the drive, it's blank."); 2634 /* 2635 if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE)) 2636 { 2637 ok_go_ahead_burn_it = FALSE; 2638 log_to_screen("There isn't a writable CD/DVD in the drive."); 2639 } 2640 else 2641 { 2642 log_to_screen("Confirmed. There is a blank CD/DVD in the drive."); 2643 } 2644 */ 2645 } else if (!does_file_exist(szcdno) 2646 || !does_file_exist(szserfname)) { 2610 } else if (!does_file_exist(szcdno) || !does_file_exist(szserfname)) { 2647 2611 mds = media_descriptor_string(g_backup_media_type); 2648 log_to_screen 2649 ("%s has data on it but it's probably not a Mondo CD.", mds); 2612 log_to_screen("%s has data on it but it's probably not a Mondo CD.", mds); 2650 2613 mr_free(mds); 2651 2614 } else { … … 2664 2627 // FIXME - should be able to use last_line_of_file(), surely? 2665 2628 } 2629 mr_free(szcdno); 2630 mr_free(szserfname); 2631 2666 2632 run_program_and_log_output(szunmount, 1); 2633 mr_free(szunmount); 2634 2667 2635 log_msg(2, "paafcd: cd_number = %d", cd_number); 2668 2636 log_msg(2, "our serial str = %s; g_serial_string = %s", our_serial_str, g_serial_string); … … 2686 2654 log_msg(2, 2687 2655 "paafcd: Can't find CD-ROM drive. Perhaps it has a blank %s in it?", mds); 2688 if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE)) { 2656 cdrw_dev = interrogate_disk_currently_in_cdrw_drive(); 2657 if (cdrw_dev == NULL) { 2689 2658 ok_go_ahead_burn_it = FALSE; 2690 2659 log_to_screen("There isn't a writable %s in the drive.", mds); 2691 2660 } 2661 mr_free(cdrw_dev); 2692 2662 mr_free(mds); 2693 2663 } … … 2709 2679 2710 2680 mds = media_descriptor_string(g_backup_media_type); 2711 log_msg(2, 2712 "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds); 2681 log_msg(2, "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds); 2713 2682 2714 2683 log_to_screen("Proceeding w/ %s in drive.", mds); 2715 2684 mr_free(mds); 2716 2685 2717 paranoid_free(cdrw_dev);2718 2686 paranoid_free(mtpt); 2719 paranoid_free(szcdno);2720 paranoid_free(szserfname);2721 paranoid_free(szunmount);2722 2687 if (pmountable) { 2723 2688 if (attempt_to_mount_returned_this) { … … 2729 2694 2730 2695 } 2731 2732 2733 2734 2735 2736 2737 2696 2738 2697 … … 2764 2723 2765 2724 /* @} - end of utilityGroup */ 2766 2767 2768 2769 2770 2771 2772 2725 2773 2726
Note:
See TracChangeset
for help on using the changeset viewer.