Ignore:
Timestamp:
Aug 18, 2009, 3:05:43 PM (11 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/common/libmondo-devices.c

    r2322 r2323  
    111111    bool is_this_a_ramdisk = FALSE;
    112112
    113     mr_asprintf(&tmp, "%s", where_is_root_mounted());
    114     mr_asprintf(&comment, "root is currently mounted at %s\n", tmp);
     113    mr_asprintf(tmp, "%s", where_is_root_mounted());
     114    mr_asprintf(comment, "root is currently mounted at %s\n", tmp);
    115115    log_msg(0, comment);
    116116    mr_free(comment);
     
    210210    if (IS_THIS_A_STREAMING_BACKUP(g_backup_media_type)
    211211        && g_backup_media_type != udev) {
    212         mr_asprintf(&command, "mt -f %s offline", dev);
     212        mr_asprintf(command, "mt -f %s offline", dev);
    213213        res1 = run_program_and_log_output(command, 1);
    214214        mr_free(command);
     
    219219#ifdef __FreeBSD__
    220220    if (strstr(dev, "acd")) {
    221         mr_asprintf(&command, "cdcontrol -f %s eject", dev);
     221        mr_asprintf(command, "cdcontrol -f %s eject", dev);
    222222    } else {
    223         mr_asprintf(&command, "camcontrol eject `echo %s | sed 's|/dev/||'`",
     223        mr_asprintf(command, "camcontrol eject `echo %s | sed 's|/dev/||'`",
    224224                dev);
    225225    }
    226226#else
    227     mr_asprintf(&command, "eject %s", dev);
     227    mr_asprintf(command, "eject %s", dev);
    228228#endif
    229229
     
    250250#ifdef __FreeBSD__
    251251    if (strstr(dev, "acd")) {
    252         mr_asprintf(&command, "cdcontrol -f %s close", dev);
     252        mr_asprintf(command, "cdcontrol -f %s close", dev);
    253253    } else {
    254         mr_asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`", dev);
     254        mr_asprintf(command, "camcontrol load `echo %s | sed 's|/dev/||'`", dev);
    255255    }
    256256#else
    257     mr_asprintf(&command, "eject -t %s", dev);
     257    mr_asprintf(command, "eject -t %s", dev);
    258258#endif
    259259    i = run_program_and_log_output(command, FALSE);
     
    277277    assert_string_is_neither_NULL_nor_zerolength(device);
    278278
    279     mr_asprintf(&tmp, "ls %s > /dev/null 2> /dev/null", device);
     279    mr_asprintf(tmp, "ls %s > /dev/null 2> /dev/null", device);
    280280
    281281    if (system(tmp)) {
     
    336336    // We assume here that this is running from mondorestore. (It is.)
    337337    tmp = build_partition_name(drive, partno);
    338     mr_asprintf(&program, "ls %s %s >/dev/null 2>&1", drive, tmp);
     338    mr_asprintf(program, "ls %s %s >/dev/null 2>&1", drive, tmp);
    339339    mr_free(tmp);
    340340
     
    347347#endif
    348348
    349     mr_asprintf(&program, "parted2fdisk -l %s 2> /dev/null", drive);
     349    mr_asprintf(program, "parted2fdisk -l %s 2> /dev/null", drive);
    350350    fin = popen(program, "r");
    351351    if (!fin) {
     
    394394    assert_string_is_neither_NULL_nor_zerolength(str);
    395395
    396     mr_asprintf(&command, "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, str);
     396    mr_asprintf(command, "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, str);
    397397    i = system(command);
    398398    mr_free(command);
     
    418418    int i;
    419419
    420     mr_asprintf(&command, "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, n, str);
     420    mr_asprintf(command, "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, n, str);
    421421    i = system(command);
    422422    mr_free(command);
     
    517517    run_program_and_log_output("insmod ide-scsi", -1);
    518518    if (find_home_of_exe("cdrecord")) {
    519         mr_asprintf(&cdr_exe, "cdrecord");
     519        mr_asprintf(cdr_exe, "cdrecord");
    520520    } else {
    521         mr_asprintf(&cdr_exe, "dvdrecord");
     521        mr_asprintf(cdr_exe, "dvdrecord");
    522522    }
    523523    if (find_home_of_exe(cdr_exe)) {
    524         mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe);
    525         mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     524        mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe);
     525        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    526526        mr_free(command);
    527527    }
     
    532532    } else {
    533533        strcpy(cdrw_device, tmp);
    534         mr_asprintf(&comment, "Found CDRW device - %s", cdrw_device);
     534        mr_asprintf(comment, "Found CDRW device - %s", cdrw_device);
    535535        log_it(comment);
    536536        strcpy(g_cdrw_drive_is_here, cdrw_device);
     
    586586    phrase_two[0] = '\0';
    587587#ifndef __FreeBSD__
    588     mr_asprintf(&dvd_last_resort, "%s", "");;
     588    mr_asprintf(dvd_last_resort, "%s", "");;
    589589#endif
    590590
     
    606606    }
    607607
    608     mr_asprintf(&mountpoint, "%s/cd.mnt", bkpinfo->tmpdir);
     608    mr_asprintf(mountpoint, "%s/cd.mnt", bkpinfo->tmpdir);
    609609    make_hole_for_dir(mountpoint);
    610610
    611611    if (find_home_of_exe("cdrecord")) {
    612         mr_asprintf(&cdr_exe, "cdrecord");
     612        mr_asprintf(cdr_exe, "cdrecord");
    613613    } else {
    614         mr_asprintf(&cdr_exe, "dvdrecord");
     614        mr_asprintf(cdr_exe, "dvdrecord");
    615615    }
    616616    tmp[0] = '\0';
     
    628628    }
    629629
    630     mr_asprintf(&command, "%s -scanbus 2> /dev/null", cdr_exe);
     630    mr_asprintf(command, "%s -scanbus 2> /dev/null", cdr_exe);
    631631    fin = popen(command, "r");
    632632    log_msg(4, "command=%s", command);
     
    668668        log_msg(4, "Not running phase two. String is empty.");
    669669    } else {
    670         mr_asprintf(&command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);
     670        mr_asprintf(command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);
    671671        fin = popen(command, "r");
    672672        mr_free(command);
     
    684684                        if (strstr(tmp, "DVD")) {
    685685                            mr_free(dvd_last_resort);
    686                             mr_asprintf(&dvd_last_resort, "/dev/%s", tmp);
     686                            mr_asprintf(dvd_last_resort, "/dev/%s", tmp);
    687687                            log_msg(4,
    688688                                    "Ignoring '%s' because it's a DVD drive",
     
    815815                found_it = FALSE;
    816816            } else {
    817                 mr_asprintf(&command, "umount %s", output);
     817                mr_asprintf(command, "umount %s", output);
    818818                paranoid_system(command);
    819819                mr_free(command);
     
    838838    }
    839839
    840     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);
     840    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);
    841841    log_msg(1, "command=%s", command);
    842     mr_asprintf(&tmp1, "%s", call_program_and_get_last_line_of_output(command));
     842    mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output(command));
    843843    mr_free(command);
    844844
     
    876876    }
    877877
    878     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output
     878    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output
    879879            ("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1")
    880880        );
     
    882882    if (!tmp[0])
    883883        mr_free(tmp);
    884         mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output
     884        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output
    885885                ("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1")
    886886            );
     
    10261026    assert_string_is_neither_NULL_nor_zerolength(format);
    10271027
    1028     mr_asprintf(&format_sz, "%s ", format);
     1028    mr_asprintf(format_sz, "%s ", format);
    10291029
    10301030#ifdef __FreeBSD__
    1031     mr_asprintf(&command, "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");
     1031    mr_asprintf(command, "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");
    10321032#else
    1033     mr_asprintf(&command, "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
     1033    mr_asprintf(command, "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
    10341034#endif
    10351035
     
    10941094        log_msg(1, "%s needs to have a '/' prefixed - I'll do it",
    10951095                device_raw);
    1096         mr_asprintf(&tmp, "/%s", device_raw);
     1096        mr_asprintf(tmp, "/%s", device_raw);
    10971097    } else {
    1098         mr_asprintf(&tmp, "%s", device_raw);
     1098        mr_asprintf(tmp, "%s", device_raw);
    10991099    }
    11001100    log_msg(1, "Is %s mounted?", tmp);
     
    11051105        return(FALSE);
    11061106    }
    1107     mr_asprintf(&device_with_tab, "%s\t", tmp);
    1108     mr_asprintf(&device_with_space, "%s ", tmp);
     1107    mr_asprintf(device_with_tab, "%s\t", tmp);
     1108    mr_asprintf(device_with_space, "%s ", tmp);
    11091109    mr_free(tmp);
    11101110
     
    11261126    mr_free(device_with_space);
    11271127    paranoid_pclose(fin);
    1128     mr_asprintf(&tmp, "%s | grep -E \"^%s\" > /dev/null 2> /dev/null", SWAPLIST_COMMAND, device_with_space);
     1128    mr_asprintf(tmp, "%s | grep -E \"^%s\" > /dev/null 2> /dev/null", SWAPLIST_COMMAND, device_with_space);
    11291129    log_msg(4, "tmp (command) = '%s'", tmp);
    11301130    if (!system(tmp)) {
     
    11931193        (call_program_and_get_last_line_of_output
    11941194         ("/sbin/sysctl -n kern.osreldate")) < 500000) {
    1195         mr_asprintf(&command, "vnconfig -d %s", dname);
     1195        mr_asprintf(command, "vnconfig -d %s", dname);
    11961196    } else {
    1197         mr_asprintf(&command, "mdconfig -d -u %s", dname);
     1197        mr_asprintf(command, "mdconfig -d -u %s", dname);
    11981198    }
    11991199    res = system(command);
     
    12271227
    12281228#ifdef __FreeBSD__
    1229     mr_asprintf(&command, "mount_vfat %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
     1229    mr_asprintf(command, "mount_vfat %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
    12301230
    12311231#else
    1232     mr_asprintf(&command, "mount %s -t vfat %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
     1232    mr_asprintf(command, "mount %s -t vfat %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
    12331233#endif
    12341234
     
    12671267    }
    12681268#ifndef __FreeBSD__
    1269     mr_asprintf(&options, "ro");
     1269    mr_asprintf(options, "ro");
    12701270#endif
    12711271
     
    12731273
    12741274#ifdef __FreeBSD__
    1275         mr_asprintf(&dev, "%s", make_vn(device));
     1275        mr_asprintf(dev, "%s", make_vn(device));
    12761276        if (!dev) {
    1277             mr_asprintf(&command, "Unable to mount ISO (make_vn(%s) failed)", device);
     1277            mr_asprintf(command, "Unable to mount ISO (make_vn(%s) failed)", device);
    12781278            fatal_error(command);
    12791279        }
     
    12901290
    12911291#ifdef __FreeBSD__
    1292     mr_asprintf(&command, "mount_cd9660 -r %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
     1292    mr_asprintf(command, "mount_cd9660 -r %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
    12931293
    12941294#else
    1295     mr_asprintf(&command, "mount %s -o %s -t iso9660 %s 2>> %s", device, options, mountpoint, MONDO_LOGFILE);
     1295    mr_asprintf(command, "mount %s -o %s -t iso9660 %s 2>> %s", device, options, mountpoint, MONDO_LOGFILE);
    12961296    paranoid_free(options);
    12971297#endif
     
    13341334    /*@ buffers ********************************************************* */
    13351335    char *tmp = NULL;
     1336    char *p = NULL;
    13361337    char *mds = NULL;
    13371338    char *request = NULL;
     
    13471348        return;
    13481349    }
    1349     mr_asprintf(&tmp, "mkdir -p " MNT_CDROM);
     1350    mr_asprintf(tmp, "mkdir -p " MNT_CDROM);
    13501351    run_program_and_log_output(tmp, 5);
    13511352    mr_free(tmp);
     
    13601361            run_program_and_log_output("umount " MNT_CDROM, 5);
    13611362        }
    1362         mr_asprintf(&tmp, "mkdir -p %s/isodir &> /dev/null", bkpinfo->tmpdir);
     1363        mr_asprintf(tmp, "mkdir -p %s/isodir &> /dev/null", bkpinfo->tmpdir);
    13631364        (void)system(tmp);
    13641365        mr_free(tmp);
    13651366
    1366         mr_asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want);
     1367        mr_asprintf(tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want);
    13671368        if (!does_file_exist(tmp)) {
    13681369            mr_free(tmp);
    1369             mr_asprintf(&tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want);
     1370            mr_asprintf(tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want);
    13701371            if (does_file_exist(tmp)) {
    13711372                log_msg(1, "FIXME - hacking bkpinfo->isodir from '%s' to %s/isodir", bkpinfo->isodir, bkpinfo->tmpdir);
    1372                 sprintf(bkpinfo->isodir, "%s/isodir", bkpinfo->tmpdir);
     1373                mr_free(bkpinfo->isodir);
     1374                mr_asprintf(p, "%s/isodir", bkpinfo->tmpdir);
     1375                bkpinfo->isodir = p;
    13731376            }
    13741377        }
     
    13841387                cd_number_i_want);
    13851388        mds = media_descriptor_string(bkpinfo->backup_media_type);
    1386         mr_asprintf(&tmp, "Insisting on %s #%d", mds, cd_number_i_want);
    1387         mr_asprintf(&request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);
     1389        mr_asprintf(tmp, "Insisting on %s #%d", mds, cd_number_i_want);
     1390        mr_asprintf(request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);
    13881391        mr_free(mds);
    13891392        log_msg(3, tmp);
     
    14991502            }
    15001503            mds = media_descriptor_string(bkpinfo->backup_media_type);
    1501             mr_asprintf(&comment, "What speed is your %s (re)writer?", mds);
     1504            mr_asprintf(comment, "What speed is your %s (re)writer?", mds);
    15021505            if (bkpinfo->backup_media_type == dvd) {
    15031506                find_dvd_device(bkpinfo->media_device, FALSE);
    1504                 strcpy(tmp1, "1");
    1505                 mr_asprintf(&sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB
     1507                mr_asprintf(tmp, "1");
     1508                mr_asprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    15061509                log_msg(1, "Setting to DVD defaults");
    15071510            } else {
    15081511                strcpy(bkpinfo->media_device, VANILLA_SCSI_CDROM);
    1509                 strcpy(tmp1, "4");
    1510                 mr_asprintf(&sz_size, "%d", 650);
     1512                mr_asprintf(tmp, "4");
     1513                mr_asprintf(sz_size, "%d", 650);
    15111514                log_msg(1, "Setting to CD defaults");
    15121515            }
     
    15271530            bkpinfo->cdrw_speed = atoi(tmp1);   // if DVD then this shouldn't ever be used anyway :)
    15281531
    1529             mr_asprintf(&comment, "How much data (in Megabytes) will each %s store?", mds);
     1532            mr_asprintf(comment, "How much data (in Megabytes) will each %s store?", mds);
    15301533            mr_free(mds);
    15311534            p = popup_and_get_string("Size", comment, sz_size);
     
    15671570                log_msg(1, "bkpinfo->media_device = %s",
    15681571                        bkpinfo->media_device);
    1569                 mr_asprintf(&comment, "Please specify your %s drive's /dev entry", mds);
     1572                mr_asprintf(comment, "Please specify your %s drive's /dev entry", mds);
    15701573                p = popup_and_get_string("Device?", comment, bkpinfo->media_device);
    15711574                mr_free(comment);
     
    15851588            if (bkpinfo->media_device[0]) {
    15861589                if (bkpinfo->backup_media_type == usb) {
    1587                     mr_asprintf(&tmp, "I think your %s media corresponds to %s. Is this correct?", mds, bkpinfo->media_device);
     1590                    mr_asprintf(tmp, "I think your %s media corresponds to %s. Is this correct?", mds, bkpinfo->media_device);
    15881591                } else {
    1589                     mr_asprintf(&tmp, "I think I've found your %s burner at SCSI node %s. Is this correct? (Say no if you have an IDE burner and you are running a 2.6 kernel. You will then be prompted for further details.)", mds, bkpinfo->media_device);
     1592                    mr_asprintf(tmp, "I think I've found your %s burner at SCSI node %s. Is this correct? (Say no if you have an IDE burner and you are running a 2.6 kernel. You will then be prompted for further details.)", mds, bkpinfo->media_device);
    15901593                }
    15911594                if (!ask_me_yes_or_no(tmp)) {
     
    16481651        }
    16491652        if (bkpinfo->media_device[0]) {
    1650             mr_asprintf(&tmp, "I think I've found your tape streamer at %s; am I right on the money?", bkpinfo->media_device);
     1653            mr_asprintf(tmp, "I think I've found your tape streamer at %s; am I right on the money?", bkpinfo->media_device);
    16511654            if (!ask_me_yes_or_no(tmp)) {
    16521655                bkpinfo->media_device[0] = '\0';
     
    16631666            mr_free(p);
    16641667        }
    1665         mr_asprintf(&tmp, "ls -l %s", bkpinfo->media_device);
     1668        mr_asprintf(tmp, "ls -l %s", bkpinfo->media_device);
    16661669        if (run_program_and_log_output(tmp, FALSE)) {
    16671670            log_to_screen("User has not specified a valid /dev entry");
     
    17261729            if (bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] == '/')
    17271730                bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] = '\0';
    1728             mr_asprintf(&command, "mount | grep \"%s \" | cut -d' ' -f3",
    1729                     bkpinfo->nfs_mount);
    1730             strcpy(bkpinfo->isodir,
    1731                    call_program_and_get_last_line_of_output(command));
     1731            mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", bkpinfo->nfs_mount);
     1732            mr_free(bkpinfo->isodir);
     1733            mr_asprintf(p, "%s", call_program_and_get_last_line_of_output(command));
     1734            bkpinfo->isodir = p;
    17321735            mr_free(command);
    17331736
    17341737            if (!bkpinfo->restore_data) {
    1735                 mr_asprintf(&comment, "How much data (in Megabytes) will each media store?");
     1738                mr_asprintf(comment, "How much data (in Megabytes) will each media store?");
    17361739                // BERLIOS: 4480 shouldn't be hardcoded here
    17371740                sz_size = popup_and_get_string("Size", comment, "4480");
     
    17421745                }
    17431746            } else {
    1744                 mr_asprintf(&sz_size, "0");
     1747                mr_asprintf(sz_size, "0");
    17451748            }
    17461749            for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
     
    17541757        }
    17551758        if (bkpinfo->disaster_recovery) {
    1756             mr_asprintf(&command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);
     1759            mr_asprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);
    17571760            (void)system(command);
    17581761            mr_free(command);
     
    17671770        }
    17681771        /* Initiate bkpinfo isodir path from running environment if mount already done */
     1772        mr_free(bkpinfo->isodir);
    17691773        if (is_this_device_mounted(bkpinfo->nfs_mount)) {
    1770             strcpy(bkpinfo->isodir,
    1771                    call_program_and_get_last_line_of_output
    1772                    ("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
     1774            mr_asprintf(p, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
     1775            bkpinfo->isodir = p;
     1776
    17731777        } else {
    1774             sprintf(bkpinfo->isodir, "%s/nfsdir", bkpinfo->tmpdir);
    1775             mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
     1778            mr_asprintf(p, "%s/nfsdir", bkpinfo->tmpdir);
     1779            bkpinfo->isodir = p;
     1780            mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir);
    17761781            run_program_and_log_output(command, 5);
    17771782            mr_free(command);
    17781783
    1779             mr_asprintf(&tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount, bkpinfo->isodir);
     1784            mr_asprintf(tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount, bkpinfo->isodir);
    17801785            run_program_and_log_output(tmp, 3);
    17811786            mr_free(tmp);
     
    18201825                finish(1);
    18211826            }
    1822             strcpy(bkpinfo->isodir,p);
    1823             mr_free(p);
     1827            bkpinfo->isodir = p;
    18241828
    18251829            if (archiving_to_media) {
     
    19181922        bkpinfo->boot_loader = i;
    19191923        mr_free(bkpinfo->include_paths);
    1920         mr_asprintf(&p, "/");
     1924        mr_asprintf(p, "/");
    19211925        bkpinfo->include_paths = p;
    19221926
     
    19291933        bkpinfo->include_paths = p;
    19301934
    1931         mr_asprintf(&tmp, "%s", list_of_NFS_mounts_only());
     1935        mr_asprintf(tmp, "%s", list_of_NFS_mounts_only());
    19321936        if (strlen(tmp) > 2) {
    19331937            mr_strcat(bkpinfo->exclude_paths, " %s",tmp);
     
    19351939        mr_free(tmp);
    19361940// NTFS
    1937         strcpy(tmp1, call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'"));
    1938         if (strlen(tmp1) > 2) {
     1941        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'"));
     1942        if (strlen(tmp) > 2) {
    19391943            p = popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp);
    19401944
     
    20082012#else
    20092013    if (bkpinfo->backup_media_type == nfs) {
    2010         log_msg(3, "I think the NFS mount is mounted at %s",
    2011                 bkpinfo->isodir);
     2014        log_msg(3, "I think the NFS mount is mounted at %s", bkpinfo->isodir);
    20122015    }
    20132016    log_it("isodir = %s", bkpinfo->isodir);
     
    20612064    static char result_sz[1024];
    20622065
    2063     mr_asprintf(&exclude_these_directories,"%s",list_of_NFS_mounts_only());
    2064     mr_asprintf(&exclude_these_devices,"%s", call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"));
     2066    mr_asprintf(exclude_these_directories,"%s",list_of_NFS_mounts_only());
     2067    mr_asprintf(exclude_these_devices,"%s", call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"));
    20652068    snprintf(result_sz, 1023, "%s %s", exclude_these_directories, exclude_these_devices);
    20662069    mr_free(exclude_these_devices);
     
    20832086    static char result_sz[512];
    20842087
    2085     mr_asprintf(&exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"));
     2088    mr_asprintf(exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"));
    20862089    snprintf(result_sz, 511, "%s", exclude_these_directories);
    20872090    mr_free(exclude_these_directories);
     
    21122115    make_hole_for_file(store_name_here);
    21132116    mkfifo(store_name_here, S_IRWXU | S_IRWXG);
    2114     mr_asprintf(&tmp, "chmod 770 %s", store_name_here);
     2117    mr_asprintf(tmp, "chmod 770 %s", store_name_here);
    21152118    paranoid_system(tmp);
    21162119    mr_free(tmp);
     
    21352138
    21362139#ifdef __FreeBSD__
    2137     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
     2140    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
    21382141#else
    2139     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660| sed 's/                  /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
     2142    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660| sed 's/                  /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
    21402143#endif
    21412144
    21422145    if (tmp[0] != '/') {
    2143         mr_asprintf(&sz, "%s", tmp);
     2146        mr_asprintf(sz, "%s", tmp);
    21442147        mr_free(tmp);
    2145         mr_asprintf(&tmp, "/%s", sz);
     2148        mr_asprintf(tmp, "/%s", sz);
    21462149        mr_free(sz);
    21472150    }
     
    21492152        fatal_error("I couldn't figure out the scratchdir!");
    21502153    }
    2151     mr_asprintf(&sz, "%s/mondo.scratch.%d", tmp, (int) (random() % 32768));
     2154    mr_asprintf(sz, "%s/mondo.scratch.%d", tmp, (int) (random() % 32768));
    21522155    mr_free(bkpinfo->scratchdir);
    21532156    bkpinfo->scratchdir = sz;
    21542157    log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);
    21552158
    2156     mr_asprintf(&command, "rm -Rf %s/mondo.scratch.*", tmp);
     2159    mr_asprintf(command, "rm -Rf %s/mondo.scratch.*", tmp);
    21572160    mr_free(tmp);
    21582161
     
    21922195        return (FALSE);
    21932196    }
    2194     mr_asprintf(&command, "dd bs=%ld count=1 if=%s of=/dev/null &> /dev/null", 512L, dev);
     2197    mr_asprintf(command, "dd bs=%ld count=1 if=%s of=/dev/null &> /dev/null", 512L, dev);
    21952198    if (!run_program_and_log_output(command, FALSE)
    21962199        && !run_program_and_log_output(command, FALSE)) {
     
    22272230//  log_it("Asking what_number_cd_is_this");
    22282231    if (g_ISO_restore_mode) {
    2229         mr_asprintf(&tmp, "mount | grep iso9660 | awk '{print $3;}'");
    2230 
    2231         mr_asprintf(&mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER");
     2232        mr_asprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'");
     2233
     2234        mr_asprintf(mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER");
    22322235        cd_number = atoi(last_line_of_file(mountdev));
    22332236        paranoid_free(mountdev);
     
    22372240    }
    22382241
    2239     mr_asprintf(&mountdev, "%s", bkpinfo->media_device);
     2242    mr_asprintf(mountdev, "%s", bkpinfo->media_device);
    22402243    if (!mountdev[0]) {
    22412244        log_it
     
    23702373    assert(which_device != NULL);
    23712374
    2372     mr_asprintf(&list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", where_is_root_mounted());
     2375    mr_asprintf(list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", where_is_root_mounted());
    23732376    log_it("list_drives_cmd = %s", list_drives_cmd);
    23742377
     
    24122415    } else {
    24132416        // We need to look on each partition then
    2414         mr_asprintf(&list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/");
     2417        mr_asprintf(list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/");
    24152418        log_it("list_drives_cmd = %s", list_drives_cmd);
    24162419
     
    25132516        while (S_ISLNK(statbuf.st_mode)) {
    25142517            log_msg(1, "curr_fname = %s", curr_fname);
    2515             mr_asprintf(&command, "file %s", curr_fname);
    2516             mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     2518            mr_asprintf(command, "file %s", curr_fname);
     2519            mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    25172520            mr_free(command);
    25182521            for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' ';
    25192522                 p--);
    25202523            p++;
    2521             mr_asprintf(&scratch, "%s", p);
     2524            mr_asprintf(scratch, "%s", p);
    25222525            for (p = scratch; *p != '\0' && *p != '\''; p++);
    25232526            *p = '\0';
     
    25632566#endif
    25642567    log_msg(0, "Looking for partition table format type");
    2565     mr_asprintf(&fdisk, "/sbin/parted2fdisk");
     2568    mr_asprintf(fdisk, "/sbin/parted2fdisk");
    25662569    log_msg(1, "Using %s", fdisk);
    2567     mr_asprintf(&command, "%s -l %s | grep 'EFI GPT'", fdisk, drive);
     2570    mr_asprintf(command, "%s -l %s | grep 'EFI GPT'", fdisk, drive);
    25682571    mr_free(fdisk);
    25692572
    2570     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     2573    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    25712574    mr_free(command);
    25722575
Note: See TracChangeset for help on using the changeset viewer.