Changeset 2395 in MondoRescue


Ignore:
Timestamp:
Sep 12, 2009, 2:57:02 AM (15 years ago)
Author:
Bruno Cornec
Message:
  • Fix interface of evaluate_mountlist (remove 2nd param useless) and fix nuke mode which wasn't working.
  • Tries to add support for bzip2 and lzma initramfs (preliminary, not tested) for 2.6.30

(Backport from 2.2.9)

Location:
branches/2.2.10
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mindi/mindi

    r2391 r2395  
    653653        lvScanRes=`gzip -cd $lvKernelImage | strings | grep -E "$lcMagicCramfs|$lcMagicExt2fs|$lcMagicExt3fs|$lcMagicInitfs"`
    654654    else
    655         # get offet of gzip magic "1f8b0800" in file
     655        # Since 2.6.30 kernel can use lzma and bzip2 in addition to gzip for initramfs compression
     656        # get offet of gzip magic "1f8b0800" in file (or 1f8b9e ??)
    656657        lvOffset=`od -vA n -t x1 $lvKernelImage | tr -d '[:space:]' | awk '{ print match($0, "1f8b0800")}'`
    657         [ $lvOffset -eq 0 ] && Die "gzip magic not found in file $lvKernelImage. Terminating."
     658        if [ $lvOffset -eq 0 ]; then
     659            # get offet of bzip2 magic "425a" in file
     660            lvOffset=`od -vA n -t x1 $lvKernelImage | tr -d '[:space:]' | awk '{ print match($0, "425a")}'`
     661            if [ $lvOffset -eq 0 ]; then
     662                # get offet of lzma magic "5d00" in file
     663                lvOffset=`od -vA n -t x1 $lvKernelImage | tr -d '[:space:]' | awk '{ print match($0, "5d00")}'`
     664                if [ $lvOffset -eq 0 ]; then
     665                    Die "No magic compression pattern found in file $lvKernelImage. Terminating."
     666                else
     667                    comp="lzma"
     668                fi
     669            else
     670                comp="bzip2"
     671            fi
     672        else
     673            comp="gzip"
     674        fi
     675
    658676        lvOffset=`expr $lvOffset / 2`
    659         LogFile "  GetInitrdFilesystemToUse(): gzip magic found at lvOffset $lvOffset.\n"
     677        LogFile "  GetInitrdFilesystemToUse(): $comp magic found in $lvKernelImage at lvOffset $lvOffset.\n"
    660678
    661679        # scan kernel image for initrd filessystem support
    662         lvScanRes=`dd ibs=1 skip=$lvOffset if=$lvKernelImage obs=1M 2>/dev/null | gunzip -c 2> /dev/null | strings | grep -E "$lcMagicCramfs|$lcMagicExt2fs|$lcMagicExt3fs|$lcMagicInitfs"`
     680        lvScanRes=`dd ibs=1 skip=$lvOffset if=$lvKernelImage obs=1M 2>/dev/null | $comp -dc 2> /dev/null | strings | grep -E "$lcMagicCramfs|$lcMagicExt2fs|$lcMagicExt3fs|$lcMagicInitfs"`
    663681    fi
    664682
  • branches/2.2.10/mondo/src/common/libmondo-mountlist-EXT.h

    r2385 r2395  
    11/* libmondo-mountlist-EXT.h */
    22
    3 extern char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res);
     3extern char *evaluate_mountlist(struct mountlist_itself *mountlist);
    44extern int find_device_in_mountlist(struct mountlist_itself *mountlist,
    55                                    char *device);
  • branches/2.2.10/mondo/src/common/libmondo-mountlist.c

    r2385 r2395  
    517517 * for each drive, and then spreads the flaws across three lines.
    518518 * @param mountlist The mountlist to evaluate.
    519  * @param flaws_str_A Where to put the first line listing errors found.
    520  * @param flaws_str_B Where to put the second line listing errors found.
    521  * @param flaws_str_C Where to put the third line listing errors found.
    522  * @return The number of flaws found (0 for success).
     519 * @return The flaws string (NULL for success).
    523520 * @see evaluate_drive_within_mountlist
    524521 */
    525 char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res) {
     522char *evaluate_mountlist(struct mountlist_itself *mountlist) {
    526523
    527524    /*@ buffer *********************************************************** */
     
    542539    /*@ initialize ******************************************************* */
    543540
    544     *res = 0;
    545541    drivelist = malloc(sizeof(struct list_of_disks));
    546542    assert(mountlist != NULL);
    547 
    548     mr_asprintf(flaws_str, "%s", "");
    549543
    550544    make_list_of_drives_in_mountlist(mountlist, drivelist);
     
    560554            log_msg(8, "Evaluating drive #%d (%s) within mountlist", i, drivelist->el[i].device);
    561555            tmp = evaluate_drive_within_mountlist(mountlist, drivelist->el[i].device);
    562             if (tmp != NULL) {
    563                 (*res)++;
    564             }
    565556        }
    566557        log_msg(8,"Entry: %d (%s)", i, drivelist->el[i].device);
    567558        /* BCO: tmp can be NULL */
    568559        if (tmp != NULL) {
    569             log_msg(8,"Adding: %s to %s", tmp, flaws_str);
     560            log_msg(8,"Adding: %s to flaws_str", tmp);
    570561            mr_strcat(flaws_str, "%s", tmp);
    571562            mr_free(tmp);
     
    589580            mr_asprintf(tmp, " %s %s's.", number_to_text(copies), curr_mountpoint);
    590581            mr_strcat(flaws_str, "%s", tmp);
    591             log_it(tmp);
     582            log_msg(8,"Adding: %s to flaws_str", tmp);
    592583            mr_free(tmp);
    593             (*res)++;
    594584        }
    595585        mr_free(curr_mountpoint);
  • branches/2.2.10/mondo/src/common/libmondo-mountlist.h

    r2385 r2395  
    44
    55
    6 char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res);
     6char *evaluate_mountlist(struct mountlist_itself *mountlist);
    77int find_device_in_mountlist(struct mountlist_itself *mountlist,
    88                             char *device);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c

    r2382 r2395  
    19241924    /** int **************************************************************/
    19251925    int i = 0;
    1926     int res = 0;
    19271926    int currline = 0;
    19281927    int finished = FALSE;
     
    19651964                          bEdit, bDelete, bReload, bCancel, bOK, NULL);
    19661965    while (!finished) {
    1967         flaws_str = evaluate_mountlist(mountlist, &res);
     1966        flaws_str = evaluate_mountlist(mountlist);
    19681967        if (strlen(flaws_str) > 0) {
    19691968            mr_asprintf(flaws_str_A, "%s", flaws_str + 1);
     
    19961995
    19971996        if (b_res == bOK) {
    1998             flaws_str = evaluate_mountlist(mountlist, &res);
    1999             mr_free(flaws_str);
    2000             if (!res) {
     1997            flaws_str = evaluate_mountlist(mountlist);
     1998            if (flaws_str != NULL) {
     1999                mr_free(flaws_str);
    20012000                finished =
    20022001                    ask_me_yes_or_no
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.h

    r2385 r2395  
    137137                   struct raidlist_itself *);
    138138void edit_raidrec_additional_vars(struct raid_device_record *);
    139 char *evaluate_mountlist(struct mountlist_itself *, int *);
     139char *evaluate_mountlist(struct mountlist_itself *);
    140140int find_device_in_mountlist(struct mountlist_itself *, char *);
    141141int find_next_free_index_in_disklist(struct list_of_disks *);
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2391 r2395  
    774774    mr_free(tmp);
    775775
    776     flaws_str = evaluate_mountlist(mountlist, &res);
    777     if (!res) {
     776    flaws_str = evaluate_mountlist(mountlist);
     777    if (flaws_str != NULL) {
    778778        mr_asprintf(tmp, "Mountlist analyzed. Result: \"%s\" Switch to Interactive Mode?", flaws_str);
    779779        mr_free(flaws_str);
     
    787787        }
    788788    }
    789     mr_free(flaws_str);
    790789
    791790    save_mountlist_to_disk(mountlist, g_mountlist_fname);
  • branches/2.2.10/mondo/src/mondorestore/mr-externs.h

    r2382 r2395  
    109109extern bool g_restoring_live_from_netfs;
    110110extern int fput_string_one_char_at_a_time(FILE *, char *);
    111 extern char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res);
     111extern char *evaluate_mountlist(struct mountlist_itself *mountlist);
    112112
    113113
  • branches/2.2.10/mondo/test/test-mountlist.c

    r2352 r2395  
    5050struct mountlist_itself *mountlist = NULL;
    5151struct raidlist_itself *raidlist = NULL;
    52 int ret = 0;
    5352char *flaws_str = NULL;
    5453
     
    8079log_it("after edit_mountlist");
    8180
    82 flaws_str = evaluate_mountlist(mountlist, &ret);
     81flaws_str = evaluate_mountlist(mountlist);
    8382log_it("after evaluate_mountlist");
    8483mr_free(flaws_str);
Note: See TracChangeset for help on using the changeset viewer.