Changeset 1594 in MondoRescue for branches/stable/mondo/src/common


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)

Location:
branches/stable/mondo/src/common
Files:
10 edited

Legend:

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

    r1152 r1594  
    2424extern int offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo
    2525                                                          *bkpinfo);
    26 extern void pause_and_ask_for_cdr(int, bool *);
     26extern void pause_and_ask_for_cdr(int);
    2727extern int slice_up_file_etc(struct s_bkpinfo *bkpinfo,
    2828                             char *biggie_filename,
  • 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++) {
  • branches/stable/mondo/src/common/libmondo-archive.h

    r543 r1594  
    2626int offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo
    2727                                                   *bkpinfo);
    28 void pause_and_ask_for_cdr(int, bool *);
     28void pause_and_ask_for_cdr(int);
    2929void set_bit_N_of_array(char *array, int N, bool true_or_false);
    3030int slice_up_file_etc(struct s_bkpinfo *bkpinfo, char *biggie_filename,
  • branches/stable/mondo/src/common/libmondo-devices.c

    r1581 r1594  
    2222#include "mr_str.h"
    2323#include "mr_gettext.h"
     24#include "mr_conf.h"
    2425
    2526#include <sys/ioctl.h>
     
    4748extern char *g_selfmounted_isodir;
    4849extern char *MONDO_LOGFILE;
     50extern struct mr_ar_conf *mr_conf;
    4951
    5052static char g_cdrw_drive_is_here[MAX_STR_LEN / 4] = "";
     
    14431445    char *prompt = NULL;
    14441446    int i = 0;
    1445     int res = 0;
    14461447    FILE *fin = NULL;
    14471448
     
    14661467        sensibly_set_tmpdir_and_scratchdir(bkpinfo);
    14671468    }
    1468     bkpinfo->cdrw_speed = (bkpinfo->backup_media_type == cdstream) ? 2 : 4;
    14691469    bkpinfo->compression_level =
    14701470        (bkpinfo->backup_media_type == cdstream) ? 1 : 5;
     
    14941494            mr_asprintf(&comment, _("What speed is your %s (re)writer?"),
    14951495                    bkpinfo->backup_media_string);
    1496             if (bkpinfo->backup_media_type == dvd) {
    1497                 find_dvd_device(bkpinfo->media_device, FALSE);
    1498                 mr_asprintf(&tmp, "1");
    1499                 mr_asprintf(&sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    1500                 mr_msg(1, "Setting to DVD defaults");
    1501             } else if (bkpinfo->backup_media_type == usb) {
    1502                 strcpy(bkpinfo->media_device, VANILLA_USB_DEVICE);
    1503                 asprintf(&sz_size, "512");
    1504             } else {
    1505                 strcpy(bkpinfo->media_device, VANILLA_SCSI_CDROM);
    1506                 mr_asprintf(&tmp, "4");
    1507                 mr_asprintf(&sz_size, "650");
    1508                 mr_msg(1, "Setting to CD defaults");
    1509             }
    1510             if ((bkpinfo->backup_media_type != dvd) && (bkpinfo->backup_media_type != usb)) {
     1496            mr_asprintf(&tmp, "%d", mr_conf->iso_burning_speed);
     1497            if (bkpinfo->backup_media_type != usb) {
     1498                /* BERLIOS: NOW that tmp isn't static anymore it does NOT work */
    15111499                if (!popup_and_get_string(_("Speed"), comment, tmp, 4)) {
    15121500                    log_to_screen(_("User has chosen not to backup the PC"));
     
    15161504            mr_free(comment);
    15171505
    1518             bkpinfo->cdrw_speed = atoi(tmp);    // if DVD then this shouldn't ever be used anyway :)
     1506            bkpinfo->writer_speed = atoi(tmp);
    15191507            mr_free(tmp);
    15201508
    1521             mr_asprintf(&comment,
    1522                     _("How much data (in Megabytes) will each %s store?"),
    1523                     bkpinfo->backup_media_string);
    1524 
    1525             if (!popup_and_get_string("Size", comment, sz_size, 5)) {
     1509            mr_asprintf(&comment, _("What is your media device ?"));
     1510            mr_asprintf(&tmp, mr_conf->media_device);
     1511
     1512            if (!popup_and_get_string("Device", comment, tmp, 5)) {
    15261513                log_to_screen(_("User has chosen not to backup the PC"));
    15271514                finish(1);
     
    15291516            mr_free(comment);
    15301517
    1531             bkpinfo->media_size = atol(sz_size);
    1532             mr_free(sz_size);
    1533 
    1534             if (bkpinfo->media_size <= 0L) {
    1535                 log_to_screen(_("User has chosen not to backup the PC"));
    1536                 finish(1);
    1537             }
    1538         }
    1539     case cdstream:
    1540         if (bkpinfo->disaster_recovery) {
    1541             strcpy(bkpinfo->media_device, "/dev/cdrom");
    1542             mr_msg(2, "CD-ROM device assumed to be at %s",
    1543                     bkpinfo->media_device);
    1544         } else if (bkpinfo->restore_data
    1545                    || bkpinfo->backup_media_type == dvd) {
    1546             if (!bkpinfo->media_device[0]) {
    1547                 strcpy(bkpinfo->media_device, "/dev/cdrom");
    1548             }                   // just for the heck of it :)
    1549             mr_msg(1, "bkpinfo->media_device = %s",
    1550                     bkpinfo->media_device);
    1551             if (bkpinfo->backup_media_type == dvd
    1552                 || find_cdrom_device(bkpinfo->media_device, FALSE)) {
    1553                 mr_msg(1, "bkpinfo->media_device = %s",
    1554                         bkpinfo->media_device);
    1555                 mr_asprintf(&comment,
    1556                         _("Please specify your %s drive's /dev entry"),
    1557                         bkpinfo->backup_media_string);
    1558                 if (!popup_and_get_string
    1559                     (_("Device?"), comment, bkpinfo->media_device, MAX_STR_LEN / 4)) {
     1518            mr_free(bkpinfo->media_device);
     1519            bkpinfo->media_device = tmp;
     1520
     1521            /* Also adapt the burning device if needed */
     1522            if ((strcmp(bkpinfo->media_device, mr_conf->media_device) != 0) &&
     1523                (strcmp(mr_conf->media_device,mr_conf->iso_burning_dev) != 0)) {
     1524                mr_asprintf(&comment, _("What is your burning media device then ?"));
     1525                mr_asprintf(&tmp, mr_conf->iso_burning_dev);
     1526   
     1527                if (!popup_and_get_string("Device", comment, tmp, 5)) {
    15601528                    log_to_screen(_("User has chosen not to backup the PC"));
    15611529                    finish(1);
    15621530                }
    15631531                mr_free(comment);
    1564             }
     1532   
     1533                /* BCO: We change the mr_conf struct. Check that it doesn't create pb */
     1534                mr_free(bkpinfo->iso_burning_dev);
     1535                bkpinfo->iso_burning_dev = tmp;
     1536            }
     1537
     1538            mr_asprintf(&comment,
     1539                    _("How much data (in Megabytes) will each %s store?"),
     1540                    bkpinfo->backup_media_string);
     1541            mr_asprintf(&sz_size, "%d", mr_conf->media_size);
     1542
     1543            if (!popup_and_get_string("Size", comment, sz_size, 5)) {
     1544                log_to_screen(_("User has chosen not to backup the PC"));
     1545                finish(1);
     1546            }
     1547            mr_free(comment);
     1548
     1549            bkpinfo->media_size = atol(sz_size);
     1550            mr_free(sz_size);
     1551
     1552            if (bkpinfo->media_size <= 0L) {
     1553                log_to_screen(_("User has chosen not to backup the PC"));
     1554                finish(1);
     1555            }
     1556        }
     1557
     1558    case cdstream:
     1559        if (bkpinfo->disaster_recovery) {
     1560            mr_allocstr(bkpinfo->media_device, "/dev/cdrom");
     1561            mr_msg(2, "CD-ROM device assumed to be at %s", bkpinfo->media_device);
     1562        } else if (bkpinfo->restore_data || bkpinfo->backup_media_type == dvd) {
     1563            if (!bkpinfo->media_device) {
     1564                mr_allocstr(bkpinfo->media_device, "/dev/cdrom");
     1565            }                   // just for the heck of it :)
     1566            mr_msg(1, "bkpinfo->media_device = %s", bkpinfo->media_device);
     1567            mr_asprintf(&comment,
     1568                _("Please specify your %s drive's /dev entry"), bkpinfo->backup_media_string);
     1569            mr_asprintf(&tmp,"/dev/cdrom");
     1570            if (!popup_and_get_string
     1571                (_("Device?"), comment, tmp, MAX_STR_LEN / 4)) {
     1572                    log_to_screen(_("User has chosen not to backup the PC"));
     1573                    finish(1);
     1574                }
     1575            mr_free(comment);
     1576            mr_free(bkpinfo->media_device);
     1577            bkpinfo->media_device=tmp;
     1578
    15651579            mr_msg(2, "%s device found at %s",
    15661580                    bkpinfo->backup_media_string,
    15671581                    bkpinfo->media_device);
    15681582        } else {
    1569             if (find_cdrw_device(bkpinfo->media_device)) {
    1570                 bkpinfo->media_device[0] = '\0';
    1571             }
    1572             if (bkpinfo->media_device[0]) {
    1573                 mr_asprintf(&tmp,
    1574                         _("I think I've found your %s burner at SCSI node %s; Is this correct ? (say no if you have an IDE burner and you are running a 2.6 kernel. You will then be prompted for further details."),
    1575                         bkpinfo->backup_media_string,
    1576                         bkpinfo->media_device);
    1577                 if (!ask_me_yes_or_no(tmp)) {
    1578                     bkpinfo->media_device[0] = '\0';
    1579                 }
    1580                 mr_free(tmp);
    1581             } else {
    1582                 if (g_kernel_version < 2.6) {
    1583                     i = popup_and_get_string("Device node?",
    1584                                              "What is the SCSI node of your CD (re)writer, please?",
    1585                                              bkpinfo->media_device,
    1586                                              MAX_STR_LEN / 4);
    1587                 } else {
    1588                     i = popup_and_get_string("/dev entry?",
    1589                                              "What is the /dev entry of your CD (re)writer, please?",
    1590                                              bkpinfo->media_device,
    1591                                              MAX_STR_LEN / 4);
    1592                 }
    1593                 if (!i) {
     1583            mr_asprintf(&comment, _("What is your media device ?"));
     1584            mr_asprintf(&tmp, mr_conf->media_device);
     1585
     1586            if (!popup_and_get_string("Device", comment, tmp, 5)) {
     1587                log_to_screen(_("User has chosen not to backup the PC"));
     1588                finish(1);
     1589            }
     1590            mr_free(comment);
     1591
     1592            mr_free(bkpinfo->media_device);
     1593            bkpinfo->media_device = tmp;
     1594
     1595            /* Also adapt the burning device if needed */
     1596            if ((strcmp(bkpinfo->media_device, mr_conf->media_device) != 0) &&
     1597                (strcmp(mr_conf->media_device,mr_conf->iso_burning_dev) != 0)) {
     1598                mr_asprintf(&comment, _("What is your burning media device then ?"));
     1599                mr_asprintf(&tmp, mr_conf->iso_burning_dev);
     1600   
     1601                if (!popup_and_get_string("Device", comment, tmp, 5)) {
    15941602                    log_to_screen(_("User has chosen not to backup the PC"));
    15951603                    finish(1);
    15961604                }
    1597             }
    1598         }
    1599         if (bkpinfo->backup_media_type == cdstream) {
    1600             bkpinfo->media_size = (long)650;
    1601         }
     1605                mr_free(comment);
     1606   
     1607                /* BCO: We change the mr_conf struct. Check that it doesn't create pb */
     1608                mr_free(bkpinfo->iso_burning_dev);
     1609                bkpinfo->iso_burning_dev = tmp;
     1610            }
     1611
     1612        }
     1613        /* BERLIOS: Is it useful ?? */
     1614        bkpinfo->media_size = (long)650;
    16021615        break;
     1616
    16031617    case udev:
    16041618        if (!ask_me_yes_or_no
     
    16071621            finish(1);
    16081622        }
     1623
    16091624    case tape:
    1610 
    1611         res = find_tape_device_and_size(bkpinfo->media_device, sz_size);
    1612         if ((res != 0) && (! bkpinfo->media_device[0])) {
    1613             mr_msg(3, "Ok, using vanilla scsi tape.");
    1614             strcpy(bkpinfo->media_device, VANILLA_SCSI_TAPE);
    1615             if ((fin = fopen(bkpinfo->media_device, "r"))) {
    1616                 paranoid_fclose(fin);
    1617             } else {
    1618                 mr_msg(2, "Don't know what your tape device is :-(");
    1619             }
    1620         }
    1621         if (bkpinfo->media_device[0]) {
     1625        if (bkpinfo->media_device) {
    16221626            if ((fin = fopen(bkpinfo->media_device, "r"))) {
    16231627                paranoid_fclose(fin);
    16241628            } else {
    16251629                if (does_file_exist("/tmp/mondo-restore.cfg")) {
     1630                    /* BERLIOS: NOW that bkpinfo->media_device isn't static anymore it does NOT work */
    16261631                    read_cfg_var("/tmp/mondo-restore.cfg", "media-dev",
    16271632                                 bkpinfo->media_device);
    16281633                }
    16291634            }
    1630             mr_asprintf(&tmp,
     1635            mr_asprintf(&comment,
    16311636                    _("I think I've found your tape streamer at %s; am I right on the money?"),
    16321637                    bkpinfo->media_device);
    1633             if (!ask_me_yes_or_no(tmp)) {
     1638            if (!ask_me_yes_or_no(comment)) {
     1639                mr_asprintf(&tmp,bkpinfo->media_device);
    16341640                if (!popup_and_get_string
    1635                     ("Device name?",
    1636                     "What is the /dev entry of your tape streamer?",
    1637                     bkpinfo->media_device, MAX_STR_LEN / 4)) {
     1641                    (_("Device name?"),
     1642                    _("What is the /dev entry of your tape streamer?"),
     1643                    tmp, MAX_STR_LEN / 4)) {
    16381644                    log_to_screen("User has chosen not to backup the PC");
    16391645                    finish(1);
    16401646                }
    1641             }
    1642             mr_free(tmp);
     1647                mr_free(bkpinfo->media_device);
     1648                bkpinfo->media_device = tmp;
     1649            }
     1650            mr_free(comment);
    16431651        } else {
     1652            mr_asprintf(&tmp,bkpinfo->media_device);
    16441653            if (!popup_and_get_string
    1645                 ("Device name?",
    1646                  "What is the /dev entry of your tape streamer?",
    1647                  bkpinfo->media_device, MAX_STR_LEN / 4)) {
     1654                (_("Device name?"),
     1655                 _("What is the /dev entry of your tape streamer?"),
     1656                 tmp, MAX_STR_LEN / 4)) {
    16481657                log_to_screen("User has chosen not to backup the PC");
    16491658                finish(1);
    16501659            }
     1660            mr_free(bkpinfo->media_device);
     1661            bkpinfo->media_device = tmp;
    16511662        }
    16521663        mr_asprintf(&tmp, "ls -l %s", bkpinfo->media_device);
     
    16561667        }
    16571668        mr_free(tmp);
    1658         mr_msg(4, "sz_size = %s", sz_size);
    1659         mr_free(sz_size);
    16601669        bkpinfo->media_size = 0L;
    16611670        mr_msg(4, "media_size = %ld", bkpinfo->media_size);
    1662         if (bkpinfo->media_size <= 0L) {
    1663             bkpinfo->media_size = 0L;
    1664         }
    16651671        if (archiving_to_media) {
    16661672            if ((bkpinfo->compression_level =
     
    17971803        mr_msg(3, "prefix set to %s", bkpinfo->prefix);
    17981804
    1799         bkpinfo->media_size = (long)650;
     1805        if (archiving_to_media) {
     1806            if (!popup_and_get_string
     1807                ("Size.",
     1808                "Please enter how big you want each NFS image to be (in megabytes).",
     1809                sz_size, 16)) {
     1810                log_to_screen("User has chosen not to backup the PC");
     1811                finish(1);
     1812            }
     1813            bkpinfo->media_size = atol(sz_size);
     1814            if (bkpinfo->media_size <= 0L) {
     1815                log_to_screen(_("User has chosen not to backup the PC"));
     1816                finish(1);
     1817            }
     1818        }
    18001819        mr_msg(3, "Just set nfs_remote_dir to %s",
    18011820                bkpinfo->nfs_remote_dir);
     
    18261845                }
    18271846                bkpinfo->media_size = atol(sz_size);
     1847            /* BERLIOS: this should be useless
     1848            */
    18281849            } else {
    18291850                bkpinfo->media_size = (long)650;
     
    19741995        g_ISO_restore_mode = TRUE;
    19751996    }
    1976 #ifdef __FreeSD__
     1997#ifdef __FreeBSD__
    19771998// skip
    19781999#else
     
    21562177
    21572178    mr_asprintf(&mountdev, bkpinfo->media_device);
    2158     if (!mountdev[0]) {
    2159         log_it
    2160             ("(what_number_cd_is_this) Warning - media_device unknown. Finding out...");
    2161         find_cdrom_device(bkpinfo->media_device, FALSE);
    2162     }
    21632179    if (!is_this_device_mounted(MNT_CDROM)) {
    21642180        mount_CDROM_here(mountdev, MNT_CDROM);
  • branches/stable/mondo/src/common/libmondo-files.c

    r1543 r1594  
    12711271{
    12721272    FILE *fout = NULL;
    1273     char *tmp = NULL;
    12741273    int retval = 0;
    12751274
     
    12791278        paranoid_fclose(fout);
    12801279        mr_msg(2, "Created %s", outfile);
    1281         mr_asprintf(&tmp, "chmod +x %s", outfile);
    1282         paranoid_system(tmp);
    1283         mr_free(tmp);
    1284 
     1280        chmod(outfile,0755);
    12851281        retval = 0;
    12861282    } else {
  • branches/stable/mondo/src/common/libmondo-fork.c

    r1592 r1594  
    119119    midway_call = mr_malloc(1200);
    120120
     121    mr_msg(5,"isofile: %s - cd_number_str: %d", isofile, cd_number_str);
    121122    mr_asprintf(&cd_number_str, "%d", cd_no);
    122123    resolve_naff_tokens(midway_call, basic_call, isofile, "_ISO_");
     
    152153        }
    153154        if (retval) {
    154             mr_msg(2, "Basic call '%s' returned an error.", basic_call);
     155            mr_msg(2, "Ultimate call '%s' returned an error.", ultimate_call);
    155156            popup_and_OK(_("Press ENTER to continue."));
    156157            popup_and_OK
  • branches/stable/mondo/src/common/libmondo-stream.c

    r1574 r1594  
    329329    log_it("At this point, dev = %s and res = %d", dev, res);
    330330
    331     strcpy(tmp, call_program_and_get_last_line_of_output("\
    332 cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | \
    333 grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | \
    334 awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));
     331    mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'", cdr_exe);
     332    strcpy(tmp, call_program_and_get_last_line_of_output(command));
     333    mr_free(command);
    335334
    336335    siz[0] = '\0';
     
    12961295        mr_asprintf(&command,
    12971296                 "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s",
    1298                  bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE,
     1297                 bkpinfo->iso_burning_dev, bkpinfo->writer_speed, MONDO_LOGFILE,
    12991298                 MONDO_LOGFILE);
    13001299        log_it("Opening OUT to next CD with the command");
  • branches/stable/mondo/src/common/libmondo-tools.c

    r1592 r1594  
    329329 * - Used: @c bkpinfo->backup_data
    330330 * - Used: @c bkpinfo->backup_media_type
    331  * - Used: @c bkpinfo->cdrw_speed
     331 * - Used: @c bkpinfo->writer_speed
    332332 * - Used: @c bkpinfo->compression_level
    333333 * - Used: @c bkpinfo->include_paths
     
    485485        }
    486486        if (bkpinfo->manual_cd_tray) {
    487             if (strstr(mr_conf->mondo_iso_burning_cmd,"growisofs") == NULL) {
     487            if (strstr(mr_conf->iso_burning_cmd,"growisofs") != NULL) {
    488488                fatal_error("Unable to use manual CD tray with growisofs");
    489489            }
     
    502502            sprintf(bkpinfo->call_make_iso,
    503503                    "%s %s %s dev=%s speed=%d %s/temporary.iso",
    504                     mr_conf->mondo_iso_burning_cmd,
     504                    mr_conf->iso_burning_cmd,
    505505                    extra_cdrom_params,
    506                     mr_conf->mondo_iso_burning_opt,
    507                     bkpinfo->media_device,
    508                     bkpinfo->cdrw_speed,
     506                    mr_conf->iso_burning_opt,
     507                    bkpinfo->iso_burning_dev,
     508                    bkpinfo->writer_speed,
    509509                    bkpinfo->tmpdir);
    510510        } else {
    511             if (strstr(mr_conf->mondo_iso_burning_cmd,"growisofs") == NULL) {
    512                 if (getenv ("SUDO_COMMAND")) {
    513                     mr_asprintf(&command, "strings `which growisofs` | grep -c SUDO_COMMAND");
    514                     if (!strcmp(call_program_and_get_last_line_of_output(command), "1")) {
    515                         fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details.");
     511            if (bkpinfo->backup_media_type == iso) {
     512                sprintf(bkpinfo->call_make_iso,
     513                    "%s %s . 2>> %s",
     514                        mr_conf->iso_creation_cmd,
     515                        mondo_mkisofs_sz,
     516                        MONDO_LOGFILE);
     517            } else {
     518                if (strstr(mr_conf->iso_burning_cmd,"growisofs") != NULL) {
     519                    if (getenv ("SUDO_COMMAND")) {
     520                        mr_asprintf(&command, "strings %s | grep -c SUDO_COMMAND", mr_conf->iso_burning_cmd);
     521                        if (!strcmp(call_program_and_get_last_line_of_output(command), "1")) {
     522                            fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details.");
     523                        }
     524                        mr_free(command);
    516525                    }
    517                     mr_free(command);
     526                    sprintf(bkpinfo->call_make_iso,
     527                        "%s %s %s %s -Z %s -speed=%d . 2>> %s",
     528                        mr_conf->iso_burning_cmd,
     529                        mondo_mkisofs_sz,
     530                        extra_cdrom_params,
     531                        mr_conf->iso_burning_opt,
     532                        bkpinfo->iso_burning_dev,
     533                        bkpinfo->writer_speed,
     534                        MONDO_LOGFILE);
     535                } else {
     536                    sprintf(bkpinfo->call_make_iso,
     537                        "%s %s . 2>> %s | %s %s %s dev=%s speed=%d -",
     538                        mr_conf->iso_creation_cmd,
     539                        mondo_mkisofs_sz,
     540                        MONDO_LOGFILE,
     541                        mr_conf->iso_burning_cmd,
     542                        extra_cdrom_params,
     543                        mr_conf->iso_burning_opt,
     544                        bkpinfo->iso_burning_dev,
     545                        bkpinfo->writer_speed);
    518546                }
    519                 sprintf(bkpinfo->call_make_iso,
    520                     "%s %s %s %s -Z %s -speed=%d . 2>> %s",
    521                     mr_conf->mondo_iso_burning_cmd,
    522                     mondo_mkisofs_sz,
    523                     extra_cdrom_params,
    524                     mr_conf->mondo_iso_burning_opt,
    525                     bkpinfo->media_device,
    526                     bkpinfo->cdrw_speed,
    527                     MONDO_LOGFILE);
    528             } else {
    529                 sprintf(bkpinfo->call_make_iso,
    530                     "%s %s . 2>> %s | %s %s %s dev=%s speed=%d -",
    531                     mr_conf->iso_creation_cmd,
    532                     mondo_mkisofs_sz,
    533                     MONDO_LOGFILE,
    534                     mr_conf->mondo_iso_burning_cmd,
    535                     extra_cdrom_params,
    536                     mr_conf->mondo_iso_burning_opt,
    537                     bkpinfo->media_device,
    538                     bkpinfo->cdrw_speed);
     547            mr_free(mondo_mkisofs_sz);
     548            mr_free(extra_cdrom_params);
    539549            }
    540550        }
    541         mr_free(mondo_mkisofs_sz);
    542         mr_free(extra_cdrom_params);
    543551    }                           // end of CD code
    544552
     
    684692void reset_bkpinfo(struct s_bkpinfo *bkpinfo)
    685693{
     694    char *tmp = NULL;
     695
    686696    mr_msg(1, "Hi");
    687697
     
    692702    bkpinfo->manual_cd_tray = FALSE;
    693703    bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
    694     bkpinfo->media_device[0] = '\0';
    695     bkpinfo->media_size = 0L;
     704    mr_asprintf(&tmp,mr_conf->media_device);
     705    bkpinfo->media_device = tmp;
     706    mr_asprintf(&tmp,mr_conf->iso_burning_dev);
     707    bkpinfo->iso_burning_dev = tmp;
     708
     709    bkpinfo->media_size = mr_conf->iso_burning_speed;
    696710    bkpinfo->boot_loader = '\0';
    697711    bkpinfo->boot_device[0] = '\0';
     
    732746    bkpinfo->wipe_media_first = FALSE;
    733747    bkpinfo->differential = FALSE;
    734     bkpinfo->cdrw_speed = 0;
     748    bkpinfo->writer_speed = mr_conf->iso_burning_speed;
    735749// patch by Herman Kuster 
    736750    bkpinfo->differential = 0;
     
    848862    }
    849863#endif
    850     retval += whine_if_not_found(mr_conf->mr_iso_creation_cmd);
    851     retval += whine_if_not_found(mr_conf->mondo_iso_burning_cmd);
     864    retval += whine_if_not_found(mr_conf->iso_creation_cmd);
     865    retval += whine_if_not_found(mr_conf->iso_burning_cmd);
    852866    retval += whine_if_not_found(MKE2FS_OR_NEWFS);
    853867    retval += whine_if_not_found("bzip2");
  • branches/stable/mondo/src/common/mondostructures.h

    r1592 r1594  
    308308   * If backup_media_type is anything else, this should be blank.
    309309   */
    310     char media_device[MAX_STR_LEN / 4];
     310    char *media_device;
     311
     312    /* SCSI node (a la 0,0,0) or NULL if we use the media_device */
     313    char *iso_burning_dev;
    311314
    312315  /**
     
    566569   * The speed of the CD-R[W] drive.
    567570   */
    568     int cdrw_speed;
     571    int writer_speed;
    569572
    570573  /**
  • branches/stable/mondo/src/common/newt-specific.c

    r1549 r1594  
    698698
    699699    /*@ buffers ********************************************************** */
    700     char *blurb = NULL;
    701     char *original_contents = NULL;
    702700    bool ret = TRUE;
     701    size_t n = 0;
    703702
    704703    assert_string_is_neither_NULL_nor_zerolength(title);
     
    706705    assert(output != NULL);
    707706
     707    n = strlen(output) + 1;
    708708    if (g_text_mode) {
    709709        printf
    710710            ("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n-->  ",
    711711             title, b);
    712         (void) fgets(output, maxsize, stdin);
    713         if (output[strlen(output) - 1] == '\n')
     712        mr_getline(&output, &n, stdin);
     713        if ((strlen(output) > 1) && (output[strlen(output) - 1] == '\n')) {
    714714            output[strlen(output) - 1] = '\0';
     715        }
    715716        return(ret);
    716717    }
    717     mr_asprintf(&blurb, b);
    718     text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
    719     mr_asprintf(&original_contents, output);
    720     output[0] = '\0';
     718
     719    text = newtTextboxReflowed(2, 1, b, 48, 5, 5, 0);
    721720    type_here =
    722721        newtEntry(2, newtTextboxGetNumLines(text) + 2,
    723                   original_contents, 50,
    724 #ifdef __cplusplus
    725                   0, NEWT_FLAG_RETURNEXIT
    726 #else
     722                  output, 50,
    727723                  (void *) &entry_value, NEWT_FLAG_RETURNEXIT
    728 #endif
    729724        );
    730725    b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, _("  OK  "));
     
    736731    center_string(blurb, 80);
    737732    */
    738     newtPushHelpLine(blurb);
    739     mr_free(blurb);
     733    newtPushHelpLine(b);
    740734
    741735    b_res = newtRunForm(myForm);
    742     strcpy(output, entry_value);
    743736    newtPopHelpLine();
    744737    if (b_res == b_2) {
    745         strcpy(output, original_contents);
    746738        ret = FALSE;
     739    } else {
     740        mr_allocstr(output, newtEntryGetValue(entry_value));
    747741    }
    748742    newtFormDestroy(myForm);
    749743    newtPopWindow();
    750     mr_free(original_contents);
    751744    return(ret);
    752745}
Note: See TracChangeset for help on using the changeset viewer.