Changeset 3147 in MondoRescue for branches/3.1/mondo


Ignore:
Timestamp:
Jun 19, 2013, 8:34:46 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • First pass on svn merge -r 2935:3146 ../3.0
Location:
branches/3.1/mondo
Files:
1 deleted
39 edited
8 copied

Legend:

Unmodified
Added
Removed
  • branches/3.1/mondo/COPYING

    r30 r3147  
    33
    44 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
    5                           675 Mass Ave, Cambridge, MA 02139, USA
     5               51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    66 Everyone is permitted to copy and distribute verbatim copies
    77 of this license document, but changing it is not allowed.
     
    283283
    284284             END OF TERMS AND CONDITIONS
     285
     286
     287    Appendix: How to Apply These Terms to Your New Programs
     288
     289  If you develop a new program, and you want it to be of the greatest
     290possible use to the public, the best way to achieve this is to make it
     291free software which everyone can redistribute and change under these terms.
     292
     293  To do so, attach the following notices to the program.  It is safest
     294to attach them to the start of each source file to most effectively
     295convey the exclusion of warranty; and each file should have at least
     296the "copyright" line and a pointer to where the full notice is found.
     297
     298    <one line to give the program's name and a brief idea of what it does.>
     299    Copyright (C) 19yy  <name of author>
     300
     301    This program is free software; you can redistribute it and/or modify
     302    it under the terms of the GNU General Public License as published by
     303    the Free Software Foundation; either version 2 of the License, or
     304    (at your option) any later version.
     305
     306    This program is distributed in the hope that it will be useful,
     307    but WITHOUT ANY WARRANTY; without even the implied warranty of
     308    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     309    GNU General Public License for more details.
     310
     311    You should have received a copy of the GNU General Public License
     312    along with this program; if not, write to the Free Software
     313    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
     314
     315Also add information on how to contact you by electronic and paper mail.
     316
     317If the program is interactive, make it output a short notice like this
     318when it starts in an interactive mode:
     319
     320    Gnomovision version 69, Copyright (C) 19yy name of author
     321    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
     322    This is free software, and you are welcome to redistribute it
     323    under certain conditions; type `show c' for details.
     324
     325The hypothetical commands `show w' and `show c' should show the appropriate
     326parts of the General Public License.  Of course, the commands you use may
     327be called something other than `show w' and `show c'; they could even be
     328mouse-clicks or menu items--whatever suits your program.
     329
     330You should also get your employer (if you work as a programmer) or your
     331school, if any, to sign a "copyright disclaimer" for the program, if
     332necessary.  Here is a sample; alter the names:
     333
     334  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
     335  `Gnomovision' (which makes passes at compilers) written by James Hacker.
     336
     337  <signature of Ty Coon>, 1 April 1989
     338  Ty Coon, President of Vice
     339
     340This General Public License does not permit incorporating your program into
     341proprietary programs.  If your program is a subroutine library, you may
     342consider it more useful to permit linking proprietary applications with the
     343library.  If this is what you want to do, use the GNU Library General
     344Public License instead of this License.
  • branches/3.1/mondo/bootstrap

    r2239 r3147  
    2626fi
    2727
     28autoscan
    2829make maintainer-clean >/dev/null 2>&1
    2930libtoolize -f -c --automake
     
    3132autoheader
    3233automake --add-missing --copy
    33 autoconf
     34autoconf -W all
    3435rm -rf autom4te.cache
  • branches/3.1/mondo/configure.in

    r2603 r3147  
    1010define(MONDO_REV,m4_normalize(rPBREV)))
    1111define(MONDO_TAG,MONDO_VER-MONDO_REV)
    12 AC_INIT([Mondo Rescue],MONDO_TAG,[mondo-devel@lists.sourceforge.net])
     12AC_INIT([Mondo Rescue],[MONDO_TAG],[mondo-devel@lists.sourceforge.net])
    1313AC_CONFIG_SRCDIR([src/mondoarchive/mondoarchive.c])
    1414AC_CONFIG_MACRO_DIR([m4])
    15 AM_CONFIG_HEADER(config.h)
     15AC_CONFIG_HEADERS([config.h])
    1616
     17AC_PREREQ([2.68])
    1718AC_CANONICAL_HOST
    1819AC_CANONICAL_TARGET
     
    2021
    2122AM_INIT_AUTOMAKE([mondo], MONDO_VER)
    22 AM_MAINTAINER_MODE
    23 
    2423LT_INIT
    2524
     
    2726AC_PROG_AWK
    2827AC_PROG_CC
    29 #AC_PROG_RANLIB
    3028AC_PROG_LIBTOOL
    3129AC_PROG_CPP
     
    120118AC_HEADER_STDC
    121119AC_HEADER_SYS_WAIT
    122 AC_CHECK_HEADERS([fcntl.h stddef.h stdlib.h string.h sys/ioctl.h sys/param.h sys/time.h unistd.h])
     120AC_HEADER_STDBOOL
     121AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h utime.h])
    123122
    124123# Checks for typedefs, structures, and compiler characteristics.
    125124AC_C_CONST
     125AC_C_INLINE
     126AC_PROG_GCC_TRADITIONAL
     127AC_TYPE_MODE_T
    126128AC_TYPE_OFF_T
    127129AC_TYPE_PID_T
     130AC_TYPE_SIZE_T
     131AC_TYPE_SSIZE_T
     132AC_STRUCT_ST_BLOCKS
    128133
    129134# Checks for library functions.
    130135AC_FUNC_CHOWN
    131136AC_FUNC_FORK
    132 AC_PROG_GCC_TRADITIONAL
     137AC_FUNC_FSEEKO
    133138AC_FUNC_LSTAT
    134139AC_FUNC_MALLOC
    135 AC_TYPE_SIGNAL
    136140AC_FUNC_VPRINTF
    137 AC_CHECK_FUNCS([bzero getcwd memmove memset mkdir mkfifo getopt setenv strcasecmp strchr strerror strrchr strstr mkdtemp])
     141AC_CHECK_FUNCS([bzero getcwd gethostbyname inet_ntoa memmove memset mkdir mkdtemp mkfifo getopt setenv strcasecmp strcspn strchr strdup strerror strncasecmp strrchr strspn strstr uname utime])
    138142
    139 AC_OUTPUT([Makefile src/Makefile src/lib/Makefile src/common/Makefile src/mondoarchive/Makefile src/mondorestore/Makefile src/restore-scripts/Makefile src/restore-scripts/mondo/Makefile src/post-nuke.sample/Makefile src/post-nuke.sample/usr/Makefile src/post-nuke.sample/usr/bin/Makefile test/Makefile deplist.d/Makefile])
     143AC_CONFIG_FILES([Makefile src/Makefile src/lib/Makefile src/common/Makefile src/mondoarchive/Makefile src/mondorestore/Makefile src/restore-scripts/Makefile src/restore-scripts/mondo/Makefile src/post-nuke.sample/Makefile src/post-nuke.sample/usr/Makefile src/post-nuke.sample/usr/bin/Makefile test/Makefile deplist.d/Makefile])
     144AC_OUTPUT
  • branches/3.1/mondo/src/common/libmondo-archive.c

    r2937 r3147  
    213213    paranoid_free(tmp);
    214214
    215     mr_asprintf(command, "star H=exustar list=%s -c " STAR_ACL_SZ " file=%s", filelist, fname);
     215    mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s", filelist, fname);
    216216    if (bkpinfo->use_lzo) {
    217217        mr_free(command);
     
    511511    char *use_star_sz = NULL;
    512512    char *bootldr_str = NULL;
     513    char *bootldr_ver = NULL;
    513514    char *tape_device = NULL;
    514515    char *broken_bios_sz = NULL;
     
    682683            run_program_and_log_output("ln -sf /boot/grub/grub.conf /boot/grub/menu.lst", 5);
    683684        }
    684         if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg"))) {
    685             fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst or /boot/grub/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?");
    686         }
     685        if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) {
     686            fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?");
     687        }
     688        mr_asprintf(&bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version"));
    687689    } else if (bkpinfo->boot_loader == 'E') {
    688690        mr_asprintf(bootldr_str, "ELILO");
     
    719721    }
    720722    log_to_screen("Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device);
     723    if (bootldr_ver != NULL) {
     724        mr_asprintf(&tmp, "Boot loader version string: %s", bootldr_ver);
     725        log_to_screen(tmp);
     726        mr_free(tmp);
     727    }
    721728
    722729    mr_asprintf(tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir);
     
    927934    char *curr_acl_list_fname = NULL;
    928935
    929     struct s_bkpinfo *bkpinfo_bis;
    930936    char *tmp = NULL;
    931937    int res = 0, retval = 0;
     
    940946    p_next_set_to_archive = (int *) (inbuf + 8);
    941947    p_list_of_fileset_flags = (char *) (inbuf + 12);
    942     bkpinfo_bis = (struct s_bkpinfo *) (inbuf + BKPINFO_LOC_OFFSET);
    943948
    944949    mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L);
     
    14741479
    14751480    log_msg(2, "make_usb_fs --- scratchdir=%s", bkpinfo->scratchdir);
    1476     (void) getcwd(old_pwd, MAX_STR_LEN - 1);
     1481    tmp1 = getcwd(old_pwd, MAX_STR_LEN - 1);
    14771482    mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    14781483    run_program_and_log_output(tmp, FALSE);
    14791484    mr_free(tmp);
    1480     (void)chdir(bkpinfo->scratchdir);
     1485    if (chdir(bkpinfo->scratchdir)) {
     1486        // FIXME
     1487    }
    14811488
    14821489    mds = media_descriptor_string(bkpinfo->backup_media_type);
     
    15421549    }
    15431550
    1544     (void)chdir(old_pwd);
     1551    if (chdir(old_pwd)) {
     1552        // FIXME
     1553    }
    15451554    if (retval) {
    15461555        log_msg(1, "WARNING - make_usb_fs returned an error");
     
    15991608
    16001609    log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile);
    1601     (void) getcwd(old_pwd, MAX_STR_LEN - 1);
     1610    tmp2 = getcwd(old_pwd, MAX_STR_LEN - 1);
    16021611    mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    16031612    run_program_and_log_output(tmp, FALSE);
    16041613    mr_free(tmp);
    16051614
    1606     chdir(bkpinfo->scratchdir);
     1615    if (chdir(bkpinfo->scratchdir)) {
     1616        // FIXME
     1617    }
    16071618
    16081619    if (bkpinfo->call_before_iso) {
     
    18131824    }
    18141825
    1815     chdir(old_pwd);
     1826    if (chdir(old_pwd)) {
     1827        // FIXME
     1828    }
    18161829    if (retval) {
    18171830        log_msg(1, "WARNING - make_iso_fs returned an error");
     
    18661879    /*@ pointers ******************************************* */
    18671880    FILE *fin = NULL;
     1881    char *q;
    18681882
    18691883    /*@ buffers ******************************************** */
     
    24112425    /*@ long long ****************************************************** */
    24122426    off_t length_of_incoming_file = (off_t)0;
    2413     t_archtype type;
    24142427    va_list ap;
    24152428
     
    24332446        write_header_block_to_stream(length_of_incoming_file, curr_file,
    24342447                                     start_chr);
    2435         if (strstr(curr_file, ".afio.") || strstr(curr_file, ".star.")) {
    2436             type = fileset;
    2437         } else if (strstr(curr_file, "slice")) {
    2438             type = biggieslice;
    2439         } else {
    2440             type = other;
    2441         }
    24422448        res = write_file_to_stream_from_file(curr_file);
    24432449        retval += res;
     
    27982804    mr_free(tmp);
    27992805
    2800     (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
    2801     fclose(fout);
    2802 
     2806    res = fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
     2807    if (fout != NULL) {
     2808        paranoid_fclose(fout);
     2809    }
    28032810    log_msg(1, "Opening in %s; slicing it and writing to CD/tape", file_to_openin);
    28042811    if (!(fin = fopen(file_to_openin, "r"))) {
     
    28392846                if (blksize > 0) {
    28402847                    totalread = totalread + blksize;
    2841                     (void) fwrite(tempblock, 1, blksize, fout);
     2848                    res = fwrite(tempblock, 1, blksize, fout);
    28422849                } else {
    28432850                    break;
     
    31313138            log_to_screen("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds);
    31323139            mr_free(mds);
    3133             chdir("/");
     3140            if (chdir("/")) {
     3141                // FIXME
     3142            }
    31343143            log_it("Before calling verification of image()");
    31353144            if (bkpinfo->backup_media_type == usb) {
     
    32093218    assert(bkpinfo != NULL);
    32103219    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    3211         chdir("/");
     3220        if (chdir("/")) {
     3221            // FIXME
     3222        }
    32123223        mvaddstr_and_log_it(g_currentY, 0,
    32133224                            "Verifying archives against live filesystem");
     
    32323243            bkpinfo->media_device = find_cdrom_device(FALSE);   // replace 0,0,0 with /dev/cdrom
    32333244        }
    3234         chdir("/");
     3245        if (chdir("/")) {
     3246            // FIXME
     3247        }
    32353248        for (cdno = 1; cdno < 99 && bkpinfo->verify_data; cdno++) {
    32363249            if (cdno != g_current_media_number) {
     
    32533266        }
    32543267        mr_asprintf(tmp, "grep 'afio: ' %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s/changed.files", MONDO_LOGFILE, MONDO_CACHE);
    3255         (void)system(tmp);
     3268        res = system(tmp);
    32563269        mr_free(tmp);
    32573270
    32583271        mr_asprintf(tmp, "grep 'star: ' %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s/changed.files", MONDO_LOGFILE, MONDO_CACHE);
    3259         (void)system(tmp);
     3272        res = system(tmp);
    32603273        mr_free(tmp);
    32613274        run_program_and_log_output("umount " MNT_CDROM, FALSE);
  • branches/3.1/mondo/src/common/libmondo-cli.c

    r2937 r3147  
    2020extern int g_loglevel;
    2121extern bool g_text_mode;
     22extern bool g_fail_immediately;
    2223extern char g_startdir[MAX_STR_LEN];    ///< ????? @bug ?????
    2324extern char *MONDO_OPTIONS;
     
    5354
    5455extern void free_MR_global_filenames(void);
     56
     57long g_max_biggie_size = BIGGIEMAXSIZE;
    5558
    5659/**
     
    101104    mr_free(tmp);
    102105
     106    /*  Before erasing dirs go into a safe place */
     107    if (chdir("/tmp")) {
     108        // FIXME
     109    }
     110    mr_asprintf(tmp, "rm -Rf %s/tmp.mondo.*", bkpinfo->tmpdir);
     111    paranoid_system(tmp);
     112    mr_free(tmp);
     113
    103114    mr_asprintf(tmp, "mkdir -p %s", bkpinfo->scratchdir);
    104115    paranoid_system(tmp);
     
    162173    int i = 0;
    163174    int retval = 0;
    164     int percent = 0;
    165     int lastpos = 0;
    166175
    167176    /*@ buffers ** */
     
    355364        mr_free(p);
    356365        log_to_screen("You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']);
    357         percent = 0;
    358366    }
    359367
     
    498506                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    499507                    mr_asprintf(tmp1, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     508                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
     509                    sprintf(tmp, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
    500510                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    501511                    mr_asprintf(tmp1, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     
    507517                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    508518                    mr_asprintf(tmp1, "sshfs %s", bkpinfo->netfs_mount);
     519                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
     520                    sprintf(tmp, "mount -t cifs %s", bkpinfo->netfs_mount);
    509521                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    510522                    mr_asprintf(tmp1, "mount %s", bkpinfo->netfs_mount);
     
    629641        }
    630642        mr_free(tmp1);
    631         lastpos = 0;
    632643
    633644        mr_make_devlist_from_pathlist(flag_val['E'], 'E');
     
    637648    if (flag_set['e']) {
    638649        bkpinfo->please_dont_eject = TRUE;
     650    }
     651
     652    if (flag_set['M']) {
     653        g_max_biggie_size = atol(flag_val['M']);
     654        log_msg(1, "Max size for biggie file is now %ld KB", g_max_biggie_size);
    639655    }
    640656
     
    778794        /* Before changing remove old ones if any */
    779795        if (bkpinfo->scratchdir) {
    780             chdir("/tmp");
     796            if (chdir("/tmp")) {
     797                // FIXME
     798            }
    781799            mr_asprintf(tmp1, "rm -Rf %s", bkpinfo->scratchdir);
    782800            paranoid_system(tmp1);
     
    859877            log_to_screen("Please install LZOP. You can't use '-L' until you do.\n");
    860878        }
     879    }
     880
     881    if (flag_set['F']) {
     882        log_msg(3, "-F means we will fail immediately at the first interaction request");
     883        g_fail_immediately = TRUE;
    861884    }
    862885
  • branches/3.1/mondo/src/common/libmondo-devices.c

    r2937 r3147  
    331331    char *searchstr = NULL;
    332332    char *tmp = NULL;
     333    char *p;
    333334
    334335    /*@ ints ******************************************************* */
     
    816817    }
    817818
    818     mr_asprintf(command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cdrw_drive_is_here);
     819    mr_asprintf(command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep -E \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cdrw_drive_is_here);
    819820    mr_free(cdr_exe);
    820821
     
    848849    }
    849850
    850     tmp = call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE);
     851    tmp = call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE);
    851852    log_msg(5, "tmp = '%s'", tmp);
    852853    if (!tmp[0])
    853854        mr_free(tmp);
    854         tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE);
     855        tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep \)\ \' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE);
    855856    if (tmp[0]) {
    856857        devno = atoi(tmp) - 1;
     
    886887#if linux
    887888    unsigned long long s = 0;
    888     int fileid, cylinders = 0, cylindersleft = 0;
     889    int fileid, cylinders = 0;
    889890    int cylindersize = 0;
    890891    int gotgeo = 0;
     
    935936            if (ioctl(fileid, HDIO_GETGEO, &hdgeo) != -1) {
    936937                if (hdgeo.cylinders && hdgeo.heads && hdgeo.sectors) {
    937                     cylindersleft = cylinders = hdgeo.cylinders;
    938938                    cylindersize = hdgeo.heads * hdgeo.sectors / 2;
    939939                    outvalA = cylindersize * cylinders / 1024;
     
    983983    char *command = NULL;
    984984    char *format_sz = NULL;
     985    char *p;
    985986
    986987    FILE *pin;
     
    18221823
    18231824        /* Check for LVM */
    1824         mr_asprintf(command, "pvdisplay -c %s | grep '%s:' 2> /dev/null", partitions[i], partitions[i]);
     1825        mr_asprintf(command, "pvdisplay -c %s 2> /dev/null", partitions[i]);
    18251826        log_msg(5, "  Running: %s", command);
    18261827        tmp = call_program_and_get_last_line_of_output(command,TRUE);
     
    26382639    char *p = NULL;
    26392640    char *q = NULL;
     2641    char *tmpro = NULL;
     2642    char *tmp1 = NULL;
    26402643    char *mds = NULL;
    26412644    char *sz_size = NULL;
     
    28732876            bkpinfo->media_size[i] = bkpinfo->media_size[0];
    28742877        }
     2878        bkpinfo->use_obdr = ask_me_yes_or_no
     2879            ("Do you want to activate OBDR support for your tapes ?");
     2880        if (bkpinfo->use_obdr) {
     2881            log_msg(4, "obdr mode = TRUE");
     2882        } else {
     2883            log_msg(4, "obdr mode = FALSE");
     2884        }
    28752885        if (archiving_to_media) {
    28762886            if ((compression_type = which_compression_type()) == NULL) {
     
    29682978        if (bkpinfo->disaster_recovery) {
    29692979            mr_asprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);
    2970             (void)system(command);
     2980            paranoid_system(command);
    29712981            mr_free(command);
    29722982
    29732983        }
    2974         p = popup_and_get_string("Network protocol", "Which Network protocol should I use?", bkpinfo->netfs_proto);
     2984<<<<<<< .courant
     2985        p = popup_and_get_string("Network protocol", "Which Network protocol should I use (nfs/sshfs/smbfs) ?", bkpinfo->netfs_proto);
    29752986        if (p == NULL) {
    29762987            log_to_screen("User has chosen not to backup the PC");
     
    30163027
    30173028            if (bkpinfo->restore_data) {
     3029                /*  mount th FS read-only in restore mode to avoid any erase of whatever */
     3030                mr_asprintf(tmpro, "-o ro");
     3031            } else {
     3032                mr_asprintf(tmpro, "");
     3033            }
     3034
     3035            /*  Build the mount string */
     3036            if (strstr(bkpinfo->netfs_proto, "smbfs")) {
     3037                mr_asprintf(tmp, "mount -t cifs %s %s %s",bkpinfo->netfs_mount, bkpinfo->isodir,tmpro);
     3038                if (bkpinfo->netfs_user) {
     3039                    mr_strcat(tmp, " -o user=%s", bkpinfo->netfs_user);
     3040                }
     3041            else {
    30183042                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    3019                     mr_asprintf(tmp, "sshfs -o ro");
     3043                    mr_asprintf(tmp, "sshfs %s ",tmpro);
    30203044                } else {
    3021                     mr_asprintf(tmp, "mount -t %s -o nolock,ro", bkpinfo->netfs_proto);
     3045                    mr_asprintf(tmp, "mount -t %s -o nolock %s ", bkpinfo->netfs_proto,tmpro);
    30223046                }
    3023             } else {
    3024                 if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    3025                     mr_asprintf(tmp, "sshfs");
    3026                 } else {
    3027                     mr_asprintf(tmp, "mount -t %s -o nolock", bkpinfo->netfs_proto);
     3047                if (bkpinfo->netfs_user) {
     3048                    mr_strcat(tmp, "%s@", bkpinfo->netfs_user);
    30283049                }
    3029             }
    3030             if (bkpinfo->netfs_user) {
    3031                 mr_strcat(tmp, "%s@", bkpinfo->netfs_user);
    3032             }
    3033             mr_strcat(tmp, "%s %s", bkpinfo->netfs_mount, bkpinfo->isodir);
     3050                mr_strcat(tmp, "%s %s", bkpinfo->netfs_mount, bkpinfo->isodir);
     3051            }
    30343052            run_program_and_log_output(tmp, 3);
    30353053            mr_free(tmp);
     
    30373055            malloc_string(g_selfmounted_isodir);
    30383056            strcpy(g_selfmounted_isodir, bkpinfo->isodir);
     3057            }
    30393058        }
    30403059        if (!is_this_device_mounted(bkpinfo->netfs_mount)) {
     
    31933212        }
    31943213
    3195 
    31963214        p = popup_and_get_string("Exclude paths", "Please enter paths which you do NOT want to backup. Separate them with '|'. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.", bkpinfo->exclude_paths);
    31973215        if (p == NULL) {
  • branches/3.1/mondo/src/common/libmondo-filelist.c

    r2937 r3147  
    3030
    3131extern char *MONDO_LOGFILE;
     32
     33extern long g_max_biggie_size;
    3234
    3335/* Reference to global bkpinfo */
     
    195197/*@ long ****************************************/
    196198    long lino = 0;
    197     long max_sane_size_for_a_file;
     199    // A big file has more than 64 MB of real content
    198200    long curr_set_size;
    199201    long noof_lines;
     
    221223    assert_string_is_neither_NULL_nor_zerolength(filelist);
    222224    assert(maxsetsizeK > 0);
    223 
    224     max_sane_size_for_a_file = 64L * 1024L;
    225 // max_sane_size_for_a_file = maxsetsizeK*2;
    226 //  if (max_sane_size_for_a_file > 32*1024)
    227 //    { max_sane_size_for_a_file = 32*1024; }
    228225
    229226    log_it("filelist=%s;", filelist);
     
    269266            siz = 0;
    270267        } else {
    271             siz = (long) (buf.st_size >> 10);
    272         }
    273         if (siz > max_sane_size_for_a_file) {
    274             log_msg(10, "Adding %s to big files\n", incoming);
     268            // blocks are 512 bytes long - cf man 2 stat - Pass to the previous unit (MB => kB e.g.)
     269            // use blocks instead of size to allow sparse file correct handling as much as possible
     270            siz = (long) ((buf.st_blocks*512) >> 10);
     271        }
     272        if (siz > g_max_biggie_size) {
     273            log_msg(10, "Adding %s to big files (size = %ld)\n", incoming, siz);
    275274            fprintf(fbig, "%s\n", incoming);
    276275        } else {
    277276            curr_set_size += siz;
    278             log_msg(10, "Adding %s to filelist %d\n", incoming, curr_set_no);
     277            log_msg(10, "Adding %s to filelist %d (size = %ld)\n", incoming, curr_set_no, siz);
    279278            fprintf(fout, "%s\n", incoming);
    280279            if (curr_set_size > maxsetsizeK) {
     
    400399    char *tmp = NULL;
    401400
     401    char *p;
     402
    402403    pattr = popen(syscall, "r");
    403404    if (!pattr) {
     
    431432    char *strtmp = NULL;
    432433    char *tmp = NULL;
     434    char *p = NULL;
    433435    int i;
    434436
     
    517519    int retval = 0;
    518520    int i;
    519     char *p, *q;
     521    char *p, *q, *r;
    520522    char *tmp = NULL;
    521523    FILE *pin, *pout, *faclin;
     
    13231325    char *skip_these = NULL;
    13241326    char *new_with_pipe;
    1325     char *strtmp;
    1326     char *token;
     1327    char *strtmp = NULL;
     1328    char *token = NULL;
    13271329    char *find_excludes = NULL;
    13281330    char *name_of_evalcall_form = NULL;
     
    13741376
    13751377        log_msg(5, "find command = %s", strtmp);
    1376         (void)system(strtmp);
     1378        paranoid_system(strtmp);
    13771379        mr_free(strtmp);
    13781380
     
    15101512    char *sz_filelist;
    15111513    char *exclude_paths = NULL;
    1512     int i;
    15131514    FILE *fout;
    15141515    char *command = NULL;
     
    15971598            fatal_error("Cannot openout to sz_filelist");
    15981599        }
    1599         i = 0;
    16001600        if ((!include_paths) || (strlen(include_paths) == 0)) {
    16011601            log_msg(1, "Including only '/' in %s", sz_filelist);
     
    16971697{
    16981698    /*@ int ******************************************************** */
    1699     int noof_chars;
    17001699    static int depth = 0;
    17011700    static char original_string[MAX_STR_LEN];
     
    17151714    assert(startnode != NULL);
    17161715    assert(string_to_find != NULL);
    1717 
    1718     noof_chars = strlen(string_to_find) + 1;    /* we include the '\0' */
    17191716
    17201717    log_msg(7, "starting --- str=%s", string_to_find);
  • branches/3.1/mondo/src/common/libmondo-files.c

    r2937 r3147  
    5151    /*@ pointers **************************************************** */
    5252    char *p = NULL;
     53    char *q;
    5354    FILE *fin;
    5455
     
    126127    char *command = NULL;
    127128    char *incoming = NULL;
     129    char *q;
    128130
    129131    /*@ long ******************************************************** */
     
    204206    char *tmp = NULL;
    205207    char *incoming = NULL;
     208    char *q;
    206209
    207210    /*@ int ********************************************************* */
     
    471474    char *output = NULL;
    472475    char *command = NULL;
     476    char *p = NULL;
    473477
    474478    /*@ pointers **************************************************** */
     
    540544    char *curr_cksum = NULL;
    541545    char *tmp = NULL;
     546    char *q;
    542547
    543548    /*@ long [long] ************************************************* */
     
    679684    /*@ buffers **************************************************** */
    680685    char *incoming = NULL;
     686    char *p = NULL;
    681687
    682688    /*@ end vars *************************************************** */
     
    743749    char *tmp = NULL;
    744750    char *command = NULL;
     751    char *comment;
    745752
    746753    /*@ long ******************************************************** */
     
    972979        return (1);
    973980    }
    974     fscanf(fin, "%s\n", contents);
     981    res = fscanf(fin, "%s\n", contents);
    975982    i = strlen(contents);
    976983    if (i > 0 && contents[i - 1] < 32) {
     
    978985    }
    979986    paranoid_fclose(fin);
     987    res = 0;
    980988    return (res);
    981989}
     
    10201028    if (res) {
    10211029        fatal_error("Failed to copy Mondo's stuff to scratchdir");
     1030    }
     1031
     1032    mr_asprintf(command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
     1033
     1034    if (run_program_and_log_output(command, FALSE)) {
     1035        fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
    10221036    }
    10231037
  • branches/3.1/mondo/src/common/libmondo-fork.c

    r2937 r3147  
    4242    char *newcall = NULL;
    4343    char *tmp = NULL;
     44    char *p;
    4445
    4546    /*@ pointers **************************************************** */
     
    258259    FILE *fin;
    259260    char *p;
     261    char *q;
    260262
    261263    /*@ end vars *************************************************** */
     
    300302    fin = fopen(tmp1, "r");
    301303    if (fin) {
    302         for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin); fgets(incoming, MAX_STR_LEN, fin)) {
     304        for (q = fgets(incoming, MAX_STR_LEN, fin); !feof(fin) && (q != NULL); q = fgets(incoming, MAX_STR_LEN, fin)) {
    303305            p = incoming;
    304306            while (p && *p) {
     
    545547                log_msg(1, "bytes_read_in = %ld", bytes_read_in);
    546548
    547                 fwrite(tmp1, 1, bytes_read_in, ftmp);
    548                 fread(tmp1, 1, tmpcap, fin);
    549                 log_msg(0, "tmp1 = '%s'", tmp1);
    550                 fwrite(tmp1, 1, tmpcap, ftmp);
     549                if (fwrite(tmp, 1, bytes_read_in, ftmp)) {
     550                    fatal_error("Can't fwrite here");
     551                }
     552
     553                sprintf(tmp, "I am here - %lld", (long long)ftello(fin));
     554                if (fread(tmp, 1, tmpcap, fin)) {
     555                    fatal_error("Can't fread here");
     556                }
     557                log_msg(0, "tmp = '%s'", tmp);
     558                if (fwrite(tmp, 1, tmpcap, ftmp)) {
     559                    fatal_error("Can't fwrite there");
     560                }
    551561                fclose(ftmp);
    552562                mr_free(tmp1);
  • branches/3.1/mondo/src/common/libmondo-mountlist.c

    r2937 r3147  
    5050    int pos = 0, npos = 0;
    5151    int res = 0;
    52     int mountpoint_copies = 0;
    5352    int device_copies = 0;
    5453    int i = 0;
     
    112111            }
    113112            /* does partition /dev/adXsYZ exist more than once in the mountlist? */
    114             for (i = 0, mountpoint_copies = 0, device_copies = 0;
     113            for (i = 0, device_copies = 0;
    115114                 i < mountlist->entries; i++) {
    116115                if (!strcmp(device, mountlist->el[i].device)) {
     
    214213            }
    215214            /* does partition /dev/adXsY exist more than once in the mountlist? */
    216             for (i = 0, mountpoint_copies = 0, device_copies = 0;
     215            for (i = 0, device_copies = 0;
    217216                 i < mountlist->entries; i++) {
    218217                if (!strcmp(device, mountlist->el[i].device)) {
     
    277276                }
    278277                /* does partition /dev/adXsYZ exist more than once in the mountlist? */
    279                 for (i = 0, mountpoint_copies = 0, device_copies = 0;
     278                for (i = 0, device_copies = 0;
    280279                     i < mountlist->entries; i++) {
    281280                    if (!strcmp(device, mountlist->el[i].device)) {
     
    384383    int pos = 0;
    385384    int res = 0;
    386     int mountpoint_copies = 0;
    387385    int device_copies = 0;
    388386    int i = 0;
     
    461459
    462460        /* does partition /dev/hdNX exist more than once in the mountlist? */
    463         for (i = 0, mountpoint_copies = 0, device_copies = 0;
     461        for (i = 0, device_copies = 0;
    464462             i < mountlist->entries; i++) {
    465463            if (!strcmp(device, mountlist->el[i].device)) {
     
    807805    char *tmp = NULL;
    808806    char *p = NULL;
     807    char *q = NULL;
    809808
    810809    int items = 0;
     
    926925    }
    927926    paranoid_fclose(fout);
     927    if (!(fout = fopen(MONDO_MNTLISTCHG, "w"))) {
     928        log_OS_error("WMTD - Cannot openout "MONDO_MNTLISTCHG);
     929        return (1);
     930    }
     931    fprintf(fout, "the mountlist was changed by mondorestore\n");
     932    paranoid_fclose(fout);
    928933    return (0);
    929934}
  • branches/3.1/mondo/src/common/libmondo-raid-EXT.h

    r558 r3147  
    5353#endif
    5454
    55 extern int parse_mdstat(struct raidlist_itself *raidlist, char *device_prefix);
    56 extern int create_raidtab_from_mdstat(char *raidtab_fname);
     55extern int parse_mdstat(char *mdstat_fname, struct raidlist_itself *raidlist, char *device_prefix);
     56extern int create_raidtab_from_mdstat(char *mdstat_fname, char *raidtab_fname);
  • branches/3.1/mondo/src/common/libmondo-raid.c

    r2937 r3147  
    1515#include "libmondo-tools-EXT.h"
    1616#include "libmondo-string-EXT.h"
     17#include "libmondo-fork-EXT.h"
    1718#include "lib-common-externs.h"
    1819#include "libmondo-raid.h"
     
    429430    char *incoming = NULL;
    430431    char *p;
     432    char *q;
    431433
    432434    assert(fin != NULL);
     
    604606        return (1);
    605607    }
     608    malloc_string(label);
     609    malloc_string(value);
    606610    items = 0;
    607611    log_it("Loading raidtab...");
     
    615619            strcpy(raidlist->el[items].additional_vars.el[v].label, label);
    616620            strcpy(raidlist->el[items].additional_vars.el[v].value, value);
     621            log_msg(2,"Found raidtab entry Label: %s Value: %s",raidlist->el[items].additional_vars.el[v].label,raidlist->el[items].additional_vars.el[v].value);
    617622            v++;
    618623            mr_free(label);
     
    690695            raidrec->raid_level = atoi(value);
    691696        }
     697        log_msg(4,"Found raid level %d",raidrec->raid_level);
    692698    } else if (!strcmp(label, "nr-raid-disks")) {   /* ignore it */
    693699    } else if (!strcmp(label, "nr-spare-disks")) {  /* ignore it */
     
    710716            log_msg(1, "Unknown RAID parity algorithm '%s'\n.", value);
    711717        }
     718        log_msg(4,"Found raid parity %d",raidrec->parity);
    712719    } else if (!strcmp(label, "device")) {
    713720        get_next_raidtab_line(fin, &labelB, &valueB);
     
    735742        strcpy(raidrec->additional_vars.el[v].label, label);
    736743        strcpy(raidrec->additional_vars.el[v].value, value);
    737         raidrec->additional_vars.entries = ++v;
     744        log_msg(4,"Found additional raid pair #%d: %s / %s",v,raidrec->additional_vars.el[v].label,raidrec->additional_vars.el[v].value);
     745        v++;
     746        raidrec->additional_vars.entries = v;
    738747    }
    739748}
     
    950959
    951960
    952 int parse_mdstat(struct raidlist_itself *raidlist, char *device_prefix) {
    953 
    954   const char delims[] = " ";
    955 
    956   FILE   *fin;
    957   int    res = 0, row, i, index_min;
    958   int lastpos = 0;
    959   size_t len = 0;
    960   char   *token;
    961   char *string = NULL;
    962   char *pos;
    963   char type;
    964   char *strtmp;
     961int parse_mdstat(char *mdstat_fname, struct raidlist_itself *raidlist, char *device_prefix) {
     962
     963const char delims[] = " ";
     964
     965FILE *fin = NULL;
     966int res = 0, row, i, index_min;
     967int v = 0;
     968int lastpos = 0;
     969size_t len = 0;
     970char *token = NULL;
     971char *string = NULL;
     972char *cmd = NULL;
     973char *pos = NULL;
     974char type;
     975char *strtmp = NULL;
     976char *strtmp2 = NULL;
    965977
    966978  // open file
     
    10441056      raidlist->el[raidlist->entries].raid_level = 10;
    10451057    } else {
    1046       log_msg(1, "Unknown RAID level '%s'.\n", token);
    1047       paranoid_free(string);
    1048       paranoid_free(token);
    1049       return 1;
    1050     }
    1051     mr_free(token);
     1058        switch (row) {
     1059        case 1:  // device information
     1060            // check whether last line of record and if so skip
     1061            log_msg(8, "This is the device line\n");
     1062            pos = strcasestr(string, "unused devices: ");
     1063            if (pos != NULL) {
     1064                break;
     1065            }
     1066            // tokenise string
     1067            token = mr_strtok(string, delims, &lastpos);
     1068            if (token == NULL) {
     1069                // should not happen !
     1070                break;
     1071            }
     1072            // get RAID device name
     1073            mr_asprintf(&strtmp,"%s%s", device_prefix, token);
     1074            strncpy(raidlist->el[raidlist->entries].raid_device, strtmp, 63);
     1075            raidlist->el[raidlist->entries].raid_device[63] = '\0';
     1076            mr_free(strtmp);
     1077            mr_free(token);
     1078            // store the UUID value in the additional_vars structure
     1079            v = raidlist->el[raidlist->entries].additional_vars.entries;
     1080            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID");
     1081            mr_asprintf(&cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
     1082            mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
     1083            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
     1084            mr_free(strtmp);
     1085            v++;
     1086            // store the Version value in the additional_vars structure
     1087            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "Version");
     1088            mr_asprintf(&cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
     1089            mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
     1090            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
     1091            mr_free(strtmp);
     1092            v++;
     1093            raidlist->el[raidlist->entries].additional_vars.entries = v;
     1094            // skip ':' and status
     1095            token = mr_strtok (string, delims, &lastpos);
     1096            if (token == NULL) {
     1097                // should not happen !
     1098                break;
     1099            }
     1100            mr_free(token);
     1101            token = mr_strtok (string, delims, &lastpos);
     1102            if (token == NULL) {
     1103                // should not happen !
     1104                break;
     1105            }
     1106            if (!strcmp(token, "inactive")) {
     1107                log_msg(1, "RAID device '%s' inactive.\n",
     1108                raidlist->el[raidlist->entries].raid_device);
     1109                mr_free(string);
     1110                mr_free(token);
     1111                return 1;
     1112            }
     1113            mr_free(token);
    10521114
    10531115    // get RAID devices (type, index, device)
     
    10971159    }
    10981160
     1161    // get RAID devices (type, index, device)
     1162    // Note: parity disk for RAID4 is last normal disk, there is no '(P)'
     1163    raidlist->el[raidlist->entries].data_disks.entries = 0;
     1164    raidlist->el[raidlist->entries].spare_disks.entries = 0;
     1165    raidlist->el[raidlist->entries].failed_disks.entries = 0;
     1166    while((token = mr_strtok (string, delims, &lastpos))) {
     1167        if ((pos = strstr(token, "("))) {
     1168                type = *(pos+1);
     1169        } else {
     1170                type = ' ';
     1171        }
     1172        pos = strstr(token, "[");
     1173        *pos = '\0';
     1174        switch(type) {
     1175        case ' ': // normal data disks
     1176                raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1);
     1177                mr_asprintf(&strtmp,"%s%s", device_prefix, token);
     1178                strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp);
     1179                mr_free(strtmp);
     1180                raidlist->el[raidlist->entries].data_disks.entries++;
     1181                break;
     1182        case 'S': // spare disks
     1183                raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1);
     1184                mr_asprintf(&strtmp,"%s%s", device_prefix, token);
     1185                strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp);
     1186                mr_free(strtmp);
     1187                raidlist->el[raidlist->entries].spare_disks.entries++;
     1188                break;
     1189        case 'F': // failed disks
     1190                raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1);
     1191                mr_asprintf(&strtmp,"%s%s", device_prefix, token);
     1192                strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp);
     1193                mr_free(strtmp);
     1194                raidlist->el[raidlist->entries].failed_disks.entries++;
     1195                log_it("At least one failed disk found in RAID array.\n");
     1196                break;
     1197        default: // error
     1198                log_msg(1, "Unknown device type '%c'\n", type);
     1199                mr_free(string);
     1200                mr_free(token);
     1201                return 1;
     1202                break;
     1203        }
     1204        mr_free(token);
     1205    }
     1206
    10991207    // adjust index for each device so that it starts with 0 for every type
    11001208    index_min = 99;
    11011209    for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) {
    1102       if (raidlist->el[raidlist->entries].data_disks.el[i].index < index_min) {
    1103         index_min = raidlist->el[raidlist->entries].data_disks.el[i].index;
    1104       }
     1210        if (raidlist->el[raidlist->entries].data_disks.el[i].index < index_min) {
     1211            index_min = raidlist->el[raidlist->entries].data_disks.el[i].index;
     1212        }
    11051213    }
    11061214    if (index_min > 0) {
    1107       for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) {
    1108         raidlist->el[raidlist->entries].data_disks.el[i].index = raidlist->el[raidlist->entries].data_disks.el[i].index - index_min;   
    1109       }
     1215        for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) {
     1216                raidlist->el[raidlist->entries].data_disks.el[i].index = raidlist->el[raidlist->entries].data_disks.el[i].index - index_min;   
     1217        }
    11101218    }
    11111219    index_min = 99;
    11121220    for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) {
    1113       if (raidlist->el[raidlist->entries].spare_disks.el[i].index < index_min) {
    1114         index_min = raidlist->el[raidlist->entries].spare_disks.el[i].index;
    1115       }
     1221        if (raidlist->el[raidlist->entries].spare_disks.el[i].index < index_min) {
     1222                index_min = raidlist->el[raidlist->entries].spare_disks.el[i].index;
     1223        }
    11161224    }
    11171225    if (index_min > 0) {
    1118       for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) {
    1119         raidlist->el[raidlist->entries].spare_disks.el[i].index = raidlist->el[raidlist->entries].spare_disks.el[i].index - index_min; 
    1120       }
     1226        for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) {
     1227                raidlist->el[raidlist->entries].spare_disks.el[i].index = raidlist->el[raidlist->entries].spare_disks.el[i].index - index_min; 
     1228        }
    11211229    }
    11221230    index_min = 99;
    11231231    for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) {
    1124       if (raidlist->el[raidlist->entries].failed_disks.el[i].index < index_min) {
    1125         index_min = raidlist->el[raidlist->entries].failed_disks.el[i].index;
    1126       }
     1232        if (raidlist->el[raidlist->entries].failed_disks.el[i].index < index_min) {
     1233                index_min = raidlist->el[raidlist->entries].failed_disks.el[i].index;
     1234        }
    11271235    }
    11281236    if (index_min > 0) {
    1129       for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) {
    1130         raidlist->el[raidlist->entries].failed_disks.el[i].index = raidlist->el[raidlist->entries].failed_disks.el[i].index - index_min;   
    1131       }
     1237        for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) {
     1238                raidlist->el[raidlist->entries].failed_disks.el[i].index = raidlist->el[raidlist->entries].failed_disks.el[i].index - index_min;   
     1239        }
    11321240    }
    11331241    break;
    1134       case 2:  // config information
     1242case 2:  // config information
    11351243    // check for persistent super block
    11361244    if (strcasestr(string, "super non-persistent")) {
    1137       raidlist->el[raidlist->entries].persistent_superblock = 0;
    1138     } else {
    1139       raidlist->el[raidlist->entries].persistent_superblock = 1;
    1140     }
    1141     // extract chunk size
    1142     if (!(pos = strcasestr(string, "k chunk"))) {
    1143       raidlist->el[raidlist->entries].chunk_size = -1;
    1144     } else {
    1145       while (*pos != ' ') {
    1146         pos -= 1;
    1147         if (pos < string) {
    1148           log_it("String underflow!\n");
    1149           paranoid_free(string);
    1150           return 1;
    1151         }
    1152       }
    1153       raidlist->el[raidlist->entries].chunk_size = atoi(pos + 1);
    1154     }
    1155     // extract parity if present
    1156     if ((pos = strcasestr(string, "algorithm"))) {
    1157       raidlist->el[raidlist->entries].parity = atoi(pos + 9);
    1158     } else {
    1159       raidlist->el[raidlist->entries].parity = -1;
    1160     }
    1161     break;
    1162       case 3:  // optional build status information
    1163     if (!(pos = strchr(string, '\%'))) {
    1164       if (strcasestr(string, "delayed")) {
    1165         raidlist->el[raidlist->entries].progress = -1;  // delayed (therefore, stuck at 0%)
    1166       } else {
    1167         raidlist->el[raidlist->entries].progress = 999; // not found
    1168       }
    1169     } else {
    1170       while (*pos != ' ') {
    1171         pos -= 1;
    1172         if (pos < string) {
    1173           printf("ERROR: String underflow!\n");
    1174           paranoid_free(string);
    1175           return 1;
    1176         }
    1177       }
    1178       raidlist->el[raidlist->entries].progress = atoi(pos);
    1179     }
    1180     break;
    1181       default: // error or IN PROGRESS
    1182     if (raidlist->el[raidlist->entries].progress != -1 &&
    1183         raidlist->el[raidlist->entries].progress != 999) {
    1184         log_msg(1, "Row %d should not occur in record!\n", row);
    1185     }
    1186     break;
    1187       }
    1188       row++;
    1189     }
    1190   }
    1191   // close file
    1192   fclose(fin);
    1193   // free string
    1194   paranoid_free(string);
    1195   // return success
    1196   return 0;
    1197 
    1198 }
    1199 
    1200 
    1201 
    1202 
    1203 int create_raidtab_from_mdstat(char *raidtab_fname)
     1245                raidlist->el[raidlist->entries].persistent_superblock = 0;
     1246            } else {
     1247                raidlist->el[raidlist->entries].persistent_superblock = 1;
     1248            }
     1249            // extract chunk size
     1250            if (!(pos = strcasestr(string, "k chunk"))) {
     1251                raidlist->el[raidlist->entries].chunk_size = -1;
     1252            } else {
     1253                while (*pos != ' ') {
     1254                    pos -= 1;
     1255                    if (pos < string) {
     1256                            log_it("String underflow!\n");
     1257                            mr_free(string);
     1258                            return 1;
     1259                    }
     1260                }
     1261                raidlist->el[raidlist->entries].chunk_size = atoi(pos + 1);
     1262            }
     1263            // extract parity if present
     1264            if ((pos = strcasestr(string, "algorithm"))) {
     1265                raidlist->el[raidlist->entries].parity = atoi(pos + 9);
     1266            } else {
     1267                raidlist->el[raidlist->entries].parity = -1;
     1268            }
     1269            break;
     1270        case 3:  // optional build status information
     1271            if (!(pos = strchr(string, '\%'))) {
     1272                if (strcasestr(string, "delayed")) {
     1273                    raidlist->el[raidlist->entries].progress = -1;  // delayed (therefore, stuck at 0%)
     1274                } else {
     1275                    raidlist->el[raidlist->entries].progress = 999; // not found
     1276                }
     1277            } else {
     1278                while (*pos != ' ') {
     1279                    pos -= 1;
     1280                    if (pos < string) {
     1281                        printf("ERROR: String underflow!\n");
     1282                            mr_free(string);
     1283                            return 1;
     1284                    }
     1285                }
     1286                raidlist->el[raidlist->entries].progress = atoi(pos);
     1287            }
     1288            break;
     1289        default: // error or IN PROGRESS
     1290            if (raidlist->el[raidlist->entries].progress != -1 &&
     1291                raidlist->el[raidlist->entries].progress != 999) {
     1292                log_msg(1, "Row %d should not occur in record!\n", row);
     1293            }
     1294            break;
     1295        }
     1296        row++;
     1297    }
     1298    // free string
     1299    mr_free(string);
     1300}
     1301// close file
     1302fclose(fin);
     1303// return success
     1304return 0;
     1305
     1306}
     1307
     1308
     1309
     1310
     1311int create_raidtab_from_mdstat(char *mdstat_fname,char *raidtab_fname)
    12041312{
    12051313    struct raidlist_itself *raidlist;
     
    12091317
    12101318    // FIXME: Prefix '/dev/' should really be dynamic!
    1211     if (parse_mdstat(raidlist, "/dev/")) {
    1212         log_to_screen("Sorry, cannot read %s", MDSTAT_FILE);
     1319    if (parse_mdstat(mdstat_fname,raidlist, "/dev/")) {
     1320        log_to_screen("Sorry, cannot read %s", mdstat_fname);
    12131321        return (1);
    12141322    }
  • branches/3.1/mondo/src/common/libmondo-raid.h

    r558 r3147  
    4343#endif
    4444
    45 int create_raidtab_from_mdstat(char *raidtab_fname);
    46 int parse_mdstat(struct raidlist_itself *raidlist, char *device_prefix);
     45int create_raidtab_from_mdstat(char *mdstat_fname, char *raidtab_fname);
     46int parse_mdstat(char *mdstat_fname, struct raidlist_itself *raidlist, char *device_prefix);
  • branches/3.1/mondo/src/common/libmondo-stream.c

    r2937 r3147  
    116116    char *blk;
    117117    int i;
     118    int j;
    118119
    119120    blk = (char *) malloc(256 * 1024);
     
    131132    }
    132133    for (i = 0; i < 8 && !feof(g_tape_stream); i++) {
    133         (void) fread(blk, 1, 256 * 1024, g_tape_stream);
     134        j = fread(blk, 1, 256 * 1024, g_tape_stream);
     135        if (j) {
     136            // FIXME
     137        }
    134138    }
    135139    sleep(1);
     
    185189    }
    186190    for (i = 0; i < 4 * 8; i++) {
    187         (void) fwrite(blk, 1, 256 * 1024, g_tape_stream);
     191        if (fwrite(blk, 1, 256 * 1024, g_tape_stream)) {
     192            //FIXME
     193        }
    188194        if (should_we_write_to_next_tape
    189195            (bkpinfo->media_size[g_current_media_number], (off_t)256 * 1024)) {
     
    362368{
    363369    int res = 0;
    364     char *fname = (char *)&res;                 /* Should NOT be NULL */
     370    char fname_buf[PATH_MAX];
     371    char *fname = (char *)fname_buf;        /* Should NOT be NULL */
    365372    char *tmp = NULL;
    366373
     
    419426    res = read_header_block_from_stream(ptmp_size, tmp_fname, pctrl_chr);
    420427    log_msg(1, "End of extended attributes, now looking for afioball");
    421     return (0);
     428    return (res);
    422429}
    423430
     
    521528{
    522529    long long final_alleged_writeK, final_projected_certain_writeK,
    523         final_actually_certain_writeK = 0, cposK, bufsize_K;
     530        cposK, bufsize_K;
    524531    int last, curr, i;
    525     t_archtype type = other;
    526532    char *command = NULL;
    527533    char *tmpdir = NULL;
     
    557563        cposK = g_tapecatalog->el[curr].tape_posK;
    558564        if (cposK < final_projected_certain_writeK) {
    559             final_actually_certain_writeK = cposK;
    560565            break;
    561566        }
     
    835840                          g_tape_stream);
    836841            }
    837             (void) fwrite(datablock, 1, (size_t) length, fout);
     842            if (fwrite(datablock, 1, (size_t) length, fout)) {
     843                // FIXME
     844            }
    838845            g_tape_posK += length / 1024;
    839846        }
     
    860867    close_evalcall_form();
    861868    log_it("Saved all.tar.gz to '%s'", outfname);
    862     (void) getcwd(old_cwd, MAX_STR_LEN);
    863     chdir(bkpinfo->tmpdir);
     869    if (getcwd(old_cwd, MAX_STR_LEN)) {
     870        // FIXME
     871    }
     872    if (chdir(bkpinfo->tmpdir)) {
     873        // FIXME
     874    }
    864875    mr_asprintf(tmp, "tar -zxf %s ."MINDI_CACHE"/mondorestore.cfg 2> /dev/null", outfname);
    865876    paranoid_system(tmp);
     
    867878
    868879    paranoid_system("cp -f ."MINDI_CACHE"/mondorestore.cfg . 2> /dev/null");
    869     chdir(old_cwd);
     880    if (chdir(old_cwd)) {
     881        // FIXME
     882    }
    870883    unlink(outfname);
    871884    mr_free(outfname);
     
    10491062    unsigned int crctt;
    10501063
    1051     bool had_to_resync = FALSE;
    1052 
    10531064    /*@ init  ******************************************************* */
    10541065    malloc_string(temp_fname);
     
    10621073
    10631074    res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
     1075    if (res) {
     1076        // FIXME
     1077    }
    10641078    if (orig_size != temp_size && orig_size != -1) {
    10651079        log_to_screen("output file's size should be %ld K but is apparently %ld K", (long) size >> 10, (long) temp_size >> 10);
     
    11001114            for (size = orig_size; size > where_I_was_before_tape_change;
    11011115                 size -= bytes_to_write) {
    1102                 bytes_read =
    1103                     fread(datablock, 1, bytes_to_read, g_tape_stream);
     1116                bytes_read = fread(datablock, 1, bytes_to_read, g_tape_stream);
    11041117            }
    11051118            log_msg(4, "'size' is now %lld (should be %lld)", size,
    11061119                    where_I_was_before_tape_change);
    11071120            log_to_screen("Successfully re-sync'd tape");
    1108             had_to_resync = TRUE;
    11091121            bytes_read = fread(datablock, 1, bytes_to_read, g_tape_stream);
    11101122        }
    11111123
    1112         (void) fwrite(datablock, 1, (size_t) bytes_to_write, fout); // for blocking reasons, bytes_successfully_read_in isn't necessarily the same as bytes_to_write
     1124        if (fwrite(datablock, 1, (size_t) bytes_to_write, fout)) {  // for blocking reasons, bytes_successfully_read_in isn't necessarily the same as bytes_to_write
     1125            // FIXME
     1126        }
    11131127
    11141128#ifdef EXTRA_TAPE_CHECKSUMS
     
    11771191    }
    11781192    while (!(*pcontrol_char = tempblock[7000])) {
    1179         g_tape_posK +=
    1180             fread(tempblock, 1, (size_t) TAPE_BLOCK_SIZE,
    1181                   g_tape_stream) / 1024;
     1193        g_tape_posK += fread(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream) / 1024;
    11821194    }
    11831195    memcpy((char *) plen, tempblock + 7001, sizeof(long long));
     
    13201332    ctrl_chr = -1;
    13211333    while (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    1322         res =
    1323             read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
     1334        res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13241335        if (ctrl_chr == BLK_START_AN_AFIO_OR_SLICE) {
    13251336            break;
     
    13301341    }
    13311342    while (ctrl_chr != BLK_START_FILE) {
    1332         res =
    1333             read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
     1343        res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13341344        if (ctrl_chr == BLK_START_FILE) {
    13351345            break;
     
    13561366            bytes_to_write =
    13571367                (size < TAPE_BLOCK_SIZE) ? (long) size : TAPE_BLOCK_SIZE;
    1358             // FIXME - needs error-checking and -catching
    1359             fread(datablock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream);
    1360         }
    1361         res =
    1362             read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
     1368            if (fread(datablock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream)) {
     1369                // FIXME - needs error-checking and -catching
     1370            }
     1371        }
     1372        res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13631373        if (ctrl_chr != BLK_STOP_FILE) {
    13641374            wrong_marker(BLK_STOP_FILE, ctrl_chr);
    13651375        }
    1366         res =
    1367             read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
     1376        res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13681377        if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
    13691378            wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
    13701379        }
    1371         res =
    1372             read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
     1380        res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13731381        if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    13741382            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    13751383        }
    1376         res =
    1377             read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
     1384        res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13781385        if (ctrl_chr != BLK_START_FILE) {
    13791386            wrong_marker(BLK_START_FILE, ctrl_chr);
     
    16891696            bytes_to_read = TAPE_BLOCK_SIZE;
    16901697        }
    1691         (void) fread(datablock, 1, (size_t) bytes_to_read, fin);
     1698        if (fread(datablock, 1, (size_t) bytes_to_read, fin)) {
     1699            // FIXME
     1700        }
    16921701        g_tape_posK +=
    16931702            fwrite(datablock, 1, /*bytes_to_read */
  • branches/3.1/mondo/src/common/libmondo-string-EXT.h

    r2508 r3147  
    2323extern void strip_spaces(char *in_out);
    2424extern char *trim_empty_quotes(char *incoming);
    25 extern char *truncate_to_drive_name(char *partition);
     25extern char *truncate_to_drive_name(const char *partition);
    2626extern char *turn_raid_level_number_to_string(int raid_level);
    2727
  • branches/3.1/mondo/src/common/libmondo-string.c

    r2508 r3147  
    665665 */
    666666void strip_spaces(char *in_out)
     667{
     668    /*@ buffers ***************************************************** */
     669    char *tmp = NULL;
     670
     671    /*@ int ******************************************************** */
     672    int i;
     673
     674    /*@ end vars *************************************************** */
     675
     676    assert(in_out != NULL);
     677    malloc_string(tmp);
     678    for (i = 0; in_out[i] <= ' ' && i < (int) strlen(in_out) -1; i++);
     679    strcpy(tmp, in_out + i);
     680    for (i = (int) strlen(tmp) -1; i >= 0 && tmp[i] <= ' '; i--);
     681    i++;
     682    tmp[i] = '\0';
     683
     684    // Now tmp contains the stripped string
     685    strcpy(in_out,tmp);
     686    paranoid_free(tmp);
     687}
     688
     689/**
     690 * Remove all characters whose ASCII value is less than or equal to 32
     691 * (spaces and control characters) from both sides of @p in_out.
     692 * @param in_out The string to strip spaces/control characters from (modified).
     693 */
     694void strip_spaces2(char *in_out)
    667695{
    668696    /*@ buffers ***************************************************** */
     
    752780 * @return @p partition.
    753781 */
    754 char *truncate_to_drive_name(char *partition)
     782char *truncate_to_drive_name(const char *partition)
    755783{
    756784    int i = strlen(partition) - 1;
  • branches/3.1/mondo/src/common/libmondo-string.h

    r2508 r3147  
    2121void strip_spaces(char *in_out);
    2222char *trim_empty_quotes(char *incoming);
    23 char *truncate_to_drive_name(char *partition);
     23char *truncate_to_drive_name(const char *partition);
    2424char *turn_raid_level_number_to_string(int raid_level);
    2525void printf_silly_message(void);
  • branches/3.1/mondo/src/common/libmondo-tools.c

    r2937 r3147  
    304304{
    305305#ifdef __FreeBSD__
    306     system("kldstat | grep msdosfs || kldload msdosfs 2> /dev/null");
    307     system("kldstat | grep ext2fs  || kldload ext2fs 2> /dev/null");
     306    paranoid_system("kldstat | grep msdosfs || kldload msdosfs 2> /dev/null");
     307    paranoid_system("kldstat | grep ext2fs  || kldload ext2fs 2> /dev/null");
    308308#else
    309     system("modprobe -a msdos vfat loop &> /dev/null");
     309    paranoid_system("modprobe -a msdos vfat loop &> /dev/null");
    310310#endif
    311311}
     
    643643                colon++;
    644644                hent = gethostbyname(colon);
    645                 mr_asprintf(bkpinfo->netfs_user,"%s", hostname);
     645                mr_asprintf(&(bkpinfo->netfs_user),"%s", hostname);
    646646            } else {
    647647                hent = gethostbyname(hostname);
     
    713713}
    714714
     715/*  From busybox under GPLv2 */
     716#ifndef HAVE_MKDTEMP
     717/* This is now actually part of POSIX.1, but was only added in 2008 */
     718char* mkdtemp(char *template)
     719{
     720    if (mktemp(template) == NULL || mkdir(template, 0700) != 0)
     721        return NULL;
     722    return template;
     723}
     724#endif
     725
    715726void setup_tmpdir(char *path) {
    716727
     
    721732        /* purging a potential old tmpdir */
    722733        log_it("Purging old tmpdir %s", bkpinfo->tmpdir);
    723         chdir("/tmp");
     734        if (chdir("/tmp")) {
     735            // FIXME
     736        }
    724737        mr_asprintf(tmp,"rm -Rf %s",bkpinfo->tmpdir);
    725738        mr_free(bkpinfo->tmpdir);
    726         (void)system(tmp);
     739        paranoid_system(tmp);
    727740        mr_free(tmp);
    728741    }
     
    10321045    mr_free(tmp);
    10331046
    1034     if (!run_program_and_log_output("parted2fdisk -l | grep -i raid", 1)
     1047    if (!run_program_and_log_output("parted2fdisk -l 2>/dev/null | grep -i raid", 1)
    10351048        && !does_file_exist("/etc/raidtab")) {
    10361049        log_to_screen
    10371050            ("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat");
    1038         create_raidtab_from_mdstat("/etc/raidtab");
     1051        create_raidtab_from_mdstat(MDSTAT_FILE,"/etc/raidtab");
    10391052    }
    10401053
  • branches/3.1/mondo/src/common/libmondo-verify.c

    r2937 r3147  
    412412    char *outlog = NULL;
    413413    char *tmp = NULL;
     414    char *p = NULL;
    414415
    415416    /*@ pointers ******************************************************* */
     
    477478        bkpinfo->use_star = TRUE;
    478479        if (strstr(tarball_fname, ".bz2"))
    479             mr_asprintf(command, "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", tarball_fname, (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, outlog);
     480            mr_asprintf(command, "star -sparse -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", tarball_fname, (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, outlog);
    480481    } else {
    481482        bkpinfo->use_star = FALSE;
     
    681682
    682683            mr_asprintf(tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir);
    683             system(tmp);
     684            paranoid_system(tmp);
    684685            mr_free(tmp);
    685686        }
     
    738739        log_it("Grabbing the EXAT files");
    739740        if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    740             res =
    741                 read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
     741            res = read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
    742742                                          curr_xattr_list_fname,
    743743                                          curr_acl_list_fname);
     
    765765        if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    766766            log_it("Reading EXAT files from tape");
    767             res =
    768                 read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
     767            res = read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
    769768                                          curr_xattr_list_fname,
    770769                                          curr_acl_list_fname);
     
    848847        if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    849848            log_it("Grabbing the EXAT biggiefiles");
    850             res =
    851                 read_EXAT_files_from_tape(&size, orig_fname,
     849            res = read_EXAT_files_from_tape(&size, orig_fname,
    852850                                          &ctrl_chr, curr_xattr_list_fname,
    853851                                          curr_acl_list_fname);
  • branches/3.1/mondo/src/common/mondostructures.h

    r2816 r3147  
    191191 * A type of file in the catalog of recent archives.
    192192 */
    193 typedef enum { other,           ///< Some other kind of file.
     193typedef enum {
     194    other,                      ///< Some other kind of file.
    194195    fileset,                    ///< An afioball (fileset), optionally compressed.
    195196    biggieslice                 ///< A slice of a biggiefile, optionally compressed.
     
    201202typedef enum {
    202203    nuke = 0,                   /// Nuke mode
    203     interactive,                /// Interactive mode
     204    interactive,                    /// Interactive mode
    204205    compare,                    /// Compare mode
    205206    mbr,                        /// MBR mode
  • branches/3.1/mondo/src/common/newt-specific.c

    r2937 r3147  
    5757 */
    5858    bool g_exiting = FALSE;
     59
     60// Decide whether we should continue to ask questions or exit (cron use case)
     61extern bool g_fail_immediately;
    5962
    6063/**
     
    122125        char *tmp;
    123126
    124          assert_string_is_neither_NULL_nor_zerolength(prompt);
    125 
     127        assert_string_is_neither_NULL_nor_zerolength(prompt);
     128
     129        if (g_fail_immediately) {
     130            // We consider the user aborted by using the -F option
     131            log_msg(3, "Exiting at first interaction request due to -F");
     132            finish(1);
     133        }
    126134        if (g_text_mode) {
    127135            while (1) {
     
    163171        /*@ buffer *********************************************************** */
    164172        char *tmp = NULL;
     173        char *p;
    165174        int i;
    166175
    167         assert_string_is_neither_NULL_nor_zerolength(prompt);
     176        if (g_fail_immediately) {
     177            // We consider the user aborted by using the -F option
     178            log_msg(3, "Exiting at first interaction request due to -F");
     179            finish(1);
     180        }
    168181
    169182        if (g_text_mode) {
     
    318331        sync();
    319332
    320         chdir("/");
     333        if (chdir("/")) {
     334            // FIXME
     335        }
    321336        if (g_selfmounted_isodir) {
    322337            mr_asprintf(command, "umount -d %s", g_selfmounted_isodir);
     
    369384
    370385        /*  Before removing dir, make sure we're out of them */
    371         chdir("/tmp");
     386        if (chdir("/tmp")) {
     387            // FIXME
     388        }
    372389        run_program_and_log_output("umount -d " MNT_CDROM, FALSE);
    373390        if (g_selfmounted_isodir) {
     
    385402                log_msg(8,"erasing tempdir %s",bkpinfo->tmpdir);
    386403                mr_asprintf(command, "rm -Rf %s", bkpinfo->tmpdir);
    387                 system(command);
     404                paranoid_system(command);
    388405                mr_free(command);
    389406            }
     
    394411                log_msg(8,"erasing scratchdir %s",bkpinfo->scratchdir);
    395412                mr_asprintf(command, "rm -Rf %s", bkpinfo->scratchdir);
    396                 system(command);
     413                paranoid_system(command);
    397414                mr_free(command);
    398415            }
     
    424441        char *command = NULL;
    425442        char *tmp = NULL;
     443        char *p = NULL;
    426444
    427445        /*@ pointers ********************************************************* */
     
    763781        /*@ buffers *********************************************************** */
    764782        char *prompt = NULL;
     783        char *q;
    765784
    766785        /*@ newt ************************************************************** */
     
    11301149        static char *possible_responses[] = { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", "netfs", "iso", NULL };
    11311150        char *outstr = NULL;
     1151        char *p;
    11321152        t_bkptype backup_type;
    11331153        int i;
     
    12861306        newtPushHelpLine("   Please specify the level of compression that you want.");
    12871307        newtCenteredWindow(34, 13, "How much compression?");
    1288         b1 = newtButton(4, 1, "Maximum");
    1289         b2 = newtButton(18, 1, "Average");
    1290         b3 = newtButton(4, 5, "Minimum");
    1291         b4 = newtButton(18, 5, " None ");
     1308        b1 = newtButton(4, 1, "Maximum (9)");
     1309        b2 = newtButton(18, 1, "Average (4)");
     1310        b3 = newtButton(4, 5, "Minimum (1)");
     1311        b4 = newtButton(18, 5, " None (0) ");
    12921312        b5 = newtButton(4, 9, "         Exit        ");
    12931313        myForm = newtForm(NULL, NULL, 0);
     
    13271347        bool done;
    13281348        char *tmp = NULL;
     1349        char *p;
    13291350        char *tmp1 = NULL;
    13301351        FILE *fin, *fout;
     
    15631584}                               /* extern "C" */
    15641585#endif
    1565 
    1566 
    1567 void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage);
  • branches/3.1/mondo/src/include/my-stuff.h

    r2850 r3147  
    313313#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE  "/dev/md"
    314314#define RAID_DEVICE_STUB    DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
    315 #define SANE_FORMATS        "swap image vfat ext2 ext3 ext4 xfs vfs jfs reiserfs vmfs dos minix coda fuse.sshfs nfs nfs4 ntfs ntfs-3g hpfs raid lvm cifs ocfs ocfs2"
     315#define SANE_FORMATS        "swap image vfat ext2 ext3 ext4 xfs vfs jfs reiserfs vmfs dos minix coda fuse.sshfs nfs nfs4 ntfs ntfs-3g hpfs raid lvm cifs ocfs ocfs2 btrfs"
    316316#define ALT_TAPE        "/dev/ht0"
    317317#define MKE2FS_OR_NEWFS "mke2fs"
     
    331331#define ACL_BIGGLST_FNAME_RAW_SZ     "%s/acl_list.big.gz"
    332332
     333#define BIGGIEMAXSIZE           64L*1024L
    333334/**
    334335 * The template for an afioball filename.
     
    339340#define ARCH_BUFFER_NUM (ARCH_THREADS*4)    // Number of permissible queued afio files
    340341#define DO_MBR_PLEASE "/tmp/DO-MBR-PLEASE"
     342#define MONDO_MNTLISTCHG "/tmp/mountlist.changed"
    341343
    342344
  • branches/3.1/mondo/src/lib/mr_conf.c

    r2508 r3147  
    9797int mr_conf_open(const char *filename) {
    9898    size_t length;              /*length of the buffer/file */
    99     size_t res = 0;
    10099
    101100    /* check if mr_conf is already opened? */
     
    126125    /*reading file in buffer (skip all 0 characters) */
    127126
    128     res = fread(buffer, sizeof(char), length, CONF);
     127    if (fread(buffer, sizeof(char), length, CONF)) {
     128        // FIXME
     129    }
    129130    buffer[length] = (char) 0;  /*finalize the string */
    130131
  • branches/3.1/mondo/src/lib/mr_str.c

    r2421 r3147  
    2828    size_t pos1 = 0;
    2929    size_t pos2 = 0;
     30
     31    if (instr == NULL) {
     32        *lastpos = 0;
     33        return token;
     34    }
     35
     36    if (delims == NULL) {
     37        *lastpos = 0;
     38        return token;
     39    }
    3040
    3141    if (strlen(instr) <= *lastpos) {
  • branches/3.1/mondo/src/mondoarchive/mondoarchive.c

    r2508 r3147  
    4747 */
    4848bool g_ISO_restore_mode = FALSE;
     49
     50/* Whether we should fail immediately at first error */
     51bool g_fail_immediately = FALSE;
    4952
    5053/* Do we use extended attributes and acl ?
     
    159162    int retval = 0;
    160163    char *say_at_end = NULL;
     164    FILE *fin = NULL;
    161165
    162166    printf("Initializing...\n");
     
    260264        g_loglevel = 10;
    261265        finish(set_acl_list(argv[2], argv[3]));
     266    }
     267    if (argc >= 2 && !strcmp(argv[1], "mkraidtab")) {
     268        g_loglevel = 10;
     269        g_text_mode = TRUE;
     270        setup_newt_stuff();
     271#undef MDSTAT_FILE
     272#define MDSTAT_FILE "/tmp/mdstat"
     273        if (!(fin = fopen(MDSTAT_FILE, "r"))) {
     274            log_msg(1, "Could not open %s.\n", MDSTAT_FILE);
     275                finish(1);
     276        }
     277
     278        create_raidtab_from_mdstat(MDSTAT_FILE,"/tmp/raidtab");
     279        finish(0);
    262280    }
    263281
     
    397415    run_program_and_log_output("mount", 2);
    398416
    399     system("rm -f "MONDO_CACHE"/last-backup.aborted");
     417    paranoid_system("rm -f "MONDO_CACHE"/last-backup.aborted");
    400418    if (!retval) {
    401419        printf("Mondoarchive ran OK.\n");
     
    421439    mr_free(tmp);
    422440
    423     chdir("/tmp");
     441    if (chdir("/tmp")) {
     442        // FIXME
     443    }
    424444
    425445    if (!g_text_mode) {
  • branches/3.1/mondo/src/mondoarchive/mondoarchive.h

    r2340 r3147  
    99 */
    1010char *MONDO_LOGFILE = "/var/log/mondoarchive.log";
    11 char *MONDO_OPTIONS = "0123456789A:B:C:DE:GHI:J:K:LNOP:QRS:T:UVWYb:c:d:ef:gik:l:mn:op:rs:tuw:x:z";
     11char *MONDO_OPTIONS = "0123456789A:B:C:DE:FGHI:J:K:LM:NOP:QRS:T:UVWYb:c:d:ef:gik:l:mn:op:rs:tuw:x:z";
    1212
    1313/* No restriction on ps options */
  • branches/3.1/mondo/src/mondorestore/mondo-prep.c

    r2937 r3147  
    110110            popup_and_OK
    111111                ("I must now reboot. Please leave the boot media in the drive and repeat your actions - e.g. type 'nuke' - and it should work fine.");
    112             system("reboot");
     112            paranoid_system("reboot");
    113113        }
    114114    }
     
    171171
    172172int do_my_funky_lvm_stuff(bool just_erase_existing_volumes,
    173                           bool vacuum_pack)
     173                            bool vacuum_pack)
    174174{
    175     /**  buffers **********************************************/
     175    /** buffers **********************************************/
    176176    char *tmp = NULL;
    177177    char *tmp1 = NULL;
     
    188188    char *p;
    189189    char *q;
     190    char *r;
    190191
    191192    /** int ***************************************************/
     
    442443    /** pointers *********************************************************/
    443444    char *p;
     445    char *q;
    444446
    445447    /** init *************************************************************/
     
    503505        } else {
    504506            strcpy(new_mountlist->el[new_mountlist->entries].device,
    505                   old_mountlist->el[lino].device);
     507                    old_mountlist->el[lino].device);
    506508            strcpy(new_mountlist->el[new_mountlist->entries].mountpoint,
    507                   old_mountlist->el[lino].mountpoint);
     509                    old_mountlist->el[lino].mountpoint);
    508510            strcpy(new_mountlist->el[new_mountlist->entries].format,
    509                   old_mountlist->el[lino].format);
     511                    old_mountlist->el[lino].format);
    510512            new_mountlist->el[new_mountlist->entries].size =
    511513                old_mountlist->el[lino].size;
     
    527529 * @return 0 for success, nonzero for failure.
    528530 */
    529 int create_raid_device_via_mdadm(struct raidlist_itself *raidlist, char *device)
    530 {
    531   /** int **************************************************************/
    532   int i   = 0;
    533   int j   = 0;
    534   int res = 0;
    535  
    536   /** buffers ***********************************************************/
    537   char *devices = NULL;
    538   char *strtmp  = NULL;
    539   char *level   = NULL;
    540   char *program = NULL;
    541   char *tmp = NULL;
    542   char *oldmd = NULL;
    543   char *bootdevice;
    544   char *name;
     531int create_raid_device_via_mdadm(struct raidlist_itself *raidlist, char *device, bool test) {
     532    /** int **************************************************************/
     533    int i   = 0;
     534    int j   = 0;
     535    int v   = 0;
     536    int res = 0;
     537   
     538    /** buffers ***********************************************************/
     539    char *devices = NULL;
     540    char *level   = NULL;
     541    char *program = NULL;
    545542
    546543  malloc_string(bootdevice);
     
    735732            /* format raid partition */
    736733            mr_asprintf(program, "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device));
    737             system(program);
     734            paranoid_system(program);
    738735            if (g_fprep) {
    739736                fprintf(g_fprep, "%s\n", program);
     
    752749
    753750                mr_asprintf(tmp, "vinum init %s", line);
    754                 system(tmp);
     751                paranoid_system(tmp);
    755752                mr_free(tmp);
    756753
     
    781778        log_to_screen("Initializing RAID device %s", device);
    782779
    783 // Shouldn't be necessary.
     780        // Shouldn't be necessary.
    784781        log_to_screen("Stopping %s", device);
    785782        stop_raid_device(device);
     
    789786        log_msg(1, "Making %s", device);
    790787        // use mkraid if it exists, otherwise use mdadm
    791         if (run_program_and_log_output("which mkraid", FALSE)) {
    792             res = create_raid_device_via_mdadm(raidlist, device);
    793             log_msg(1, "Creating RAID device %s via mdadm returned %d", device, res);
     788            if (run_program_and_log_output("which mkraid", FALSE)) {
     789                res = create_raid_device_via_mdadm(raidlist, device, TRUE);
     790                log_msg(1, "Creating RAID device %s via mdadm returned %d", device, res);
    794791        } else {
    795792            mr_asprintf(program, "mkraid --really-force %s", device);
     
    884881 */
    885882int format_everything(struct mountlist_itself *mountlist, bool interactively,
    886                           struct raidlist_itself *raidlist)
     883                            struct raidlist_itself *raidlist)
    887884{
    888885    /** int **************************************************************/
     
    907904    log_it("format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false");
    908905
    909     mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions     ");
     906    mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions      ");
    910907    open_progress_form("Formatting partitions",
    911                       "I am now formatting your hard disk partitions.",
    912                       "This may take up to five minutes.", "",
    913                       mountlist->entries + 1);
     908                        "I am now formatting your hard disk partitions.",
     909                        "This may take up to five minutes.", "",
     910                        mountlist->entries + 1);
    914911
    915912    progress_step =
     
    949946    sleep(2);
    950947// This last step is probably necessary
    951 //  log_to_screen("Re-starting software RAIDs...");
    952 //  start_all_raid_devices(mountlist);
    953 //  system("sync"); system("sync"); system("sync");
    954 //  sleep(5);
     948//  log_to_screen("Re-starting software RAIDs...");
     949//  start_all_raid_devices(mountlist);
     950//  paranoid_system("sync"); paranoid_system("sync"); paranoid_system("sync");
     951//  sleep(5);
    955952// do LVMs now
    956953    log_msg(1, "Creating LVMs");
     
    992989            continue;
    993990        } else if (!does_file_exist(me->device)
    994                   && strncmp(me->device, "/dev/hd", 7)
    995                   && strncmp(me->device, "/dev/sd", 7)) {
     991                    && strncmp(me->device, "/dev/hd", 7)
     992                    && strncmp(me->device, "/dev/sd", 7)) {
    996993            log_it("Not formatting %s yet - doesn't exist - probably an LVM", me->device);
    997994            continue;
     
    10491046    }
    10501047    newtSuspend();
    1051     system("clear");
     1048    paranoid_system("clear");
    10521049    newtResume();
    10531050    return (retval);
     
    10641061 */
    10651062int make_dummy_partitions(FILE * pout_to_fdisk, char *drivename,
    1066                           int devno_we_must_allow_for)
     1063                            int devno_we_must_allow_for)
    10671064{
    10681065    /** int **************************************************************/
     
    11781175    fprintf(f, "\n\n%u partitions:\n", lp->d_npartitions);
    11791176    fprintf(f,
    1180             "#        size   offset    fstype   [fsize bsize bps/cpg]\n");
     1177            "#        size   offset    fstype   [fsize bsize bps/cpg]\n");
    11811178    pp = lp->d_partitions;
    11821179    for (i = 0; i < lp->d_npartitions; i++, pp++) {
    11831180        if (pp->p_size) {
    1184             fprintf(f, "  %c: %8lu %8lu  ", 'a' + i, (u_long) pp->p_size,
     1181            fprintf(f, "    %c: %8lu %8lu  ", 'a' + i, (u_long) pp->p_size,
    11851182                    (u_long) pp->p_offset);
    11861183            if (pp->p_fstype < FSMAXTYPES)
     
    11911188
    11921189            case FS_UNUSED: /* XXX */
    1193                 fprintf(f, "    %5lu %5lu %5.5s ", (u_long) pp->p_fsize,
     1190                fprintf(f, "      %5lu %5lu %5.5s ", (u_long) pp->p_fsize,
    11941191                        (u_long) (pp->p_fsize * pp->p_frag), "");
    11951192                break;
    11961193
    11971194            case FS_BSDFFS:
    1198                 fprintf(f, "    %5lu %5lu %5u ", (u_long) pp->p_fsize,
     1195                fprintf(f, "      %5lu %5lu %5u ", (u_long) pp->p_fsize,
    11991196                        (u_long) (pp->p_fsize * pp->p_frag), pp->p_cpg);
    12001197                break;
    12011198
    12021199            case FS_BSDLFS:
    1203                 fprintf(f, "    %5lu %5lu %5d", (u_long) pp->p_fsize,
     1200                fprintf(f, "      %5lu %5lu %5d", (u_long) pp->p_fsize,
    12041201                        (u_long) (pp->p_fsize * pp->p_frag), pp->p_cpg);
    12051202                break;
     
    12171214            fprintf(f, "- %lu",
    12181215                    (u_long) ((pp->p_offset + pp->p_size +
    1219                               lp->d_secpercyl - 1) / lp->d_secpercyl -
    1220                               1));
     1216                                lp->d_secpercyl - 1) / lp->d_secpercyl -
     1217                                1));
    12211218            if (pp->p_size % lp->d_secpercyl)
    12221219                putc('*', f);
     
    12561253    /*
    12571254     * Nobody in these enligthened days uses the CHS geometry for
    1258      * anything, but nontheless try to get it right.  If we fail
     1255     * anything, but nontheless try to get it right.    If we fail
    12591256     * to get any good ideas from the device, construct something
    12601257     * which is IBM-PC friendly.
     
    13401337                lp->d_partitions[c - 'a'].p_cpg = 64;
    13411338            } else if (!strcasecmp(mountlist->el[idx].format, "raid")
    1342                       || !strcasecmp(mountlist->el[idx].format, "vinum")) {
     1339                        || !strcasecmp(mountlist->el[idx].format, "vinum")) {
    13431340                lp->d_partitions[c - 'a'].p_fstype = FS_VINUM;
    13441341            } else if (!strcmp(mountlist->el[idx].format, "swap")) {
     
    14221419    char *format = NULL;
    14231420    char *tmp = NULL;
     1421    char *tmp1 = NULL;
    14241422    char *tmp1 = NULL;
    14251423
     
    15111509
    15121510        /* OK, we've found partition /dev/hdxN in mountlist; let's prep it */
    1513         /* For FreeBSD, that is      /dev/adXsY */
     1511        /* For FreeBSD, that is     /dev/adXsY */
    15141512
    15151513        log_it("Found partition %s in mountlist", device_str);
     
    15401538                previous_devno =
    15411539                    make_dummy_partitions(pout_to_fdisk, drivename,
    1542                                           current_devno);
     1540                                            current_devno);
    15431541            }
    15441542        }
     
    15951593        sync();
    15961594        paranoid_pclose(pout_to_fdisk);
    1597         log_msg(0,
    1598                 "------------------- fdisk.log looks like this ------------------");
     1595        paranoid_system("sync");
     1596        log_msg(0,"------------------- fdisk.log looks like this ------------------");
    15991597        mr_asprintf(tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);
    16001598        system(tmp);
     
    16251623 * Create partition number @p partno on @p drive with @p fdisk.
    16261624 * @param drive The drive to create the partition on.
    1627 //  * @param partno The partition number of the new partition (1-4 are primary, >=5 is logical).
     1625//  * @param partno The partition number of the new partition (1-4 are primary, >=5 is logical).
    16281626 * @param prev_partno The partition number of the most recently prepped partition.
    16291627 * @param format The filesystem type of this partition (used to set the type).
     
    16561654
    16571655    log_it("partition_device('%s', %d, %d, '%s', %lld) --- starting",
    1658           drive, partno, prev_partno, format, partsize);
     1656            drive, partno, prev_partno, format, partsize);
    16591657
    16601658    if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
     
    17431741            retval =
    17441742                set_partition_type(pout_to_fdisk, drive, partno, format,
    1745                                   partsize);
     1743                                    partsize);
    17461744            if (retval) {
    17471745                log_msg(1, "Failed. Trying again...");
    17481746                retval =
    17491747                    set_partition_type(pout_to_fdisk, drive, partno,
    1750                                       format, partsize);
     1748                                        format, partsize);
    17511749            }
    17521750        }
     
    17831781            retval =
    17841782                set_partition_type(pout_to_fdisk, drive, partno, format,
    1785                                   partsize);
     1783                                    partsize);
    17861784            if (retval) {
    17871785                log_it("Partitioned %s but failed to set its type", partition_name);
     
    18321830    /** buffer *********************************************************/
    18331831    struct list_of_disks *drivelist;
    1834     /*  struct mountlist_itself new_mtlist, *mountlist; */
     1832    /*  struct mountlist_itself new_mtlist, *mountlist; */
    18351833
    18361834    /** end ************************************************************/
     
    18401838
    18411839    log_it("partition_everything() --- starting");
    1842     mvaddstr_and_log_it(g_currentY, 0, "Partitioning hard drives      ");
    1843     /*  mountlist=orig_mtlist; */
     1840    mvaddstr_and_log_it(g_currentY, 0, "Partitioning hard drives        ");
     1841    /*  mountlist=orig_mtlist; */
    18441842    if (mountlist_contains_raid_devices(mountlist)) {
    1845         /*      mountlist=&new_mtlist; */
    1846         /*      extrapolate_mountlist_to_include_raid_partitions(mountlist,orig_mtlist); */
     1843        /*      mountlist=&new_mtlist; */
     1844        /*      extrapolate_mountlist_to_include_raid_partitions(mountlist,orig_mtlist); */
    18471845        log_msg(0,
    18481846                "Mountlist, including the partitions incorporated in RAID devices:-");
     
    18651863
    18661864    open_progress_form("Partitioning devices",
    1867                       "I am now going to partition all your drives.",
    1868                       "This should not take more than five minutes.", "",
    1869                       mountlist->entries);
     1865                        "I am now going to partition all your drives.",
     1866                        "This should not take more than five minutes.", "",
     1867                        mountlist->entries);
    18701868
    18711869    make_list_of_drives_in_mountlist(mountlist, drivelist);
     
    18851883    }
    18861884    newtSuspend();
    1887     system("clear");
     1885    paranoid_system("clear");
    18881886    newtResume();
    18891887    paranoid_free(drivelist);
     
    19061904 */
    19071905int set_partition_type(FILE * pout_to_fdisk, const char *drive, int partno,
    1908                       const char *format, long long partsize)
     1906                        const char *format, long long partsize)
    19091907{
    19101908    /** buffers *********************************************************/
     
    19391937        }
    19401938    } else if (strcmp(format, "ext2") == 0
    1941                || strcmp(format, "reiserfs") == 0
    1942                || strcmp(format, "ext3") == 0
    1943                || strcmp(format, "ext4") == 0
    1944                || strcmp(format, "xfs") == 0
    1945                || strcmp(format, "jfs") == 0) {
     1939                 || strcmp(format, "reiserfs") == 0
     1940                 || strcmp(format, "ext3") == 0
     1941                 || strcmp(format, "ext4") == 0
     1942                 || strcmp(format, "xfs") == 0
     1943                 || strcmp(format, "jfs") == 0
     1944                     || strcmp(format, "btrfs") == 0) {
    19461945        mr_asprintf(partcode, "83");
    19471946    } else if (strcmp(format, "minix") == 0) {
     
    19561955        mr_asprintf(partcode, "7");
    19571956    } else if ((strcmp(format, "ufs") == 0)
    1958               || (strcmp(format, "ffs") == 0)) {   /* raid autodetect */
     1957                || (strcmp(format, "ffs") == 0)) { /* raid autodetect */
    19591958        mr_asprintf(partcode, "a5");
    19601959    } else if (strcmp(format, "lvm") == 0) {
     
    21082107    mr_asprintf(program, "vinum stop -f %s", raid_device);
    21092108#else
    2110     // use raidstop if it exists, otherwise use mdadm
    2111     if (run_program_and_log_output("which raidstop", FALSE)) {
     2109        // use raidstop if it exists, otherwise use mdadm
     2110        if (run_program_and_log_output("which raidstop", FALSE)) {
    21122111        mr_asprintf(program, "mdadm -S %s", raid_device);
    21132112    } else {
     
    21742173    /** pointers ********************************************************/
    21752174    FILE *fin;
     2175    char *q;
    21762176    int i;
    21772177
     
    22032203                for (p = dev; *p > 32; p++);
    22042204                *p = '\0';
    2205                 res = stop_raid_device(dev);
     2205                retval += stop_raid_device(dev);
    22062206                mr_free(dev);
    22072207            }
     
    22612261    } else if (strcmp(format, "ext4") == 0) {
    22622262        mr_asprintf(program, "mkfs -t ext4 -F -q");
     2263    } else if (strcmp(format, "btrfs") == 0) {
     2264              strcpy(program, "mkfs.btrfs");
    22632265    } else if (strcmp(format, "minix") == 0) {
    22642266        mr_asprintf(program, "mkfs.minix");
     
    22972299 * There are a few problems with this function:
    22982300 * - It won't work if there was any unallocated space on the user's hard drive
    2299  *  when it was backed up.
     2301 *  when it was backed up.
    23002302 * - It won't work if the user's hard drive lies about its size (more common
    2301  *  than you'd think).
     2303 *  than you'd think).
    23022304 *
    23032305 * @param mountlist The mountlist to use for resizing @p drive_name.
     
    23112313    /** int *************************************************************/
    23122314    int partno, lastpart;
    2313                /** remove driveno, noof_drives stan benoit apr 2002**/
    23142315
    23152316    /** float ***********************************************************/
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-compare.c

    r2704 r3147  
    7171        return (1);
    7272    }
    73     fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin);
     73    if (fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin)) {
     74        // FIXME
     75    }
    7476    paranoid_fclose(fin);
    7577
     
    218220    int retval = 0;
    219221    int res;
    220     long noof_lines;
    221222    long archiver_errors;
    222223    bool use_star;
     
    289290    if (use_star) {
    290291        // doesn't use compressor_exe
    291         mr_asprintf(command, "%s -diff H=exustar file=%s >> %s 2>> %s", archiver_exe, tarball_fname, logfile, logfile);
     292        mr_asprintf(command, "%s -sparse -diff H=exustar file=%s >> %s 2>> %s", archiver_exe, tarball_fname, logfile, logfile);
    292293    } else {
    293294        mr_asprintf(command, "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", archiver_exe, TAPE_BLOCK_SIZE, BUFSIZE, compressor_exe, tarball_fname, logfile, logfile);
     
    308309    if (length_of_file(logfile) > 5) {
    309310        mr_asprintf(command, "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", logfile);
    310         system(command);
     311        paranoid_system(command);
    311312        mr_free(command);
    312313
     
    337338{
    338339    int retval = 0;
    339     int res;
    340340    int current_tarball_number = 0;
    341341
     
    409409            log_to_screen(progress_str);
    410410        } else {
    411             res = compare_a_tarball(tarball_fname, current_tarball_number);
     411            retval += compare_a_tarball(tarball_fname, current_tarball_number);
    412412
    413413            g_current_progress++;
     
    459459    assert(bkpinfo != NULL);
    460460
    461     getcwd(cwd, MAX_STR_LEN - 1);
    462     chdir(bkpinfo->restore_path);
    463     getcwd(new, MAX_STR_LEN - 1);
     461    if (getcwd(cwd, MAX_STR_LEN - 1)) {
     462        // FIXME
     463    }
     464    if (chdir(bkpinfo->restore_path)) {
     465        //FIXME
     466    }
     467    if (getcwd(new, MAX_STR_LEN - 1)) {
     468        // FIXME
     469    }
    464470    insist_on_this_cd_number(g_current_media_number);
    465471    unlink(MONDO_CACHE"/changed.txt");
     
    467473    resA = compare_all_tarballs();
    468474    resB = compare_all_biggiefiles();
    469     chdir(cwd);
     475    if (chdir(cwd)) {
     476        // FIXME
     477    }
    470478    noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt");
    471479    if (noof_changed_files) {
     
    594602
    595603            log_msg(2, "calling popup_changelist_from_file()");
    596             getcwd(cwd, MAX_STR_LEN - 1);
    597             chdir(bkpinfo->restore_path);
    598             getcwd(new, MAX_STR_LEN - 1);
     604            if (getcwd(cwd, MAX_STR_LEN - 1)) {
     605                //FIXME
     606            }
     607            if (chdir(bkpinfo->restore_path)) {
     608                // FIXME
     609            }
     610            if (getcwd(new, MAX_STR_LEN - 1)) {
     611                //FIXME
     612            }
    599613            popup_changelist_from_file(MONDO_CACHE"/changed.files");
    600             chdir(cwd);
     614            if (chdir(cwd)) {
     615                // FIXME
     616            }
    601617            log_msg(2, "Returning from popup_changelist_from_file()");
    602618        }
     
    634650    assert(bkpinfo != NULL);
    635651    malloc_string(dir);
    636     getcwd(dir, MAX_STR_LEN);
    637     chdir(bkpinfo->restore_path);
     652    if (getcwd(dir, MAX_STR_LEN)) {
     653        // FIXME
     654    }
     655    if (chdir(bkpinfo->restore_path)) {
     656        // FIXME
     657    }
    638658
    639659    mvaddstr_and_log_it(g_currentY,
     
    647667    }
    648668    res = verify_tape_backups();
    649     chdir(dir);
     669    if (chdir(dir)) {
     670        // FIXME
     671    }
    650672    if (length_of_file(MONDO_CACHE"/changed.txt") > 2
    651673        && length_of_file(MONDO_CACHE"/changed.files") > 2) {
     
    686708    malloc_string(dir);
    687709
    688     getcwd(dir, MAX_STR_LEN);
    689     chdir(bkpinfo->restore_path);
     710    if (getcwd(dir, MAX_STR_LEN)) {
     711        // FIXME
     712    }
     713    if (chdir(bkpinfo->restore_path)) {
     714        // FIXME
     715    }
    690716
    691717    mvaddstr_and_log_it(g_currentY,
    692718                        0, "Verifying archives against filesystem");
    693719    res = verify_tape_backups();
    694     chdir(dir);
     720    if (chdir(dir)) {
     721        // FIXME
     722    }
    695723    if (res) {
    696724        mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-newt.c

    r2937 r3147  
    137137    /** int **************************************************************/
    138138    int i = 0;
    139     int num_to_add = 0;
    140139
    141140    /** newt *************************************************************/
     
    233232    mr_asprintf(drive_to_add, "%s", device_str);
    234233    for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--);
    235     num_to_add = atoi(drive_to_add + i);
    236234    mr_free(drive_to_add);
    237235
     
    19431941        finish(1);
    19441942    }
    1945     newtPushHelpLine
    1946         ("   Please edit the mountlist to your satisfaction, then click OK or Cancel.");
     1943    newtPushHelpLine("WARNING: No LVM modification possible here. Edit /tmp/i-want-my-lvm instead");
    19471944    i = 4;
    19481945    bAdd = newtCompactButton(i, 17, " Add ");
     
    24232420    newtComponent b2;
    24242421    newtComponent b3;
    2425     newtComponent b_res;
    24262422
    24272423
     
    24342430    myForm = newtForm(NULL, NULL, 0);
    24352431    newtFormAddComponents(myForm, b1, b2, b3, NULL);
    2436     b_res = newtRunForm(myForm);
    24372432    newtFormDestroy(myForm);
    24382433    newtPopWindow();
     
    28862881            mr_getline(tmp, stdin);
    28872882            output = tmp[0];
    2888             free(tmp);
     2883            mr_free(tmp);
    28892884        }
    28902885        return (output);
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-tools.c

    r2937 r3147  
    8080char *incoming = NULL;
    8181char *question = NULL;
     82char *q;
    8283
    8384assert_string_is_neither_NULL_nor_zerolength(infname);
     
    209210if (is_this_device_mounted(g_isodir_device)) {
    210211    log_to_screen("WARNING - isodir is already mounted");
    211     already_mounted = TRUE;
    212212} else {
    213213    mr_asprintf(mount_isodir_command, "mount %s", g_isodir_device);
     
    10821082char *tmp;
    10831083char *tmp1 = NULL;
     1084char *q;
    10841085int res = 0;
    10851086pid_t pid;
     
    10881089malloc_string(tmp);
    10891090
    1090     getcwd(tmp, MAX_STR_LEN);
    1091     chdir(bkpinfo->tmpdir);
     1091    if (getcwd(tmp, MAX_STR_LEN) == NULL) {
     1092        // FIXME
     1093    }
     1094    if (chdir(bkpinfo->tmpdir)) {
     1095        // FIXME
     1096    }
    10921097    log_msg(1, "chdir(%s)", bkpinfo->tmpdir);
    10931098    log_to_screen("Extracting filelist and biggielist from media...");
     
    11161121        }
    11171122    }
    1118     chdir(tmp);
     1123    if (chdir(tmp)) {
     1124        // FIXME
     1125    }
    11191126
    11201127    log_msg(2, "Forking");
     
    11471154    unlink(MINDI_CACHE"/filelist.full.gz");
    11481155    if (g_text_mode) {
    1149         printf("Restore which directory? --> ");
    1150         mr_getline(tmp1, stdin);
    1151         toggle_path_selection(filelist, tmp1, TRUE);
    1152         if (strlen(tmp1) == 0) {
     1156        q = NULL;
     1157        while (q == NULL) {
     1158            printf("Restore which directory? --> ");
     1159            mr_getline(q, stdin);
     1160        }
     1161        toggle_path_selection(filelist, q, TRUE);
     1162        if (strlen(q) == 0) {
    11531163            res = 1;
    11541164        } else {
    11551165            res = 0;
    11561166        }
    1157         mr_free(tmp1);
     1167        mr_free(q);
    11581168    } else {
    11591169        res = edit_filelist(filelist);
     
    12291239            newtSuspend();
    12301240        }
    1231         (void)system("chroot " MNT_RESTORING);
     1241        paranoid_system("chroot " MNT_RESTORING);
    12321242        if (!g_text_mode) {
    12331243            newtResume();
     
    12711281    backup_crucial_file(MNT_RESTORING, "/boot/grub/menu.lst");
    12721282    backup_crucial_file(MNT_RESTORING, "/boot/grub/grub.cfg");
     1283    backup_crucial_file(MNT_RESTORING, "/boot/grub2/grub.cfg");
    12731284    backup_crucial_file(MNT_RESTORING, "/etc/lilo.conf");
    12741285    backup_crucial_file(MNT_RESTORING, "/etc/elilo.conf");
    12751286    backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map");
     1287    backup_crucial_file(MNT_RESTORING, "/boot/grub2/device.map");
    12761288    backup_crucial_file(MNT_RESTORING, "/etc/mtab");
    12771289    device = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "bootloader.device");
     
    13851397    char *p = NULL;
    13861398
    1387     int res = 0;
    13881399    bool done;
     1400    int res = 0;        /*  FALSE */
     1401    bool mntlistchg = FALSE;
     1402    FILE *fin = NULL;
    13891403
    13901404    assert_string_is_neither_NULL_nor_zerolength(bd);
     
    13971411                            0,
    13981412                            "Modifying fstab, mtab, device.map and menu.lst/grub.cfg, and running GRUB...                             ");
     1413        /*  Did we changed the mountlist ? If yes, then force editing conf files */
     1414        if ((fin = fopen(MONDO_MNTLISTCHG, "r")) != NULL) {
     1415            mntlistchg = TRUE;
     1416        }
    13991417        for (done = FALSE; !done;) {
    14001418            p = popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device);
     
    14061424                continue;
    14071425            }
    1408             mr_asprintf(command, "stabgrub-me %s", p);
    1409             mr_free(p);
    1410 
    1411             res = run_program_and_log_output(command, 1);
    1412             mr_free(command);
    1413 
    1414             if (res) {
     1426            /*  Only try to adapt grub here first if the mountlist wasn't changed before */
     1427            if (! mntlistchg) {
     1428                mr_asprintf(command, "stabgrub-me %s", p);
     1429                mr_free(p);
     1430
     1431                res = run_program_and_log_output(command, 1);
     1432                mr_free(command);
     1433            }
     1434
     1435            if ((res) || (mntlistchg)){
    14151436                popup_and_OK
    14161437                    ("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
     1438                } else {
     1439                    popup_and_OK("The mountlist was changed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
     1440                }
    14171441                if (!g_text_mode) {
    14181442                    newtSuspend();
     
    14261450                } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
    14271451                    sprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);
     1452                } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) {
     1453                    sprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor);
    14281454                }
    14291455                paranoid_system(tmp);
    1430                 sprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
     1456                if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) {
     1457                    sprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
     1458                } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) {
     1459                    sprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor);
     1460                                }
    14311461                paranoid_system(tmp);
    14321462                if (!g_text_mode) {
     
    14391469                        ("GRUB installation failed. Please fix the conf files so that a manual install using 'grub-install' or similar command works. You are now chroot()'ed to your restored system. Please type 'exit' when you are done.");
    14401470                    newtSuspend();
    1441                     system("chroot " MNT_RESTORING);
     1471                    paranoid_system("chroot " MNT_RESTORING);
    14421472                    newtResume();
    14431473                    popup_and_OK("Thank you.");
     
    15011531                ("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished.");
    15021532            newtSuspend();
    1503             system("chroot " MNT_RESTORING);
     1533            paranoid_system("chroot " MNT_RESTORING);
    15041534            newtResume();
    15051535            popup_and_OK("Thank you.");
     
    18461876    FILE *fout;
    18471877    char *incoming = NULL;
     1878    char *q;
    18481879
    18491880    assert_string_is_neither_NULL_nor_zerolength(output_file);
     
    19351966                       "in preparation for the post-restoration reboot.",
    19361967                       "", mountlist->entries);
    1937     chdir("/");
     1968    if (chdir("/")) {
     1969        // FIXME
     1970    }
    19381971    for (i = 0;
    19391972         i < 10
     
    20322065/* @} - end restoreUtilityGroup */
    20332066
    2034 void wait_until_software_raids_are_prepped(char *mdstat_file,
    2035                                            int wait_for_percentage)
     2067void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage)
    20362068{
    20372069    struct raidlist_itself *raidlist;
    2038     int unfinished_mdstat_devices = 9999, i;
     2070    int unfinished_mdstat_devices = 9999;
     2071    int i = 0;
    20392072    char *screen_message = NULL;
    20402073
     
    20452078    while (unfinished_mdstat_devices > 0) {
    20462079            // FIXME: Prefix '/dev/' should really be dynamic!
    2047         if (parse_mdstat(raidlist, "/dev/")) {
     2080        if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) {
    20482081            log_to_screen("Sorry, cannot read %s", MDSTAT_FILE);
    20492082            log_msg(1,"Sorry, cannot read %s", MDSTAT_FILE);
    20502083            return;
    20512084        }
    2052         for (unfinished_mdstat_devices = i = 0; i <= raidlist->entries; i++) {
     2085        for (unfinished_mdstat_devices = 0; i <= raidlist->entries; i++) {
    20532086            if (raidlist->el[i].progress < wait_for_percentage) {
    20542087                unfinished_mdstat_devices++;
     
    20672100                    sleep(2);
    20682101                    // FIXME: Prefix '/dev/' should really be dynamic!
    2069                     if (parse_mdstat(raidlist, "/dev/")) {
     2102                    if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) {
    20702103                        break;
    20712104                    }
  • branches/3.1/mondo/src/mondorestore/mondoprep.h

    r2316 r3147  
    8282
    8383
    84 char *truncate_to_drive_name(char *partition);
     84char *truncate_to_drive_name(const char *partition);
    8585void create_mountlist_for_drive(struct mountlist_itself *mountlist,
    8686                                char *drive_name,
  • branches/3.1/mondo/src/mondorestore/mondorestore.c

    r2937 r3147  
    6363 */
    6464bool g_ISO_restore_mode = FALSE;    /* are we in Iso Mode? */
     65
     66/* Whether we should fail immediately at first error */
     67bool g_fail_immediately = FALSE;
    6568
    6669/**
     
    618621        ("Label/Identify your ext2/ext3/ext4 partitions if necessary?")) {
    619622        mvaddstr_and_log_it(g_currentY, 0,
    620                             "Using tune2fs to identify your ext2,3,4 partitions");
     623                            "Using tune2fs/tune4fs to identify your ext2,3,4 partitions");
    621624        if (does_file_exist("/tmp/fstab.new")) {
    622625            mr_asprintf(fstab_fname, "/tmp/fstab.new");
     
    710713
    711714
    712 /*            MONDO - saving your a$$ since Feb 18th, 2000            */
     715/*            MONDO - saving your systems since Feb 18th, 2000            */
    713716
    714717
     
    730733    int retval = 0;
    731734    int res = 0;
    732     bool boot_loader_installed = FALSE;
    733735    char *tmp = NULL;
    734736    char *tmp1 = NULL;
     
    829831        log_msg(1,
    830832                "Great! Boot loader was installed. No need for msg at end.");
    831         boot_loader_installed = TRUE;
    832833    }
    833834    clean_blkid();
     
    836837    mvaddstr_and_log_it(g_currentY,
    837838                        0,
    838                         "Using tune2fs to identify your ext2,3 partitions");
     839                        "Using tune2fs/tune4fs to identify your ext2,3,4 partitions");
    839840
    840841    mr_asprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab >> %s 2>> %s", MINDI_CACHE"/mountlist.txt", MONDO_LOGFILE, MONDO_LOGFILE);
     
    16011602
    16021603        if (use_star) {
    1603             mr_asprintf(command, "star -x -force-remove -U " STAR_ACL_SZ " errctl= file=%s", tarball_fname);
     1604            mr_asprintf(command, "star -x -force-remove -sparse -U " STAR_ACL_SZ " file=%s", tarball_fname);
    16041605            if (strstr(tarball_fname, ".bz2")) {
    16051606                mr_strcat(command, " -bz");
     
    16391640        }
    16401641
    1641         if (g_getfattr) {
    1642             log_msg(1, "Setting fattr list %s", xattr_fname);
    1643             if (length_of_file(xattr_fname) > 0) {
    1644                 res = set_fattr_list(filelist_subset_fname, xattr_fname);
    1645                 if (res) {
    1646                     log_to_screen("Errors occurred while setting extended attributes");
    1647                 } else {
    1648                     log_msg(1, "I set xattr OK");
     1642        if (! use_star) {
     1643            if (g_getfattr) {
     1644                log_msg(1, "Setting fattr list %s", xattr_fname);
     1645                if (length_of_file(xattr_fname) > 0) {
     1646                    res = set_fattr_list(filelist_subset_fname, xattr_fname);
     1647                    if (res) {
     1648                        log_to_screen("Errors occurred while setting extended attributes");
     1649                    } else {
     1650                        log_msg(1, "I set xattr OK");
     1651                    }
     1652                    retval += res;
    16491653                }
    1650                 retval += res;
    1651             }
    1652         }
    1653         if (g_getfacl) {
    1654             log_msg(1, "Setting acl list %s", acl_fname);
    1655             if (length_of_file(acl_fname) > 0) {
    1656                 res = set_acl_list(filelist_subset_fname, acl_fname);
    1657                 if (res) {
    1658                     log_to_screen
    1659                         ("Errors occurred while setting access control lists");
    1660                 } else {
    1661                     log_msg(1, "I set ACL OK");
     1654            }
     1655            if (g_getfacl) {
     1656                log_msg(1, "Setting acl list %s", acl_fname);
     1657                if (length_of_file(acl_fname) > 0) {
     1658                    res = set_acl_list(filelist_subset_fname, acl_fname);
     1659                    if (res) {
     1660                        log_to_screen("Errors occurred while setting access control lists");
     1661                    } else {
     1662                        log_msg(1, "I set ACL OK");
     1663                    }
     1664                    retval += res;
    16621665                }
    1663                 retval += res;
    1664             }
    1665         }
    1666         if (retval) {
     1666            }
     1667        } else {
     1668            retval = res;
     1669        }
     1670        // Be verbose for star
     1671        if (retval || use_star) {
    16671672            mr_asprintf(command, "cat %s >> %s", temp_log, MONDO_LOGFILE);
    1668             system(command);
     1673            paranoid_system(command);
    16691674            paranoid_free(command);
    16701675
    1671             log_msg(2, "Errors occurred while processing fileset #%d",
    1672                     current_tarball_number);
     1676            if (retval) {
     1677                log_msg(2, "Errors occurred while processing fileset #%d", current_tarball_number);
     1678            }
    16731679        } else {
    16741680            log_msg(2, "Fileset #%d processed OK", current_tarball_number);
     
    17821788        if (strstr(tarball_fname, ".star.")) {
    17831789            use_star = TRUE;
    1784             mr_asprintf(command, "star -t file=%s %s", afio_fname, executable);
     1790            mr_asprintf(command, "star -sparse -t file=%s %s", afio_fname, executable);
    17851791        } else {
    17861792            use_star = FALSE;
     
    18161822    if (strstr(tarball_fname, ".star.")) {
    18171823        // star
    1818         mr_asprintf(command, "star -x file=%s %s", afio_fname, executable);
     1824        mr_asprintf(command, "star -sparse -x file=%s %s", afio_fname, executable);
    18191825        if (filelist) {
    18201826            mr_strcat(command, " list=%s", filelist_subset_fname);
     
    22162222    res = read_header_block_from_stream(&biggie_size, biggie_fname, &ctrl_chr);
    22172223    if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    2218         res =
    2219             read_EXAT_files_from_tape(&biggie_size, biggie_fname, &ctrl_chr, xattr_fname, acl_fname);
     2224        res = read_EXAT_files_from_tape(&biggie_size, biggie_fname, &ctrl_chr, xattr_fname, acl_fname);
    22202225    }
    22212226
     
    23542359    mr_free(tmp);
    23552360
    2356     chdir(bkpinfo->restore_path);   /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */
     2361    if (chdir(bkpinfo->restore_path)) { /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */
     2362        //FIXME
     2363    }
    23572364
    23582365    run_program_and_log_output("pwd", 5);
     
    24702477    log_msg(2, "restore_everything() --- starting");
    24712478    g_current_media_number = 1;
    2472     getcwd(cwd, MAX_STR_LEN - 1);
     2479    if (getcwd(cwd, MAX_STR_LEN - 1)) {
     2480        // FIXME
     2481    }
    24732482    mr_asprintf(tmp, "mkdir -p %s", bkpinfo->restore_path);
    24742483    run_program_and_log_output(tmp, FALSE);
     
    24762485
    24772486    log_msg(1, "Changing dir to %s", bkpinfo->restore_path);
    2478     chdir(bkpinfo->restore_path);
    2479     getcwd(newpath, MAX_STR_LEN - 1);
     2487    if (chdir(bkpinfo->restore_path)) {
     2488        //FIXME
     2489    }
     2490    if (getcwd(newpath, MAX_STR_LEN - 1)) {
     2491        // FIXME
     2492    }
    24802493    log_msg(1, "path is now %s", newpath);
    24812494    log_msg(1, "restoring everything");
     
    25112524        resB = restore_all_biggiefiles_from_CD(filelist);
    25122525    }
    2513     chdir(cwd);
     2526    if (chdir(cwd)) {
     2527        //FIXME
     2528    }
    25142529    if (resA + resB) {
    25152530        log_to_screen("Errors occurred while data was being restored.");
     
    26542669    if (argc == 2 && strcmp(argv[1], "--edit-mountlist") == 0) {
    26552670#ifdef __FreeBSD__
    2656         system("mv -f /tmp/raidconf.txt /etc/raidtab");
     2671        paranoid_system("mv -f /tmp/raidconf.txt /etc/raidtab");
    26572672        if (!does_file_exist("/etc/raidtab"))
    2658             system("vinum printconfig > /etc/raidtab");
     2673            paranoid_system("vinum printconfig > /etc/raidtab");
    26592674#endif
    26602675        load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    26612676        res = let_user_edit_the_mountlist(mountlist, raidlist);
    26622677#ifdef __FreeBSD__
    2663         system("mv -f /etc/raidtab /tmp/raidconf.txt");
     2678        paranoid_system("mv -f /etc/raidtab /tmp/raidconf.txt");
    26642679#endif
    26652680        paranoid_MR_finish(res);
     
    27342749
    27352750    if (argc == 3 && strcmp(argv[1], "--mdconv") == 0) {
    2736         finish(create_raidtab_from_mdstat(argv[2]));
     2751        finish(create_raidtab_from_mdstat(MDSTAT_FILE,argv[2]));
    27372752    }
    27382753
     
    28202835                        mr_asprintf(tmp, "sshfs -o ro %s /tmp/isodir", bkpinfo->netfs_mount);
    28212836                    }
    2822                 } else {
    2823                     if (bkpinfo->netfs_user) {
    2824                         mr_asprintf(tmp, "mount %s@%s -o nolock,ro /tmp/isodir", bkpinfo->netfs_user,bkpinfo->netfs_mount);
     2837                } else  {
     2838                    if (strstr(bkpinfo->netfs_proto, "smbfs")) {
     2839                        if (bkpinfo->netfs_user) {
     2840                            mr_asprintf(tmp, "mount -t cifs %s /tmp/isodir -o user=%s,nolock,ro ", bkpinfo->netfs_mount,bkpinfo->netfs_user);
     2841                        } else {
     2842                            mr_asprintf(tmp, "mount -t cifs %s /tmp/isodir -o nolock,ro ", bkpinfo->netfs_mount);
     2843                        }
    28252844                    } else {
    2826                         mr_asprintf(tmp, "mount %s -o nolock,ro /tmp/isodir", bkpinfo->netfs_mount);
     2845                        if (bkpinfo->netfs_user) {
     2846                            mr_asprintf(tmp, "mount %s@%s -o nolock,ro /tmp/isodir", bkpinfo->netfs_user,bkpinfo->netfs_mount);
     2847                        } else {
     2848                            mr_asprintf(tmp, "mount %s -o nolock,ro /tmp/isodir", bkpinfo->netfs_mount);
     2849                        }
    28272850                    }
    28282851                }
     
    29562979    if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) {
    29572980        mr_asprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);
    2958         system(tmp);
     2981        paranoid_system(tmp);
    29592982        mr_free(tmp);
    29602983    }
  • branches/3.1/mondo/src/restore-scripts/mondo/grub-MR

    r2937 r3147  
    107107if [ "$MNT_RESTORING" ] ; then
    108108    if [ -x $MNT_RESTORING/usr/sbin/grub-install.unsupported ]; then
    109         echo "Now I'll use grub-install.unsupported in chroot" >> $LOGFILE
    110         chroot $MNT_RESTORING /usr/sbin/grub-install.unsupported $1 >> $LOGFILE 2>> $LOGFILE
     109        echo "Now I'll use OpenSuSE/SLES new grub-install in chroot" >> $LOGFILE
     110        chroot $MNT_RESTORING /usr/sbin/grub-install >> $LOGFILE 2>> $LOGFILE
    111111        res=$?
    112         echo "grub-install.unsupported in chroot returned $res" >> $LOGFILE
     112        echo "grub-install in chroot returned $res" >> $LOGFILE
    113113    fi
    114114else
    115115    if [ -x /usr/sbin/grub-install.unsupported ]; then
    116         echo "Now I'll use grub-install.unsupported locally" >> $LOGFILE
    117         /usr/sbin/grub-install.unsupported $1 >> $LOGFILE 2>> $LOGFILE
     116        echo "Now I'll use OpenSuSE/SLES new grub-install locally" >> $LOGFILE
     117        /usr/sbin/grub-install >> $LOGFILE 2>> $LOGFILE
    118118        res=$?
    119         echo "grub-install.unsupported returned $res" >> $LOGFILE
     119        echo "grub-install returned $res" >> $LOGFILE
    120120    fi
    121121fi
     
    124124echo "Now I'll use grub-install" >> $LOGFILE
    125125if [ "$MNT_RESTORING" ] ; then
     126    echo "Launching: chroot $MNT_RESTORING grub-install $1" >> $LOGFILE
    126127    chroot $MNT_RESTORING grub-install $1 >> $LOGFILE 2>> $LOGFILE
    127128    res=$?
    128129else
     130    echo "Launching: grub-install $1" >> $LOGFILE
    129131    grub-install $1 >> $LOGFILE 2>> $LOGFILE
    130132    res=$?
    131133fi
    132134echo "grub-install returned $res" >> $LOGFILE
     135[ "$res" -eq "0" ] && exit 0
     136
     137
     138echo "Now I'll use grub2-install" >> $LOGFILE
     139if [ "$MNT_RESTORING" ] ; then
     140    chroot $MNT_RESTORING grub2-install $1 >> $LOGFILE 2>> $LOGFILE
     141    res=$?
     142else
     143    grub2-install $1 >> $LOGFILE 2>> $LOGFILE
     144    res=$?
     145fi
     146echo "grub2-install returned $res" >> $LOGFILE
    133147[ "$res" -eq "0" ] && exit 0
    134148
     
    190204elif [ -f "/mnt/RESTORING/boot/grub/grub.cfg" ]; then
    191205    grep -vE '^#' /boot/grub/grub.cfg > /mnt/RESTORING/tmp/grub.conf
     206elif [ -f "/mnt/RESTORING/boot/grub2/grub.cfg" ]; then
     207    grep -vE '^#' /boot/grub2/grub.cfg > /mnt/RESTORING/tmp/grub.conf
    192208else
    193209    echo "Unable to find Grub conf file" | tee -a $LOGFILE
  • branches/3.1/mondo/src/restore-scripts/mondo/label-partitions-as-necessary

    r2462 r3147  
    2828    else
    2929        if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] || [ "$format" = "ext4" ]; then
    30             command="tune2fs $opttun $label $mountpt"
     30            if [ "$format" = "ext4" ] && [ -x "/sbin/tune4fs" ]; then
     31                command="/sbin/tune4fs $opttun $label $mountpt"
     32            else
     33                command="tune2fs $opttun $label $mountpt"
     34            fi
    3135            LogIt "Running $command"
    3236            $command
     
    3842            if [ "$opttun" = "-U" ]; then
    3943                LogIt "Creating uuid $label on swap partition $mountpt"
    40                 echo -n "$label" | perl -ne 's/-//g;chomp;print pack "H*",$_' | dd conv=notrunc "of=$mountpt" obs=1 seek=1036
     44                if [ -x "/sbin/swaplabel" ]; then
     45                    /sbin/swaplabel $opttun $label $mountpt
     46                else
     47                    echo -n "$label" | perl -ne 's/-//g;chomp;print pack "H*",$_' | dd conv=notrunc "of=$mountpt" obs=1 seek=1036
     48                fi
    4149            else
    42                 command="mkswap $opttun $label $mountpt"
     50                if [ -x "/sbin/swaplabel" ]; then
     51                    command="/sbin/swaplabel $opttun $label $mountpt"
     52                else
     53                    command="mkswap $opttun $label $mountpt"
     54                fi
    4355                LogIt "Running $command"
    4456                $command
    4557            fi
    4658        else
    47             LogIt "I am NOT going to run tune2fs/reiserfstune: the partition is format '$format', which doesn't like tune2fs/reiserfstune anyway"
     59            LogIt "I am NOT going to run tune2|4fs/reiserfstune: the partition is format '$format', which doesn't like tune2|4fs/reiserfstune anyway"
    4860        fi
    4961    fi
     
    5365# ---------------------------------------------
    5466
    55 LogIt "Identifying your drives with tune2fs"
     67LogIt "Identifying your drives with FS tune tool"
    5668if [ "$#" -ne "1" ] ; then
    5769    LogIt "label-partitions-as-necessary $MINDI_CACHE/mountlist.txt < /tmp/fstab.new" 1
  • branches/3.1/mondo/src/restore-scripts/mondo/make-me-bootable

    r2196 r3147  
    22
    33
    4 if [ "$#" -ne "1" ] && [ "$#" -ne "2" ] ; then
    5     echo "make-me-bootable <fname> (dummy)"
     4if [ "$#" -ne "2" ] && [ "$#" -ne "3" ] ; then
     5    echo "make-me-bootable <fname> <drive> [noaction]"
    66    exit 1
    77fi
    88
    9 dummy=$2
     9drivetouse=$2
    1010boot_drv=""
    1111boot_part=""
    1212root_drv=""
    1313root_part=""
     14if [ ! "$LOGFILE" ]; then
     15    LOGFILE="/tmp/mondorestore2.log"
     16fi
     17dummy="$3"
    1418
    15 HAVE_ACTIVE="false"
     19activepart=`parted2fdisk -l $drivetouse | tr -s '\t' ' ' | grep "$drivetouse" | grep '*' | cut -d' ' -f1`
     20
    1621for i in `cat $1 | tr -s '\t' ' ' | cut -d' ' -f1 | grep -vE "/dev/fd|none|#"` ; do
    17     mountpt=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f2`
    18     format=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f3`
    1922    # Warning wrong if LVM !
    2023    drive=`echo $i | sed -e 's/[0-9]*$//' -e 's/\([0-9]\)p$/\1/'`
    21     partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
     24    if [ "$drivetouse" = "$drive" ]; then
     25        # We can continue as this is the drive we ned to work on
     26        partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
     27        mountpt=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f2`
    2228
    23     if [ "$HAVE_ACTIVE" = "false" ] && [ "`parted2fdisk -l $drive | tr -s '\t' ' ' | grep "$i " | grep -v "*"`" ] ; then
    2429        if [ "$mountpt" = "/" ] ; then
    2530            root_drv=$drive
    26         root_part=$partno
     31            root_part=$partno
    2732        elif [ "$mountpt" = "/boot" ] ; then
    2833            boot_drv=$drive
     
    4651
    4752if [ "$drive" ] ; then
     53    if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
     54        partno="1"
     55    fi
     56    cmd=""
     57    for p in "$activepart"; do
     58        # First desactivate active partitions (coming from previous usage)
     59        cmd="${cmd}a\n$p\n"
     60        if [ "$dummy" != "" ] ; then
     61            echo "Will desactivate $p on $drive" >> $LOGFILE
     62        fi
     63    done
     64    # Then activate the one which should
    4865    if [ "$dummy" != "" ] ; then
    49         if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
    50             partno="1"
    51         fi
    52         echo "$partno"
    53     else
    54         echo -en "a\n$partno\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
    55     fi
     66        echo "Would activate $partno on $drive" >> $LOGFILE
     67    else
     68        echo -en "${cmd}a\n$partno\np\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
     69    fi
    5670fi
    5771exit 0
  • branches/3.1/mondo/src/restore-scripts/mondo/stabgrub-me

    r2508 r3147  
    5757LocateOldGrub() {
    5858    old_grubconf=""
    59     if [ -f "/mnt/RESTORING/boot/grub/menu.lst" ] || [ -f "/mnt/RESTORING/boot/grub/grub.cfg" ] ; then
     59    if [ -f "/mnt/RESTORING/boot/grub/menu.lst" ] || [ -f "/mnt/RESTORING/boot/grub/grub.cfg" ] || [ -f "/mnt/RESTORING/boot/grub2/grub.cfg" ] ; then
    6060        LogIt "No need for menu.lst/grub.cfg search." 2
    6161        if [ -f "/mnt/RESTORING/boot/grub/menu.lst" ]; then
     
    6363        elif [ -f "/mnt/RESTORING/boot/grub/grub.cfg" ]; then
    6464            old_grubconf=/mnt/RESTORING/boot/grub/grub.cfg
     65        elif [ -f "/mnt/RESTORING/boot/grub2/grub.cfg" ]; then
     66            old_grubconf=/mnt/RESTORING/boot/grub2/grub.cfg
    6567        fi
    6668        if [ -L "$old_grubconf" ] ; then
     
    6870            if [ _"`echo $l | cut -c1`" = _"/" ]; then
    6971                # If readlink gives an absolute path it's related to the chroot
    70                 old_grubconf=/mnt/RESTORING/$l
     72                        old_grubconf=/mnt/RESTORING/$l
    7173            else
    7274                # If readlink gives a relative path, it's in the same dir
    73                 old_grubconf=/mnt/RESTORING/boot/grub/$l
     75                    d=`dirname "$old_grubconf"`
     76                        old_grubconf=$d/$l
    7477            fi
    75         fi 
     78        fi
    7679        return 0
    7780    fi
     
    128131elif [ -f /mnt/RESTORING/boot/grub/grub.cfg ]; then
    129132    new_grubconf=/mnt/RESTORING/boot/grub/grub.cfg.NEW
     133elif [ -f /mnt/RESTORING/boot/grub2/grub.cfg ]; then
     134    new_grubconf=/mnt/RESTORING/boot/grub2/grub.cfg.NEW
    130135fi
    131136# change back to /tmp if /mnt/RESTORING/etc be problematic
  • branches/3.1/mondo/test/Makefile.am

    r2310 r3147  
    33## The program
    44sbin_PROGRAMS         = mrtest_mountlist mrtest_truncname mrtest_conf mrtest_mem mrtest_msg mrtest_string
     5mrtestdir                 = $(pkglibdir)/test
     6mrtest_PROGRAMS           = mrtest_mountlist mrtest_truncname mrtest_stresc
    57mrtest_mountlist_SOURCES  = test-mountlist.c ${top_builddir}/src/mondorestore/mondo-prep.c ${top_builddir}/src/mondorestore/mondo-rstr-newt.c ${top_builddir}/src/mondorestore/mondo-rstr-tools.c
    68mrtest_mountlist_LDADD    = ${top_builddir}/src/common/libmondo.a ${top_builddir}/src/lib/libmr.a @MONDORESTORE_STATIC@
     
    1517mrtest_string_SOURCES       = test-string.c
    1618mrtest_string_LDADD         = ${top_builddir}/src/common/libmondo.a ${top_builddir}/src/lib/libmr.a @MONDORESTORE_STATIC@
     19mrtest_stresc_SOURCES     = test-mr_stresc.c
     20mrtest_stresc_LDADD       = ${top_builddir}/src/lib/libmr.a @MONDORESTORE_STATIC@
  • branches/3.1/mondo/test/test-mountlist.c

    r2623 r3147  
    33 *
    44 * Test program for mountlist management at restore time
    5  * Cn be used on host system with valgrind easier than with mondorestore
     5 * Can be used on host system with valgrind easier than with mondorestore
    66 */
    77#include <stdio.h>
     
    1212#include "../mondorestore/mondorestore.h"
    1313#include "../mondorestore/mr-externs.h"
     14
     15#define RAIDTAB_TEST "/tmp/raidtab"
     16#define MOUNTLIST_TEST "/tmp/mountlist.txt"
    1417
    1518extern void twenty_seconds_til_yikes(void);
     
    2326extern int g_partition_table_locked_up;
    2427extern int g_noof_rows;
     28
     29/* Whether we should fail immediately at first error */
     30bool g_fail_immediately = FALSE;
    2531
    2632bool g_ISO_restore_mode = FALSE;    /* are we in Iso Mode? */
     
    6470
    6571setup_newt_stuff();
     72mr_asprintf(&g_mountlist_fname, MOUNTLIST_TEST);
    6673log_it("before mountlist");
    6774load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt");
     
    6976resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    7077log_it("after resize_mountlist_proportionately_to_suit_new_drives");
    71 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
     78load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
    7279log_it("after load_raidtab_into_raidlist");
    7380edit_mountlist(MINDI_CACHE"/mountlist.txt", mountlist, raidlist);
     
    7885mr_free(flaws_str);
    7986
     87log_it("before check raidlist content");
     88log_it("after check raidlist content");
     89
     90log_it("before create mdadm dev");
     91create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
     92create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
     93log_it("after create mdadm dev");
     94
     95free(mountlist);
     96free(raidlist);
    8097mr_free(MONDO_LOGFILE);
     98mr_free(g_mountlist_fname);
    8199exit(0);
    82100}
  • branches/3.1/mondo/test/test-truncname.c

    r2623 r3147  
    2323extern int g_noof_rows;
    2424
     25/* Whether we should fail immediately at first error */
     26bool g_fail_immediately = FALSE;
     27
    2528bool g_ISO_restore_mode = FALSE;    /* are we in Iso Mode? */
    2629bool g_I_have_just_nuked = FALSE;
     
    3740
    3841extern char *MONDO_LOGFILE;
    39 extern char *truncate_to_drive_name(char *);
     42extern char *truncate_to_drive_name(const char *);
    4043/* We don't have a cleanup function yet */
    4144void (*mr_cleanup)(int) = NULL;
Note: See TracChangeset for help on using the changeset viewer.