Ignore:
Timestamp:
Jan 28, 2007, 7:04:41 PM (17 years ago)
Author:
Bruno Cornec
Message:
  • Fix mindi install messages (reported by Andree Leidenfrost)
  • remove paranoid_free/free for mr_free
  • mr_asprintf used everywhere
  • mr_malloc used everywhere
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/mondorestore/mondo-rstr-tools.c

    r1067 r1080  
    11/***************************************************************************
    2 mondo-rstr-tools.c  -  description
    3 -----------------
    4 
    5 begin: Sun Sep 21 16:40:35 EDT 2003
    6 copyright : (C) 2002 Mondo  Hugo Rabson
    7 email     : Hugo Rabson <hugorabson@msn.com>
    8 edited by : by Stan Benoit ?/2003
    9 email     : troff@nakedsoul.org
    10 cvsid     : $Id: mondo-rstr-tools.c
    11 ***************************************************************************/
    12 
    13 /***************************************************************************
    14  *                                                                         *
    15  *   This program is free software; you can redistribute it and/or modify  *
    16  *   it under the terms of the GNU General Public License as published by  *
    17  *   the Free Software Foundation; either version 2 of the License, or     *
    18  *   (at your option) any later version.                                   *
    19  *                                                                         *
    20  ***************************************************************************/
    21 /* mondo-rstr-tools.c               Hugo Rabson
    22 
    23 
    24 07/27
    25 - if the user is foolish enough to use /dev/md0 as boot device,
    26   call lilo -M /dev/hda to make sure lilo does its job properly
    27 - better NFS+nuke support
    28 
    29 07/20
    30 - use backup's i-want-my-lvm file
    31 - be sure to use archives' raidtab when restoring
    32 
    33 07/18
    34 - use /tmp/isodir for NFS if DR mode
    35 - better support of users who boot from LVM CD and nuke-restore non-LVM backups
    36 
    37 07/12
    38 - bugfix to allow user to burn ISOs to CDs and restore from CDs (not original src)
    39 
    40 06/29
    41 - mount ext3 partitions as ext2, just in case :)
    42 
    43 06/26
    44 - delete make_relevant_partition_bootable()
    45 
    46 06/19
    47 - futzed with the call to mount floppy, to stop it from locking up on my AMD64 system
    48 
    49 06/14
    50 - shell out to /mnt/RESTORING chroot in order to let user install GRUB
    51   manually if automatic GRUB installation fails
    52 
    53 06/15
    54 - Added check for different 'isodir' chosen by user than stored in the archive
    55   Conor Daly <conor.daly@met.ie>
    56 
    57 04/17
    58 - replaced INTERNAL_TAPE_BLK_SIZE with bkpinfo->internal_tape_block_size
    59 
    60 04/09
    61 - don't try to mount CD if tape bkp
    62 
    63 04/03
    64 - trying to copy tmp/mondo-restore.cfg to itself - silly! - fixed
    65 
    66 04/02
    67 - when extracting cfg file and mountlist from all.tar.gz (tape copy),
    68   use block size of INTERNAL_TAPE_BLK_SIZE, not TAPE_BLOCK_SIZE
    69 
    70 02/21
    71 - don't use 'mv -v' cos Busybox won't support it
    72 
    73 02/09
    74 - make hole for cfg file before moving it (line 2094 or so)
    75 
    76 02/03
    77 - changed a couple of refs to filelist.full, to filelist.full.gz
    78 
    79 01/16/2004
    80 - instead of copying filelist, use 'ln -sf' to link to original;
    81   saves space
    82 
    83 11/20/2003
    84 - also retrieve /tmp/mountlist.txt if user wants
    85 
    86 11/16
    87 - fixed NFS path bug affecting the extractions of filelist/biggielist
    88   during selective restore
    89 
    90 11/02
    91 - fixed mount_cdrom() to run properly w/ nfs restores
    92 - mount_device() returns 0 if swap mount fails cos swap isn't crucial
    93 
    94 10/17
    95 - run_grub() uses MNT_RESTORING instead of "/mnt/RESTORING"
    96 
    97 10/26
    98 - cleaned up run_grub()
    99 
    100 10/25
    101 - fixed mount_cdrom() to run properly w/ nfs restores
    102 
    103 10/21
    104 - mount_device() returns 0 if swap mount fails cos swap isn't crucial
    105 
    106 10/15
    107 - run_grub() now uses its initiative instead
    108   of calling grub-install
    109 
    110 10/10
    111 - don't leave copies of filelist.full lying around, clogging up
    112   the ramdisk, there's a good fellow :-)
    113 
    114 10/02
    115 - added 'dvd' to the range of media types I'll understand
    116 - fixed iso->cdr problem (thanks, Stan Benoit & Fred Beondo)
    117 
    118 09/24
    119 - try lots of tape devs if /dev/st0 fails
    120 
    121 09/23/2003
    122 - first incarnation
     2 * $Id$
    1233*/
    1244
     
    13212//#include "mondo-rstr-compare-EXT.h"
    13313#include "mondo-rstr-tools.h"
     14#include "mr_mem.h"
    13415
    13516extern bool g_sigpipe_caught;
     
    17455void free_MR_global_filenames()
    17556{
    176     paranoid_free(g_biggielist_txt);
    177     paranoid_free(g_filelist_full);
    178     paranoid_free(g_filelist_imagedevs);
    179 //  paranoid_free (g_imagedevs_pot );
    180     paranoid_free(g_imagedevs_restthese);
    181     paranoid_free(g_mondo_cfg_file);
    182     paranoid_free(g_mountlist_fname);
    183     paranoid_free(g_mondo_home);
    184     paranoid_free(g_tmpfs_mountpt);
    185     paranoid_free(g_isodir_device);
    186     paranoid_free(g_isodir_format);
     57    mr_free(g_biggielist_txt);
     58    mr_free(g_filelist_full);
     59    mr_free(g_filelist_imagedevs);
     60//  mr_free (g_imagedevs_pot );
     61    mr_free(g_imagedevs_restthese);
     62    mr_free(g_mondo_cfg_file);
     63    mr_free(g_mountlist_fname);
     64    mr_free(g_mondo_home);
     65    mr_free(g_tmpfs_mountpt);
     66    mr_free(g_isodir_device);
     67    mr_free(g_isodir_format);
    18768
    18869}
     
    21394    assert_string_is_neither_NULL_nor_zerolength(outfname);
    21495
    215     incoming_ptr = malloc(sizeof(incoming));
    216     if (incoming_ptr == NULL) {
    217         fprintf(stderr, "Out of Memory\n");
    218         exit(EXIT_FAILURE);
    219     }
    220 
    221     question_ptr = malloc(sizeof(question));
    222     if (question_ptr == NULL) {
    223         fprintf(stderr, "Out of Memory\n");
    224         exit(EXIT_FAILURE);
    225     }
     96    incoming_ptr = mr_malloc(sizeof(incoming));
     97    question_ptr = mr_malloc(sizeof(question));
    22698
    22799    memset(incoming_ptr, '\0', sizeof(incoming));
     
    253125
    254126  /*** free memory ***********/
    255     paranoid_free(incoming_ptr);
     127    mr_free(incoming_ptr);
    256128    incoming_ptr = NULL;
    257     paranoid_free(question_ptr);
     129    mr_free(question_ptr);
    258130    question_ptr = NULL;
    259131
     
    341213        retval = 0;
    342214    }
    343     paranoid_free(mountpt);
    344     paranoid_free(command);
    345     paranoid_free(orig_fname);
     215    mr_free(mountpt);
     216    mr_free(command);
     217    mr_free(orig_fname);
    346218    return (retval);
    347219
     
    406278    sprintf(command, "grep -E '^%s$' %s", file, list_fname);
    407279    res = run_program_and_log_output(command, FALSE);
    408     paranoid_free(command);
    409     paranoid_free(file);
    410     paranoid_free(tmp);
     280    mr_free(command);
     281    mr_free(file);
     282    mr_free(tmp);
    411283    if (res) {
    412284        return (FALSE);
     
    500372    log_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__,
    501373            bkpinfo->isodir);
    502     paranoid_free(mount_isodir_command);
    503     paranoid_free(tmp);
    504     paranoid_free(command);
     374    mr_free(mount_isodir_command);
     375    mr_free(tmp);
     376    mr_free(command);
    505377    return (retval);
    506378}
     
    519391            "kill `ps 2> /dev/null | grep petris 2> /dev/null | grep -v grep | cut -d' ' -f2` 2> /dev/null");
    520392    paranoid_system(command);
    521     paranoid_free(command);
     393    mr_free(command);
    522394}
    523395
     
    556428    }
    557429    if (!does_file_exist(rclocal_fname)) {
    558         paranoid_free(rclocal_fname);
    559         paranoid_free(newfile_fname);
    560         paranoid_free(tmp);
     430        mr_free(rclocal_fname);
     431        mr_free(newfile_fname);
     432        mr_free(tmp);
    561433        return (1);
    562434    }
     
    582454    sprintf(tmp, "chmod +x \"%s\"", newfile_fname);
    583455    run_program_and_log_output(tmp, FALSE);
    584     paranoid_free(rclocal_fname);
    585     paranoid_free(newfile_fname);
    586     paranoid_free(tmp);
     456    mr_free(rclocal_fname);
     457    mr_free(newfile_fname);
     458    mr_free(tmp);
    587459    return (0);
    588460}
     
    613485    malloc_string(these_failed);
    614486    assert(p_external_copy_of_mountlist != NULL);
    615     mountlist = malloc(sizeof(struct mountlist_itself));
     487    mountlist = mr_malloc(sizeof(struct mountlist_itself));
    616488    memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist,
    617489           sizeof(struct mountlist_itself));
     
    684556    }
    685557    run_program_and_log_output("df -m", 3);
    686     paranoid_free(mountlist);
    687     paranoid_free(tmp);
    688     paranoid_free(format);
    689     paranoid_free(these_failed);
     558    mr_free(mountlist);
     559    mr_free(tmp);
     560    mr_free(format);
     561    mr_free(these_failed);
    690562    return (retval);
    691563}
     
    720592        || bkpinfo->backup_media_type == udev) {
    721593        log_msg(8, "Tape/udev. Therefore, no need to mount CDROM.");
    722         paranoid_free(mount_cmd);
     594        mr_free(mount_cmd);
    723595        return 0;
    724596    }
     
    726598    if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) {
    727599        log_msg(2, "mount_cdrom() - CD already mounted. Fair enough.");
    728         paranoid_free(mount_cmd);
     600        mr_free(mount_cmd);
    729601        return (0);
    730602    }
     
    807679        log_msg(2, "Mounted CD-ROM drive OK");
    808680    }
    809     paranoid_free(mount_cmd);
     681    mr_free(mount_cmd);
    810682    return (res);
    811683}
     
    918790    }
    919791
    920     paranoid_free(tmp);
    921     paranoid_free(command);
    922     paranoid_free(mountdir);
    923     paranoid_free(mountpoint);
    924     paranoid_free(additional_parameters);
     792    mr_free(tmp);
     793    mr_free(command);
     794    mr_free(mountdir);
     795    mr_free(mountpoint);
     796    mr_free(additional_parameters);
    925797
    926798    return (res);
     
    1107979    read_cfg_var(cfg_file, "acl", value);
    1108980    if (strstr(value, "TRUE")) {
    1109         asprintf(&g_getfacl,"setfacl");
     981        mr_asprintf(&g_getfacl,"setfacl");
    1110982        log_msg(1, "We will restore ACLs");
    1111983        if (! find_home_of_exe("setfacl")) {
     
    1115987    read_cfg_var(cfg_file, "xattr", value);
    1116988    if (strstr(value, "TRUE")) {
    1117         asprintf(&g_getfattr,"setfattr");
     989        mr_asprintf(&g_getfattr,"setfattr");
    1118990        log_msg(1, "We will restore XATTRs");
    1119991        if (! find_home_of_exe("setfattr")) {
     
    12901162    }
    12911163    g_backup_media_type = bkpinfo->backup_media_type;
    1292     paranoid_free(value);
    1293     paranoid_free(tmp);
    1294     paranoid_free(command);
    1295     paranoid_free(iso_mnt);
    1296     paranoid_free(iso_path);
    1297     paranoid_free(old_isodir);
     1164    mr_free(value);
     1165    mr_free(tmp);
     1166    mr_free(command);
     1167    mr_free(iso_mnt);
     1168    mr_free(iso_path);
     1169    mr_free(old_isodir);
    12981170    return (0);
    12991171
     
    14801352    }
    14811353
    1482     paranoid_free(command);
    1483     paranoid_free(tmp);
     1354    mr_free(command);
     1355    mr_free(tmp);
    14841356    return (filelist);
    14851357}
     
    15141386
    15151387    res = run_program_and_log_output(command, 5);
    1516     paranoid_free(tmp);
    1517     paranoid_free(command);
     1388    mr_free(tmp);
     1389    mr_free(command);
    15181390    return (res);
    15191391}
     
    15931465        log_to_screen("Your boot loader ran OK");
    15941466    }
    1595     paranoid_free(device);
    1596     paranoid_free(tmp);
    1597     paranoid_free(name);
     1467    mr_free(device);
     1468    mr_free(tmp);
     1469    mr_free(name);
    15981470    return (retval);
    15991471}
     
    17391611        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    17401612    }
    1741     paranoid_free(rootdev);
    1742     paranoid_free(rootdrive);
    1743     paranoid_free(conffile);
    1744     paranoid_free(command);
    1745     paranoid_free(boot_device);
    1746     paranoid_free(tmp);
    1747     paranoid_free(editor);
     1613    mr_free(rootdev);
     1614    mr_free(rootdrive);
     1615    mr_free(conffile);
     1616    mr_free(command);
     1617    mr_free(boot_device);
     1618    mr_free(tmp);
     1619    mr_free(editor);
    17481620
    17491621    return (res);
     
    18131685        res = TRUE;
    18141686    }
    1815     paranoid_free(command);
    1816     paranoid_free(tmp);
    1817     paranoid_free(editor);
     1687    mr_free(command);
     1688    mr_free(tmp);
     1689    mr_free(editor);
    18181690    return (res);
    18191691}
     
    19241796                                   " lilo -M /dev/sda", 3);
    19251797    }
    1926     paranoid_free(command);
    1927     paranoid_free(tmp);
    1928     paranoid_free(editor);
     1798    mr_free(command);
     1799    mr_free(tmp);
     1800    mr_free(editor);
    19291801    return (res);
    19301802}
     
    20061878        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    20071879    }
    2008     paranoid_free(command);
    2009     paranoid_free(boot_device);
    2010     paranoid_free(tmp);
    2011     paranoid_free(editor);
     1880    mr_free(command);
     1881    mr_free(boot_device);
     1882    mr_free(tmp);
     1883    mr_free(editor);
    20121884    return (res);
    20131885}
     
    21292001    paranoid_fclose(fout);
    21302002    paranoid_fclose(fin);
    2131     paranoid_free(incoming);
     2003    mr_free(incoming);
    21322004}
    21332005
     
    21772049    }
    21782050    close_progress_form();
    2179     paranoid_free(tmp);
     2051    mr_free(tmp);
    21802052}
    21812053
     
    22222094    assert(p_external_copy_of_mountlist != NULL);
    22232095
    2224     mountlist = malloc(sizeof(struct mountlist_itself));
     2096    mountlist = mr_malloc(sizeof(struct mountlist_itself));
    22252097    memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist,
    22262098           sizeof(struct mountlist_itself));
     
    23062178        log_to_screen("All partitions were unmounted OK.");
    23072179    }
    2308     free(mountlist);
    2309     paranoid_free(command);
    2310     paranoid_free(tmp);
     2180    mr_free(mountlist);
     2181    mr_free(command);
     2182    mr_free(tmp);
    23112183    return (retval);
    23122184}
     
    23462218        res = 0;
    23472219    }
    2348     paranoid_free(command);
     2220    mr_free(command);
    23492221    return (res);
    23502222}
     
    26102482    run_program_and_log_output(command, FALSE);
    26112483    g_backup_media_type = bkpinfo->backup_media_type;
    2612     paranoid_free(device);
    2613     paranoid_free(command);
    2614     paranoid_free(tmp);
    2615     paranoid_free(cfg_file);
    2616     paranoid_free(mounted_cfgf_path);
    2617     paranoid_free(mountpt);
    2618     paranoid_free(ramdisk_fname);
    2619     paranoid_free(mountlist_file);
     2484    mr_free(device);
     2485    mr_free(command);
     2486    mr_free(tmp);
     2487    mr_free(cfg_file);
     2488    mr_free(mounted_cfgf_path);
     2489    mr_free(mountpt);
     2490    mr_free(ramdisk_fname);
     2491    mr_free(mountlist_file);
    26202492    return (retval);
    26212493}
     
    26492521
    26502522    malloc_string(screen_message);
    2651     raidlist = malloc(sizeof(struct raidlist_itself));
     2523    raidlist = mr_malloc(sizeof(struct raidlist_itself));
    26522524
    26532525    assert(wait_for_percentage <= 100);
     
    26842556        }
    26852557    }
    2686     paranoid_free(screen_message);
    2687     paranoid_free(raidlist);
    2688 }
     2558    mr_free(screen_message);
     2559    mr_free(raidlist);
     2560}
Note: See TracChangeset for help on using the changeset viewer.