Changeset 1548 for branches/stable


Ignore:
Timestamp:
Jul 24, 2007, 1:39:36 AM (12 years ago)
Author:
bruno
Message:
  • Add the possibiilty to edit in interactive mode mtab and device.map for grub
  • Remove blkid cache files after restore to avoid problems in cloning mode
  • Fix what seems to appear a huge number of bugs in hack-fstab (illustration of 1 LOC = 1 bug :-)
  • Especially improve LABEL and UUID support.
  • Should fix #185
  • Exclude_path should be 4*MAX_STR_LEN everywhere. Fixed now.
  • Increasing that value will allow to having larger exclude paths.
  • Should solve bug #137 (and maybe #3 as well)
  • Adds support for fedora 7

(merge -r 1533:1547 $SVN_M/branches/2.2.5)

Location:
branches/stable/mondo/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/libmondo-devices.c

    r1543 r1548  
    19301930            ("Exclude paths",
    19311931             "Please enter paths which you do NOT want to backup. Separate them with spaces. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.",
    1932              bkpinfo->exclude_paths, MAX_STR_LEN)) {
     1932             bkpinfo->exclude_paths, (4*MAX_STR_LEN)-1)) {
    19331933            log_to_screen("User has chosen not to backup the PC");
    19341934            finish(1);
  • branches/stable/mondo/src/common/libmondo-filelist.c

    r1543 r1548  
    15251525
    15261526    malloc_string(sz_datefile);
    1527     malloc_string(exclude_paths);
     1527    if (!(exclude_paths = malloc(8*MAX_STR_LEN))) {
     1528        fatal_error("Cannot malloc exclude_paths");
     1529    }
    15281530    malloc_string(g_skeleton_filelist);
    15291531    // The pathname to the skeleton filelist, used to give better progress reporting for mondo_makefilelist().
     
    15831585        mr_msg(2, "include_paths = '%s'", include_paths);
    15841586        mr_msg(1, "Calculating filelist");
    1585         sprintf(exclude_paths, " %s %s %s %s %s %s . .. \
     1587        snprintf(exclude_paths, (size_t)8*MAX_STR_LEN," %s %s %s %s %s %s . .. \
    15861588" MNT_CDROM " " MNT_FLOPPY " /media \
    15871589/proc /sys /tmp /var/log/lastlog /root/images/mondo " MINDI_CACHE " " MONDO_CACHE, excp, call_program_and_get_last_line_of_output("locate /win386.swp 2> /dev/null"), call_program_and_get_last_line_of_output("locate /hiberfil.sys 2> /dev/null"), call_program_and_get_last_line_of_output("locate /pagefile.sys 2> /dev/null"), (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
  • branches/stable/mondo/src/common/libmondo-fork.c

    r1344 r1548  
    66#include "mr_msg.h"
    77#include "mr_str.h"
     8#include "mr_gettext.h"
    89
    910#include "mondostructures.h"
  • branches/stable/mondo/src/common/libmondo-mountlist.c

    r1440 r1548  
    1717#include "libmondo-string-EXT.h"
    1818#include "newt-specific-EXT.h"
     19
    1920#include "mr_mem.h"
    2021#include "mr_msg.h"
     22#include "mr_gettext.h"
    2123
    2224/*@unused@*/
  • branches/stable/mondo/src/common/libmondo-stream.c

    r1424 r1548  
    1616#include "mr_msg.h"
    1717#include "mr_list.h"
     18#include "mr_gettext.h"
    1819
    1920#include "mondostructures.h"
     
    13521353int write_backcatalog_to_tape(struct s_bkpinfo *bkpinfo)
    13531354{
    1354     int i, last, res = 0;
     1355    int res = 0;
    13551356    char *fname = NULL;
    13561357    struct mr_list_elt *elt = NULL;
  • branches/stable/mondo/src/mondoarchive/mondo-cli.c

    r1529 r1548  
    577577        mr_asprintf(&psz, list_of_NFS_mounts_only());
    578578        if (bkpinfo->exclude_paths[0]) {
    579             strncat(bkpinfo->exclude_paths, " ", MAX_STR_LEN);
    580         }
    581         strncat(bkpinfo->exclude_paths, psz, MAX_STR_LEN);
     579            strncat(bkpinfo->exclude_paths, " ", 4*MAX_STR_LEN);
     580        }
     581        strncat(bkpinfo->exclude_paths, psz, 4*MAX_STR_LEN);
    582582        mr_free(psz);
    583583        mr_msg(3, "-N means we're now excluding %s",
    584584                bkpinfo->exclude_paths);
    585585    }
    586     if (strlen(bkpinfo->exclude_paths) >= MAX_STR_LEN) {
     586    if (strlen(bkpinfo->exclude_paths) >= 4*MAX_STR_LEN) {
    587587        fatal_error
    588             ("Your '-E' parameter is too long. Please use '-J'. (See manual.)");
     588            ("Your '-E' parameter is too long. Increase MAX_STR_LEN");
    589589    }
    590590    if (flag_set['b']) {
  • branches/stable/mondo/src/mondorestore/mondo-rstr-tools.c

    r1500 r1548  
    14101410        mvaddstr_and_log_it(g_currentY,
    14111411                            0,
    1412                             _
    1413                             ("Modifying fstab and grub.conf, and running GRUB...                             "));
     1412                            ("Modifying fstab, mtab, device.map and grub.conf, and running GRUB...                             "));
    14141413        for (done = FALSE; !done;) {
    14151414            popup_and_get_string(_("Boot device"),
     
    14301429                done = TRUE;
    14311430            }
    1432             popup_and_OK(_("You will now edit fstab and grub.conf"));
     1431            popup_and_OK(_("You will now edit fstab, mtab, device.map and grub.conf"));
    14331432            if (!g_text_mode) {
    14341433                newtSuspend();
     
    14381437            mr_free(tmp);
    14391438
     1439            mr_asprintf(&tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
     1440            paranoid_system(tmp);
     1441            mr_free(tmp);
     1442
    14401443            mr_asprintf(&tmp, "chroot %s %s /etc/grub.conf", MNT_RESTORING, editor);
     1444            paranoid_system(tmp);
     1445            mr_free(tmp);
     1446
     1447            mr_asprintf(&tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
    14411448            paranoid_system(tmp);
    14421449            mr_free(tmp);
  • branches/stable/mondo/src/mondorestore/mondorestore.c

    r1458 r1548  
    345345 *END_  EXTRACT_CONFIG_FILE_FROM_RAMDISK                                  *
    346346 **************************************************************************/
     347
     348static void clean_blkid(struct s_bkpinfo *bkpinfo) {
     349
     350    char *tmp1 = NULL;
     351
     352    /* Clean up blkid cache file if they exist */
     353    mr_asprintf(&tmp1,"%s/etc/blkid.tab",bkpinfo->restore_path);
     354    (void)unlink(tmp1);
     355    mr_free(tmp1);
     356    mr_asprintf(&tmp1,"%s/etc/blkid.tab.old",bkpinfo->restore_path);
     357    (void)unlink(tmp1);
     358    mr_free(tmp1);
     359}
    347360
    348361
     
    586599    }
    587600
     601    clean_blkid(bkpinfo);
    588602    protect_against_braindead_sysadmins();
    589603    retval += unmount_all_devices(mountlist);
     
    839853        boot_loader_installed = TRUE;
    840854    }
     855    clean_blkid(bkpinfo);
    841856    protect_against_braindead_sysadmins();
    842857    retval += unmount_all_devices(mountlist);
  • branches/stable/mondo/src/restore-scripts/mondo/hack-fstab

    r1039 r1548  
    33# $Id$
    44#
     5# Recreate /etc/fstab from first mountlist analysis
     6# and then complement wirh old fstab content.
    57
    68LogIt() {
     
    1012
    1113AddFancyParams() {
    12     local incoming device mountpoint format size original_fstab_line
    13 #    echo "AddFancyParams '$1'" >> /dev/stderr
     14    local incoming device mountpoint format size original_fstab_line label uuid
     15
    1416    incoming=`echo "$1" | tr -s '\t' ' '`
    1517    [ "$incoming" = "" ] && return
    1618    device=`echo "$incoming"     | cut -d' ' -f1`
    17     [ "`echo "$device" | grep "/dev/"`" = "" ] && return
    1819    mountpoint=`echo "$incoming" | cut -d' ' -f2`
    1920    format=`echo "$incoming"     | cut -d' ' -f3`
    2021    size=`echo "$incoming"       | cut -d' ' -f4`
    21 #    echo "'$device' '$mountpoint' '$format' '$size'" > /dev/stderr
     22    label=`echo "$incoming"       | cut -d' ' -f5`
     23    uuid=`echo "$incoming"       | cut -d' ' -f6`
    2224    original_fstab_line=`grep " $mountpoint " $old_fstab | grep -v "#" | tr -s ' ' ' '`
    23 #    echo "original_fstab_line = $original_fstab_line" >> /dev/stderr
    24     if [ "`grep "LABEL=" $old_fstab`" != "" ] ; then
    25         if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then
    26             device="LABEL=$mountpoint"
     25    if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then
     26        if [ "`echo "$original_fstab_line" | grep "LABEL="`" != "" ] ; then
     27            device="LABEL=$label"
     28        fi
     29        if [ "`echo "$original_fstab_line" | grep "UUID="`" != "" ] ; then
     30            device="UUID=$uuid"
    2731        fi
    2832    fi
    29 
    30 #    LogIt "my_res = $my_res"
    3133
    3234    echo -e -n "$device $mountpoint $format "
    3335
    3436    if [ "$original_fstab_line" != "" ] ; then
    35 #   echo $original_fstab_line | gawk '{i=index($0,$4); print substr($0,i);}'
    36         echo "$original_fstab_line" | cut -d' ' -f4-19 | tr -s ' ' ' '
     37        echo "$original_fstab_line" | cut -d' ' -f4- | tr -s ' ' ' '
    3738    else
    3839        echo -e "defaults 0 0"
     
    4344ProcessFstab() {
    4445    local incoming dev mountlist_entry blanklines new_i
     46
    4547    read incoming
    4648    blanklines=0
    4749    while [ "$blanklines" -lt "5" ] ; do
    48     if [ "$incoming" = "" ] ; then
    49         blanklines=$(($blanklines+1))
    50         read incoming
    51         continue
    52     fi
    53     incoming=`echo "$incoming" | tr -s '\t' ' '`
    54 #   new_i=`HackIncomingIfLABELused "$incoming"`
    55 #   if [ ! "$new_i" ] ; then
    56     if [ "`echo "$incoming" | grep -v "LABEL="`" ] ; then
    57         dev=`echo "$incoming" | cut -d' ' -f1`
    58 #       echo "OK, $dev isn't a label" >> /dev/stderr
    59         mountlist_entry=`grep "$dev " $old_mountlist`
    60 #       echo "MLE($dev) = '$mountlist_entry'" >> /dev/stderr
    61         if [ "$mountlist_entry" = "" ] ; then
    62 #       echo "(PF) '$incoming'" >> /dev/stderr
    63         echo "$incoming"
    64         fi
    65 #   else
    66 #       echo "Skipping '$incoming'" >> /dev/stderr
    67     fi
    68     read incoming
     50        if [ "$incoming" = "" ] ; then
     51            blanklines=$(($blanklines+1))
     52            read incoming
     53            continue
     54        fi
     55        incoming=`echo "$incoming" | tr -s '\t' ' '`
     56        if [ "`echo "$incoming" | grep -vE "LABEL=|UUID="`" ] ; then
     57            dev=`echo "$incoming" | cut -d' ' -f1`
     58            mountlist_entry=`grep "$dev " $old_mountlist`
     59            if [ "$mountlist_entry" = "" ] ; then
     60                echo "$incoming"
     61            fi
     62        fi
     63        read incoming
    6964    done
    7065}
     
    7368HackIncomingIfLABELused() {
    7469    local incoming col1 col2 col_rest orig out result
     70
     71    # Keep LABEL or UUID if originally there in fstab
    7572    result=""
    7673    incoming=`echo "$1" | tr -s '\t' ' '`
    77     col1=`echo "$incoming" | cut -f1`
    78     col2=`echo "$incoming" | cut -f2`
    79     col_rest=`echo "$incoming" | cut -f3-19 | tr -s ' ' ' '`
    80     orig="`grep " $col2 " $old_fstab | cut -f1`"
    81     if [ "`echo "$orig" | grep "LABEL="`" != "" ] ; then
    82     echo "orig = $orig" >> /dev/stderr
    83     echo -e "$orig $col2 $col_rest | tr -s ' ' ' '"
     74    col1=`echo "$incoming" | cut -d' ' -f1`
     75    col2=`echo "$incoming" | cut -d' ' -f2`
     76    col_rest=`echo "$incoming" | cut -d' ' -f3- | tr -s ' ' ' '`
     77    orig="`grep " $col2 " $old_fstab | cut -d' ' -f1`"
     78    if [ "`echo "$orig" | grep -E "LABEL=|UUID="`" != "" ] ; then
     79        echo "orig = $orig" >> /dev/stderr
     80        echo -e "$orig $col2 $col_rest" | tr -s ' ' ' '
    8481    fi
    8582}
     
    9390ProcessMountlist() {
    9491    local incoming outstr res spc
     92
    9593    read incoming
    9694    while [ "$incoming" != "" ] ; do
    97     incoming=`echo "$incoming" | tr -s '\t' ' '`
    98 #   echo "(PM) incoming = '$incoming'" >> /dev/stderr
    99     res=`HackIncomingIfLABELused "$incoming"`
    100     if [ ! "$res" ] ; then
    101         outstr=`AddFancyParams "$incoming"`
    102     else
    103         outstr=`AddFancyParams "$res"`
    104     fi
    105     spc="`echo "$outstr" | tr -s '\t' ' '`"
    106     if [ "$spc" != "" ] && [ "$spc" != " " ] && [ "`echo "$spc" | grep "raid raid"`" = "" ] ; then
    107         echo "$spc"
    108 #       echo "(PM) outgoing = '$outstr'" >> /dev/stderr
    109     fi
    110     read incoming
     95        incoming=`echo "$incoming" | tr -s '\t' ' '`
     96        res=`HackIncomingIfLABELused "$incoming"`
     97        if [ ! "$res" ] ; then
     98            outstr=`AddFancyParams "$incoming"`
     99        else
     100            outstr=`AddFancyParams "$res"`
     101        fi
     102        spc="`echo "$outstr" | tr -s '\t' ' '`"
     103        if [ "$spc" != "" ] && [ "$spc" != " " ] && [ "`echo "$spc" | grep "raid raid"`" = "" ] ; then
     104            echo "$spc"
     105        fi
     106        read incoming
    111107    done
    112108}
Note: See TracChangeset for help on using the changeset viewer.