Ignore:
Timestamp:
Aug 18, 2009, 3:05:43 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3334@localhost: bruno | 2009-08-08 12:17:37 +0200

  • Change mr_asprintf interface to pass only the char * (makes bkpinfo usage more easy)
File:
1 edited

Legend:

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

    r2322 r2323  
    144144}
    145145
    146 mr_asprintf(&question_ptr, "Should I restore the image of %s ?", incoming_ptr);
     146mr_asprintf(question_ptr, "Should I restore the image of %s ?", incoming_ptr);
    147147
    148148if (ask_me_yes_or_no(question_ptr)) {
     
    228228}
    229229log_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles", f, file);
    230 mr_asprintf(&command, "grep -E '^%s$' %s", file, list_fname);
     230mr_asprintf(command, "grep -E '^%s$' %s", file, list_fname);
    231231res = run_program_and_log_output(command, FALSE);
    232232mr_free(command);
     
    260260    char *command = NULL;
    261261    char *mds = NULL;
     262    char *p = NULL;
    262263    int retval = 0, i;
    263264    bool already_mounted = FALSE;
    264265    char *isodir_format = NULL;
    265266
    266 assert(bkpinfo != NULL);
    267267g_ISO_restore_mode = TRUE;
    268268read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
     
    271271    * Don't let this clobber an existing bkpinfo->isodir */
    272272    if (!bkpinfo->isodir[0]) {
    273         strcpy(bkpinfo->isodir, "/tmp/isodir");
     273        mr_free(bkpinfo->isodir);
     274        mr_asprintf(p, "/tmp/isodir");
     275        bkpinfo->isodir = p;
    274276    }
    275277    /* End patch */
    276     mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
     278    mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir);
    277279    run_program_and_log_output(command, 5);
    278280    mr_free(command);
     
    290292    already_mounted = TRUE;
    291293} else {
    292     mr_asprintf(&mount_isodir_command, "mount %s", g_isodir_device);
     294    mr_asprintf(mount_isodir_command, "mount %s", g_isodir_device);
    293295    if (isodir_format) {
    294296        mr_strcat(mount_isodir_command, " -t %s", isodir_format);
     
    320322log_msg(1, "%s #%d has been mounted via loopback mount", mds, i);
    321323if (i < 0) {
    322 popup_and_OK
    323     ("Cannot find ISO images in the directory you specified.");
    324 retval = 1;
    325 }
    326 log_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__,
    327     bkpinfo->isodir);
     324    popup_and_OK("Cannot find ISO images in the directory you specified.");
     325    retval = 1;
     326}
     327log_msg(2, "bkpinfo->isodir is now %s", bkpinfo->isodir);
    328328return (retval);
    329329}
     
    368368
    369369    if (!strcmp(mpt, "/1")) {
    370         mr_asprintf(&mountpoint, "/");
     370        mr_asprintf(mountpoint, "/");
    371371        log_msg(3, "Mommm! SME is being a dildo!");
    372372    } else {
    373         mr_asprintf(&mountpoint, "%s", mpt);
     373        mr_asprintf(mountpoint, "%s", mpt);
    374374    }
    375375
     
    380380        return (0);
    381381    }
    382     mr_asprintf(&tmp, "Mounting device %s   ", device);
     382    mr_asprintf(tmp, "Mounting device %s   ", device);
    383383    log_msg(1, tmp);
    384384    /* Deal with additional params only if not /proc or /sys */
    385     mr_asprintf(&additional_parameters, "");
     385    mr_asprintf(additional_parameters, "");
    386386    if (strcmp(format, "proc") && strcmp(format, "sys")) {
    387387        if (writeable) {
     
    399399
    400400    if (!strcmp(mountpoint, "swap")) {
    401         mr_asprintf(&command, "swapon %s", device);
    402         mr_asprintf(&mountdir, "swap");
     401        mr_asprintf(command, "swapon %s", device);
     402        mr_asprintf(mountdir, "swap");
    403403    } else {
    404404        if (!strcmp(mountpoint, "/")) {
    405             mr_asprintf(&mountdir, "%s", MNT_RESTORING);
     405            mr_asprintf(mountdir, "%s", MNT_RESTORING);
    406406        } else {
    407             mr_asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint);
    408         }
    409         mr_asprintf(&command, "mkdir -p %s", mountdir);
     407            mr_asprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint);
     408        }
     409        mr_asprintf(command, "mkdir -p %s", mountdir);
    410410        run_program_and_log_output(command, FALSE);
    411411        mr_free(command);
    412412
    413         mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, additional_parameters, mountdir, MONDO_LOGFILE);
     413        mr_asprintf(command, "mount -t %s %s %s %s 2>> %s", format, device, additional_parameters, mountdir, MONDO_LOGFILE);
    414414        log_msg(2, "command='%s'", command);
    415415    }
     
    420420        log_msg(1, "Re-trying without the fancy extra parameters");
    421421        mr_free(command);
    422         mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, mountdir, MONDO_LOGFILE);
     422        mr_asprintf(command, "mount -t %s %s %s 2>> %s", format, device, mountdir, MONDO_LOGFILE);
    423423        res = run_program_and_log_output(command, TRUE);
    424424    }
     
    432432            log_msg(2, "Retrying w/o the '-t' switch");
    433433            mr_free(command);
    434             mr_asprintf(&command, "mount %s %s 2>> %s", device, mountdir, MONDO_LOGFILE);
     434            mr_asprintf(command, "mount %s %s 2>> %s", device, mountdir, MONDO_LOGFILE);
    435435            log_msg(2, "2nd command = '%s'", command);
    436436            res = run_program_and_log_output(command, TRUE);
     
    492492               "", mountlist->entries);
    493493
    494     mr_asprintf(&these_failed, "");
     494    mr_asprintf(these_failed, "");
    495495    for (lino = 0; lino < mountlist->entries; lino++) {
    496496        if (!strcmp(mountlist->el[lino].device, "/proc")) {
     
    498498                "Again with the /proc - why is this in your mountlist?");
    499499        } else if (is_this_device_mounted(mountlist->el[lino].device)) {
    500             mr_asprintf(&tmp, "%s is already mounted", mountlist->el[lino].device);
     500            mr_asprintf(tmp, "%s is already mounted", mountlist->el[lino].device);
    501501            log_to_screen(tmp);
    502502            mr_free(tmp);
     
    505505           && strcmp(mountlist->el[lino].mountpoint, "raid")
    506506           && strcmp(mountlist->el[lino].mountpoint, "image")) {
    507             mr_asprintf(&tmp, "Mounting %s", mountlist->el[lino].device);
     507            mr_asprintf(tmp, "Mounting %s", mountlist->el[lino].device);
    508508            update_progress_form(tmp);
    509509            mr_free(tmp);
     
    529529                ("format and restore *without* partitioning first. Sorry for the inconvenience.");
    530530        }
    531         mr_asprintf(&tmp, "Could not mount device(s) %s- shall I abort?", these_failed);
     531        mr_asprintf(tmp, "Could not mount device(s) %s- shall I abort?", these_failed);
    532532
    533533        if (!ask_me_yes_or_no(tmp)) {
     
    570570* @return 0 for success, nonzero for failure.
    571571*/
    572 int mount_media()
    573 {
    574 char *mount_cmd = NULL;
    575 int i, res;
     572int mount_media() {
     573
     574    char *mount_cmd = NULL;
     575    char *p = NULL;
     576    int i, res;
    576577#ifdef __FreeBSD__
    577 char mdd[32];
    578 char *mddev = mdd;
     578    char mdd[32];
     579    char *mddev = mdd;
    579580#endif
    580581
    581 assert(bkpinfo != NULL);
    582 
    583     if (bkpinfo->backup_media_type == tape
    584         || bkpinfo->backup_media_type == udev) {
     582    if (bkpinfo->backup_media_type == tape || bkpinfo->backup_media_type == udev) {
    585583        log_msg(8, "Tape/udev. Therefore, no need to mount a media.");
    586584        return 0;
     
    595593        log_msg(2, "Mounting for NFS thingy");
    596594        log_msg(2, "isodir = %s", bkpinfo->isodir);
    597         if ((!bkpinfo->isodir[0] || !strcmp(bkpinfo->isodir, "/"))
    598             && am_I_in_disaster_recovery_mode()) {
    599             strcpy(bkpinfo->isodir, "/tmp/isodir");
     595        if (!strcmp(bkpinfo->isodir, "/") && am_I_in_disaster_recovery_mode()) {
     596            mr_free(bkpinfo->isodir);
     597            mr_asprintf(p, "/tmp/isodir");
     598            bkpinfo->isodir = p;
    600599            log_msg(1, "isodir is being set to %s", bkpinfo->isodir);
    601600        }
    602601#ifdef __FreeBSD__
    603         mr_asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);
     602        mr_asprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);
    604603        mddev = make_vn(mount_cmd);
    605604        mr_free(mount_cmd);
    606605
    607         mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
     606        mr_asprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
    608607#else
    609         mr_asprintf(&mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     608        mr_asprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    610609#endif
    611610
    612611    } else if (bkpinfo->backup_media_type == iso) {
    613612#ifdef __FreeBSD__
    614         mr_asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number);
     613        mr_asprintf(mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number);
    615614        mddev = make_vn(mount_cmd);
    616615        mr_free(mount_cmd);
    617616
    618         mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
     617        mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
    619618#else
    620         mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     619        mr_asprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    621620#endif
    622621    } else if (bkpinfo->backup_media_type == usb) {
    623         mr_asprintf(&mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);
     622        mr_asprintf(mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);
    624623    } else if (strstr(bkpinfo->media_device, "/dev/")) {
    625624#ifdef __FreeBSD__
    626         mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
     625        mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
    627626#else
    628         mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
     627        mr_asprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
    629628#endif
    630629    } else {
     
    638637
    639638#ifdef __FreeBSD__
    640         mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
     639        mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
    641640#else
    642         mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
     641        mr_asprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
    643642#endif
    644643    }
     
    727726malloc_string(iso_mnt);
    728727malloc_string(iso_path);
    729 malloc_string(old_isodir);
    730728malloc_string(value);
    731729malloc_string(tmp);
     
    774772    mr_free(bkpinfo->prefix);
    775773    if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
    776         mr_asprintf(&tmp1, "%s", value);
     774        mr_asprintf(tmp1, "%s", value);
    777775    } else {
    778         mr_asprintf(&tmp1, "%s", STD_PREFIX);
     776        mr_asprintf(tmp1, "%s", STD_PREFIX);
    779777    }
    780778    bkpinfo->prefix = tmp1;
     
    784782    mr_free(bkpinfo->prefix);
    785783    if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
    786         mr_asprintf(&tmp1, "%s", value);
     784        mr_asprintf(tmp1, "%s", value);
    787785    } else {
    788         mr_asprintf(&tmp1, "%s", STD_PREFIX);
     786        mr_asprintf(tmp1, "%s", STD_PREFIX);
    789787    }
    790788    bkpinfo->prefix = tmp1;
     
    798796        }
    799797        mr_free(bkpinfo->prefix);
    800         mr_asprintf(&tmp1, "%s", envtmp1);
     798        mr_asprintf(tmp1, "%s", envtmp1);
    801799        bkpinfo->prefix = tmp1;
    802800    }
     
    863861read_cfg_var(cfg_file, "acl", value);
    864862if (strstr(value, "TRUE")) {
    865     mr_asprintf(&g_getfacl,"setfacl");
     863    mr_asprintf(g_getfacl,"setfacl");
    866864    log_msg(1, "We will restore ACLs");
    867865    if (! find_home_of_exe("setfacl")) {
     
    871869read_cfg_var(cfg_file, "xattr", value);
    872870if (strstr(value, "TRUE")) {
    873     mr_asprintf(&g_getfattr,"setfattr");
     871    mr_asprintf(g_getfattr,"setfattr");
    874872    log_msg(1, "We will restore XATTRs");
    875873    if (! find_home_of_exe("setfattr")) {
     
    968966    * isodir in disaster recovery mode
    969967    */
    970     strcpy(old_isodir, bkpinfo->isodir);
     968    mr_asprintf(old_isodir, "%s", bkpinfo->isodir);
    971969    read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt);
    972970    read_cfg_var(g_mondo_cfg_file, "isodir", iso_path);
    973     sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
     971    mr_free(bkpinfo->isodir);
     972    mr_asprintf(tmp1, "%s%s", iso_mnt, iso_path);
     973    bkpinfo->isodir = tmp1;
    974974    if (!bkpinfo->isodir[0]) {
    975         strcpy(bkpinfo->isodir, old_isodir);
     975        mr_free(bkpinfo->isodir);
     976        bkpinfo->isodir = old_isodir;
     977    } else {
     978        mr_free(old_isodir);
    976979    }
    977980    if (!bkpinfo->disaster_recovery) {
    978981        if (strcmp(old_isodir, bkpinfo->isodir)) {
    979             log_it
    980                 ("user nominated isodir differs from archive, keeping user's choice: %s %s\n",
    981                 old_isodir, bkpinfo->isodir);
    982             strcpy(bkpinfo->isodir, old_isodir);
     982            log_it("user nominated isodir %s differs from archive, keeping user's choice: %s\n", bkpinfo->isodir, old_isodir );
     983            mr_free(bkpinfo->isodir);
     984            bkpinfo->isodir = old_isodir;
     985        } else {
     986            mr_free(old_isodir);
    983987        }
    984988    }
    985989    read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
    986     log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir,
    987             g_isodir_device);
     990    log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device);
     991
    988992    if (bkpinfo->disaster_recovery) {
    989993        if (is_this_device_mounted(g_isodir_device)) {
    990994            log_msg(2, "NB: isodir is already mounted");
    991995            /* Find out where it's mounted */
    992             mr_asprintf(&command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);
     996            mr_asprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);
    993997            log_it("command = %s", command);
    994998            log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
     
    9971001        } else {
    9981002            sprintf(iso_mnt, "/tmp/isodir");
    999             mr_asprintf(&tmp1, "mkdir -p %s", iso_mnt);
     1003            mr_asprintf(tmp1, "mkdir -p %s", iso_mnt);
    10001004            run_program_and_log_output(tmp1, 5);
    10011005            mr_free(tmp1);
    10021006
    1003             mr_asprintf(&tmp1, "mount %s %s", g_isodir_device, iso_mnt);
     1007            mr_asprintf(tmp1, "mount %s %s", g_isodir_device, iso_mnt);
    10041008            if (run_program_and_log_output(tmp1, 3)) {
    10051009                log_msg(1,
     
    10071011                bkpinfo->backup_media_type = cdr;
    10081012                strcpy(bkpinfo->media_device, "/dev/cdrom");    /* superfluous */
    1009                 bkpinfo->isodir[0] = iso_mnt[0] = iso_path[0] = '\0';
     1013                iso_mnt[0] = iso_path[0] = '\0';
    10101014                if (mount_media()) {
    10111015                    mr_free(tmp1);
    1012                     fatal_error
    1013                         ("Unable to mount isodir. Failed to mount CD-ROM as well.");
     1016                    fatal_error("Unable to mount isodir. Failed to mount CD-ROM as well.");
    10141017                } else {
    1015                     log_msg(1,
    1016                             "You backed up to disk, then burned some CDs.");
     1018                    log_msg(1, "You backed up to disk, then burned some CDs.");
    10171019                }
    10181020            }
     
    10211023        /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */
    10221024        if (bkpinfo->backup_media_type == iso) {
    1023             sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
     1025            mr_free(bkpinfo->isodir);
     1026            mr_asprintf(tmp1, "%s%s", iso_mnt, iso_path);
     1027            bkpinfo->isodir = tmp1;
    10241028        }
    10251029    }
     
    10471051paranoid_free(iso_mnt);
    10481052paranoid_free(iso_path);
    1049 paranoid_free(old_isodir);
    10501053return (0);
    10511054
     
    11051108    unlink(FILELIST_FULL_STUB);
    11061109    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1107         mr_asprintf(&command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
     1110        mr_asprintf(command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
    11081111        log_msg(1, "tarcommand = %s", command);
    11091112        run_program_and_log_output(command, 1);
     
    11131116            /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    11141117            log_msg(2, "pre-2.2.4 compatible mode on");
    1115             mr_asprintf(&command, "tar -b %ld -zxf %s %s %s %s %s %s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
     1118            mr_asprintf(command, "tar -b %ld -zxf %s %s %s %s %s %s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
    11161119            log_msg(1, "tarcommand = %s", command);
    11171120            run_program_and_log_output(command, 1);
     
    11191122        }
    11201123    } else {
    1121         log_msg(2,
    1122             "Calling insist_on_this_cd_number; bkpinfo->isodir=%s",
    1123             bkpinfo->isodir);
     1124        log_msg(2, "Calling insist_on_this_cd_number; bkpinfo->isodir=%s", bkpinfo->isodir);
    11241125        insist_on_this_cd_number(1);
    11251126        log_msg(2, "Back from iotcn");
    11261127        run_program_and_log_output("mount", 1);
    1127         mr_asprintf(&command, "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
     1128        mr_asprintf(command, "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
    11281129
    11291130        log_msg(1, "tarcommand = %s", command);
     
    11341135            /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    11351136            log_msg(2, "pre-2.2.4 compatible mode on");
    1136             mr_asprintf(&command, "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
     1137            mr_asprintf(command, "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
    11371138
    11381139            log_msg(1, "tarcommand = %s", command);
     
    11491150        }
    11501151    }
    1151     mr_asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB, g_mondo_cfg_file);
     1152    mr_asprintf(command, "cp -f %s %s", MONDO_CFG_FILE_STUB, g_mondo_cfg_file);
    11521153    run_program_and_log_output(command, FALSE);
    11531154    mr_free(command);
    11541155
    1155     mr_asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB, g_biggielist_txt);
     1156    mr_asprintf(command, "cp -f %s/%s %s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB, g_biggielist_txt);
    11561157    log_msg(1, "command = %s", command);
    11571158    paranoid_system(command);
    11581159    mr_free(command);
    11591160
    1160     mr_asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir, FILELIST_FULL_STUB, g_filelist_full);
     1161    mr_asprintf(command, "ln -sf %s/%s %s", bkpinfo->tmpdir, FILELIST_FULL_STUB, g_filelist_full);
    11611162    log_msg(1, "command = %s", command);
    11621163    paranoid_system(command);
     
    11701171    &&
    11711172    ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) {
    1172         mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir);
     1173        mr_asprintf(command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir);
    11731174        paranoid_system(command);
    11741175        mr_free(command);
     
    11951196        log_to_screen("Pre-processing filelist");
    11961197        if (!does_file_exist(g_biggielist_txt)) {
    1197             mr_asprintf(&command, "echo -n > %s", g_biggielist_txt);
     1198            mr_asprintf(command, "echo -n > %s", g_biggielist_txt);
    11981199            paranoid_system(command);
    11991200            mr_free(command);
    12001201        }
    1201         mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s", g_biggielist_txt, g_filelist_imagedevs);
     1202        mr_asprintf(command, "grep -E '^/dev/.*' %s > %s", g_biggielist_txt, g_filelist_imagedevs);
    12021203        paranoid_system(command);
    12031204        mr_free(command);
     
    12761277    assert_string_is_neither_NULL_nor_zerolength(filename);
    12771278
    1278     mr_asprintf(&tmp, "%s/%s", path_root, filename);
    1279     mr_asprintf(&command, "cp -f %s %s.pristine", tmp, tmp);
     1279    mr_asprintf(tmp, "%s/%s", path_root, filename);
     1280    mr_asprintf(command, "cp -f %s %s.pristine", tmp, tmp);
    12801281    mr_free(tmp);
    12811282
     
    13341335     * the current /dev location
    13351336     */
    1336     mr_asprintf(&cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING);
     1337    mr_asprintf(cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING);
    13371338    run_program_and_log_output(cmd, 3);
    13381339    paranoid_free(cmd);
     
    13611362#ifdef __FreeBSD__
    13621363    else if (!strcmp(name, "BOOT0")) {
    1363         mr_asprintf(&tmp, "boot0cfg -B %s", device);
     1364        mr_asprintf(tmp, "boot0cfg -B %s", device);
    13641365        res = run_program_and_log_output(tmp, FALSE);
    13651366        paranoid_free(tmp);
    13661367    } else {
    1367         mr_asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);
     1368        mr_asprintf(tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);
    13681369        if (!system(tmp)) {
    13691370            mr_free(tmp);
    1370             mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
     1371            mr_asprintf(tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
    13711372            res = run_program_and_log_output(tmp, 3);
    13721373        } else {
     
    14521453    assert_string_is_neither_NULL_nor_zerolength(bd);
    14531454    strcpy(editor, find_my_editor());
    1454     mr_asprintf(&boot_device, "%s", bd);
     1455    mr_asprintf(boot_device, "%s", bd);
    14551456
    14561457    if (offer_to_run_stabgrub
     
    14691470                continue;
    14701471            }
    1471             mr_asprintf(&command, "stabgrub-me %s", p);
     1472            mr_asprintf(command, "stabgrub-me %s", p);
    14721473            mr_free(p);
    14731474
     
    14891490                newtSuspend();
    14901491            }
    1491             mr_asprintf(&tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
     1492            mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
    14921493            paranoid_system(tmp);
    14931494            mr_free(tmp);
    14941495
    1495             mr_asprintf(&tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
     1496            mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
    14961497            paranoid_system(tmp);
    14971498            mr_free(tmp);
    14981499
    1499             mr_asprintf(&tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
     1500            mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
    15001501            paranoid_system(tmp);
    15011502            mr_free(tmp);
    15021503
    1503             mr_asprintf(&tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
     1504            mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
    15041505            paranoid_system(tmp);
    15051506            mr_free(tmp);
     
    15131514        if (!run_program_and_log_output("which grub-MR", FALSE)) {
    15141515            log_msg(1, "Yay! grub-MR found...");
    1515             mr_asprintf(&command, "grub-MR %s /tmp/mountlist.txt", boot_device);
     1516            mr_asprintf(command, "grub-MR %s /tmp/mountlist.txt", boot_device);
    15161517            log_msg(1, "command = %s", command);
    15171518        } else {
    1518             mr_asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", boot_device);
     1519            mr_asprintf(command, "chroot " MNT_RESTORING " grub-install %s", boot_device);
    15191520            log_msg(1, "WARNING - grub-MR not found; using grub-install");
    15201521        }
     
    15911592                            0,
    15921593                            "Modifying fstab and elilo.conf...                             ");
    1593         mr_asprintf(&command, "stabelilo-me");
     1594        mr_asprintf(command, "stabelilo-me");
    15941595        res = run_program_and_log_output(command, 3);
    15951596        mr_free(command);
     
    16021603                    newtSuspend();
    16031604                }
    1604                 mr_asprintf(&tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
     1605                mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
    16051606                paranoid_system(tmp);
    16061607                mr_free(tmp);
    16071608
    1608                 mr_asprintf(&tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor);
     1609                mr_asprintf(tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor);
    16091610                paranoid_system(tmp);
    16101611                mr_free(tmp);
     
    16671668                            0,
    16681669                            "Modifying fstab and lilo.conf, and running LILO...                             ");
    1669         mr_asprintf(&command, "stablilo-me");
     1670        mr_asprintf(command, "stablilo-me");
    16701671        res = run_program_and_log_output(command, 3);
    16711672        mr_free(command);
     
    16781679                    newtSuspend();
    16791680                }
    1680                 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1681                mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    16811682                paranoid_system(tmp);
    16821683                mr_free(tmp);
    16831684
    1684                 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
     1685                mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
    16851686                paranoid_system(tmp);
    16861687                mr_free(tmp);
     
    17701771
    17711772    strcpy(editor, find_my_editor());
    1772     mr_asprintf(&boot_device, "%s", bd);
     1773    mr_asprintf(boot_device, "%s", bd);
    17731774
    17741775    if (offer_to_hack_scripts
     
    17831784                    newtSuspend();
    17841785                }
    1785                 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1786                mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    17861787                paranoid_system(tmp);
    17871788                mr_free(tmp);
     
    17981799                continue;
    17991800            }
    1800             mr_asprintf(&command, "stabraw-me %s", p);
     1801            mr_asprintf(command, "stabraw-me %s", p);
    18011802            mr_free(p);
    18021803
     
    18121813    } else {
    18131814        /* nuke mode */
    1814         mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", boot_device);
     1815        mr_asprintf(command, "raw-MR %s /tmp/mountlist.txt", boot_device);
    18151816        log_msg(2, "run_raw_mbr() --- command='%s'", command);
    18161817
     
    19391940    for (i = 0; i < 20; i++) {
    19401941        g_current_progress = i;
    1941         mr_asprintf(&tmp, "You have %d seconds left to abort.", 20 - i);
     1942        mr_asprintf(tmp, "You have %d seconds left to abort.", 20 - i);
    19421943        update_progress_form(tmp);
    19431944        mr_free(tmp);
     
    19911992    paranoid_system("sync");
    19921993
    1993     mr_asprintf(&tmp, "cp -f %s " MNT_RESTORING "/var/log", MONDO_LOGFILE);
     1994    mr_asprintf(tmp, "cp -f %s " MNT_RESTORING "/var/log", MONDO_LOGFILE);
    19941995    if (run_program_and_log_output(tmp, FALSE)) {
    19951996        log_msg(1,
     
    20102011            continue;
    20112012        }
    2012         mr_asprintf(&tmp, "Unmounting device %s  ", mountlist->el[lino].device);
     2013        mr_asprintf(tmp, "Unmounting device %s  ", mountlist->el[lino].device);
    20132014
    20142015        update_progress_form(tmp);
     
    20162017        if (is_this_device_mounted(mountlist->el[lino].device)) {
    20172018            if (!strcmp(mountlist->el[lino].mountpoint, "swap")) {
    2018                 mr_asprintf(&command, "swapoff %s", mountlist->el[lino].device);
     2019                mr_asprintf(command, "swapoff %s", mountlist->el[lino].device);
    20192020            } else {
    20202021                if (!strcmp(mountlist->el[lino].mountpoint, "/1")) {
    2021                     mr_asprintf(&command, "umount %s/", MNT_RESTORING);
     2022                    mr_asprintf(command, "umount %s/", MNT_RESTORING);
    20222023                    log_msg(3,
    20232024                            "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight...");
    20242025                } else {
    2025                     mr_asprintf(&command, "umount " MNT_RESTORING "%s", mountlist->el[lino].mountpoint);
     2026                    mr_asprintf(command, "umount " MNT_RESTORING "%s", mountlist->el[lino].mountpoint);
    20262027
    20272028                    /* To support latest Ubuntu where /var is a separate FS
     
    20902091    }
    20912092
    2092     mr_asprintf(&command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
     2093    mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
    20932094    log_msg(2, "command = '%s'", command);
    20942095    res = run_program_and_log_output(command, -1);
     
    21012102            /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    21022103            log_msg(2, "pre-2.2.4 compatible mode on");
    2103             mr_asprintf(&command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
     2104            mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
    21042105            log_msg(2, "command = '%s'", command);
    21052106            res = run_program_and_log_output(command, -1);
     
    21482149    log_msg(2, "gcffa --- starting");
    21492150    log_to_screen("I'm thinking...");
    2150     mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
     2151    mr_asprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
    21512152    device[0] = '\0';
    21522153    chdir(bkpinfo->tmpdir);
    2153     mr_asprintf(&cfg_file, "%s", MONDO_CFG_FILE_STUB);
     2154    mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB);
    21542155    unlink(cfg_file);           // cfg_file[] is missing the '/' at the start, FYI, by intent
    21552156    mr_free(cfg_file);
     
    21572158    unlink(FILELIST_FULL_STUB);
    21582159    unlink(BIGGIELIST_TXT_STUB);
    2159     mr_asprintf(&command, "mkdir -p %s", mountpt);
     2160    mr_asprintf(command, "mkdir -p %s", mountpt);
    21602161    run_program_and_log_output(command, FALSE);
    21612162    mr_free(command);
    21622163
    2163     mr_asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
    2164     mr_asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
     2164    mr_asprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
     2165    mr_asprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    21652166    log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file);
    21662167    mr_free(mountpt);
     
    21922193                log_msg(2, "media_device is blank; assuming %s");
    21932194            }
    2194             mr_asprintf(&tmp, "%s", bkpinfo->media_device);
     2195            mr_asprintf(tmp, "%s", bkpinfo->media_device);
    21952196            if (extract_cfg_file_and_mountlist_from_tape_dev
    21962197                (bkpinfo->media_device)) {
     
    22312232                log_msg(2,
    22322233                        "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz");
    2233                 mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);   // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
     2234                mr_asprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);    // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
    22342235                run_program_and_log_output(command, TRUE);
    22352236                mr_free(command);
     
    22382239                    /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    22392240                    log_msg(2, "pre-2.2.4 compatible mode on");
    2240                     mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
     2241                    mr_asprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);  // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
    22412242                    run_program_and_log_output(command, TRUE);
    22422243                    mr_free(command);
     
    22512252    if (does_file_exist(MONDO_CFG_FILE_STUB)) {
    22522253        log_msg(1, "gcffa --- great! We've got the config file");
    2253         mr_asprintf(&tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB);
    2254         mr_asprintf(&command, "cp -f %s %s", tmp, cfg_file);
     2254        mr_asprintf(tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB);
     2255        mr_asprintf(command, "cp -f %s %s", tmp, cfg_file);
    22552256        log_it("%s",command);
    22562257        if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) {
     
    22612262        mr_free(command);
    22622263
    2263         mr_asprintf(&command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"),
     2264        mr_asprintf(command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"),
    22642265            MOUNTLIST_FNAME_STUB, mountlist_file);
    22652266        log_it("%s",command);
     
    22712272
    22722273                mr_free(command);
    2273                 mr_asprintf(&command, "cp -f %s %s", mountlist_file, g_mountlist_fname);
     2274                mr_asprintf(command, "cp -f %s %s", mountlist_file, g_mountlist_fname);
    22742275                if (run_program_and_log_output(command, 1)) {
    22752276                    log_msg(1, "Failed to copy mountlist to /tmp");
     
    22772278                    log_msg(1, "Copied mountlist to /tmp as well OK");
    22782279                    mr_free(command);
    2279                     mr_asprintf(&command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
     2280                    mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
    22802281                    run_program_and_log_output(command, 1);
    22812282                }
     
    23012302            /* Is this code really useful ??? */
    23022303        if (extract_mountlist_stub) {
    2303             mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
     2304            mr_asprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    23042305            run_program_and_log_output(command, FALSE);
    23052306            mr_free(command);
     
    23072308    }
    23082309
    2309     mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
     2310    mr_asprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
    23102311    mr_free(cfg_file);
    23112312
     
    23142315
    23152316    if (extract_mountlist_stub) {
    2316         mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
     2317        mr_asprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
    23172318        run_program_and_log_output(command, FALSE);
    23182319        mr_free(command);
     
    23202321    mr_free(mountlist_file);
    23212322
    2322     mr_asprintf(&command, "cp -f etc/raidtab /etc/");
     2323    mr_asprintf(command, "cp -f etc/raidtab /etc/");
    23232324    run_program_and_log_output(command, FALSE);
    23242325    mr_free(command);
    23252326
    23262327    if (extract_i_want_my_lvm) {
    2327         mr_asprintf(&command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
     2328        mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
    23282329        run_program_and_log_output(command, FALSE);
    23292330        mr_free(command);
     
    23822383                }
    23832384                log_msg(1,"Sync'ing %s (i=%d)", raidlist->el[i].raid_device, i);
    2384                 mr_asprintf(&screen_message, "Sync'ing %s", raidlist->el[i].raid_device);
     2385                mr_asprintf(screen_message, "Sync'ing %s", raidlist->el[i].raid_device);
    23852386                open_evalcall_form(screen_message);
    23862387                mr_free(screen_message);
Note: See TracChangeset for help on using the changeset viewer.