Changeset 3892 in MondoRescue for branches


Ignore:
Timestamp:
Mar 12, 2024, 3:10:24 AM (2 months ago)
Author:
Bruno Cornec
Message:

More compiler fixes

  • Fix unused vars
  • Fix FreeBSD #if alone
  • Use MDSTAT_FILE everywhere
  • Fix missing break
  • Fix some strncpy. mr_strncpy used when safe
  • Fix wrong g_isoform_header_str proto !
  • find-cd & find-dvd => find-optical
Location:
branches/3.3/mondo/src
Files:
18 edited

Legend:

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

    r3891 r3892  
    14461446 * @param ntfsprog_fifo The FIFO to ntfsclone if this is an imagedev, NULL otherwise.
    14471447 * @param biggie_file_number The sequence number of this biggie file (starting from 0).
    1448  * @param noof_biggie_files The number of biggie files there are total.
    14491448 * @return The number of errors encountered (0 for success)
    14501449 * @see make_slices_and_images
    14511450 * @ingroup LLarchiveGroup
    14521451 */
    1453 int slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, long noof_biggie_files, bool use_ntfsprog) {
     1452int slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, bool use_ntfsprog) {
    14541453
    14551454    /*@ buffers ************************************************** */
     
    18121811                write_header_block_to_stream(biggie_fsize, bigfile_fname, use_ntfsprog ?  BLK_START_A_PIHBIGGIE : BLK_START_A_NORMBIGGIE);
    18131812            }
    1814             res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, noof_biggie_files, use_ntfsprog);
     1813            res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, use_ntfsprog);
    18151814
    18161815            /* Free it here as ntfsprog_fifo is not used anymore */
     
    24172416    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    24182417        write_header_block_to_stream((off_t)0, "start-of-afioballs", BLK_START_AFIOBALLS);
     2418#ifdef __FreeBSD__
    24192419#if __FreeBSD__ == 5
    24202420        log_msg(1, "Using single-threaded make_afioballs_and_images() to suit b0rken FreeBSD 5.0");
    24212421        res = make_afioballs_and_images_OLD();
     2422#endif
    24222423#else
    24232424        res = make_afioballs_and_images_OLD();
     
    26432644    mr_asprintf(broken_bios_sz, "yes"); /* assume so */
    26442645
    2645     if (pkpinfo->auto_recovery) {
     2646    if (bkpinfo->auto_recovery) {
    26462647        mr_asprintf(cd_recovery_sz, "yes");
    26472648    } else {
  • branches/3.3/mondo/src/common/libmondo-cli.c

    r3890 r3892  
    998998void termination_in_progress(int sig)
    999999{
    1000     log_msg(1, "Termination in progress");
     1000    log_msg(1, "Termination in progress by signal %d",sig);
    10011001    usleep(1000);
    10021002    pthread_exit(0);
  • branches/3.3/mondo/src/common/libmondo-devices.c

    r3889 r3892  
    443443                mr_free(mount_list);
    444444
    445                 mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
     445                mr_asprintf(command, "%s", "cat " MDSTAT_FILE " |grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    446446                log_msg (5, "Running: %s", command);
    447447                mount_list = call_program_and_get_last_line_of_output(command);
     
    499499
    500500        /* Get the Software raid device list */
    501         mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
     501        mr_asprintf(command, "%s", "cat " MDSTAT_FILE " | grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    502502        log_msg (5, "  Running: %s", command);
    503503        mount_list = call_program_and_get_last_line_of_output(command);
     
    788788bool does_nonMS_partition_exist(void)
    789789{
    790 #if __FreeBSD__
     790#ifdef __FreeBSD__
    791791    return
    792792        !system("for drive in /dev/ad? /dev/da?; do fdisk $drive | grep -q FreeBSD && exit 0; done; false");
     
    21362136
    21372137    case udev:
    2138         if (!ask_me_yes_or_no
    2139             ("This option is for advanced users only. Are you sure?")) {
     2138        if (!ask_me_yes_or_no("This option is for advanced users only. Are you sure?")) {
    21402139            log_to_screen("User has chosen not to backup the machine");
    21412140            finish(1);
    21422141        }
     2142        break;
     2143
    21432144    case tape:
    21442145
     
    24832484// NTFS
    24842485        tmp = call_program_and_get_last_line_of_output("mr-parted2fdisk -l 2>/dev/null | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'");
    2485         strncpy(tmp1, tmp,(MAX_STR_LEN / 4)-1);
     2486        if (strlen(tmp) > 2) {
     2487            tmp1 = mr_popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp);
     2488            if (tmp1 == NULL) {
     2489                log_to_screen("User has chosen not to backup the machine");
     2490                mr_free(tmp);
     2491                mr_free(tmp1);
     2492                finish(1);
     2493            }
     2494            mr_free(bkpinfo->image_devs);
     2495            bkpinfo->image_devs = tmp1;
     2496        }
    24862497        mr_free(tmp);
    2487         if (strlen(tmp1) > 2) {
    2488             if (!popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp1,(MAX_STR_LEN / 4)-1)) {
    2489                 log_to_screen("User has chosen not to backup the machine");
    2490                 finish(1);
    2491             }
    2492             mr_asprintf(bkpinfo->image_devs, "%s", tmp1);
    2493         }
    24942498
    24952499        if (bkpinfo->exclude_paths != NULL ) {
     
    25722576        mr_free(compression_type);
    25732577
     2578#ifdef __FreeBSD__
    25742579#if __FreeBSD__ == 5
    25752580        mr_asprintf(bkpinfo->kernel_path, "%s", "/boot/kernel/kernel");
    25762581#elif __FreeBSD__ == 4
    25772582        mr_asprintf(bkpinfo->kernel_path, "%s", "/kernel");
     2583#endif
    25782584#elif linux
    25792585        if (figure_out_kernel_path_interactively_if_necessary(bkpinfo->kernel_path)) {
  • branches/3.3/mondo/src/common/libmondo-filelist.c

    r3879 r3892  
    14821482/**
    14831483 * Create the filelist for the backup. It will be stored in [scratchdir]/archives/filelist.full.
    1484  * @param logfile Unused.
    14851484 * @param tmpdir The tmpdir of the backup.
    14861485 * @param scratchdir The scratchdir of the backup.
     
    14901489 * @param userdef_filelist The user-defined filelist, or NULL if you're using @p include_paths.
    14911490 * @return 0, always.
    1492  * @bug @p logfile is unused.
    14931491 * @bug Return value is meaningless.
    14941492 */
    1495 int mondo_makefilelist(char *logfile, char *tmpdir, char *scratchdir,
     1493int mondo_makefilelist(char *tmpdir, char *scratchdir,
    14961494                       char *include_paths, char *excp, int differential,
    14971495                       char *userdef_filelist)
     
    16571655
    16581656    if (bkpinfo->make_filelist) {
    1659         res = mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
     1657        res = mondo_makefilelist(bkpinfo->tmpdir, bkpinfo->scratchdir, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
    16601658    } else {
    1661         res = mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
     1659        res = mondo_makefilelist(bkpinfo->tmpdir, bkpinfo->scratchdir, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
    16621660    }
    16631661
  • branches/3.3/mondo/src/common/libmondo-raid.c

    r3879 r3892  
    5656        mr_strcat(command, "raid%d", raidno);
    5757    }
    58     mr_strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null");
     58    mr_strcat(command, "\" " MDSTAT_FILE " > /dev/null 2> /dev/null");
    5959    log_it("Is raid %d registered? Command = '%s'", raidno, command);
    6060    res = system(command);
  • branches/3.3/mondo/src/common/libmondo-stream.c

    r3882 r3892  
    317317{
    318318    int res = 0;
    319     char *command = NULL;
    320319
    321320    if (bkpinfo->media_device == NULL) {
  • branches/3.3/mondo/src/common/libmondo-string.c

    r3882 r3892  
    387387    switch (i) {
    388388    case 0:
    389         mr_asprintf(output, "zero");
     389        mr_asprintf(output, "%s", "zero");
    390390        break;
    391391    case 1:
    392         mr_asprintf(output, "one");
     392        mr_asprintf(output, "%s", "one");
    393393        break;
    394394    case 2:
    395         mr_asprintf(output, "two");
     395        mr_asprintf(output, "%s", "two");
    396396        break;
    397397    case 3:
    398         mr_asprintf(output, "three");
     398        mr_asprintf(output, "%s", "three");
    399399        break;
    400400    case 4:
    401         mr_asprintf(output, "four");
     401        mr_asprintf(output, "%s", "four");
    402402        break;
    403403    case 5:
    404         mr_asprintf(output, "five");
     404        mr_asprintf(output, "%s", "five");
    405405        break;
    406406    case 6:
    407         mr_asprintf(output, "six");
     407        mr_asprintf(output, "%s", "six");
    408408        break;
    409409    case 7:
    410         mr_asprintf(output, "seven");
     410        mr_asprintf(output, "%s", "seven");
    411411        break;
    412412    case 8:
    413         mr_asprintf(output, "eight");
     413        mr_asprintf(output, "%s", "eight");
    414414        break;
    415415    case 9:
    416         mr_asprintf(output, "nine");
     416        mr_asprintf(output, "%s", "nine");
     417        break;
    417418    case 10:
    418         mr_asprintf(output, "ten");
     419        mr_asprintf(output, "%s", "ten");
     420        break;
    419421    default:
    420422        mr_asprintf(output, "%d", i);
     423        break;
    421424    }
    422425    return (output);
  • branches/3.3/mondo/src/common/libmondo-tools.c

    r3890 r3892  
    735735
    736736    if (!run_program_and_log_output("mr-parted2fdisk -l 2>/dev/null | grep -i raid", 1) && !does_file_exist("/etc/raidtab")) {
    737         log_to_screen("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat");
     737        log_to_screen("You have RAID partitions but no /etc/raidtab - creating one from " MDSTAT_FILE);
    738738        create_raidtab_from_mdstat(MDSTAT_FILE,"/etc/raidtab");
    739739    }
  • branches/3.3/mondo/src/common/libmondo-verify.c

    r3878 r3892  
    345345 * @param bkpinfo The backup information structure. @c bkpinfo->tmpdir is the only field used.
    346346 * @param biggie_fname The filename of the biggiefile to verify.
    347  * @param size The size in bytes of said biggiefile.
     347 * @param size The size in bytes of said biggiefile. TODO: Removed as not used. Is it linked to slice_siz ?
    348348 * @return 0 for success (even if the file doesn't match); nonzero for a tape error.
    349349 */
    350350int
    351 verify_a_biggiefile_from_stream(char *biggie_fname, long long size)
     351verify_a_biggiefile_from_stream(char *biggie_fname)
    352352{
    353353
     
    609609        if (bkpinfo->restore_path != NULL) {
    610610            mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
    611             res = verify_a_biggiefile_from_stream(logical_fname, size);
     611            res = verify_a_biggiefile_from_stream(logical_fname);
    612612            mr_free(logical_fname);
    613613            retval += res;
  • branches/3.3/mondo/src/common/newt-specific.c

    r3882 r3892  
    7979    long g_isoform_starttime;   ///< The time (in seconds since the epoch) that the evalcall form was opened.
    8080    int g_isoform_old_progress = -1;    ///< The most recent progress update of the evalcall form (percent).
    81     char g_isoform_header_str = NULL;   ///< The string for the evalcall form title.
     81    char *g_isoform_header_str = NULL;  ///< The string for the evalcall form title.
    8282    int g_mysterious_dot_counter;   ///< The counter for the twirling baton (/ | \\ - ...) on percentage less than 3
    8383    int g_noof_log_lines = 6;   ///< The number of lines to show in the log at the bottom of the screen.
     
    602602
    603603        assert(ttl != NULL);
    604         //strcpy(g_isoform_header_str, ttl);
    605604        if (g_text_mode) {
    606605            log_msg(0, ttl);
     
    614613        g_isoform_starttime = get_time();
    615614        if (g_text_mode) {
    616             log_msg(0, g_isoform_header_str);
     615            log_msg(0, "g_isoform_header_str = %s", g_isoform_header_str);
    617616        } else {
    618617            g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
     
    10121011        }
    10131012
    1014         /* not sure it's useful to shrink here
    1015         prompt = malloc(MAX_NEWT_COMMENT_LEN);
    1016         strncpy(prompt, p, MAX_NEWT_COMMENT_LEN - 1);
    1017         prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0';
    1018         text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
    1019         */
    10201013        text = newtTextboxReflowed(1, 1, p, 40, 5, 5, 0);
    10211014        b_1 = newtButton(20 - ((button2[0] != '\0') ? strlen(button1) + 2 : strlen(button1) / 2), newtTextboxGetNumLines(text) + 3, button1);
     
    15281521 * @param flentry The filelist entry to stringify.
    15291522 * @return The string form of @p flentry.
    1530  * @note The returned value points to static storage that will be overwritten with each call.
     1523 * @note The returned value points to a dynamically allocated string that the caller needs to free.
    15311524 */
    15321525char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
    1533         static char comment[100];
    1534         char *tmp = NULL;
     1526        char *comment = NULL;
    15351527
    15361528        log_msg(8, "entering");
    15371529        assert(flentry != NULL);
    15381530        if (flentry->severity == 0) {
    1539             mr_asprintf(tmp, "0   ");
     1531            mr_asprintf(comment, "0   ");
    15401532        } else if (flentry->severity == 1) {
    1541             mr_asprintf(tmp, "low ");
     1533            mr_asprintf(comment, "low ");
    15421534        } else if (flentry->severity == 2) {
    1543             mr_asprintf(tmp, "med ");
    1544         } else {
    1545             mr_asprintf(tmp, "high");
    1546         }
    1547         mr_strcat(tmp, "  ");
    1548         mr_strcat(tmp, flentry->filename);
    1549         strncpy(comment, tmp, 99);
    1550         mr_free(tmp);
    1551 
     1535            mr_asprintf(comment, "med ");
     1536        } else {
     1537            mr_asprintf(comment, "high");
     1538        }
     1539        mr_strcat(comment, "  ");
     1540        mr_strcat(comment, flentry->filename);
    15521541        log_it("leaving");
    15531542        return (comment);
     
    16151604        for (i = 0; i < filelist->entries; i++) {
    16161605            keylist[i] = (void *) i;
     1606            tmp = filelist_entry_to_string(&(filelist->el[i]));
    16171607            newtListboxAppendEntry(fileListbox,
    1618                                    filelist_entry_to_string(&
    1619                                                             (filelist->
    1620                                                              el[i])),
     1608                                    tmp,
    16211609                                   keylist[i]);
     1610            mr_free(tmp);
    16221611        }
    16231612        mr_asprintf(differ_sz, "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i);
  • branches/3.3/mondo/src/include/mr_str.h

    r3708 r3892  
    2020extern char *mr_strip_spaces(const char *instr);
    2121extern char *mr_str_substitute(const char *in, const char *token, const char *subst);
     22
     23// All safe strncpy calls are prefixed
     24#define mr_strncpy strncpy
    2225/*
    2326extern void mr_strip_char(char *in_out, char *caracs);
  • branches/3.3/mondo/src/lib/mr_str.c

    r3794 r3892  
    1212
    1313#include "mr_mem.h"
     14#include "mr_str.h"
    1415
    1516// to get bool type
     
    5253pos1 = strcspn(strptr, delims);
    5354token = (char *)mr_malloc(sizeof(*token) * (pos1 + 1));
    54 strncpy(token, strptr, pos1);
     55mr_strncpy(token, strptr, pos1);
    5556token[pos1] = '\0';
    5657*lastpos = *lastpos + pos1 + pos2 + 1;
  • branches/3.3/mondo/src/mondoarchive/mondoarchive.c

    r3885 r3892  
    276276    }
    277277
    278     if (argc > 2 && !strcmp(argv[1], "find-cd")) {
     278    if (argc > 2 && !strcmp(argv[1], "find-optical")) {
    279279        g_loglevel = 10;
    280280        setup_newt_stuff();
     
    283283        } else {
    284284            printf("Optical drive is at %s\n", tmp);
    285         }
    286         mr_free(tmp);
    287         finish(0);
    288     }
    289 
    290     if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
    291         g_loglevel = 10;
    292         setup_newt_stuff();
    293         if (tmp = find_optical_device()) {
    294             printf("Failed to find DVD drive\n");
    295         } else {
    296             printf("DVD is at %s\n", tmp);
    297285        }
    298286        mr_free(tmp);
  • branches/3.3/mondo/src/mondorestore/mondo-prep.c

    r3885 r3892  
    10261026    }
    10271027#else
    1028     fin = fopen("/proc/mdstat", "r");
     1028    fin = fopen(MDSTAT_FILE, "r");
    10291029    if (!fin) {
    1030         log_OS_error("/proc/mdstat");
     1030        log_OS_error(MDSTAT_FILE);
    10311031        paranoid_free(incoming);
    10321032        return (1);
     
    11271127log_msg(1, "Creating LVMs");
    11281128if (does_file_exist("/tmp/i-want-my-lvm")) {
    1129     wait_until_software_raids_are_prepped("/proc/mdstat", 100);
     1129    wait_until_software_raids_are_prepped(100);
    11301130    log_to_screen("Configuring LVM");
    11311131    if (!g_text_mode) {
     
    18991899log_it("Partitioning drive %s", drivename);
    19001900
    1901 #if __FreeBSD__
     1901#ifdef __FreeBSD__
    19021902    log_it("(Not opening fdisk now; that's the Linux guy's job)");
    19031903    pout_to_fdisk = NULL;
     
    19201920    if (lino < 0) {
    19211921        // device not found in mountlist
    1922 #if __FreeBSD__
     1922#ifdef __FreeBSD__
    19231923            // If this is the first partition (just as a sentinel value),
    19241924            // then see if the user has picked 'dangerously-dedicated' mode.
     
    19861986
    19871987        log_it("Wiping %s's partition table", drivename);
    1988 #if __FreeBSD__
     1988#ifdef __FreeBSD__
    19891989            // FreeBSD doesn't let you write to blk devices in <512byte chunks.
    19901990            file = open(drivename, O_WRONLY);
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-newt.c

    r3879 r3892  
    615615 * @ingroup restoreGuiMountlist
    616616 */
    617 void
    618 choose_raid_level(struct OSSWAP (raid_device_record, vinum_plex) * raidrec)
    619 {
     617void choose_raid_level(struct OSSWAP (raid_device_record, vinum_plex) * raidrec) {
    620618
    621619#ifdef __FreeBSD__
    622620
    623621    /** int ***************************************************************/
    624     int res = 0;
    625622    int out = 0;
    626623
    627624    /** buffers ***********************************************************/
    628     char tmp[MAX_STR_LEN];
     625    char *tmp = NULL;
     626    char *tmp1 = NULL;
    629627    char *prompt = NULL;
    630     char sz[MAX_STR_LEN];
     628    char *sz = NULL;
    631629
    632630    mr_asprintf(prompt, "Please enter the RAID level you want. (concat, striped, raid5)");
    633631    if (raidrec->raidlevel == -1) {
    634         strcpy(tmp, "concat");
     632        mr_asprintf(tmp, "%s", "concat");
    635633    } else if (raidrec->raidlevel == 0) {
    636         strcpy(tmp, "striped");
     634        mr_asprintf(tmp, "%s", "striped");
    637635    } else {
    638         sprintf(tmp, "raid%i", raidrec->raidlevel);
     636        mr_asprintf(tmp, "raid%i", raidrec->raidlevel);
    639637    }
    640638    for (out = 999; out == 999;) {
    641         res = popup_and_get_string("Specify RAID level", prompt, tmp, 10);
    642         if (!res) {
     639        tmp1 = mr_popup_and_get_string("Specify RAID level", prompt, tmp);
     640        if (tmp1 == NULL) {
    643641            mr_free(prompt);
     642            mr_free(tmp);
    644643            return;
    645644        }
    646         strip_spaces(tmp);
     645        mr_free(tmp);
     646        tmp = mr_strip_spaces(tmp1);
     647        log_it(tmp);
     648
    647649        if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') {
    648             strcpy(sz, tmp);
    649             strncpy(tmp, sz + 1, strlen(sz) - 2);
     650            sz = tmp;
     651            // safe as shorter
     652            mr_strncpy(tmp, sz + 1, strlen(sz) - 2);
    650653            tmp[strlen(sz) - 2] = '\0';
    651654        }
     
    657660            out = 5;
    658661        }
    659         log_it(tmp);
     662        mr_free(tmp);
     663
    660664        if (is_this_raid_personality_registered(out)) {
    661665            log_it("Groovy. You've picked a RAID personality which is registered.");
     
    664668            {
    665669                out = 999;
     670                if (raidrec->raid_level == -1) {
     671                    mr_asprintf(tmp, "%s", "linear");
     672                } else {
     673                    mr_asprintf(tmp, "%d", raidrec->raid_level);
     674                }
    666675            }
    667676        }
    668677    }
    669678    mr_free(prompt);
     679    mr_free(tmp);
    670680
    671681    raidrec->raidlevel = out;
    672682#else
    673683    /** buffers ***********************************************************/
    674     char tmp[MAX_STR_LEN];
     684    char *tmp = NULL;
     685    char *tmp1 = NULL;
    675686    char *personalities = NULL;
    676687    char *prompt = NULL;
    677     char sz[MAX_STR_LEN];
     688    char *sz;
    678689    int out = 0;
    679     int res = 0;
    680690
    681691
    682692    assert(raidrec != NULL);
    683     paranoid_system("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null");
     693    paranoid_system("grep Pers " MDSTAT_FILE " > /tmp/raid-personalities.txt 2> /dev/null");
    684694    mr_asprintf(personalities, "%s", last_line_of_file("/tmp/raid-personalities.txt"));
    685695    mr_asprintf(prompt, "Please enter the RAID level you want. %s", personalities);
     
    687697
    688698    if (raidrec->raid_level == -1) {
    689         strcpy(tmp, "linear");
     699        mr_asprintf(tmp, "%s", "linear");
    690700    } else {
    691         sprintf(tmp, "%d", raidrec->raid_level);
     701        mr_asprintf(tmp, "%d", raidrec->raid_level);
    692702    }
    693703    for (out = 999;
    694704         out != -1 && out != 0 && out != 1 && out != 4 && out != 5
    695705         && out != 10;) {
    696         res = popup_and_get_string("Specify RAID level", prompt, tmp, 10);
    697         if (!res) {
     706        tmp1 = mr_popup_and_get_string("Specify RAID level", prompt, tmp);
     707        if (tmp1 == NULL) {
     708            mr_free(tmp);
     709            mr_free(prompt);
    698710            return;
    699711        }
    700         strip_spaces(tmp);
     712        mr_free(tmp);
     713        tmp = mr_strip_spaces(tmp1);
     714        log_it(tmp);
     715
    701716        if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') {
    702             strcpy(sz, tmp);
    703             strncpy(tmp, sz + 1, strlen(sz) - 2);
     717            sz = tmp;
     718            // safe as shorter
     719            mr_strncpy(tmp, sz + 1, strlen(sz) - 2);
    704720            tmp[strlen(sz) - 2] = '\0';
    705721        }
     
    711727            out = atoi(tmp);
    712728        }
    713         log_it(tmp);
     729        mr_free(tmp);
     730
    714731        if (is_this_raid_personality_registered(out)) {
    715732            log_it("Groovy. You've picked a RAID personality which is registered.");
     
    717734            if (ask_me_yes_or_no("You have chosen a RAID personality which is not registered with the kernel. Make another selection?")) {
    718735                out = 999;
     736                mr_free(tmp);
     737                if (raidrec->raid_level == -1) {
     738                    mr_asprintf(tmp, "%s", "linear");
     739                } else {
     740                    mr_asprintf(tmp, "%d", raidrec->raid_level);
     741                }
    719742            }
    720743        }
    721744    }
    722745    mr_free(prompt);
     746    mr_free(tmp);
    723747
    724748    raidrec->raid_level = out;
     
    24832507
    24842508
    2485 #if __FreeBSD__
     2509#ifdef __FreeBSD__
    24862510/**
    24872511 * Add a subdisk to @p raidrec.
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-tools-EXT.h

    r3885 r3892  
    2929extern void ask_about_these_imagedevs(char *infname, char *outfname);
    3030
    31 extern void wait_until_software_raids_are_prepped(char *mdstat_file,
    32                                                   int wait_for_percentage);
     31extern void wait_until_software_raids_are_prepped(int wait_for_percentage);
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c

    r3889 r3892  
    2222// no include for now in mondo-rstr-newt.c
    2323extern int edit_filelist(struct s_node *);
     24
     25extern struct s_bkpinfo *bkpinfo;
    2426
    2527/**
     
    9092extern char *MONDO_LOGFILE;
    9193
    92 /* Reference to global bkpinfo */
    93 extern struct s_bkpinfo *bkpinfo;
    94 
    9594/* Should we use or not extended attributes and acl when restoring */
    9695extern char *g_getfattr;
     
    525524 * @return TRUE if OK was pressed, FALSE otherwise.
    526525 */
    527 bool get_isodir_info(char *isodir_device, char *isodir_format,
    528                 struct s_bkpinfo *bkpinfo, bool nuke_me_please)
     526bool get_isodir_info(char *isodir_device, char *isodir_format, bool nuke_me_please)
    529527{
    530528
     
    610608}
    611609
    612 if (!get_isodir_info(g_isodir_device, g_isodir_format, bkpinfo, nuke_me_please)) {
     610if (!get_isodir_info(g_isodir_device, g_isodir_format, nuke_me_please)) {
    613611    return (1);
    614612}
     
    678676/** malloc **/
    679677char *tmp = NULL;
    680 char *tmp1 = NULL;
    681678char *command = NULL;
    682679char *mountdir = NULL;
     
    22582255/* @} - end restoreUtilityGroup */
    22592256
    2260 void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage)
     2257void wait_until_software_raids_are_prepped(int wait_for_percentage)
    22612258{
    22622259    struct raidlist_itself *raidlist;
  • branches/3.3/mondo/src/mondorestore/mondorestore.c

    r3885 r3892  
    3232#include "newt-specific-EXT.h"
    3333
    34 extern void wait_until_software_raids_are_prepped(char *, int);
    3534extern void twenty_seconds_til_yikes(void);
    3635// in mondo-prep.c
     
    377376        case -1:
    378377            fatal_error("Fork failure");
     378            break;
    379379        case 0:
    380380            log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", biggiestruct.filename, ntfsprog_fifo);
     
    10411041 * @param orig_bf_fname The original filename of the biggiefile.
    10421042 * @param biggiefile_number The number of the biggiefile (starting from 0).
    1043  * @param orig_checksum Unused.
    1044  * @param biggiefile_size Unused.
    10451043 * @param filelist The node structure containing the list of files to be restored.
    10461044 * If @p orig_bf_fname is not in the list, it will be ignored.
    10471045 * @return 0 for success (or skip), nonzero for failure.
    1048  * @bug orig_checksum and biggiefile_size are unused (except to check that they are non-NULL).
    1049  */
    1050 int restore_a_biggiefile_from_stream(char *orig_bf_fname, long biggiefile_number, char *orig_checksum,  //UNUSED
    1051                                      long long biggiefile_size, //UNUSED
     1046 */
     1047int restore_a_biggiefile_from_stream(char *orig_bf_fname, long biggiefile_number,
    10521048                                     struct s_node *filelist,
    10531049                                     int use_ntfsprog,
     
    10851081    assert(bkpinfo != NULL);
    10861082    assert(orig_bf_fname != NULL);
    1087     assert(orig_checksum != NULL);
    10881083
    10891084    pathname_of_last_file_restored[0] = '\0';
     
    11441139        case -1:
    11451140            fatal_error("Fork failure");
     1141            break;
    11461142        case 0:
    11471143            log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", outfile_fname, ntfsprog_fifo);
     
    13721368        res = restore_a_biggiefile_from_stream(biggie_fname,
    13731369                                               current_bigfile_number,
    1374                                                biggie_cksum,
    1375                                                biggie_size,
    13761370                                               filelist, ctrl_chr,
    13771371                                               pathname_of_last_biggie_restored);
     
    27302724    }
    27312725
    2732     if (argc == 3 && strcmp(argv[1], "--mdstat") == 0) {
    2733         wait_until_software_raids_are_prepped(argv[2], 100);
     2726    if (argc == 2 && strcmp(argv[1], "--mdstat") == 0) {
     2727        wait_until_software_raids_are_prepped(100);
    27342728        finish(0);
    27352729    }
     
    29522946    }
    29532947
    2954 /* 
    2955   log_to_screen("If you are REALLY in a hurry, hit Ctrl-Alt-Del now.");
    2956   log_to_screen("Otherwise, please wait until the RAID disks are done.");
    2957   wait_until_software_raids_are_prepped("/proc/mdstat", 100);
    2958   log_to_screen("Thank you.");
    2959 */
    29602948    unlink("/tmp/mondo-run-prog.tmp");
    29612949    set_signals(FALSE);
Note: See TracChangeset for help on using the changeset viewer.