Changeset 2352 in MondoRescue


Ignore:
Timestamp:
Aug 28, 2009, 2:46:29 AM (15 years ago)
Author:
Bruno Cornec
Message:

Change inerface of evaluate_mountlist and spread_flaws_across_three_lines in order to solve bugs linked to strings management in these functions. May fix a restoration crash seen by some customers (backport from 2.2.9)

Location:
branches/2.2.10/mondo
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-mountlist-EXT.h

    r2202 r2352  
    11/* libmondo-mountlist-EXT.h */
    22
    3 extern int evaluate_mountlist(struct mountlist_itself *mountlist,
    4                               char *flaws_str_A, char *flaws_str_B,
    5                               char *flaws_str_C);
     3extern char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res);
    64extern int find_device_in_mountlist(struct mountlist_itself *mountlist,
    75                                    char *device);
  • branches/2.2.10/mondo/src/common/libmondo-mountlist.c

    r2331 r2352  
    519519 * @see evaluate_drive_within_mountlist
    520520 */
    521 int
    522 evaluate_mountlist(struct mountlist_itself *mountlist, char *flaws_str_A,
    523                    char *flaws_str_B, char *flaws_str_C)
    524 {
     521char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res) {
    525522
    526523    /*@ buffer *********************************************************** */
     
    531528    /*@ int ************************************************************** */
    532529    int i = 0;
    533     int res = 0;
    534530
    535531    /*@ initialize ******************************************************* */
    536532
     533    *res = 0;
    537534    drivelist = malloc(sizeof(struct list_of_disks));
    538535    assert(mountlist != NULL);
    539     assert(flaws_str_A != NULL);
    540     assert(flaws_str_B != NULL);
    541     assert(flaws_str_C != NULL);
    542536
    543537    mr_asprintf(flaws_str, "%s", "");
     
    556550            tmp = evaluate_drive_within_mountlist(mountlist, drivelist->el[i].device);
    557551            if (tmp == NULL) {
    558                 res++;
     552                (*res)++;
    559553            }
    560554        }
     
    567561        }
    568562    }
    569     res += look_for_duplicate_mountpoints(mountlist, flaws_str);
    570     res = spread_flaws_across_three_lines(flaws_str, flaws_str_A, flaws_str_B, flaws_str_C,res);
    571     mr_free(flaws_str);
    572     return(res);
     563    *res += look_for_duplicate_mountpoints(mountlist, flaws_str);
     564    return(flaws_str);
    573565}
    574566
  • branches/2.2.10/mondo/src/common/libmondo-mountlist.h

    r2202 r2352  
    44
    55
    6 int evaluate_mountlist(struct mountlist_itself *mountlist,
    7                        char *flaws_str_A, char *flaws_str_B,
    8                        char *flaws_str_C);
     6char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res);
    97int find_device_in_mountlist(struct mountlist_itself *mountlist,
    108                             char *device);
  • branches/2.2.10/mondo/src/common/libmondo-string-EXT.h

    r2316 r2352  
    1919                         char *s);
    2020extern int special_dot_char(int i);
    21 extern bool spread_flaws_across_three_lines(char *flaws_str,
     21extern void spread_flaws_across_three_lines(char *flaws_str,
    2222                                            char *flaws_str_A,
    2323                                            char *flaws_str_B,
    24                                             char *flaws_str_C, int res);
     24                                            char *flaws_str_C);
    2525extern int strcmp_inc_numbers(char *stringA, char *stringB);
    2626extern char *strip_afio_output_line(char *input);
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2334 r2352  
    599599 * @param flaws_str_B Where to put the second 74-or-less characters.
    600600 * @param flaws_str_C Where to put the rest.
    601  * @param res The result of the original evaluate_mountlist() operation.
    602  * @return TRUE if res == 0, FALSE otherwise.
    603  */
    604 bool
     601 */
     602void
    605603spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
    606                                 char *flaws_str_B, char *flaws_str_C,
    607                                 int res)
     604                                char *flaws_str_B, char *flaws_str_C)
    608605{
    609606
     
    612609
    613610    /*@ initialize ****************************************************** */
    614     assert(flaws_str_A != NULL);
    615     assert(flaws_str_B != NULL);
    616     assert(flaws_str_C != NULL);
    617611    assert(flaws_str != NULL);
    618612
    619     if (!res && !strlen(flaws_str)) {
    620         return (TRUE);
    621     }
    622613    if (strlen(flaws_str) > 0) {
    623         paranoid_free(flaws_str_A);
    624614        mr_asprintf(flaws_str_A, "%s", flaws_str + 1);
    625615    }
    626616    if (strlen(flaws_str_A) >= 74) {
    627617        for (i = 74; flaws_str_A[i] != ' '; i--);
    628         paranoid_free(flaws_str_B);
    629618        mr_asprintf(flaws_str_B, "%s", flaws_str_A + i + 1);
    630619        flaws_str_A[i] = '\0';
     
    632621    if (strlen(flaws_str_B) >= 74) {
    633622        for (i = 74; flaws_str_B[i] != ' '; i--);
    634         paranoid_free(flaws_str_C);
    635623        mr_asprintf(flaws_str_C, "%s", flaws_str_B + i + 1);
    636624        flaws_str_B[i] = '\0';
    637     }
    638     if (res) {
    639         return (FALSE);
    640     } else {
    641         return (TRUE);
    642625    }
    643626}
  • branches/2.2.10/mondo/src/common/libmondo-string.h

    r2316 r2352  
    1717char *slice_fname(long bigfileno, long sliceno, char *path, char *s);
    1818int special_dot_char(int i);
    19 bool spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
    20                                      char *flaws_str_B, char *flaws_str_C,
    21                                      int res);
     19void spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
     20                                     char *flaws_str_B, char *flaws_str_C);
    2221int strcmp_inc_numbers(char *stringA, char *stringB);
    2322char *strip_afio_output_line(char *input);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c

    r2334 r2352  
    19241924    /** int **************************************************************/
    19251925    int i = 0;
     1926    int res = 0;
    19261927    int currline = 0;
    19271928    int finished = FALSE;
     
    19291930    /** buffers **********************************************************/
    19301931    char *tmp = NULL;
     1932    char *flaws_str = NULL;
    19311933    char *flaws_str_A = NULL;
    19321934    char *flaws_str_B = NULL;
     
    19361938    assert(raidlist != NULL);
    19371939
    1938     mr_asprintf(flaws_str_A, "%s", "         ");
    1939     mr_asprintf(flaws_str_B, "%s", "         ");
    1940     mr_asprintf(flaws_str_C, "%s", "         ");
    19411940    if (mountlist->entries > ARBITRARY_MAXIMUM) {
    19421941        log_to_screen("Arbitrary limits suck, man!");
     
    19541953    mr_asprintf(tmp, "%-24s %-24s %-8s  %s", "Device", "Mountpoint", "Format", "Size (MB)");
    19551954    headerMsg = newtLabel(2, 1, tmp);
    1956     flawsLabelA = newtLabel(2, 13, flaws_str_A);
    1957     flawsLabelB = newtLabel(2, 14, flaws_str_B);
    1958     flawsLabelC = newtLabel(2, 15, flaws_str_C);
     1955    flawsLabelA = newtLabel(2, 13, "         ");
     1956    flawsLabelB = newtLabel(2, 14, "         ");
     1957    flawsLabelC = newtLabel(2, 15, "         ");
    19591958    partitionsListbox =
    19601959        newtListbox(2, 2, 10, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
     
    19661965                          bEdit, bDelete, bReload, bCancel, bOK, NULL);
    19671966    while (!finished) {
    1968         evaluate_mountlist(mountlist, flaws_str_A, flaws_str_B,
    1969                            flaws_str_C);
     1967        flaws_str = evaluate_mountlist(mountlist, &res);
     1968        spread_flaws_across_three_lines(flaws_str, flaws_str_A, flaws_str_B, flaws_str_C);
     1969
     1970        mr_free(flaws_str);
     1971
    19701972        newtLabelSetText(flawsLabelA, flaws_str_A);
    19711973        newtLabelSetText(flawsLabelB, flaws_str_B);
    19721974        newtLabelSetText(flawsLabelC, flaws_str_C);
    19731975        b_res = newtRunForm(myForm);
     1976        mr_free(flaws_str_A);
     1977        mr_free(flaws_str_B);
     1978        mr_free(flaws_str_C);
     1979
    19741980        if (b_res == bOK) {
    1975             if (!evaluate_mountlist
    1976                 (mountlist, flaws_str_A, flaws_str_B, flaws_str_C)) {
     1981            flaws_str = evaluate_mountlist(mountlist, &res);
     1982            mr_free(flaws_str);
     1983            if (!res) {
    19771984                finished =
    19781985                    ask_me_yes_or_no
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.h

    r2316 r2352  
    137137                   struct raidlist_itself *);
    138138void edit_raidrec_additional_vars(struct raid_device_record *);
    139 int evaluate_mountlist(struct mountlist_itself *, char *, char *, char *);
     139char *evaluate_mountlist(struct mountlist_itself *, int *);
    140140int find_device_in_mountlist(struct mountlist_itself *, char *);
    141141int find_next_free_index_in_disklist(struct list_of_disks *);
     
    180180void setup_newt_stuff(void);
    181181long size_of_specific_device(struct mountlist_itself *, char *);
    182 bool spread_flaws_across_three_lines(char *, char *, char *, char *, int);
     182void spread_flaws_across_three_lines(char *, char *, char *, char *);
    183183char *turn_raid_level_number_to_string(int);
    184184void update_evalcall_form(int);
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2338 r2352  
    752752  /** malloc **/
    753753    char *tmp = NULL;
    754     char *tmpA = NULL;
    755     char *tmpB = NULL;
    756     char *tmpC = NULL;
     754    char *flaws_str = NULL;
    757755
    758756    assert(bkpinfo != NULL);
    759757    assert(mountlist != NULL);
    760758    assert(raidlist != NULL);
    761 
    762     mr_asprintf(tmpA, "%s", "         ");
    763     mr_asprintf(tmpB, "%s", "         ");
    764     mr_asprintf(tmpC, "%s", "         ");
    765759
    766760    log_msg(2, "nuke_mode --- starting");
     
    773767        resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    774768    }
    775     if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) {
    776         mr_asprintf(tmp, "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?", tmpA, tmpB, tmpC);
     769    flaws_str = evaluate_mountlist(mountlist, &res);
     770    if (!res) {
     771        mr_asprintf(tmp, "Mountlist analyzed. Result: \"%s\" Switch to Interactive Mode?", flaws_str);
     772        mr_free(flaws_str);
    777773        res = ask_me_yes_or_no(tmp);
    778774        mr_free(tmp);
     
    784780        }
    785781    }
     782    mr_free(flaws_str);
     783
    786784    save_mountlist_to_disk(mountlist, g_mountlist_fname);
    787785    mvaddstr_and_log_it(1, 30, "Restoring Automatically");
  • branches/2.2.10/mondo/src/mondorestore/mr-externs.h

    r2325 r2352  
    109109extern bool g_restoring_live_from_nfs;
    110110extern int fput_string_one_char_at_a_time(FILE *, char *);
    111 
    112 
    113 
    114 
    115 
    116 extern int
    117 evaluate_mountlist(struct mountlist_itself *mountlist, char *flaws_str_A,
    118                    char *flaws_str_B, char *flaws_str_C);
    119 
     111extern char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res);
    120112
    121113
  • branches/2.2.10/mondo/test/test-mountlist.c

    r2323 r2352  
    4949
    5050struct mountlist_itself *mountlist = NULL;
    51 struct raidlist_itself *raidlist;
    52 char *tmpA = NULL;
    53 char *tmpB = NULL;
    54 char *tmpC = NULL;
    55 bool ret = FALSE;
     51struct raidlist_itself *raidlist = NULL;
     52int ret = 0;
     53char *flaws_str = NULL;
    5654
    5755mr_asprintf(MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
     
    8280log_it("after edit_mountlist");
    8381
    84 mr_asprintf(tmpA, "%s", "         ");
    85 mr_asprintf(tmpB, "%s", "         ");
    86 mr_asprintf(tmpC, "%s", "         ");
    87 ret = evaluate_mountlist(mountlist, tmpA, tmpB, tmpC);
     82flaws_str = evaluate_mountlist(mountlist, &ret);
    8883log_it("after evaluate_mountlist");
     84mr_free(flaws_str);
    8985
    9086mr_free(MONDO_LOGFILE);
Note: See TracChangeset for help on using the changeset viewer.