Ignore:
Timestamp:
Dec 6, 2013, 3:40:47 PM (10 years ago)
Author:
Bruno Cornec
Message:
  • Fix mondoarchive which now works in text mode. GUI mode still not working and crashing on first update for backup. Needs more

investigation in newt-specific.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/common/libmondo-archive.c

    r3197 r3205  
    526526
    527527    /*@ long     ********************************************************** */
    528     long lines_in_filelist = 0;
     528    long lines_in_filelist = 0L;
    529529
    530530    /*@ int     ************************************************************* */
    531531    int res = 0;
    532     long estimated_total_noof_slices = 0;
     532    long estimated_total_noof_slices = 0L;
    533533
    534534    assert(bkpinfo != NULL);
     
    608608
    609609    update_evalcall_form(2);
    610     if (!bkpinfo->nonbootable_backup
    611         && (bkpinfo->boot_loader == '\0'
    612             || bkpinfo->boot_device[0] == '\0')) {
     610    if (!bkpinfo->nonbootable_backup && (bkpinfo->boot_loader == '\0' || bkpinfo->boot_device[0] == '\0')) {
    613611
    614612#ifdef __FreeBSD__
    615         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output
    616                ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     613        mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
    617614        if (!bootdev[0]) {
    618615            mr_free(bootdev);
    619             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output
    620                    ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     616            mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
    621617        }
    622618#else
    623619        /* Linux */
    624620#ifdef __IA64__
    625         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output
    626                ("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     621        mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
    627622#else
    628         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output
    629                ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     623        mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
    630624#endif
    631625        if (strstr(bootdev, "/dev/cciss/")) {
    632626            mr_free(bootdev);
    633627#ifdef __IA64__
    634             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output
    635                    ("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     628            mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
    636629#else
    637             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output
    638                    ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     630            mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
    639631#endif
    640632        }
    641633        if (!bootdev[0]) {
    642634            mr_free(bootdev);
    643             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output
    644                    ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     635            mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
    645636            if (strstr(bootdev, "/dev/cciss/")) {
    646637                mr_free(bootdev);
    647                 mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output
    648                        ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     638                mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
    649639            }
    650640        }
     
    675665           bkpinfo->boot_loader != 'E' &&
    676666#endif
    677            bkpinfo->boot_loader != 'L' && bkpinfo->boot_loader != 'G'
    678            && bkpinfo->boot_loader != 'R'
    679            && !bkpinfo->nonbootable_backup) {
    680         fatal_error
    681             ("Please specify your boot loader and device, e.g. -l GRUB -f /dev/hda. Type 'man mondoarchive' to read the manual.");
     667           bkpinfo->boot_loader != 'L' && bkpinfo->boot_loader != 'G' && bkpinfo->boot_loader != 'R' && !bkpinfo->nonbootable_backup) {
     668        fatal_error("Please specify your boot loader and device, e.g. -l GRUB -f /dev/hda. Type 'man mondoarchive' to read the manual.");
    682669    }
    683670    if (bkpinfo->boot_loader == 'L') {
    684671        mr_asprintf(bootldr_str, "LILO");
    685672        if (!does_file_exist("/etc/lilo.conf")) {
     673            mr_free(bootldr_str);
    686674            fatal_error("The de facto standard location for your boot loader's config file is /etc/lilo.conf but I cannot find it there. What is wrong with your Linux distribution?");
    687675        }
     
    692680        }
    693681        if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) {
     682            mr_free(bootldr_str);
    694683            fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?");
    695684        }
     
    697686    } else if (bkpinfo->boot_loader == 'E') {
    698687        mr_asprintf(bootldr_str, "ELILO");
    699         /* BCO: fix it for Debian, Mandrake, ... */
     688        /* BCO: fix it for Debian, Mageia, ... */
    700689        if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) {
    701690            run_program_and_log_output("ln -sf /boot/efi/efi/redhat/elilo.conf /etc/elilo.conf", 5);
     
    711700        }
    712701        if (!does_file_exist("/etc/elilo.conf")) {
     702            mr_free(bootldr_str);
    713703            fatal_error("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf but I cannot find it there. What is wrong with your Linux distribution? Try finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'");
    714704        }
     
    783773        log_msg(1, "%ld: Unable to write one-liner backup-media-type", __LINE__);
    784774    }
    785     mr_free(value);
    786775    mr_free(tmp);
    787776
     
    791780        log_msg(1, "%ld: Unable to write one-liner bootloader.name", __LINE__);
    792781    }
    793     mr_free(bootldr_str);
     782    r_free(bootldr_str);
    794783    mr_free(tmp);
    795784
     
    814803        mr_asprintf(tmp1, "%s/XATTR", bkpinfo->tmpdir);
    815804        if (write_one_liner_data_file(tmp1, "TRUE")) {
    816             log_msg(1, "%ld: Unable to write one-liner XATTR",
    817                 __LINE__);
    818         }
    819         paranoid_free(tmp1);
     805            log_msg(1, "%ld: Unable to write one-liner XATTR", __LINE__);
     806        }
     807        mr_free(tmp1);
    820808    }
    821809    if (g_getfacl) {
    822810        mr_asprintf(tmp1, "%s/ACL", bkpinfo->tmpdir);
    823811        if (write_one_liner_data_file(tmp1, "TRUE")) {
    824             log_msg(1, "%ld: Unable to write one-liner ACL",
    825                 __LINE__);
    826         }
    827         paranoid_free(tmp1);
     812            log_msg(1, "%ld: Unable to write one-liner ACL", __LINE__);
     813        }
     814        mr_free(tmp1);
    828815    }
    829816    if (bkpinfo->use_obdr) {
    830817        mr_asprintf(tmp1, "%s/OBDR", bkpinfo->tmpdir);
    831818        if (write_one_liner_data_file(tmp1, "TRUE")) {
    832             log_msg(1, "%ld: Unable to write one-liner OBDR",
    833                 __LINE__);
    834         }
    835         paranoid_free(tmp1);
     819            log_msg(1, "%ld: Unable to write one-liner OBDR", __LINE__);
     820        }
     821        mr_free(tmp1);
    836822    }
    837823
     
    876862            MONDO_LOGFILE);
    877863
     864    mr_free(tmp2);
     865    mr_free(tape_device);
     866    mr_free(tape_size_sz);
     867    mr_free(use_lzo_sz);
     868    mr_free(cd_recovery_sz);
     869    mr_free(broken_bios_sz);
    878870    mr_free(last_filelist_number);
    879     mr_free(tape_device);
    880     mr_free(use_lzo_sz);
     871    mr_free(use_comp_sz);
     872    mr_free(use_lilo_sz);
     873    mr_free(use_star_sz);
    881874    mr_free(use_gzip_sz);
    882875    mr_free(use_lzma_sz);
    883     mr_free(use_star_sz);
    884     mr_free(use_comp_sz);
    885     mr_free(broken_bios_sz);
    886     mr_free(cd_recovery_sz);
    887     mr_free(use_lilo_sz);
    888     mr_free(tape_size_sz);
     876    mr_free(value);
    889877
    890878    /* This parameter is always the last one and optional */
     
    11831171 * @ingroup MLarchiveGroup
    11841172 */
    1185 int do_that_initial_phase()
    1186 {
     1173int do_that_initial_phase() {
    11871174    /*@ int *************************************** */
    11881175    int retval = 0;
     
    12291216    mr_free(data_disks_file);
    12301217
    1231     mr_asprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix);
     1218    if (bkpinfo->netfs_remote_dir != NULL) {
     1219        mr_asprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix);
     1220    } else {
     1221        mr_asprintf(command, "rm -f %s/%s-[1-9]*.iso", bkpinfo->isodir, bkpinfo->prefix);
     1222    }
    12321223    paranoid_system(command);
    12331224    mr_free(command);
     
    12361227    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    12371228    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1238         write_header_block_to_stream((off_t)0, "start-of-tape",
    1239                                      BLK_START_OF_TAPE);
    1240         write_header_block_to_stream((off_t)0, "start-of-backup",
    1241                                      BLK_START_OF_BACKUP);
     1229        write_header_block_to_stream((off_t)0, "start-of-tape", BLK_START_OF_TAPE);
     1230        write_header_block_to_stream((off_t)0, "start-of-backup", BLK_START_OF_BACKUP);
    12421231    }
    12431232    return (retval);
     
    13551344    srand((unsigned int) getpid());
    13561345    g_sem_key = 1234 + random() % 30000;
    1357     if ((g_sem_id =
    1358          semget((key_t) g_sem_key, 1,
    1359                 IPC_CREAT | S_IREAD | S_IWRITE)) == -1) {
     1346    if ((g_sem_id = semget((key_t) g_sem_key, 1, IPC_CREAT | S_IREAD | S_IWRITE)) == -1) {
    13601347        fatal_error("MABAI - unable to semget");
    13611348    }
     
    13661353        log_msg(8, "Creating thread #%d", noof_threads);
    13671354        (*p_archival_threads_running)++;
    1368         if ((res =
    1369              pthread_create(&archival_thread[noof_threads], NULL,
    1370                             create_afio_files_in_background,
    1371                             (void *) transfer_block))) {
     1355        if ((res = pthread_create(&archival_thread[noof_threads], NULL, create_afio_files_in_background, (void *) transfer_block))) {
    13721356            fatal_error("Unable to create an archival thread");
    13731357        }
     
    13811365        if (*p_archival_threads_running == 0
    13821366            && *p_last_set_archived == storing_set_no - 1) {
    1383             log_msg(2,
    1384                     "No archival threads are running. The last stored set was %d and I'm looking for %d. Take off your make-up; the party's over... :-)",
    1385                     *p_last_set_archived, storing_set_no);
     1367            log_msg(2, "No archival threads are running. The last stored set was %d and I'm looking for %d. Take off your make-up; the party's over... :-)", *p_last_set_archived, storing_set_no);
    13861368            done_storing = TRUE;
    13871369        } else
    1388             if (!get_bit_N_of_array
    1389                 (p_list_of_fileset_flags, storing_set_no)) {
    1390             misc_counter_that_is_not_important = (misc_counter_that_is_not_important + 1) % 5;
    1391             /* BCO the media_usage_comment is not really initialized there !
    1392             if (!misc_counter_that_is_not_important) {
    1393                 update_progress_form(media_usage_comment);
    1394             }
    1395             */
    1396             sleep(1);
     1370            if (!get_bit_N_of_array(p_list_of_fileset_flags, storing_set_no)) {
     1371                misc_counter_that_is_not_important = (misc_counter_that_is_not_important + 1) % 5;
     1372                sleep(1);
    13971373            } else {
    13981374                // store set N
     
    14071383
    14081384                log_msg(2, "Storing set %d", storing_set_no);
    1409                 while (!does_file_exist(storing_filelist_fname)
    1410                     || !does_file_exist(storing_afioball_fname)) {
    1411                     log_msg(2,
    1412                             "Warning - either %s or %s doesn't exist yet. I'll pause 5 secs.",
    1413                         storing_filelist_fname, storing_afioball_fname);
     1385                while (!does_file_exist(storing_filelist_fname) || !does_file_exist(storing_afioball_fname)) {
     1386                    log_msg(2, "Warning - either %s or %s doesn't exist yet. I'll pause 5 secs.", storing_filelist_fname, storing_afioball_fname);
    14141387                    sleep(5);
    14151388                }
    14161389                /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
    14171390                if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1418                     register_in_tape_catalog(fileset, storing_set_no, -1,
    1419                                          storing_afioball_fname);
     1391                    register_in_tape_catalog(fileset, storing_set_no, -1, storing_afioball_fname);
    14201392                    maintain_collection_of_recent_archives(bkpinfo->tmpdir, storing_afioball_fname);
    14211393                    log_it("Writing EXAT files");
    1422                     res +=
    1423                         write_EXAT_files_to_tape(curr_xattr_list_fname,
    1424                                              curr_acl_list_fname);
     1394                    res += write_EXAT_files_to_tape(curr_xattr_list_fname, curr_acl_list_fname);
    14251395                    // archives themselves
    1426                     res +=
    1427                         move_files_to_stream(storing_afioball_fname,
    1428                                          NULL);
     1396                    res += move_files_to_stream(storing_afioball_fname, NULL);
    14291397                } else {
    14301398                    if (g_getfacl) {
    14311399                        if (g_getfattr) {
    1432                             res = move_files_to_cd(storing_filelist_fname,
    1433                                      curr_xattr_list_fname,
    1434                                      curr_acl_list_fname,
    1435                                      storing_afioball_fname, NULL);
     1400                            res = move_files_to_cd(storing_filelist_fname, curr_xattr_list_fname, curr_acl_list_fname, storing_afioball_fname, NULL);
    14361401                        } else {
    1437                             res = move_files_to_cd(storing_filelist_fname,
    1438                                     curr_acl_list_fname,
    1439                                     storing_afioball_fname, NULL);
     1402                            res = move_files_to_cd(storing_filelist_fname, curr_acl_list_fname, storing_afioball_fname, NULL);
    14401403                        }
    14411404                    } else {
    14421405                        if (g_getfattr) {
    1443                             res = move_files_to_cd(storing_filelist_fname,
    1444                                     curr_xattr_list_fname,
    1445                                     storing_afioball_fname, NULL);
     1406                            res = move_files_to_cd(storing_filelist_fname, curr_xattr_list_fname, storing_afioball_fname, NULL);
    14461407                        } else {
    1447                             res = move_files_to_cd(storing_filelist_fname,
    1448                                     storing_afioball_fname, NULL);
     1408                            res = move_files_to_cd(storing_filelist_fname, storing_afioball_fname, NULL);
    14491409                        }
    14501410                    }
     
    19671927    char *ntfsprog_fifo = NULL;
    19681928    /*@ long *********************************************** */
    1969     long biggie_file_number = 0;
    1970     long noof_biggie_files = 0;
    1971     long estimated_total_noof_slices = 0;
     1929    long biggie_file_number = 0L;
     1930    long noof_biggie_files = 0L;
     1931    long estimated_total_noof_slices = 0L;
    19721932
    19731933    /*@ int ************************************************ */
     
    19831943    assert_string_is_neither_NULL_nor_zerolength(biggielist_fname);
    19841944
    1985     estimated_total_noof_slices =
    1986         size_of_all_biggiefiles_K() / bkpinfo->optimal_set_size + 1;
    1987 
    1988     log_msg(1, "size of all biggiefiles = %ld",
    1989             size_of_all_biggiefiles_K());
    1990     log_msg(1, "estimated_total_noof_slices = %ld KB / %ld KB = %ld",
    1991             size_of_all_biggiefiles_K(), bkpinfo->optimal_set_size,
    1992             estimated_total_noof_slices);
     1945    estimated_total_noof_slices = size_of_all_biggiefiles_K() / bkpinfo->optimal_set_size + 1L;
     1946
     1947    log_msg(1, "size of all biggiefiles = %ld", size_of_all_biggiefiles_K());
     1948    log_msg(1, "estimated_total_noof_slices = %ld KB / %ld KB = %ld", size_of_all_biggiefiles_K(), bkpinfo->optimal_set_size, estimated_total_noof_slices);
    19931949
    19941950    if (length_of_file(biggielist_fname) < 6) {
     
    21022058
    21032059    log_msg(1, "Finished backing up bigfiles");
    2104     log_msg(1, "estimated slices = %ld; actual slices = %ld",
    2105             estimated_total_noof_slices, g_current_progress);
     2060    log_msg(1, "estimated slices = %ld; actual slices = %ld", estimated_total_noof_slices, g_current_progress);
    21062061    close_progress_form();
    21072062    paranoid_fclose(fin);
     
    22542209    assert(bkpinfo != NULL);
    22552210
    2256     mvaddstr_and_log_it(g_currentY, 0,
    2257                         "Archiving regular files to media          ");
     2211    mvaddstr_and_log_it(g_currentY, 0, "Archiving regular files to media          ");
    22582212
    22592213    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    2260         write_header_block_to_stream((off_t)0, "start-of-afioballs",
    2261                                      BLK_START_AFIOBALLS);
     2214        write_header_block_to_stream((off_t)0, "start-of-afioballs", BLK_START_AFIOBALLS);
    22622215#if __FreeBSD__ == 5
    2263         log_msg(1,
    2264                 "Using single-threaded make_afioballs_and_images() to suit b0rken FreeBSD 5.0");
     2216        log_msg(1, "Using single-threaded make_afioballs_and_images() to suit b0rken FreeBSD 5.0");
    22652217        res = make_afioballs_and_images_OLD();
    22662218#else
Note: See TracChangeset for help on using the changeset viewer.