Changeset 3892 in MondoRescue for branches/3.3/mondo/src/mondorestore


Ignore:
Timestamp:
Mar 12, 2024, 3:10:24 AM (2 years 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/mondorestore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 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.