Changeset 2316 in MondoRescue


Ignore:
Timestamp:
Aug 18, 2009, 2:34:29 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3327@localhost: bruno | 2009-08-04 00:17:46 +0200
popup_and_get_string and build_partition_name now return an allocated string

Location:
branches/2.2.10
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2303 r2316  
    12811281        && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
    12821282        if (g_kernel_version >= 2.6) {
    1283             if (popup_and_get_string
    1284                 ("Device", "Please specify the device",
    1285                  bkpinfo->media_device, MAX_STR_LEN / 4)) {
     1283            tmp2 = popup_and_get_string("Device", "Please specify the device", bkpinfo->media_device);
     1284            if (tmp2 == NULL) {
    12861285                retval++;
    12871286                log_to_screen("User opted to cancel.");
    12881287            }
     1288            mr_free(tmp2);
    12891289        } else if (find_cdrw_device(bkpinfo->media_device)) {
    12901290            retval++;
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2306 r2316  
    323323    char *incoming;
    324324    char *searchstr = NULL;
    325     char *tmp;
     325    char *tmp = NULL;
    326326
    327327    /*@ ints ******************************************************* */
     
    337337
    338338    malloc_string(incoming);
    339     malloc_string(searchstr);
    340     malloc_string(tmp);
    341339
    342340#ifdef __FreeBSD__
    343341    // We assume here that this is running from mondorestore. (It is.)
    344     mr_asprintf(&program, "ls %s %s >/dev/null 2>&1", drive, build_partition_name(tmp, drive, partno));
     342    tmp = build_partition_name(drive, partno);
     343    mr_asprintf(&program, "ls %s %s >/dev/null 2>&1", drive, tmp);
     344    mr_free(tmp);
     345
    345346    res = system(program);
    346347    mr_free(program);
    347348    return (res);
    348349#else
    349     tmp[0] = '\0';
     350    /* To avoid compiler warnings */
     351    tmp = NULL;
    350352#endif
    351353
     
    360362    mr_free(program);
    361363
    362     (void) build_partition_name(searchstr, drive, partno);
    363     strcat(searchstr, " ");
     364    searchstr = build_partition_name(drive, partno);
     365    mr_strcat(searchstr, " ");
    364366    for (res = 0; !res && fgets(incoming, MAX_STR_LEN - 1, fin);) {
    365367        if (strstr(incoming, searchstr)) {
     
    367369        }
    368370    }
     371    mr_free(searchstr);
     372
    369373    if (pclose(fin)) {
    370374        log_OS_error("Cannot pclose fin");
    371375    }
    372376    paranoid_free(incoming);
    373     paranoid_free(searchstr);
    374     paranoid_free(tmp);
    375377    return (res);
    376378}
     
    448450    int res;
    449451    char *dev;
     452    char *p = NULL;
    450453
    451454    /*@ end vars **************************************************** */
     
    472475
    473476    if (!dev[0] || (res = mount_CDROM_here(dev, mountpoint))) {
    474         if (!popup_and_get_string
    475             ("CD-ROM device", "Please enter your CD-ROM's /dev device",
    476              dev, MAX_STR_LEN / 4)) {
     477        p = popup_and_get_string ("CD-ROM device", "Please enter your CD-ROM's /dev device",dev);
     478        if (p == NULL) {
    477479            res = 1;
    478480        } else {
    479             res = mount_CDROM_here(dev, mountpoint);
    480         }
     481            res = mount_CDROM_here(p, mountpoint);
     482        }
     483        mr_free(p);
    481484    }
    482485    if (res) {
     
    10251028    FILE *pin;
    10261029    int retval;
    1027     malloc_string(good_formats);
    10281030
    10291031    assert_string_is_neither_NULL_nor_zerolength(format);
     
    10441046        retval = 0;
    10451047    } else {
    1046         strcpy(good_formats, " ");
    1047         (void) fgets(good_formats + 1, MAX_STR_LEN - 1, pin);
     1048        mr_getline(&good_formats, pin);
    10481049        if (pclose(pin)) {
    10491050            log_OS_error("Cannot pclose good formats");
    10501051        }
    1051         strip_spaces(good_formats);
    1052         strcat(good_formats, " swap lvm raid ntfs-3g ntfs 7 "); // " ntfs 7 " -- um, cheating much? :)
     1052        mr_strip_spaces(good_formats);
     1053        mr_strcat(good_formats, " swap lvm raid ntfs-3g ntfs 7 ");  // " ntfs 7 " -- um, cheating much? :)
    10531054        if (strstr(good_formats, format_sz)) {
    10541055            retval = 1;
     
    10561057            retval = 0;
    10571058        }
     1059        mr_free(good_formats);
    10581060    }
    10591061    mr_free(format_sz);
    10601062
    1061     paranoid_free(good_formats);
    10621063    return (retval);
    10631064}
     
    14451446{
    14461447    char *tmp = NULL;
    1447     char *tmp1 = NULL;
     1448    char *p = NULL;
    14481449    char *mds = NULL;
    14491450    char *sz_size = NULL;
     
    14551456
    14561457    malloc_string(prompt);
    1457     malloc_string(sz_size);
    14581458    malloc_string(tmp1);
    14591459    assert(bkpinfo != NULL);
     
    15141514                find_dvd_device(bkpinfo->media_device, FALSE);
    15151515                strcpy(tmp1, "1");
    1516                 sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
     1516                mr_asprintf(&sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    15171517                log_msg(1, "Setting to DVD defaults");
    15181518            } else {
    15191519                strcpy(bkpinfo->media_device, VANILLA_SCSI_CDROM);
    15201520                strcpy(tmp1, "4");
    1521                 sprintf(sz_size, "%d", 650);
     1521                mr_asprintf(&sz_size, "%d", 650);
    15221522                log_msg(1, "Setting to CD defaults");
    15231523            }
    15241524            if ((bkpinfo->backup_media_type != dvd) && (bkpinfo->backup_media_type != usb)) {
    1525                 if (!popup_and_get_string("Speed", comment, tmp1, 4)) {
     1525                p = popup_and_get_string("Speed", comment, tmp);
     1526                mr_free(tmp);
     1527
     1528                if (p == NULL) {
    15261529                    log_to_screen("User has chosen not to backup the PC");
    15271530                    mr_free(comment);
    15281531                    finish(1);
    15291532                }
     1533                /* tmp now has the new value given by the user */
     1534                tmp = p;
    15301535            }
    15311536            mr_free(comment);
     
    15351540            mr_asprintf(&comment, "How much data (in Megabytes) will each %s store?", mds);
    15361541            mr_free(mds);
    1537             if (!popup_and_get_string("Size", comment, sz_size, 5)) {
    1538                 mr_free(comment);
     1542            p = popup_and_get_string("Size", comment, sz_size);
     1543            mr_free(sz_size);
     1544            mr_free(comment);
     1545
     1546            if (p == NULL) {
    15391547                log_to_screen("User has chosen not to backup the PC");
    15401548                finish(1);
    15411549            }
    1542             mr_free(comment);
     1550            sz_size = p;
    15431551
    15441552            for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
     
    15711579                        bkpinfo->media_device);
    15721580                mr_asprintf(&comment, "Please specify your %s drive's /dev entry", mds);
    1573                 if (!popup_and_get_string
    1574                     ("Device?", comment, bkpinfo->media_device,
    1575                      MAX_STR_LEN / 4)) {
    1576                     mr_free(comment);
     1581                p = popup_and_get_string("Device?", comment, bkpinfo->media_device);
     1582                mr_free(comment);
     1583
     1584                if (p == NULL) {
    15771585                    log_to_screen("User has chosen not to backup the PC");
    15781586                    finish(1);
    15791587                }
    1580                 mr_free(comment);
     1588                strcpy(bkpinfo->media_device, p);
     1589                mr_free(p);
    15811590            }
    15821591            log_msg(2, "%s device found at %s", mds, bkpinfo->media_device);
     
    15981607            if (!bkpinfo->media_device[0]) {
    15991608                if (bkpinfo->backup_media_type == usb) {
    1600                     i = popup_and_get_string("/dev entry?",
    1601                                          "What is the /dev entry of your USB Disk/Key, please?",
    1602                                          bkpinfo->media_device,
    1603                                          MAX_STR_LEN / 4);
     1609                    p = popup_and_get_string("/dev entry?", "What is the /dev entry of your USB Disk/Key, please?", bkpinfo->media_device);
    16041610                } else {
    16051611                    if (g_kernel_version < 2.6) {
    1606                         i = popup_and_get_string("Device node?",
    1607                                              "What is the SCSI node of your CD (re)writer, please?",
    1608                                              bkpinfo->media_device,
    1609                                              MAX_STR_LEN / 4);
     1612                        p = popup_and_get_string("Device node?", "What is the SCSI node of your CD (re)writer, please?", bkpinfo->media_device);
    16101613                    } else {
    1611                         i = popup_and_get_string("/dev entry?",
    1612                                              "What is the /dev entry of your CD (re)writer, please?",
    1613                                              bkpinfo->media_device,
    1614                                              MAX_STR_LEN / 4);
     1614                        p = popup_and_get_string("/dev entry?", "What is the /dev entry of your CD (re)writer, please?", bkpinfo->media_device);
    16151615                    }
    16161616                }
    1617                 if (!i) {
     1617                if (p == NULL) {
    16181618                    log_to_screen("User has chosen not to backup the PC");
    16191619                    finish(1);
    16201620                }
     1621                strcpy(bkpinfo->media_device, p);
     1622                mr_free(p);
    16211623            }
    16221624        }
     
    16641666        }
    16651667        if (!bkpinfo->media_device[0]) {
    1666             if (!popup_and_get_string
    1667                 ("Device name?",
    1668                  "What is the /dev entry of your tape streamer?",
    1669                  bkpinfo->media_device, MAX_STR_LEN / 4)) {
     1668            p = popup_and_get_string("Device name?", "What is the /dev entry of your tape streamer?", bkpinfo->media_device);
     1669            if (p == NULL) {
    16701670                log_to_screen("User has chosen not to backup the PC");
    16711671                finish(1);
    16721672            }
     1673            strcpy(bkpinfo->media_device, p);
     1674            mr_free(p);
    16731675        }
    16741676        mr_asprintf(&tmp, "ls -l %s", bkpinfo->media_device);
     
    17161718#endif
    17171719        {
    1718             if (!popup_and_get_string
    1719                 ("NFS dir.",
    1720                  "Please enter path and directory where archives are stored remotely. (Mondo has taken a guess at the correct value. If it is incorrect, delete it and type the correct one.)",
    1721                  bkpinfo->nfs_mount, MAX_STR_LEN / 4)) {
     1720            p = popup_and_get_string("NFS dir.", "Please enter path and directory where archives are stored remotely. (Mondo has taken a guess at the correct value. If it is incorrect, delete it and type the correct one.)", bkpinfo->nfs_mount);
     1721            if (p == NULL) {
    17221722                log_to_screen("User has chosen not to backup the PC");
    17231723                finish(1);
    17241724            }
     1725            strcpy(bkpinfo->nfs_mount, p);
     1726            mr_free(p);
    17251727            if (!bkpinfo->restore_data) {
    17261728                if ((bkpinfo->compression_level =
     
    17431745            if (!bkpinfo->restore_data) {
    17441746                mr_asprintf(&comment, "How much data (in Megabytes) will each media store?");
    1745                 if (!popup_and_get_string("Size", comment, sz_size, 5)) {
    1746                     mr_free(comment);
     1747                // BERLIOS: 4480 shouldn't be hardcoded here
     1748                sz_size = popup_and_get_string("Size", comment, "4480");
     1749                mr_free(comment);
     1750                if (sz_size == NULL) {
    17471751                    log_to_screen("User has chosen not to backup the PC");
    17481752                    finish(1);
    17491753                }
    1750                 mr_free(comment);
    17511754            } else {
    1752                 strcpy(sz_size, "0");
     1755                mr_asprintf(&sz_size, "0");
    17531756            }
    17541757            for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    17551758                bkpinfo->media_size[i] = atoi(sz_size);
    17561759            }
     1760            mr_free(sz_size);
    17571761            if (bkpinfo->media_size[0] < 0) {
    17581762                log_to_screen("User has chosen not to backup the PC");
     
    17651769            mr_free(command);
    17661770
    1767             if (!popup_and_get_string
    1768                 ("NFS share", "Which remote NFS share should I mount?",
    1769                  bkpinfo->nfs_mount, MAX_STR_LEN)) {
     1771            p = popup_and_get_string("NFS share", "Which remote NFS share should I mount?", bkpinfo->nfs_mount);
     1772            if (p == NULL) {
    17701773                log_to_screen("User has chosen not to backup the PC");
    17711774                finish(1);
    17721775            }
     1776            strcpy(bkpinfo->nfs_mount, p);
     1777            mr_free(p);
    17731778        }
    17741779        /* Initiate bkpinfo isodir path from running environment if mount already done */
     
    17951800            finish(1);
    17961801        }
    1797         strcpy(tmp1, bkpinfo->nfs_remote_dir);
    1798         if (!popup_and_get_string
    1799             ("Directory", "Which directory within that mountpoint?", tmp1,
    1800              MAX_STR_LEN)) {
     1802        p = popup_and_get_string("Directory", "Which directory within that mountpoint?", bkpinfo->nfs_remote_dir);
     1803        if (p == NULL) {
    18011804            log_to_screen("User has chosen not to backup the PC");
    18021805            finish(1);
    18031806        }
    1804         strcpy(bkpinfo->nfs_remote_dir, tmp1);
     1807        strcpy(bkpinfo->nfs_remote_dir, p);
     1808        mr_free(p);
    18051809
    18061810        // check whether writable - we better remove surrounding spaces for this
    18071811        strip_spaces(bkpinfo->nfs_remote_dir);
    18081812
    1809         if (!popup_and_get_string
    1810             ("Prefix.",
    1811              "Please enter the prefix that will be prepended to your ISO filename.  Example: machine1 to obtain machine1-[1-9]*.iso files",
    1812             bkpinfo->prefix, MAX_STR_LEN / 4)) {
     1813        p = popup_and_get_string("Prefix.", "Please enter the prefix that will be prepended to your ISO filename.  Example: machine1 to obtain machine1-[1-9]*.iso files", bkpinfo->prefix);
     1814        if (p == NULL) {
    18131815            log_to_screen("User has chosen not to backup the PC");
    18141816            finish(1);
    18151817        }
    18161818        log_msg(3, "prefix set to %s", bkpinfo->prefix);
    1817 
    1818         for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    1819             bkpinfo->media_size[i] = 650;
    1820         }
    1821         log_msg(3, "Just set nfs_remote_dir to %s",
    1822                 bkpinfo->nfs_remote_dir);
     1819        strcpy(bkpinfo->prefix, p);
     1820        mr_free(p);
     1821
     1822        log_msg(3, "Just set nfs_remote_dir to %s", bkpinfo->nfs_remote_dir);
    18231823        log_msg(3, "isodir is still %s", bkpinfo->isodir);
    18241824        break;
     
    18261826    case iso:
    18271827        if (!bkpinfo->disaster_recovery) {
    1828             if (!popup_and_get_string
    1829                 ("Storage dir.",
    1830                  "Please enter the full path name to the directory for your ISO images.  Example: /mnt/raid0_0",
    1831                  bkpinfo->isodir, MAX_STR_LEN / 4)) {
     1828            p = popup_and_get_string("Storage dir.", "Please enter the full path name to the directory for your ISO images.  Example: /mnt/raid0_0", bkpinfo->isodir);
     1829            if (p == NULL) {
    18321830                log_to_screen("User has chosen not to backup the PC");
    18331831                finish(1);
    18341832            }
     1833            strcpy(bkpinfo->isodir,p);
     1834            mr_free(p);
     1835
    18351836            if (archiving_to_media) {
    18361837                if ((bkpinfo->compression_level =
     
    18391840                    finish(1);
    18401841                }
    1841                 if (!popup_and_get_string
    1842                     ("ISO size.",
    1843                      "Please enter how big you want each ISO image to be (in megabytes). This should be less than or equal to the size of the CD-R[W]'s or DVD's you plan to backup to.",
    1844                      sz_size, 16)) {
     1842                p = popup_and_get_string("ISO size.", "Please enter how big you want each ISO image to be (in megabytes). This should be less than or equal to the size of the CD-R[W]'s or DVD's you plan to backup to.", sz_size);
     1843                if (p == NULL) {
    18451844                    log_to_screen("User has chosen not to backup the PC");
    18461845                    finish(1);
    18471846                }
    18481847                for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    1849                     bkpinfo->media_size[i] = atoi(sz_size);
     1848                    bkpinfo->media_size[i] = atoi(p);
    18501849                }
     1850                mr_free(p);
    18511851            } else {
    18521852                for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
     
    18551855            }
    18561856        }
    1857         if (!popup_and_get_string
    1858             ("Prefix.",
    1859              "Please enter the prefix that will be prepended to your ISO filename.  Example: machine1 to obtain machine1-[1-9]*.iso files",
    1860              bkpinfo->prefix, MAX_STR_LEN / 4)) {
     1857        p = popup_and_get_string("Prefix.", "Please enter the prefix that will be prepended to your ISO filename.  Example: machine1 to obtain machine1-[1-9]*.iso files", bkpinfo->prefix);
     1858        if (p == NULL) {
    18611859            log_to_screen("User has chosen not to backup the PC");
    18621860            finish(1);
    18631861        }
     1862        strcpy(bkpinfo->prefix, p);
     1863        mr_free(p);
    18641864        log_msg(3, "prefix set to %s", bkpinfo->prefix);
    18651865        break;
     
    18851885
    18861886#ifdef __FreeBSD__
    1887             if (!popup_and_get_string
    1888                 ("Boot device",
    1889                  "What is your boot device? (e.g. /dev/ad0)",
    1890                  bkpinfo->boot_device, MAX_STR_LEN / 4)) {
     1887            p = popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/ad0)", bkpinfo->boot_device);
     1888            if (!p == NULL) {
    18911889                log_to_screen("User has chosen not to backup the PC");
    18921890                finish(1);
    18931891            }
     1892            strcpy(bkpinfo->boot_device, p);
     1893            mr_free(p);
    18941894            i = which_boot_loader(bkpinfo->boot_device);
    18951895#else
    1896             if (!popup_and_get_string
    1897                 ("Boot device",
    1898                  "What is your boot device? (e.g. /dev/hda)",
    1899                  bkpinfo->boot_device, MAX_STR_LEN / 4)) {
     1896            p = popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/hda)", bkpinfo->boot_device);
     1897            if (p == NULL) {
    19001898                log_to_screen("User has chosen not to backup the PC");
    19011899                finish(1);
    19021900            }
    1903             if (does_string_exist_in_boot_block
    1904                 (bkpinfo->boot_device, "LILO")) {
     1901            strcpy(bkpinfo->boot_device, p);
     1902            mr_free(p);
     1903
     1904            if (does_string_exist_in_boot_block(bkpinfo->boot_device, "LILO")) {
    19051905                i = 'L';
    19061906            } else
    1907                 if (does_string_exist_in_boot_block
    1908                     (bkpinfo->boot_device, "ELILO")) {
     1907                if (does_string_exist_in_boot_block(bkpinfo->boot_device, "ELILO")) {
    19091908                i = 'E';
    19101909            } else
    1911                 if (does_string_exist_in_boot_block
    1912                     (bkpinfo->boot_device, "GRUB")) {
     1910                if (does_string_exist_in_boot_block(bkpinfo->boot_device, "GRUB")) {
    19131911                i = 'G';
    19141912            } else {
     
    19301928        bkpinfo->boot_loader = i;
    19311929        strcpy(bkpinfo->include_paths, "/");
    1932         if (!popup_and_get_string
    1933             ("Backup paths",
    1934              "Please enter paths which you want me to backup. The default is '/' (i.e. everything).",
    1935              bkpinfo->include_paths, MAX_STR_LEN)) {
     1930        p = popup_and_get_string("Backup paths", "Please enter paths which you want me to backup. The default is '/' (i.e. everything).", bkpinfo->include_paths);
     1931        if (p == NULL) {
    19361932            log_to_screen("User has chosen not to backup the PC");
    19371933            finish(1);
    19381934        }
     1935        strcpy(bkpinfo->include_paths, p);
     1936        mr_free(p);
     1937
    19391938        mr_asprintf(&tmp, "%s", list_of_NFS_mounts_only());
    19401939        if (strlen(tmp) > 2) {
     
    19481947        strcpy(tmp1, call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'"));
    19491948        if (strlen(tmp1) > 2) {
    1950             if (!popup_and_get_string
    1951                 ("NTFS partitions",
    1952                  "Please enter/confirm the NTFS partitions you wish to backup as well.",
    1953                  tmp1, MAX_STR_LEN / 4)) {
     1949            p = popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp);
     1950
     1951            if (p == NULL) {
    19541952                log_to_screen("User has chosen not to backup the PC");
    19551953                finish(1);
    19561954            }
    1957             strncpy(bkpinfo->image_devs, tmp1, MAX_STR_LEN / 4);
    1958         }
    1959 
    1960 
    1961         if (!popup_and_get_string
    1962             ("Exclude paths",
    1963              "Please enter paths which you do NOT want to backup. Separate them with spaces. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.",
    1964              bkpinfo->exclude_paths, (4*MAX_STR_LEN)-1)) {
     1955            strncpy(bkpinfo->image_devs, p, MAX_STR_LEN / 4);
     1956            mr_free(p);
     1957        }
     1958
     1959
     1960        p = popup_and_get_string("Exclude paths", "Please enter paths which you do NOT want to backup. Separate them with spaces. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.", bkpinfo->exclude_paths);
     1961        if (p == NULL) {
    19651962            log_to_screen("User has chosen not to backup the PC");
    19661963            finish(1);
    19671964        }
    1968         if (!popup_and_get_string
    1969             ("Temporary directory",
    1970              "Please enter your temporary directory.",
    1971              bkpinfo->tmpdir, (4*MAX_STR_LEN)-1)) {
     1965        strcpy(bkpinfo->exclude_paths, p);
     1966        mr_free(p);
     1967
     1968        p = popup_and_get_string("Temporary directory", "Please enter your temporary directory.", bkpinfo->tmpdir);
     1969        if (p == NULL) {
    19721970            log_to_screen("User has chosen not to backup the PC");
    19731971            finish(1);
    19741972        }
    1975         if (!popup_and_get_string
    1976             ("Scratch directory",
    1977              "Please enter your scratch directory.",
    1978              bkpinfo->scratchdir, (4*MAX_STR_LEN)-1)) {
     1973        strcpy(bkpinfo->tmpdir, p);
     1974        mr_free(p);
     1975
     1976        p = popup_and_get_string("Scratch directory", "Please enter your scratch directory.", bkpinfo->scratchdir);
     1977        if (p == NULL) {
    19791978            log_to_screen("User has chosen not to backup the PC");
    19801979            finish(1);
    19811980        }
     1981        strcpy(bkpinfo->scratchdir, p);
     1982        mr_free(p);
     1983
    19821984// Interactive mode:
    19831985#ifdef __IA64__
  • branches/2.2.10/mondo/src/common/libmondo-files.c

    r2296 r2316  
    306306            return (1);
    307307        }
    308         if (!popup_and_get_string
    309             ("Kernel path",
    310              "What is the full path and filename of your kernel, please?",
    311              kernel, MAX_STR_LEN / 4)) {
    312             fatal_error
    313                 ("Kernel not found. Please specify with the '-k' flag.");
    314         }
    315         mr_asprintf(&tmp, "User says kernel is at %s", kernel);
    316         log_it(tmp);
     308        tmp = popup_and_get_string("Kernel path", "What is the full path and filename of your kernel, please?", kernel);
     309        if (tmp == NULL) {
     310            fatal_error("Kernel not found. Please specify with the '-k' flag.");
     311        }
     312        strcpy(kernel, tmp);
    317313        mr_free(tmp);
     314
     315        log_it("User says kernel is at %s", kernel);
    318316    }
    319317    return (0);
     
    11841182    }
    11851183
    1186     mr_asprintf(tmp, "%s/NFS-DEV", bkpinfo->tmpdir);
     1184    mr_asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir);
    11871185    write_one_liner_data_file(tmp, nfs_dev);
    11881186    mr_free(nfs_dev);
    11891187    mr_free(tmp);
    11901188
    1191     mr_asprintf(tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);
     1189    mr_asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);
    11921190    write_one_liner_data_file(tmp, nfs_client_ipaddr);
    11931191    mr_free(nfs_client_ipaddr);
    11941192    mr_free(tmp);
    11951193
    1196     mr_asprintf(tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);
     1194    mr_asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);
    11971195    write_one_liner_data_file(tmp, nfs_client_netmask);
    11981196    mr_free(nfs_client_netmask);
    11991197    mr_free(tmp);
    12001198
    1201     mr_asprintf(tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
     1199    mr_asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
    12021200    write_one_liner_data_file(tmp, nfs_client_broadcast);
    12031201    mr_free(nfs_client_broadcast);
    12041202    mr_free(tmp);
    12051203
    1206     mr_asprintf(tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);
     1204    mr_asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);
    12071205    write_one_liner_data_file(tmp, nfs_client_defgw);
    12081206    mr_free(nfs_client_defgw);
    12091207    mr_free(tmp);
    12101208
    1211     mr_asprintf(tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);
     1209    mr_asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);
    12121210    write_one_liner_data_file(tmp, nfs_server_ipaddr);
    12131211    mr_free(tmp);
    12141212    mr_free(nfs_server_ipaddr);
    12151213
    1216     mr_asprintf(tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);
     1214    mr_asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);
    12171215    write_one_liner_data_file(tmp, bkpinfo->nfs_mount);
    12181216    mr_free(tmp);
    12191217    mr_free(nfs_mount);
    12201218
    1221     mr_asprintf(tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);
     1219    mr_asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);
    12221220    write_one_liner_data_file(tmp, bkpinfo->nfs_remote_dir);
    12231221    mr_free(tmp);
    12241222
    1225     mr_asprintf(tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
     1223    mr_asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
    12261224    write_one_liner_data_file(tmp, bkpinfo->prefix);
    12271225    mr_free(tmp);
  • branches/2.2.10/mondo/src/common/libmondo-fork.c

    r2315 r2316  
    248248    char *callstr = NULL;
    249249    char incoming[MAX_STR_LEN * 2];
    250     char tmp[MAX_STR_LEN * 2];
    251250    char *tmp1 = NULL;
    252     char initial_label[MAX_STR_LEN * 2];
    253251
    254252    /*@ int ********************************************************* */
    255253    int res;
    256254    int i;
    257     int len;
    258255    bool log_if_failure = FALSE;
    259256    bool log_if_success = FALSE;
     
    284281
    285282
    286     len = (int) strlen(program);
    287     for (i = 0; i < 35 - len / 2; i++) {
    288         tmp[i] = '-';
    289     }
    290     tmp[i] = '\0';
    291     strcat(tmp, " ");
    292     strcat(tmp, program);
    293     strcat(tmp, " ");
    294     for (i = 0; i < 35 - len / 2; i++) {
    295         strcat(tmp, "-");
    296     }
    297     strcpy(initial_label, tmp);
    298283    res = system(callstr);
    299284    if (((res == 0) && log_if_success) || ((res != 0) && log_if_failure)) {
    300285        log_msg(0, "running: %s", callstr);
    301         log_msg(0,
    302                 "--------------------------------start of output-----------------------------");
     286        log_msg(0, "--------------------------------start of output-----------------------------");
    303287    }
    304288    mr_free(callstr);
  • branches/2.2.10/mondo/src/common/libmondo-mountlist.c

    r2306 r2316  
    5959    /*@ buffers ******************************************************** */
    6060    char tmp = NULL;
    61     char device[MAX_STR_LEN];
     61    char *device = NULL;
    6262    char mountpoint[MAX_STR_LEN];
    6363
     
    9090    /* check DD */
    9191    for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    92         sprintf(device, "%s%c", drive, cur_sp_no);
    93         if (find_device_in_mountlist(mountlist, device) >= 0)
     92        mr_asprintf(&device, "%s%c", drive, cur_sp_no);
     93        if (find_device_in_mountlist(mountlist, device) >= 0) {
    9494            foundsome = TRUE;
     95        }
     96        mr_free(device);
    9597    }
    9698    if (foundsome) {
    9799        for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    98             sprintf(device, "%s%c", drive, cur_sp_no);
     100            mr_asprintf(&device, "%s%c", drive, cur_sp_no);
    99101            pos = find_device_in_mountlist(mountlist, device);
    100102            if (pos < 0) {
     103                mr_free(device);
    101104                continue;
    102105            }
     
    156159                res++;
    157160            }
     161            mr_free(device);
     162
    158163            amount_allocated += mountlist->el[pos].size / 1024L;
    159164            prev_sp_no = cur_sp_no;
     
    163168    npos = pos = 0;
    164169    for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
    165         build_partition_name(device, drive, curr_part_no);
     170        device = build_partition_name(drive, curr_part_no);
    166171        pos = find_device_in_mountlist(mountlist, device);
    167172        npos = 0;
    168173        for (cur_sp_no = 'a'; cur_sp_no <= 'h'; cur_sp_no++) {
    169             sprintf(device, "%ss%i%c", device, curr_part_no, cur_sp_no);
    170             if (find_device_in_mountlist(mountlist, device) >= 0)
     174            mr_asprintf(&tmp, "%ss%i%c", device, curr_part_no, cur_sp_no);
     175            if (find_device_in_mountlist(mountlist, tmp) >= 0) {
    171176                npos++;
    172         }
     177            }
     178            mr_free(tmp);
     179        }
     180        mr_free(device);
     181
    173182        if (((pos >= 0) || npos) && foundsome) {
    174183            mr_strcat(flaws_str, " %s has both DD and PC-style partitions.", drive);
     
    176185        }
    177186
    178         build_partition_name(device, drive, curr_part_no);
     187        device = build_partition_name(drive, curr_part_no);
    179188        strcpy(mountpoint, mountlist->el[pos].mountpoint);
    180189        if (pos > 0 && !npos) {
     
    256265            /* Check subpartitions */
    257266            for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    258                 sprintf(device, "%ss%d%c", drive, curr_part_no, cur_sp_no);
     267                mr_free(device);
     268                mr_asprintf(device, "%ss%d%c", drive, curr_part_no, cur_sp_no);
    259269                pos = find_device_in_mountlist(mountlist, device);
    260270                if (pos < 0) {
     
    321331            }
    322332        }
     333        mr_free(device);
    323334
    324335        /* OK, continue with main loop */
     
    380391    mr_asprintf(&flaws_str, "%s", "");
    381392
    382     malloc_string(device);
    383393    prev_part_no = 0;
    384394
     
    391401        log_msg(1, tmp);
    392402        mr_free(tmp);
    393         goto endoffunc;
     403        return(flaws_str);
    394404    } else {
    395405        mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
     
    399409
    400410    for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
    401         build_partition_name(device, drive, curr_part_no);
     411        device = build_partition_name(drive, curr_part_no);
    402412        pos = find_device_in_mountlist(mountlist, device);
    403413        if (pos < 0) {
     
    441451        }
    442452        if (device_copies > 1) {
    443             mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
    444                     device);
     453            mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), device);
    445454            if (!strstr(flaws_str, tmp)) {
    446455                log_it(tmp);
     
    482491        amount_allocated += mountlist->el[pos].size / 1024L;
    483492        prev_part_no = curr_part_no;
     493        mr_free(device);
    484494    }
    485495
     
    499509        mr_free(tmp);
    500510    }
    501 
    502   endoffunc:
    503     paranoid_free(device);
    504511
    505512    if (res) {
  • branches/2.2.10/mondo/src/common/libmondo-string-EXT.h

    r2315 r2316  
    33 */
    44
    5 extern char *build_partition_name(char *partition, const char *drive,
    6                                   int partno);
     5extern char *build_partition_name(const char *drive, int partno);
    76extern void center_string(char *in_out, int width);
    87extern char *commarize(char *);
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2315 r2316  
    3434 * @param drive The drive basename of the partition name (e.g. /dev/hda)
    3535 * @param partno The partition number (e.g. 1)
    36  * @param partition Where to put the partition name (e.g. /dev/hda1)
    3736 * @return @p partition.
    3837 * @note If @p drive ends in a digit, then 'p' (on Linux) or 's' (on *BSD) is added before @p partno.
    3938 */
    40 char *build_partition_name(char *partition, const char *drive, int partno)
    41 {
    42     char *p, *c;
    43 
    44     assert(partition != NULL);
     39char *build_partition_name(const char *drive, int partno)
     40{
     41    char *c = NULL;
     42    char *partition = NULL;
     43
    4544    assert_string_is_neither_NULL_nor_zerolength(drive);
    4645    assert(partno >= 0);
    4746
    48     p = strcpy(partition, drive);
     47    mr_asprintf(&partition, drive);
    4948    /* is this a devfs device path? */
    5049    c = strrchr(partition, '/');
    5150    if (c && strncmp(c, "/disc", 5) == 0) {
    5251        /* yup it's devfs, return the "part" path */
     52        /* This strcpy is safe */
    5353        strcpy(c + 1, "part");
    54         p = c + 5;
    5554    } else {
    56         p += strlen(p);
    57         if (isdigit(p[-1])) {
    58             *p++ =
     55        if (isdigit(partition[-1])) {
     56            mr_strcat(partition,
    5957#ifdef BSD
    60                 's';
     58                's');
    6159#else
    62                 'p';
     60                'p');
    6361#endif
    6462        }
    6563    }
    66     sprintf(p, "%d", partno);
    67     return (partition);
    68 }
    69 
    70 
    71 
    72 
    73 
    74 
    75 
    76 
    77 
    78 
    79 
     64    mr_strcat(partition, "%d", partno);
     65    return(partition);
     66}
    8067
    8168
  • branches/2.2.10/mondo/src/common/libmondo-string.h

    r2315 r2316  
    33 */
    44
    5 char *build_partition_name(char *partition, const char *drive, int partno);
     5char *build_partition_name(const char *drive, int partno);
    66void center_string(char *in_out, int width);
    77char *commarize(char *);
  • branches/2.2.10/mondo/src/common/libmondo-verify.h

    r1713 r2316  
    4242extern int openin_tape();
    4343extern void popup_and_OK(char *);
    44 extern bool popup_and_get_string(char *, char *, char *, int);
     44extern char *popup_and_get_string(char *, char *, char *);
    4545extern int read_file_from_tape_to_file(char *,
    4646                                       long long);
  • branches/2.2.10/mondo/src/common/newt-specific-EXT.h

    r128 r2316  
    1515extern void log_to_screen(const char *fmt, ...);
    1616extern void popup_and_OK(char *prompt);
    17 extern bool popup_and_get_string(char *title, char *b, char *output,
    18                                  int maxsize);
     17extern char *popup_and_get_string(char *title, char *b, char *input);
    1918extern bool popup_with_buttons(char *p, char *button1, char *button2);
    2019extern void refresh_log_screen();
  • branches/2.2.10/mondo/src/common/newt-specific.c

    r2296 r2316  
    358358            log_msg(0, fatalstr);
    359359            log_msg(0, error_string);
    360             //      popup_and_OK (error_string);
    361360            newtFinished();
    362361        }
     
    400399     finish(int signal) {
    401400        char *command = NULL;
    402 
    403         /*  if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */
    404 
    405         /* newtPopHelpLine(); */
    406401
    407402        chdir("/");
     
    750745 * @param title The title of the dialog box.
    751746 * @param b The blurb (e.g. what you want the user to enter).
    752  * @param output The string to put the user's answer in.
    753  * @param maxsize The size in bytes allocated to @p output.
    754  * @return TRUE if the user pressed OK, FALSE if they pressed Cancel.
    755  */
    756     bool popup_and_get_string(char *title, char *b, char *output,
    757                               int maxsize) {
     747 * @param input The string given originaly as default
     748 * @return output string if the user pressed OK, NULL if they pressed Cancel.
     749 */
     750    char *popup_and_get_string(char *title, char *b, char *input) {
    758751
    759752        /*@ newt ************************************************************ */
     
    769762
    770763        /*@ buffers ********************************************************** */
    771         char *blurb;
    772         char *original_contents;
    773 
    774         blurb = malloc(MAX_NEWT_COMMENT_LEN);
    775         original_contents = malloc(MAX_NEWT_COMMENT_LEN);
     764        char *blurb = NULL;
     765        char *output = NULL;
     766
    776767        assert_string_is_neither_NULL_nor_zerolength(title);
    777768        assert(b != NULL);
    778         assert(output != NULL);
    779769
    780770        if (g_text_mode) {
    781             printf
    782                 ("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n-->  ",
    783                  title, b);
    784             (void) fgets(output, maxsize, stdin);
     771            printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q--- [%s]\n-->  ", title, b, input);
     772            mr_getline(&output, stdin);
     773            if (! strcmp(output,"\n")) {
     774                /* take default if ENTER was typed */
     775                mr_free(output);
     776                mr_asprintf(&output, "%s", input);
     777            }
    785778            if (output[strlen(output) - 1] == '\n')
    786779                output[strlen(output) - 1] = '\0';
    787             paranoid_free(blurb);
    788             paranoid_free(original_contents);
    789             return (TRUE);
    790         }
    791         strcpy(blurb, b);
     780            return (output);
     781        }
     782
     783        mr_asprintf(&blurb, "%s", b);
    792784        text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
    793         strcpy(original_contents, output);
    794         output[0] = '\0';
    795785        type_here =
    796786            newtEntry(2, newtTextboxGetNumLines(text) + 2,
    797                       original_contents, 50,
     787                      input, 50,
    798788#ifdef __cplusplus
    799789                      0, NEWT_FLAG_RETURNEXIT
     
    804794        b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, "  OK  ");
    805795        b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel");
    806         //  newtOpenWindow (8, 5, 54, newtTextboxGetNumLines (text) + 9, title);
    807796        newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title);
    808797        myForm = newtForm(NULL, NULL, 0);
     
    811800        newtPushHelpLine(blurb);
    812801        b_res = newtRunForm(myForm);
    813         strcpy(output, entry_value);
     802
     803        if (b_res == b_1) {
     804            mr_asprintf(&output, "%s", newtEntryGetValue(type_here));
     805        }
    814806        newtPopHelpLine();
    815807        newtFormDestroy(myForm);
    816808        newtPopWindow();
    817         if (b_res == b_2) {
    818             strcpy(output, original_contents);
    819             paranoid_free(blurb);
    820             paranoid_free(original_contents);
    821             return (FALSE);
    822         } else {
    823             paranoid_free(blurb);
    824             paranoid_free(original_contents);
    825             return (TRUE);
    826         }
     809        mr_free(blurb);
     810
     811        return (output);
    827812    }
    828813
     
    11791164        } else {
    11801165            mr_asprintf(&timeline_str, "%2ld:%02ld taken               %2ld:%02ld remaining  ", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
    1181             mr_asprintf(percentline_str, " %3d%% done                 %3d%% to go", percentage, 100 - percentage);
     1166            mr_asprintf(&percentline_str, " %3d%% done                 %3d%% to go", percentage, 100 - percentage);
    11821167
    11831168            center_string(blurb1, 54);
  • branches/2.2.10/mondo/src/common/newt-specific.h

    r128 r2316  
    2121                        long max_val);
    2222void popup_and_OK(char *prompt);
    23 bool popup_and_get_string(char *title, char *b, char *output, int maxsize);
     23char *popup_and_get_string(char *title, char *b, char *input);
    2424bool popup_with_buttons(char *p, char *button1, char *button2);
    2525void refresh_log_screen();
  • branches/2.2.10/mondo/src/include/mr_mem.h

    r2208 r2316  
    2020#define mr_allocstr(x,y) mr_allocstr_int(x,y,__LINE__,__FILE__)
    2121#define mr_asprintf(x,y,args...) mr_asprintf_int(x,__LINE__,__FILE__,y,## args)
    22 #define mr_getline(x,y,z) mr_getline_int(x,y,z,__LINE__,__FILE__)
     22#define mr_getline(x,z) mr_getline_int(x,z,__LINE__,__FILE__)
    2323#define mr_malloc(x) mr_malloc_int((size_t)x,__LINE__,__FILE__)
    2424#define mr_setenv(x,y) mr_setenv_int(x,y,__LINE__,__FILE__)
     
    3030extern inline void mr_allocstr_int(char *alloc, const char *orig, int line, char *file);
    3131extern inline void mr_asprintf_int(char **alloc, int line, char *file, const char *fmt, ...);
    32 extern inline void mr_getline_int(char **lineptr, size_t *n, FILE *stream, int line, char *file);
     32extern inline void mr_getline_int(char **lineptr, FILE *stream, int line, char *file);
    3333extern inline void *mr_malloc_int(size_t size, int line, char *file);
    3434extern inline void mr_setenv_int(const char *name, const char *value, int line, char *file);
  • branches/2.2.10/mondo/src/lib/mr_mem.c

    r2307 r2316  
    5454
    5555/* encapsulation function for getline */
    56 void mr_getline_int(char **lineptr, size_t *n, FILE *fd, int line, const char *file) {
     56void mr_getline_int(char **lineptr, FILE *fd, int line, const char *file) {
    5757   
    5858    ssize_t ret;
     59    ssize_t *n;
    5960
    6061    ret = getline(lineptr,n,fd);
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2299 r2316  
    14571457
    14581458    /** buffers *********************************************************/
    1459     char *device_str;
     1459    char *device_str = NULL;
    14601460    char *format;
    14611461    char *tmp = NULL;
     
    14661466    assert_string_is_neither_NULL_nor_zerolength(drivename);
    14671467
    1468     malloc_string(device_str);
    14691468    malloc_string(format);
    14701469
     
    14831482    if (!pout_to_fdisk) {
    14841483        log_to_screen("Cannot call parted2fdisk to configure %s", drivename);
    1485         paranoid_free(device_str);
    14861484        paranoid_free(format);
    14871485        return (1);
     
    14891487#endif
    14901488    for (current_devno = 1; current_devno < 99; current_devno++) {
    1491         build_partition_name(device_str, drivename, current_devno);
     1489        device_str = build_partition_name(drivename, current_devno);
    14921490        lino = find_device_in_mountlist(mountlist, device_str);
    14931491
     
    15181516                    }
    15191517                    mr_free(command);
    1520                     paranoid_free(device_str);
     1518                    mr_free(device_str);
    15211519                    paranoid_free(format);
    15221520                    return r;
     
    15471545                }
    15481546            } else {
     1547                mr_free(device_str);
    15491548                continue;
    15501549            }
    15511550#else
     1551            mr_free(device_str);
    15521552            continue;
    15531553#endif
     
    16061606            log_to_screen
    16071607                ("You must leave at least one partition spare as the Extended partition.");
    1608             paranoid_free(device_str);
     1608            mr_free(device_str);
    16091609            paranoid_free(format);
    16101610            return (1);
     
    16271627        }
    16281628#endif
     1629        mr_free(device_str);
    16291630
    16301631        previous_devno = current_devno;
     
    16661667        }
    16671668    }
    1668     paranoid_free(device_str);
    16691669    paranoid_free(format);
    16701670    return (retval);
     
    16901690    /** buffers **********************************************************/
    16911691    char *program = NULL;
    1692     char *partition_name;
     1692    char *partition_name = NULL;
    16931693    char *tmp = NULL;
    16941694    char *output = NULL;
     
    17011701    /** end ***************************************************************/
    17021702
    1703     malloc_string(partition_name);
    1704 
    17051703    assert_string_is_neither_NULL_nor_zerolength(drive);
    17061704    assert(format != NULL);
     
    17141712        mr_free(tmp);
    17151713
    1716         paranoid_free(partition_name);
    17171714        return (0);
    17181715    }
    1719     build_partition_name(partition_name, drive, partno);
     1716    partition_name = build_partition_name(drive, partno);
    17201717    if (partsize <= 0) {
    17211718        mr_asprintf(&tmp, "Partitioning device %s (max size)", partition_name);
     
    17311728        log_to_screen(tmp);
    17321729        mr_free(tmp);
    1733         paranoid_free(partition_name);
     1730        mr_free(partition_name);
    17341731        return (1);
    17351732    }
     
    17491746            if (partno == 5) {
    17501747                if (prev_partno >= 4) {
    1751                     log_to_screen
    1752                         ("You need to leave at least one partition free, for 'extended/logical'");
    1753                     paranoid_free(partition_name);
     1748                    log_to_screen("You need to leave at least one partition free, for 'extended/logical'");
     1749                    mr_free(partition_name);
    17541750                    paranoid_free(output);
    17551751                    return (1);
     
    17761772    log_it(tmp);
    17771773    mr_free(tmp);
     1774
    17781775    log_it("---fdisk command---");
    17791776    log_it(output);
     
    18671864    }
    18681865    mr_free(program);
     1866    mr_free(partition_name);
    18691867    paranoid_free(output);
    18701868
    18711869    g_current_progress++;
    18721870    log_it("partition_device() --- leaving");
    1873     paranoid_free(partition_name);
    18741871    return (retval);
    18751872}
     
    19791976{
    19801977    /** buffers *********************************************************/
    1981     char *partition;
     1978    char *partition = NULL;
    19821979    char *command = NULL;
    19831980    char *output = NULL;
    19841981    char *tmp = NULL;
    1985     char *partcode;
     1982    char *partcode = NULL;
    19861983
    19871984    /** pointers *********************************************************/
     
    19971994    assert(format != NULL);
    19981995
    1999     malloc_string(partition);
    2000     malloc_string(partcode);
    2001 
    2002     build_partition_name(partition, drive, partno);
     1996    partition = build_partition_name(drive, partno);
    20031997    p = (char *) strrchr(partition, '/');
    20041998    if (strcmp(format, "swap") == 0) {
    2005         strcpy(partcode, "82");
     1999        mr_asprintf(&partcode, "82");
    20062000    } else if (strcmp(format, "vfat") == 0) {
    20072001        if (partsize / 1024 > 8192) {
    2008             strcpy(partcode, "c");
     2002            mr_asprintf(&partcode, "c");
    20092003        } else {
    2010             strcpy(partcode, "b");
     2004            mr_asprintf(&partcode, "b");
    20112005        }
    20122006    } else if (strcmp(format, "ext2") == 0
     
    20162010               || strcmp(format, "xfs") == 0
    20172011               || strcmp(format, "jfs") == 0) {
    2018         strcpy(partcode, "83");
     2012        mr_asprintf(&partcode, "83");
    20192013    } else if (strcmp(format, "minix") == 0) {
    2020         strcpy(partcode, "81");
     2014        mr_asprintf(&partcode, "81");
    20212015    } else if (strcmp(format, "vmfs3") == 0) {
    2022         strcpy(partcode, "fb");
     2016        mr_asprintf(&partcode, "fb");
    20232017    } else if (strcmp(format, "vmkcore") == 0) {
    2024         strcpy(partcode, "fc");
     2018        mr_asprintf(&partcode, "fc");
    20252019    } else if (strcmp(format, "raid") == 0) {
    2026         strcpy(partcode, "fd");
     2020        mr_asprintf(&partcode, "fd");
    20272021    } else if (strcmp(format, "ntfs") == 0) {
    2028         strcpy(partcode, "7");
     2022        mr_asprintf(&partcode, "7");
    20292023    } else if ((strcmp(format, "ufs") == 0)
    20302024               || (strcmp(format, "ffs") == 0)) {   /* raid autodetect */
    2031         strcpy(partcode, "a5");
     2025        mr_asprintf(&partcode, "a5");
    20322026    } else if (strcmp(format, "lvm") == 0) {
    2033         strcpy(partcode, "8e");
     2027        mr_asprintf(&partcode, "8e");
    20342028    } else if (format[0] == '\0') { /* LVM physical partition */
    2035         partcode[0] = '\0';
     2029        mr_asprintf(&partcode, "");
    20362030    } else if (strlen(format) >= 1 && strlen(format) <= 2) {
    2037         strcpy(partcode, format);
     2031        mr_asprintf(&partcode, format);
    20382032    } else {
    20392033        /* probably an image */
     
    20422036        mr_free(tmp);
    20432037#ifdef __FreeBSD__
    2044         strcpy(partcode, format);   // was a5
     2038        mr_asprintf(&partcode, format); // was a5
    20452039#else
    2046         strcpy(partcode, format);   // was 83
     2040        mr_asprintf(&partcode, format); // was 83
    20472041#endif
    20482042    }
    20492043    log_msg(1, tmp, "Setting %s's type to %s (%s)", partition, format, partcode);
    2050     if (partcode[0] != '\0' && strcmp(partcode, "83")) {    /* no need to set type if 83: 83 is default */
     2044    mr_free(partition);
     2045
     2046    if (partcode != NULL && strcmp(partcode, "83")) {   /* no need to set type if 83: 83 is default */
    20512047
    20522048        if (pout_to_fdisk) {
     
    21042100    }
    21052101
    2106     paranoid_free(partition);
    2107     paranoid_free(partcode);
    2108 
     2102    mr_free(partcode);
    21092103    return (res);
    21102104}
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c

    r2314 r2316  
    1212#include "mondo-rstr-newt.h"
    1313#include "mr_mem.h"
     14#include "mr_str.h"
    1415
    1516//static char cvsid[] = "$Id$";
     
    255256{
    256257
    257     /** buffers ***********************************************************/
    258     char sz_out[MAX_STR_LEN];
    259 
    260258    /** int ****************************************************************/
    261259    int items = 0;
    262260    int i = 0;
    263261
     262    char *p = NULL;
     263
    264264    assert(raidrec != NULL);
    265265
    266     sz_out[0] = '\0';
    267     if (popup_and_get_string
    268         ("Add variable", "Enter the name of the variable to add", sz_out,
    269          MAX_STR_LEN)) {
    270         strip_spaces(sz_out);
     266    p = popup_and_get_string("Add variable", "Enter the name of the variable to add", "");
     267    if (p != NULL) {
     268        mr_strip_spaces(p);
    271269        items = raidrec->additional_vars.entries;
    272270        for (i = 0;
    273271             i < items
    274              && strcmp(raidrec->additional_vars.el[i].label, sz_out); i++);
     272             && strcmp(raidrec->additional_vars.el[i].label, p); i++);
    275273        if (i < items) {
    276274            popup_and_OK
    277275                ("No need to add that variable. It is already listed here.");
    278276        } else {
    279             strcpy(raidrec->additional_vars.el[items].label, sz_out);
     277            strcpy(raidrec->additional_vars.el[items].label, p);
    280278            edit_varslist_entry(raidrec, items);
    281279            raidrec->additional_vars.entries = ++items;
    282280        }
    283281    }
     282    mr_free(p);
    284283}
    285284#endif
     
    464463
    465464    /** int ***************************************************************/
    466     int res = 0;
    467465    int out = 0;
     466    int i = 0;
    468467
    469468    /** buffers ***********************************************************/
    470     char tmp[MAX_STR_LEN];
     469    char *tmp = NULL;
     470    char *p = NULL;
     471    char *q = NULL;
    471472    char *prompt = NULL;
    472     char *sz = NULL;
    473473
    474474    mr_asprintf(&prompt, "Please enter the RAID level you want. (concat, striped, raid5)");
    475475    if (raidrec->raidlevel == -1) {
    476         strcpy(tmp, "concat");
     476        mr_asprintf(&tmp, "concat");
    477477    } else if (raidrec->raidlevel == 0) {
    478         strcpy(tmp, "striped");
     478        mr_asprintf(&tmp, "striped");
    479479    } else {
    480         sprintf(tmp, "raid%i", raidrec->raidlevel);
     480        mr_asprintf(&tmp, "raid%i", raidrec->raidlevel);
    481481    }
    482482    for (out = 999; out == 999;) {
    483         res = popup_and_get_string("Specify RAID level", prompt, tmp, 10);
    484         if (!res) {
     483        p = popup_and_get_string("Specify RAID level", prompt, tmp);
     484        if (p == NULL) {
     485            mr_free(tmp);
     486            mr_free(prompt);
    485487            mr_free(prompt);
    486488            return;
    487489        }
    488         strip_spaces(tmp);
    489         if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') {
    490             mr_asprintf(&sz, "%s", tmp);
    491             strncpy(tmp, sz + 1, strlen(sz) - 2);
    492             tmp[strlen(sz) - 2] = '\0';
     490        mr_strip_spaces(p);
     491        /* Suppress brakets at each hend */
     492        if (p[0] == '[' && p[strlen(p) - 1] == ']') {
     493            q = p+1;
     494            i = 0;
     495            while (*q != ']') {
     496                p[i] = *q;
     497                i++;
     498                q++;
     499            }
     500            p[i] = '\0';
    493501            mr_free(sz);
    494502        }
    495         if (!strcmp(tmp, "concat")) {
     503        if (!strcmp(p, "concat")) {
    496504            out = -1;
    497         } else if (!strcmp(tmp, "striped")) {
     505        } else if (!strcmp(p, "striped")) {
    498506            out = 0;
    499         } else if (!strcmp(tmp, "raid5")) {
     507        } else if (!strcmp(p, "raid5")) {
    500508            out = 5;
    501509        }
    502         log_it(tmp);
     510        log_it("Raid level : %s",p);
     511        mr_free(p);
     512
    503513        if (is_this_raid_personality_registered(out)) {
    504             log_it
    505                 ("Groovy. You've picked a RAID personality which is registered.");
     514            log_it("Groovy. You've picked a RAID personality which is registered.");
    506515        } else {
    507             if (ask_me_yes_or_no
    508                 ("You have chosen a RAID personality which is not registered with the kernel. Make another selection?"))
     516            if (ask_me_yes_or_no("You have chosen a RAID personality which is not registered with the kernel. Make another selection?"))
    509517            {
    510518                out = 999;
     
    512520        }
    513521    }
     522    mr_free(tmp);
    514523    mr_free(prompt);
     524
    515525    raidrec->raidlevel = out;
    516526#else
    517527    /** buffers ***********************************************************/
    518     char tmp[MAX_STR_LEN];
     528    char *tmp = NULL;
    519529    char *personalities = NULL;
    520530    char *prompt = NULL;
    521     char *sz = NULL;
    522     int out = 0, res = 0;
     531    char *p = NULL;
     532    char *q = NULL;
     533    int out = 0;
     534    int i = 0;
    523535
    524536
    525537    assert(raidrec != NULL);
    526     system
    527         ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null");
     538
     539    system("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null");
    528540    mr_asprintf(&personalities, "%s", last_line_of_file("/tmp/raid-personalities.txt"));
    529541    mr_asprintf(&prompt, "Please enter the RAID level you want. %s", personalities);
     
    531543
    532544    if (raidrec->raid_level == -1) {
    533         strcpy(tmp, "linear");
     545        mr_asprintf(&tmp, "linear");
    534546    } else {
    535         sprintf(tmp, "%d", raidrec->raid_level);
     547        mr_asprintf(&tmp, "%d", raidrec->raid_level);
    536548    }
    537549    for (out = 999;
    538550         out != -1 && out != 0 && out != 1 && out != 4 && out != 5
    539551         && out != 10;) {
    540         res = popup_and_get_string("Specify RAID level", prompt, tmp, 10);
    541         if (!res) {
     552        p = popup_and_get_string("Specify RAID level", prompt, tmp);
     553
     554        if (p == NULL) {
     555            mr_free(tmp);
     556            mr_free(prompt);
    542557            mr_free(prompt);
    543558            return;
    544559        }
    545         strip_spaces(tmp);
    546         if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') {
    547             mr_asprintf(&sz, "%s", tmp);
    548             strncpy(tmp, sz + 1, strlen(sz) - 2);
    549             tmp[strlen(sz) - 2] = '\0';
     560        mr_strip_spaces(p);
     561        if (p[0] == '[' && p[strlen(p) - 1] == ']') {
     562            q = p+1;
     563            i = 0;
     564            while (*q != ']') {
     565                p[i] = *q;
     566                i++;
     567                q++;
     568            }
     569            p[i] = '\0';
    550570            mr_free(sz);
    551571        }
    552         if (!strcmp(tmp, "linear")) {
     572        if (!strcmp(p, "linear")) {
    553573            out = -1;
    554         } else if (!strncmp(tmp, "raid", 4)) {
    555             out = atoi(tmp + 4);
     574        } else if (!strncmp(p, "raid", 4)) {
     575            out = atoi(p + 4);
    556576        } else {
    557             out = atoi(tmp);
    558         }
    559         log_it(tmp);
     577            out = atoi(p);
     578        }
     579        log_it("Raid level : %s",p);
    560580        if (is_this_raid_personality_registered(out)) {
    561             log_it
    562                 ("Groovy. You've picked a RAID personality which is registered.");
     581            log_it("Groovy. You've picked a RAID personality which is registered.");
    563582        } else {
    564             if (ask_me_yes_or_no
    565                 ("You have chosen a RAID personality which is not registered with the kernel. Make another selection?"))
    566             {
     583            if (ask_me_yes_or_no("You have chosen a RAID personality which is not registered with the kernel. Make another selection?")) {
    567584                out = 999;
    568585            }
    569586        }
    570587    }
     588    mr_free(tmp);
    571589    mr_free(prompt);
    572590    raidrec->raid_level = out;
     
    16961714    int currline_a, currline_u;
    16971715
     1716    char *p = NULL;
     1717
    16981718    struct mountlist_itself *unallocparts;
    16991719
     
    18281848            choose_raid_level(raidrec);
    18291849        } else if (b_res == bStripeSize) {
    1830             char tmp[64];
    1831             sprintf(tmp, "%i", raidrec->stripesize);
    1832             if (popup_and_get_string
    1833                 ("Stripe size",
    1834                  "Please enter the stripe size in kilobytes.", tmp, 20)) {
    1835                 raidrec->stripesize = atoi(tmp);
     1850            char *tmp = NULL;
     1851
     1852            mr_asprintf(&tmp, "%i", raidrec->stripesize);
     1853            p = popup_and_get_string("Stripe size", "Please enter the stripe size in kilobytes.", tmp);
     1854            mr_free(tmp);
     1855
     1856            if (p != NULL) {
     1857                raidrec->stripesize = atoi(p);
    18361858            }
     1859            mr_free(p);
    18371860        } else if ((b_res == bAlloc) || (b_res == unallocListbox)) {
    18381861            if (currline_u <= unallocparts->entries)
     
    18681891
    18691892    /** buffers ***********************************************************/
    1870     char header[MAX_STR_LEN];
    1871     char comment[MAX_STR_LEN];
    1872     char sz_out[MAX_STR_LEN];
     1893    char *header = NULL;
     1894    char *comment = NULL;
     1895    char *sz_out = NULL;
     1896    char *p = NULL;
    18731897
    18741898    assert(raidrec != 0);
    18751899    assert(lino >= 0);
    18761900
    1877     strcpy(sz_out, raidrec->additional_vars.el[lino].value);
    1878     sprintf(header, "Edit %s", raidrec->additional_vars.el[lino].label);
    1879     sprintf(comment, "Please set %s's value (currently '%s')",
    1880             raidrec->additional_vars.el[lino].label, sz_out);
    1881     if (popup_and_get_string(header, comment, sz_out, MAX_STR_LEN)) {
    1882         strip_spaces(sz_out);
    1883         strcpy(raidrec->additional_vars.el[lino].value, sz_out);
    1884     }
     1901    mr_asprintf(&sz_out, "%s", raidrec->additional_vars.el[lino].value);
     1902    mr_asprintf(&header, "Edit %s", raidrec->additional_vars.el[lino].label);
     1903    mr_asprintf(&comment, "Please set %s's value (currently '%s')", raidrec->additional_vars.el[lino].label, sz_out);
     1904    p = popup_and_get_string(header, comment, sz_out);
     1905    if (p != NULL) {
     1906        mr_strip_spaces(p);
     1907        strcpy(raidrec->additional_vars.el[lino].value, p);
     1908    }
     1909    mr_free(p);
    18851910}
    18861911
     
    22422267 * @return TRUE if OK was pressed, FALSE otherwise.
    22432268 */
    2244 bool
    2245 get_isodir_info(char *isodir_device, char *isodir_format,
    2246                 char *isodir_path, bool nuke_me_please)
    2247 {
     2269bool get_isodir_info(char *isodir_device, char *isodir_format, char *isodir_path, bool nuke_me_please)
     2270{
     2271
     2272    char *p = NULL;
     2273    char *q = NULL;
     2274    char *r = NULL;
     2275    char *idev = NULL;
     2276    bool ret = FALSE;       /* Should be false by default, and modfiy if conditions respected */
    22482277
    22492278    /** initialize ********************************************************/
    22502279
    22512280    assert(isodir_device != NULL);
    2252     assert(isodir_format != NULL);
    22532281    assert(isodir_path != NULL);
    22542282
    22552283    log_it("isodir_path = %s", isodir_path);
    2256     isodir_format[0] = '\0';
    22572284    if (isodir_device[0] == '\0') {
    2258         strcpy(isodir_device, "/dev/");
    2259     }
     2285        mr_asprintf(&idev, "/dev/");
     2286    } else {
     2287        mr_asprintf(&idev, "%s", isodir_device);
     2288    }
     2289
    22602290    if (isodir_path[0] == '\0') {
    22612291        strcpy(isodir_path, "/");
    22622292    }
    22632293    if (does_file_exist("/tmp/NFS-SERVER-PATH")) {
    2264         strcpy(isodir_device, last_line_of_file("/tmp/NFS-SERVER-MOUNT"));
    2265         strcpy(isodir_format, "nfs");
     2294        mr_free(idev);
     2295        mr_asprintf(&idev, "%s", last_line_of_file("/tmp/NFS-SERVER-MOUNT"));
     2296        mr_asprintf(&isodir_format, "nfs");
    22662297        strcpy(isodir_path, last_line_of_file("/tmp/NFS-SERVER-PATH"));
    22672298    }
     2299
     2300    /* modify for the caller */
     2301    strcpy(isodir_device, idev);
    22682302    if (nuke_me_please) {
    2269         return (TRUE);
    2270     }
    2271 
    2272     if (popup_and_get_string
    2273         ("ISO Mode - device", "On what device do the ISO files live?",
    2274          isodir_device, MAX_STR_LEN / 4)) {
    2275         if (popup_and_get_string
    2276             ("ISO Mode - format",
    2277              "What is the disk format of the device? (Hit ENTER if you don't know.)",
    2278              isodir_format, 16)) {
    2279             if (popup_and_get_string
    2280                 ("ISO Mode - path",
    2281                  "At what path on this device can the ISO files be found?",
    2282                  isodir_path, MAX_STR_LEN / 4)) {
    2283                 strip_spaces(isodir_device);
    2284                 strip_spaces(isodir_format);
    2285                 strip_spaces(isodir_path);
    2286                 log_it("isodir_device = %s - isodir_format = %s - isodir_path = %s", isodir_device, isodir_format, isodir_path);
    2287                 return (TRUE);
     2303        ret = TRUE;
     2304    } else {
     2305        p = popup_and_get_string("ISO Mode - device", "On what device do the ISO files live?", idev);
     2306        if (p != NULL) {
     2307            q = popup_and_get_string("ISO Mode - format", "What is the disk format of the device? (Hit ENTER if you don't know.)", isodir_format);
     2308            mr_free(isodir_format);
     2309   
     2310            if (q != NULL) {
     2311                r = popup_and_get_string("ISO Mode - path", "At what path on this device can the ISO files be found?", isodir_path);
     2312                if (r != NULL) {
     2313                    mr_strip_spaces(p);
     2314                    mr_strip_spaces(q);
     2315                    mr_strip_spaces(r);
     2316
     2317                    isodir_format = q;
     2318   
     2319                    /* modify for the caller */
     2320                    strcpy(isodir_device, p);
     2321                    strcpy(isodir_path, r);
     2322                    log_it("isodir_device = %s - isodir_format = %s - isodir_path = %s", isodir_device, isodir_format, isodir_path);
     2323                    mr_free(r);
     2324   
     2325                    ret = TRUE;
     2326                }
    22882327            }
    22892328        }
    2290     }
    2291     return (FALSE);
     2329        mr_free(p);
     2330    }
     2331    mr_free(idev);
     2332    mr_free(isodir_format);
     2333    return(ret);
    22922334}
    22932335
     
    27002742    /** buffers **********************************************************/
    27012743    void *keylist[ARBITRARY_MAXIMUM];
    2702     char *tmp;
    2703     char *help_text;
    2704     char *title_of_window;
    2705     char *sz_res;
    2706     char *header_text;
     2744    char *tmp = NULL;
     2745    char *help_text = NULL;
     2746    char *title_of_window = NULL;
     2747    char *sz_res = NULL;
     2748    char *header_text = NULL;
     2749    char *p = NULL;
    27072750
    27082751  /** int **************************************************************/
     
    27172760
    27182761    log_it("malloc'ing");
    2719     malloc_string(tmp);
    2720     malloc_string(help_text);
    2721     malloc_string(title_of_window);
    2722     malloc_string(sz_res);
    2723     malloc_string(header_text);
    2724     if (!(bkp_raidrec = malloc(sizeof(struct raid_device_record)))) {
    2725         fatal_error("Cannot malloc space for raidrec");
    2726     }
    2727     if (!(bkp_disklist = malloc(sizeof(struct list_of_disks)))) {
    2728         fatal_error("Cannot malloc space for disklist");
    2729     }
    2730     if (!(bkp_raidlist = malloc(sizeof(struct raidlist_itself)))) {
    2731         fatal_error("Cannot malloc space for raidlist");
    2732     }
    2733     if (!
    2734         (unallocated_raid_partitions =
    2735          malloc(sizeof(struct mountlist_itself)))) {
    2736         fatal_error("Cannot malloc space for unallocated_raid_partitions");
    2737     }
    2738 
    2739     memcpy((void *) bkp_raidlist, (void *) raidlist,
    2740            sizeof(struct raidlist_itself));
    2741     memcpy((void *) bkp_raidrec, (void *) raidrec,
    2742            sizeof(struct raid_device_record));
    2743     memcpy((void *) bkp_disklist, (void *) disklist,
    2744            sizeof(struct list_of_disks));
     2762    bkp_raidrec = mr_malloc(sizeof(struct raid_device_record));
     2763    bkp_disklist = mr_malloc(sizeof(struct list_of_disks));
     2764    bkp_raidlist = mr_malloc(sizeof(struct raidlist_itself));
     2765    unallocated_raid_partitions = mr_malloc(sizeof(struct mountlist_itself));
     2766
     2767    memcpy((void *) bkp_raidlist, (void *) raidlist, sizeof(struct raidlist_itself));
     2768    memcpy((void *) bkp_raidrec, (void *) raidrec, sizeof(struct raid_device_record));
     2769    memcpy((void *) bkp_disklist, (void *) disklist, sizeof(struct list_of_disks));
    27452770
    27462771    log_it("Post-malloc");
    2747     strcpy(help_text,
    2748            "   Edit this RAID device's list of partitions. Choose OK or Cancel when done.");
    2749     sprintf(header_text, "%-24s    %s", "Device", "Index");
    2750     sprintf(title_of_window, "%s contains...", raidrec->raid_device);
     2772    mr_asprintf(&help_text, "   Edit this RAID device's list of partitions. Choose OK or Cancel when done.");
     2773    mr_asprintf(&header_text, "%-24s    %s", "Device", "Index");
     2774    mr_asprintf(&title_of_window, "%s contains...", raidrec->raid_device);
    27512775    newtPushHelpLine(help_text);
    27522776    for (b_res = (newtComponent) 12345; b_res != bOK && b_res != bCancel;) {
     
    28032827                    redraw_disklist(disklist, keylist, partitionsListbox);
    28042828                } else {
    2805                     sprintf(tmp, "%s's index is %d. What should it be?",
    2806                             raidrec->raid_device,
    2807                             disklist->el[currline].index);
    2808                     sprintf(sz_res, "%d", disklist->el[currline].index);
    2809                     if (popup_and_get_string("Set index", tmp, sz_res, 10)) {
     2829                    mr_asprintf(&tmp, "%s's index is %d. What should it be?", raidrec->raid_device, disklist->el[currline].index);
     2830                    mr_asprintf(&sz_res, "%d", disklist->el[currline].index);
     2831                    p = popup_and_get_string("Set index", tmp, sz_res);
     2832                    mr_free(tmp);
     2833                    if (p != NULL) {
    28102834                        disklist->el[currline].index = atoi(sz_res);
    28112835                    }
    28122836                    redraw_disklist(disklist, keylist, partitionsListbox);
     2837                    mr_free(sz_res);
    28132838                }
    28142839            }
     
    28182843    }
    28192844    newtPopHelpLine();
     2845    mr_free(help_text);
     2846    mr_free(header_text);
     2847    mr_free(title_of_window);
     2848
    28202849    if (b_res == bCancel) {
    2821         memcpy((void *) raidlist, (void *) bkp_raidlist,
    2822                sizeof(struct raidlist_itself));
    2823         memcpy((void *) raidrec, (void *) bkp_raidrec,
    2824                sizeof(struct raid_device_record));
    2825         memcpy((void *) disklist, (void *) bkp_disklist,
    2826                sizeof(struct list_of_disks));
    2827     }
    2828     paranoid_free(tmp);
    2829     paranoid_free(help_text);
    2830     paranoid_free(title_of_window);
    2831     paranoid_free(sz_res);
    2832     paranoid_free(header_text);
    2833     paranoid_free(bkp_raidrec);
    2834     paranoid_free(bkp_disklist);
    2835     paranoid_free(bkp_raidlist);
    2836     paranoid_free(unallocated_raid_partitions);
     2850        memcpy((void *) raidlist, (void *) bkp_raidlist, sizeof(struct raidlist_itself));
     2851        memcpy((void *) raidrec, (void *) bkp_raidrec, sizeof(struct raid_device_record));
     2852        memcpy((void *) disklist, (void *) bkp_disklist, sizeof(struct list_of_disks));
     2853    }
     2854    mr_free(bkp_raidrec);
     2855    mr_free(bkp_disklist);
     2856    mr_free(bkp_raidlist);
     2857    mr_free(unallocated_raid_partitions);
    28372858}
    28382859#endif
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.h

    r2202 r2316  
    159159void open_progress_form(char *, char *, char *, char *, long);
    160160void popup_and_OK(char *);
    161 bool popup_and_get_string(char *, char *, char *, int);
     161char *popup_and_get_string(char *, char *, char *);
    162162bool popup_with_buttons(char *, char *, char *);
    163163void redraw_disklist(struct list_of_disks *, void *keylist[],
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2296 r2316  
    4242*/
    4343extern char *g_isodir_device;
    44 extern char *g_isodir_format;
    4544extern long g_current_progress, g_maximum_progress;
    4645extern char *g_biggielist_txt;  // where 'biggielist.txt' is stored, on ramdisk / tempdir;
     
    9695*/
    9796paranoid_free(g_isodir_device);
    98 paranoid_free(g_isodir_format);
    9997
    10098}
     
    264262    int retval = 0, i;
    265263    bool already_mounted = FALSE;
     264    char *isodir_format = NULL;
    266265
    267266assert(bkpinfo != NULL);
     
    281280}
    282281
    283 if (!get_isodir_info(g_isodir_device, g_isodir_format, bkpinfo->isodir, nuke_me_please)) {
     282if (!get_isodir_info(g_isodir_device, isodir_format, bkpinfo->isodir, nuke_me_please)) {
     283    mr_free(isodir_format);
    284284    return (1);
    285285}
     
    291291} else {
    292292    mr_asprintf(&mount_isodir_command, "mount %s", g_isodir_device);
    293     if (strlen(g_isodir_format) > 1) {
    294         mr_strcat(mount_isodir_command, " -t %s", g_isodir_format);
    295     }
     293    if (isodir_format) {
     294        mr_strcat(mount_isodir_command, " -t %s", isodir_format);
     295    }
     296
    296297    mr_strcat(mount_isodir_command, " -o ro %s", bkpinfo->isodir);
    297298    run_program_and_log_output("df -m", FALSE);
     
    308309    ("I have mounted the device where the ISO files are stored.");
    309310}
     311mr_free(isodir_format);
     312
    310313if (!IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    311314    mount_media();
     
    14261429  /** malloc **/
    14271430    char *command = NULL;
    1428     char *boot_device;
     1431    char *boot_device = NULL;
    14291432    char *rootdev;
    14301433    char *rootdrive;
     
    14321435    char *tmp = NULL;
    14331436    char *editor;
    1434 
    1435     int res;
    1436     int done;
    1437 
    1438     malloc_string(boot_device);
     1437    char *p = NULL;
     1438
     1439    int res = 0;
     1440    bool done;
     1441
    14391442    malloc_string(editor);
    14401443    malloc_string(rootdev);
     
    14431446    assert_string_is_neither_NULL_nor_zerolength(bd);
    14441447    strcpy(editor, find_my_editor());
    1445     strcpy(boot_device, bd);
     1448    mr_asprintf(&boot_device, "%s", bd);
    14461449
    14471450    if (offer_to_run_stabgrub
    1448         && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?"))
     1451        && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) {
    14491452        /* interactive mode */
    1450     {
    14511453        mvaddstr_and_log_it(g_currentY,
    14521454                            0,
    14531455                            "Modifying fstab, mtab, device.map and menu.lst, and running GRUB...                             ");
    14541456        for (done = FALSE; !done;) {
    1455             popup_and_get_string("Boot device",
    1456                                  "Please confirm/enter the boot device. If in doubt, try /dev/hda",
    1457                                  boot_device, MAX_STR_LEN / 4);
    1458             mr_asprintf(&command, "stabgrub-me %s", boot_device);
     1457            p = popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device);
     1458            if (p == NULL) {
     1459                done = TRUE;
     1460                mr_free(p);
     1461                /* we want some warnings later on */
     1462                res = 1;
     1463                continue;
     1464            }
     1465            mr_asprintf(&command, "stabgrub-me %s", p);
     1466            mr_free(p);
     1467
    14591468            res = run_program_and_log_output(command, 1);
    14601469            mr_free(command);
     
    14941503            }
    14951504        }
    1496     } else
     1505    } else {
    14971506        /* nuke mode */
    1498     {
    14991507        if (!run_program_and_log_output("which grub-MR", FALSE)) {
    15001508            log_msg(1, "Yay! grub-MR found...");
     
    15211529        }
    15221530    }
     1531    mr_free(boot_device);
     1532
    15231533    if (res) {
    15241534        mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
     
    15401550    paranoid_free(rootdrive);
    15411551    paranoid_free(conffile);
    1542     paranoid_free(boot_device);
    15431552    paranoid_free(editor);
    15441553
     
    17441753  /** malloc **/
    17451754    char *command = NULL;
    1746     char *boot_device;
     1755    char *boot_device = NULL;
    17471756    char *tmp = NULL;
    17481757    char *editor;
     1758    char *p = NULL;
    17491759    int res;
    17501760    int done;
    17511761
    1752     malloc_string(boot_device);
    17531762    malloc_string(editor);
    17541763    assert_string_is_neither_NULL_nor_zerolength(bd);
    17551764
    17561765    strcpy(editor, find_my_editor());
    1757     strcpy(boot_device, bd);
     1766    mr_asprintf(&boot_device, "%s", bd);
    17581767
    17591768    if (offer_to_hack_scripts
    1760         && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?"))
     1769        && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) {
    17611770        /* interactive mode */
    1762     {
    17631771        mvaddstr_and_log_it(g_currentY, 0,
    17641772                            "Modifying fstab and restoring MBR...                           ");
     
    17761784                }
    17771785            }
    1778             popup_and_get_string("Boot device",
    1779                                  "Please confirm/enter the boot device. If in doubt, try /dev/hda",
    1780                                  boot_device, MAX_STR_LEN / 4);
    1781             mr_asprintf(&command, "stabraw-me %s", boot_device);
     1786            p = popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device);
     1787            if (p == NULL) {
     1788                done = TRUE;
     1789                mr_free(p);
     1790                /* we want some warnings later on */
     1791                res = 1;
     1792                continue;
     1793            }
     1794            mr_asprintf(&command, "stabraw-me %s", p);
     1795            mr_free(p);
     1796
    17821797            res = run_program_and_log_output(command, 3);
    17831798            mr_free(command);
     
    17891804            }
    17901805        }
    1791     } else
     1806    } else {
    17921807        /* nuke mode */
    1793     {
    17941808        mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", boot_device);
    17951809        log_msg(2, "run_raw_mbr() --- command='%s'", command);
     
    18001814        mr_free(command);
    18011815    }
     1816    mr_free(boot_device);
    18021817
    18031818    if (res) {
     
    18081823        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    18091824    }
    1810     paranoid_free(boot_device);
    18111825    paranoid_free(editor);
    18121826    return (res);
     
    18391853    malloc_string(g_mondo_home);
    18401854    malloc_string(g_isodir_device);
    1841     malloc_string(g_isodir_format);
    18421855
    18431856    temppath = bkpinfo->tmpdir;
  • branches/2.2.10/mondo/src/mondorestore/mondoprep.h

    r2281 r2316  
    3333extern void close_progress_form(void);
    3434extern void popup_and_OK(char *);
    35 extern bool popup_and_get_string(char *, char *, char *, int);
     35extern char *popup_and_get_string(char *, char *, char *);
    3636extern long get_time(void);
    3737extern bool is_this_device_mounted(char *);
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2296 r2316  
    439439  /** needs malloc **********/
    440440    char *tmp;
     441    char *p = NULL;
    441442    char *tmp1 = NULL;
    442443    char *fstab_fname;
     
    470471    read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
    471472    log_it("Done loading config file; resizing ML");
    472     if (bkpinfo->backup_media_type == nfs) {
    473         strcpy(tmp, bkpinfo->prefix);
    474         if (popup_and_get_string
    475             ("Prefix", "Prefix of your ISO images ?", tmp, MAX_STR_LEN / 4)) {
    476             strcpy(bkpinfo->prefix, tmp);
    477             log_msg(1, "Prefix set to %s",bkpinfo->prefix);
    478         }
    479     }
    480473
    481474#ifdef __FreeBSD__
     
    607600              gotos_suck:
    608601                strcpy(tmp, old_restpath);
    609 // (NB: %s is where your filesystem is mounted now, by default)", MNT_RESTORING);
    610                 if (popup_and_get_string
    611                     ("Restore path", "Restore files to where?", tmp,
    612                      MAX_STR_LEN / 4)) {
     602                // (NB: %s is where your filesystem is mounted now, by default)", MNT_RESTORING);
     603                p = popup_and_get_string("Restore path", "Restore files to where?", tmp);
     604                if (p != NULL) {
     605                    strcpy(tmp, p);
    613606                    if (!strcmp(tmp, "/")) {
    614607                        if (!ask_me_yes_or_no("Are you sure?")) {
     
    625618                    free_filelist(filelist);
    626619                }
     620                mr_free(p);
     621
    627622                if (!ask_me_yes_or_no
    628623                    ("Restore another subset of your backup?")) {
     
    952947  /** malloc **/
    953948    char *old_restpath;
     949    char *p = NULL;
    954950
    955951    struct mountlist_itself *mountlist = NULL;
     
    997993        save_filelist(filelist, "/tmp/selected-files.txt");
    998994        strcpy(old_restpath, bkpinfo->restore_path);
    999         if (popup_and_get_string("Restore path",
    1000                                  "Restore files to where? )",
    1001                                  bkpinfo->restore_path, MAX_STR_LEN / 4)) {
     995        p = popup_and_get_string("Restore path", "Restore files to where? )", bkpinfo->restore_path);
     996        if (p != NULL) {
     997            strcpy(bkpinfo->restore_path, p);
     998            mr_free(p);
     999
    10021000            log_it("Restoring everything");
    10031001            retval += restore_everything(filelist);
  • branches/2.2.10/mondo/src/mondorestore/mr-externs.h

    r2281 r2316  
    5959extern int partition_everything(struct mountlist_itself *);
    6060extern void popup_and_OK(char *);
    61 extern bool popup_and_get_string(char *, char *, char *, int);
     61extern char *popup_and_get_string(char *, char *, char *);
    6262extern void setup_newt_stuff(void);
    6363extern void reset_bkpinfo();
  • branches/2.2.10/tools/quality

    r2312 r2316  
    4949cat /tmp/mondo.quality
    5050echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` mr_asprintf without \""
     51find . -name '*.c' -o -name '*.h' |  egrep -v '\.svn|/\*|monitas|/\*|mindi-busybox' | xargs grep -rw mr_getline | egrep -v '/\*' | egrep -v 'mr_getline\(&' > /tmp/mondo.quality
     52cat /tmp/mondo.quality
     53echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` mr_getline without &"
     54
    5155echo " "
    5256echo "Splint: "
Note: See TracChangeset for help on using the changeset viewer.