Changeset 3103


Ignore:
Timestamp:
May 2, 2013, 11:49:27 PM (7 years ago)
Author:
bruno
Message:
  • Fix #681 by reintroducing code from mindi 2.0.6 in order to support detection of initrd tyep support deep in kernel with some black magic.
  • Fix ReadAllLink? by suppoting multi-level of ../.. in link names
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mindi/mindi

    r3100 r3103  
    756756
    757757    # say where we are.
    758     LogFile "INFO:   GetInitrdFilesystemToUse(): called with parameter: $lvKernelImage"
     758    LogFile "INFO: GetInitrdFilesystemToUse(): called with parameter: $lvKernelImage"
    759759
    760760    # verify that file exists
     
    762762
    763763    # Kernel may be gzip compressed - Case of RHEL5 - SLES11SP1
    764     # kernel is x86 boot sector in RHEL3/4
    765764    file $lvKernelImage 2>&1 | grep -q gzip
    766765    if [ $? -eq 0 ]; then
    767         lvScanRes=`gzip -cd $lvKernelImage | strings | grep -E "$lcMagicCramfs|$lcMagicExt2fs|$lcMagicExt3fs|$lcMagicInitfs"`
    768 
    769         # determine which filesystem to use for initrd image: ext2|3fs, gzip'ed cpio (initramfs) or cramfs
    770         if [ `echo $lvScanRes | grep -Ec "$lcMagicExt2fs"` -eq 1 ]; then
    771             lvUseFilesystem="ext2fs"
    772         elif [ `echo $lvScanRes | grep -Ec "$lcMagicExt3fs"` -eq 1 ]; then
    773             lvUseFilesystem="ext3fs"
    774         elif [ `echo $lvScanRes | grep -Ec "$lcMagicInitfs"` -eq 1 ]; then
    775             lvUseFilesystem="initramfs"
    776         elif [ `echo $lvScanRes | grep -Ec "$lcMagicCramfs"` -eq 1 ]; then
    777             lvUseFilesystem="cramfs"
     766        LogFile "INFO: Found a gzip compressed kernel $lvKernelImage"
     767        lvScanRes=`gzip -cd $lvKernelImage | strings | grep -E "$lcMagicCramfs|$lcMagicExt2fs|$lcMagicExt3fs|$lcMagicInitfs" 2> /dev/null`
     768    else
     769        LogFile "INFO: Found a non gzip compressed kernel $lvKernelImage"
     770        # kernel is x86 boot sector in RHEL3/4 with embedded gzip content
     771        # get offet of gzip magic "1f8b0800" in file (for these older kernels)
     772        lvOffset=`od -vA n -t x1 $lvKernelImage | tr -d '[:space:]' | awk '{ print match($0, "1f8b0800")}' 2> /dev/null`
     773        if [ $lvOffset -eq 0 ]; then
     774            LogFile "INFO: gzip magic not found in file $lvKernelImage. Supposing initramfs."
     775            lvScanRes=$lcMagicInitfs
    778776        else
    779             lvUseFilesystem="UNSUPPORTED"
    780         fi
    781 
    782     else
    783         # In that case, we are after 2.6.30 and use the supported initramfs
     777            lvOffset=`expr $lvOffset / 2`
     778            LogFile "INFO: GetInitrdFilesystemToUse(): gzip magic found at lvOffset $lvOffset."
     779            # scan again  kernel image
     780            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" 2> /dev/null`
     781        fi
     782    fi
     783
     784    # determine which filesystem to use for initrd image: ext2|3fs, gzip'ed cpio (initramfs) or cramfs
     785    if [ `echo $lvScanRes | grep -Ec "$lcMagicExt2fs"` -eq 1 ]; then
     786        lvUseFilesystem="ext2fs"
     787    elif [ `echo $lvScanRes | grep -Ec "$lcMagicExt3fs"` -eq 1 ]; then
     788        lvUseFilesystem="ext3fs"
     789    elif [ `echo $lvScanRes | grep -Ec "$lcMagicInitfs"` -eq 1 ]; then
    784790        lvUseFilesystem="initramfs"
    785     fi
     791    elif [ `echo $lvScanRes | grep -Ec "$lcMagicCramfs"` -eq 1 ]; then
     792        lvUseFilesystem="cramfs"
     793    else
     794        # In that case, we are most probably after 2.6.30 and use the supported initramfs
     795        LogFile "No automatic detection found previously. Supposing initramfs."
     796        LogFile "Report on the MondoRescue mailing-list withyour log files"
     797        lvUseFilesystem="initramfs"
     798    fi
     799
    786800    # say what we are using
    787     LogFile "INFO:   GetInitrdFilesystemToUse(): Filesytem to use for initial ram disk is $lvUseFilesystem."
     801    LogFile "INFO: GetInitrdFilesystemToUse(): Filesytem to use for initial ram disk is $lvUseFilesystem."
    788802
    789803    # return file system to use
     
    923937    file="$1"
    924938
    925     echo $file | grep -q '\.\./'
    926     if [ $? -eq 0 ]; then
     939    while [ `echo $file | grep -Ec '\.\./'` -ne 0 ]; do
    927940        # We need to normalise the path with .. in it
    928         file=`echo $file | perl -pi -e 's|([^/]+)/([^/]+)/\.\./([^/]+)|$1/$3|'`
    929     fi
     941        file=`echo $file | perl -pi -e 's|([^/]*)/([^/]+)/\.\./([^/]+)|$1/$3|g'`
     942    done
    930943    echo "$file"
    931944    if [ ! -h $file ]; then
     
    25892602        fi
    25902603    done
    2591     tar cf - $finallist 2>> $MINDI_TMP/$$.log | tar xUf - || LogIt "ERROR: Problem in minimal analysis" $MINDI_TMP/$$.log
     2604    tar cf - $finallist 2>> $MINDI_TMP/$$.log | tar xUf - || LogIt "WARNING: Problem in minimal analysis" $MINDI_TMP/$$.log
    25922605
    25932606    # To improve support for distribution scripts, we now prefer to use bash as the std shell. Also fixes #600
Note: See TracChangeset for help on using the changeset viewer.