Ignore:
Timestamp:
Aug 26, 2007, 12:26:06 PM (17 years ago)
Author:
Bruno Cornec
Message:

Use of conf file entries (iso_burning_*, media_device, media_size)
and adapatation of the rest of the code to that (including bkpinfo)

File:
1 edited

Legend:

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

    r1592 r1594  
    5454    struct seminfo *__buf;
    5555};
     56#endif
    5657#endif                          /* __FreeBSD__ */
    5758
     
    12181219 * @param bkpinfo The backup information structure. Fields used:
    12191220 * - @c backup_media_type
    1220  * - @c cdrw_speed
     1221 * - @c writer_speed
    12211222 * - @c prefix
    12221223 * - @c isodir
     
    12581259    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    12591260        if (bkpinfo->backup_media_type == cdstream) {
    1260             openout_cdstream(bkpinfo->media_device, bkpinfo->cdrw_speed);
     1261            openout_cdstream(bkpinfo->media_device, bkpinfo->writer_speed);
    12611262        } else {
    12621263            openout_tape(bkpinfo->media_device, bkpinfo->internal_tape_block_size); /* sets g_tape_stream */
     
    15821583    char *tmp = NULL;
    15831584    char *old_pwd;
    1584     char *result_sz = NULL;
    15851585    char *message_to_screen = NULL;
    15861586    char *sz_blank_disk = NULL;
    15871587    char *tmp2 = NULL;
    15881588    char *tmp3 = NULL;
    1589     bool cd_is_mountable;
    15901589
    15911590    malloc_string(old_pwd);
     
    16081607    mr_free(tmp);
    16091608
    1610     if (bkpinfo->backup_media_type == iso && bkpinfo->manual_cd_tray) {
     1609    if (bkpinfo->backup_media_type != iso && bkpinfo->manual_cd_tray) {
    16111610        popup_and_OK(_("Please insert new media and press Enter."));
    16121611    }
     
    16161615    /* BERLIOS: Do not ignore getcwd result */
    16171616    (void) getcwd(old_pwd, MAX_STR_LEN - 1);
    1618     mr_asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);
    1619     run_program_and_log_output(tmp, FALSE);
    1620     mr_free(tmp);
     1617    chmod(bkpinfo->scratchdir,0755);
    16211618    chdir(bkpinfo->scratchdir);
    16221619
     
    16431640
    16441641        /* if g_current_media_number >= 2 then pause & ask */
    1645         pause_and_ask_for_cdr(2, &cd_is_mountable);
     1642        if (bkpinfo->backup_media_type != iso) {
     1643            pause_and_ask_for_cdr(2);
     1644        }
    16461645        if (retval) {
    16471646            log_to_screen
     
    16491648        } else {
    16501649            res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_make_iso,
    1651                                         bkpinfo->scratchdir,
    1652                                         g_current_media_number,
     1650                                        destfile, g_current_media_number,
    16531651                                        MONDO_LOGFILE, message_to_screen);
    16541652            if (res) {
     
    17121710                res =
    17131711                    eval_call_to_make_ISO(bkpinfo, bkpinfo->call_make_iso,
    1714                                           bkpinfo->scratchdir,
     1712                                          destfile,
    17151713                                          g_current_media_number,
    17161714                                          MONDO_LOGFILE,
     
    24692467                                             bool keep_looping)
    24702468{
    2471     char *tmp;
    24722469    int res = 0;
    2473     char *bkp;
    2474     char *cdrecord;
    2475 
    2476     malloc_string(tmp);
     2470    char *bkp = NULL;
     2471    char *cdrecord = NULL;
     2472
    24772473    malloc_string(bkp);
    2478     malloc_string(cdrecord);
    24792474    strcpy(bkp, cdrw_dev);
    24802475    if (find_cdrw_device(cdrw_dev)) {
     
    24822477    } else {
    24832478        if (!system("which cdrecord > /dev/null 2> /dev/null")) {
    2484             sprintf(cdrecord, "cdrecord dev=%s -atip", cdrw_dev);
     2479            mr_asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_dev);
    24852480        } else if (!system("which dvdrecord > /dev/null 2> /dev/null")) {
    2486             sprintf(cdrecord, "cdrecord dev=%s -atip", cdrw_dev);
     2481            mr_asprintf(&cdrecord, "dvdrecord dev=%s -atip", cdrw_dev);
    24872482        } else {
    2488             cdrecord[0] = '\0';
    24892483            mr_msg(2, "Oh well. I guess I'll just pray then.");
    24902484        }
    2491         if (cdrecord[0]) {
     2485        if (cdrecord != NULL) {
    24922486            if (!keep_looping) {
    24932487                retract_CD_tray_and_defeat_autorun();
     
    25052499            }
    25062500        }
     2501        mr_free(cdrecord);
    25072502    }
    25082503//  retract_CD_tray_and_defeat_autorun();
    2509     mr_free(tmp);
    2510     mr_free(cdrecord);
    25112504    mr_free(bkp);
    25122505    return (res);
     
    25172510 * Asks the user to put a CD-R(W) in the drive.
    25182511 * @param ask_for_one_if_more_than_this (unused)
    2519  * @param pmountable If non-NULL, pointed-to value is set to TRUE if the CD is mountable, FALSE otherwise.
    25202512 */
    25212513void
    2522 pause_and_ask_for_cdr(int ask_for_one_if_more_than_this, bool * pmountable)
     2514pause_and_ask_for_cdr(int ask_for_one_if_more_than_this)
    25232515{
    25242516
     
    25372529    char *szunmount = NULL;
    25382530
    2539     malloc_string(tmp);
    25402531    malloc_string(szmsg);
    25412532    malloc_string(cdrom_dev);
     
    25662557      retract_CD_tray_and_defeat_autorun();
    25672558*/
    2568         sprintf(tmp, "umount %s", cdrom_dev);
     2559        mr_asprintf(&tmp, "umount %s", cdrom_dev);
    25692560        run_program_and_log_output(tmp, 1);
     2561        mr_free(tmp);
    25702562        sprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
    25712563        sprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);
     
    25732565        cd_number = -1;
    25742566        our_serial_str[0] = '\0';
    2575         sprintf(tmp, "mount %s %s", cdrom_dev, mtpt);
    2576         if ((attempt_to_mount_returned_this =
    2577              run_program_and_log_output(tmp, 1))) {
     2567        mr_asprintf(&tmp, "mount %s %s", cdrom_dev, mtpt);
     2568        attempt_to_mount_returned_this = run_program_and_log_output(tmp, 1);
     2569        mr_free(tmp);
     2570        if (attempt_to_mount_returned_this) {
    25782571            mr_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt);
    25792572            log_to_screen("If there's a CD/DVD in the drive, it's blank.");
    2580             /*
    2581                if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE))
    2582                {
    2583                ok_go_ahead_burn_it = FALSE;
    2584                log_to_screen("There isn't a writable CD/DVD in the drive.");
    2585                }
    2586                else
    2587                {
    2588                log_to_screen("Confirmed. There is a blank CD/DVD in the drive.");
    2589                }
    2590              */
    25912573        } else if (!does_file_exist(szcdno)
    25922574                   || !does_file_exist(szserfname)) {
     
    25982580                          media_descriptor_string(g_backup_media_type));
    25992581            cd_number = atoi(last_line_of_file(szcdno));
    2600             sprintf(tmp, "cat %s 2> /dev/null", szserfname);
     2582            mr_asprintf(&tmp, "cat %s 2> /dev/null", szserfname);
    26012583            strcpy(our_serial_str,
    26022584                   call_program_and_get_last_line_of_output(tmp));
     2585            mr_free(tmp);
    26032586            // FIXME - should be able to use last_line_of_file(), surely?
    26042587        }
     
    26342617    }
    26352618
    2636 /*
    2637   if (g_current_media_number > ask_for_one_if_more_than_this)
    2638     {
    2639       ok_go_ahead_burn_it = FALSE;
    2640       log_it("paafcd: %d > %d, so I'll definitely pause.", g_current_media_number > ask_for_one_if_more_than_this);
    2641     }
    2642 */
    2643 
    26442619    if (!ok_go_ahead_burn_it) {
    26452620        eject_device(cdrom_dev);
    2646         sprintf(tmp,
     2621        mr_asprintf(&tmp,
    26472622                "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
    26482623                media_descriptor_string(g_backup_media_type),
     
    26502625                media_descriptor_string(g_backup_media_type));
    26512626        popup_and_OK(tmp);
     2627        mr_free(tmp);
    26522628        goto gotos_make_me_puke;
    26532629    } else {
     
    26632639    log_to_screen("Proceeding w/ %s in drive.",
    26642640                  media_descriptor_string(g_backup_media_type));
    2665     mr_free(tmp);
    26662641    mr_free(szmsg);
    26672642    mr_free(cdrom_dev);
     
    26722647    mr_free(our_serial_str);
    26732648    mr_free(szunmount);
    2674     if (pmountable) {
    2675         if (attempt_to_mount_returned_this) {
    2676             *pmountable = FALSE;
    2677         } else {
    2678             *pmountable = TRUE;
    2679         }
    2680     }
    2681 
    26822649}
    26832650
     
    33003267        mvaddstr_and_log_it(g_currentY, 0,
    33013268                            "Verifying archives against live filesystem");
    3302         if (bkpinfo->backup_media_type == cdstream) {
    3303             strcpy(bkpinfo->media_device, "/dev/cdrom");
    3304         }
    33053269        verify_tape_backups(bkpinfo);
    33063270        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     
    33143278    } else {
    33153279        g_current_media_number = cdno;
    3316         if (bkpinfo->backup_media_type != iso) {
    3317             find_cdrom_device(bkpinfo->media_device, FALSE);    // replace 0,0,0 with /dev/cdrom
    3318         }
    33193280        chdir("/");
    33203281        for (cdno = 1; cdno < 99 && bkpinfo->verify_data; cdno++) {
Note: See TracChangeset for help on using the changeset viewer.