Changeset 2316 in MondoRescue for branches/2.2.10/mondo/src/common
- Timestamp:
- Aug 18, 2009, 2:34:29 PM (16 years ago)
- Location:
- branches/2.2.10/mondo/src/common
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2303 r2316 1281 1281 && (flag_set['c'] || flag_set['w'] || flag_set['C'])) { 1282 1282 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) { 1286 1285 retval++; 1287 1286 log_to_screen("User opted to cancel."); 1288 1287 } 1288 mr_free(tmp2); 1289 1289 } else if (find_cdrw_device(bkpinfo->media_device)) { 1290 1290 retval++; -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2306 r2316 323 323 char *incoming; 324 324 char *searchstr = NULL; 325 char *tmp ;325 char *tmp = NULL; 326 326 327 327 /*@ ints ******************************************************* */ … … 337 337 338 338 malloc_string(incoming); 339 malloc_string(searchstr);340 malloc_string(tmp);341 339 342 340 #ifdef __FreeBSD__ 343 341 // 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 345 346 res = system(program); 346 347 mr_free(program); 347 348 return (res); 348 349 #else 349 tmp[0] = '\0'; 350 /* To avoid compiler warnings */ 351 tmp = NULL; 350 352 #endif 351 353 … … 360 362 mr_free(program); 361 363 362 (void) build_partition_name(searchstr,drive, partno);363 strcat(searchstr, " ");364 searchstr = build_partition_name(drive, partno); 365 mr_strcat(searchstr, " "); 364 366 for (res = 0; !res && fgets(incoming, MAX_STR_LEN - 1, fin);) { 365 367 if (strstr(incoming, searchstr)) { … … 367 369 } 368 370 } 371 mr_free(searchstr); 372 369 373 if (pclose(fin)) { 370 374 log_OS_error("Cannot pclose fin"); 371 375 } 372 376 paranoid_free(incoming); 373 paranoid_free(searchstr);374 paranoid_free(tmp);375 377 return (res); 376 378 } … … 448 450 int res; 449 451 char *dev; 452 char *p = NULL; 450 453 451 454 /*@ end vars **************************************************** */ … … 472 475 473 476 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) { 477 479 res = 1; 478 480 } else { 479 res = mount_CDROM_here(dev, mountpoint); 480 } 481 res = mount_CDROM_here(p, mountpoint); 482 } 483 mr_free(p); 481 484 } 482 485 if (res) { … … 1025 1028 FILE *pin; 1026 1029 int retval; 1027 malloc_string(good_formats);1028 1030 1029 1031 assert_string_is_neither_NULL_nor_zerolength(format); … … 1044 1046 retval = 0; 1045 1047 } else { 1046 strcpy(good_formats, " "); 1047 (void) fgets(good_formats + 1, MAX_STR_LEN - 1, pin); 1048 mr_getline(&good_formats, pin); 1048 1049 if (pclose(pin)) { 1049 1050 log_OS_error("Cannot pclose good formats"); 1050 1051 } 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? :) 1053 1054 if (strstr(good_formats, format_sz)) { 1054 1055 retval = 1; … … 1056 1057 retval = 0; 1057 1058 } 1059 mr_free(good_formats); 1058 1060 } 1059 1061 mr_free(format_sz); 1060 1062 1061 paranoid_free(good_formats);1062 1063 return (retval); 1063 1064 } … … 1445 1446 { 1446 1447 char *tmp = NULL; 1447 char * tmp1= NULL;1448 char *p = NULL; 1448 1449 char *mds = NULL; 1449 1450 char *sz_size = NULL; … … 1455 1456 1456 1457 malloc_string(prompt); 1457 malloc_string(sz_size);1458 1458 malloc_string(tmp1); 1459 1459 assert(bkpinfo != NULL); … … 1514 1514 find_dvd_device(bkpinfo->media_device, FALSE); 1515 1515 strcpy(tmp1, "1"); 1516 sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB1516 mr_asprintf(&sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB 1517 1517 log_msg(1, "Setting to DVD defaults"); 1518 1518 } else { 1519 1519 strcpy(bkpinfo->media_device, VANILLA_SCSI_CDROM); 1520 1520 strcpy(tmp1, "4"); 1521 sprintf(sz_size, "%d", 650);1521 mr_asprintf(&sz_size, "%d", 650); 1522 1522 log_msg(1, "Setting to CD defaults"); 1523 1523 } 1524 1524 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) { 1526 1529 log_to_screen("User has chosen not to backup the PC"); 1527 1530 mr_free(comment); 1528 1531 finish(1); 1529 1532 } 1533 /* tmp now has the new value given by the user */ 1534 tmp = p; 1530 1535 } 1531 1536 mr_free(comment); … … 1535 1540 mr_asprintf(&comment, "How much data (in Megabytes) will each %s store?", mds); 1536 1541 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) { 1539 1547 log_to_screen("User has chosen not to backup the PC"); 1540 1548 finish(1); 1541 1549 } 1542 mr_free(comment);1550 sz_size = p; 1543 1551 1544 1552 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { … … 1571 1579 bkpinfo->media_device); 1572 1580 mr_asprintf(&comment, "Please specify your %s drive's /dev entry", mds); 1573 if (!popup_and_get_string1574 ("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) { 1577 1585 log_to_screen("User has chosen not to backup the PC"); 1578 1586 finish(1); 1579 1587 } 1580 mr_free(comment); 1588 strcpy(bkpinfo->media_device, p); 1589 mr_free(p); 1581 1590 } 1582 1591 log_msg(2, "%s device found at %s", mds, bkpinfo->media_device); … … 1598 1607 if (!bkpinfo->media_device[0]) { 1599 1608 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); 1604 1610 } else { 1605 1611 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); 1610 1613 } 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); 1615 1615 } 1616 1616 } 1617 if ( !i) {1617 if (p == NULL) { 1618 1618 log_to_screen("User has chosen not to backup the PC"); 1619 1619 finish(1); 1620 1620 } 1621 strcpy(bkpinfo->media_device, p); 1622 mr_free(p); 1621 1623 } 1622 1624 } … … 1664 1666 } 1665 1667 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) { 1670 1670 log_to_screen("User has chosen not to backup the PC"); 1671 1671 finish(1); 1672 1672 } 1673 strcpy(bkpinfo->media_device, p); 1674 mr_free(p); 1673 1675 } 1674 1676 mr_asprintf(&tmp, "ls -l %s", bkpinfo->media_device); … … 1716 1718 #endif 1717 1719 { 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) { 1722 1722 log_to_screen("User has chosen not to backup the PC"); 1723 1723 finish(1); 1724 1724 } 1725 strcpy(bkpinfo->nfs_mount, p); 1726 mr_free(p); 1725 1727 if (!bkpinfo->restore_data) { 1726 1728 if ((bkpinfo->compression_level = … … 1743 1745 if (!bkpinfo->restore_data) { 1744 1746 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) { 1747 1751 log_to_screen("User has chosen not to backup the PC"); 1748 1752 finish(1); 1749 1753 } 1750 mr_free(comment);1751 1754 } else { 1752 strcpy(sz_size, "0");1755 mr_asprintf(&sz_size, "0"); 1753 1756 } 1754 1757 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { 1755 1758 bkpinfo->media_size[i] = atoi(sz_size); 1756 1759 } 1760 mr_free(sz_size); 1757 1761 if (bkpinfo->media_size[0] < 0) { 1758 1762 log_to_screen("User has chosen not to backup the PC"); … … 1765 1769 mr_free(command); 1766 1770 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) { 1770 1773 log_to_screen("User has chosen not to backup the PC"); 1771 1774 finish(1); 1772 1775 } 1776 strcpy(bkpinfo->nfs_mount, p); 1777 mr_free(p); 1773 1778 } 1774 1779 /* Initiate bkpinfo isodir path from running environment if mount already done */ … … 1795 1800 finish(1); 1796 1801 } 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) { 1801 1804 log_to_screen("User has chosen not to backup the PC"); 1802 1805 finish(1); 1803 1806 } 1804 strcpy(bkpinfo->nfs_remote_dir, tmp1); 1807 strcpy(bkpinfo->nfs_remote_dir, p); 1808 mr_free(p); 1805 1809 1806 1810 // check whether writable - we better remove surrounding spaces for this 1807 1811 strip_spaces(bkpinfo->nfs_remote_dir); 1808 1812 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) { 1813 1815 log_to_screen("User has chosen not to backup the PC"); 1814 1816 finish(1); 1815 1817 } 1816 1818 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); 1823 1823 log_msg(3, "isodir is still %s", bkpinfo->isodir); 1824 1824 break; … … 1826 1826 case iso: 1827 1827 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) { 1832 1830 log_to_screen("User has chosen not to backup the PC"); 1833 1831 finish(1); 1834 1832 } 1833 strcpy(bkpinfo->isodir,p); 1834 mr_free(p); 1835 1835 1836 if (archiving_to_media) { 1836 1837 if ((bkpinfo->compression_level = … … 1839 1840 finish(1); 1840 1841 } 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) { 1845 1844 log_to_screen("User has chosen not to backup the PC"); 1846 1845 finish(1); 1847 1846 } 1848 1847 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { 1849 bkpinfo->media_size[i] = atoi( sz_size);1848 bkpinfo->media_size[i] = atoi(p); 1850 1849 } 1850 mr_free(p); 1851 1851 } else { 1852 1852 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { … … 1855 1855 } 1856 1856 } 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) { 1861 1859 log_to_screen("User has chosen not to backup the PC"); 1862 1860 finish(1); 1863 1861 } 1862 strcpy(bkpinfo->prefix, p); 1863 mr_free(p); 1864 1864 log_msg(3, "prefix set to %s", bkpinfo->prefix); 1865 1865 break; … … 1885 1885 1886 1886 #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) { 1891 1889 log_to_screen("User has chosen not to backup the PC"); 1892 1890 finish(1); 1893 1891 } 1892 strcpy(bkpinfo->boot_device, p); 1893 mr_free(p); 1894 1894 i = which_boot_loader(bkpinfo->boot_device); 1895 1895 #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) { 1900 1898 log_to_screen("User has chosen not to backup the PC"); 1901 1899 finish(1); 1902 1900 } 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")) { 1905 1905 i = 'L'; 1906 1906 } 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")) { 1909 1908 i = 'E'; 1910 1909 } 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")) { 1913 1911 i = 'G'; 1914 1912 } else { … … 1930 1928 bkpinfo->boot_loader = i; 1931 1929 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) { 1936 1932 log_to_screen("User has chosen not to backup the PC"); 1937 1933 finish(1); 1938 1934 } 1935 strcpy(bkpinfo->include_paths, p); 1936 mr_free(p); 1937 1939 1938 mr_asprintf(&tmp, "%s", list_of_NFS_mounts_only()); 1940 1939 if (strlen(tmp) > 2) { … … 1948 1947 strcpy(tmp1, call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'")); 1949 1948 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) { 1954 1952 log_to_screen("User has chosen not to backup the PC"); 1955 1953 finish(1); 1956 1954 } 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) { 1965 1962 log_to_screen("User has chosen not to backup the PC"); 1966 1963 finish(1); 1967 1964 } 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) { 1972 1970 log_to_screen("User has chosen not to backup the PC"); 1973 1971 finish(1); 1974 1972 } 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) { 1979 1978 log_to_screen("User has chosen not to backup the PC"); 1980 1979 finish(1); 1981 1980 } 1981 strcpy(bkpinfo->scratchdir, p); 1982 mr_free(p); 1983 1982 1984 // Interactive mode: 1983 1985 #ifdef __IA64__ -
branches/2.2.10/mondo/src/common/libmondo-files.c
r2296 r2316 306 306 return (1); 307 307 } 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); 317 313 mr_free(tmp); 314 315 log_it("User says kernel is at %s", kernel); 318 316 } 319 317 return (0); … … 1184 1182 } 1185 1183 1186 mr_asprintf( tmp, "%s/NFS-DEV", bkpinfo->tmpdir);1184 mr_asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir); 1187 1185 write_one_liner_data_file(tmp, nfs_dev); 1188 1186 mr_free(nfs_dev); 1189 1187 mr_free(tmp); 1190 1188 1191 mr_asprintf( tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);1189 mr_asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir); 1192 1190 write_one_liner_data_file(tmp, nfs_client_ipaddr); 1193 1191 mr_free(nfs_client_ipaddr); 1194 1192 mr_free(tmp); 1195 1193 1196 mr_asprintf( tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);1194 mr_asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir); 1197 1195 write_one_liner_data_file(tmp, nfs_client_netmask); 1198 1196 mr_free(nfs_client_netmask); 1199 1197 mr_free(tmp); 1200 1198 1201 mr_asprintf( tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);1199 mr_asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir); 1202 1200 write_one_liner_data_file(tmp, nfs_client_broadcast); 1203 1201 mr_free(nfs_client_broadcast); 1204 1202 mr_free(tmp); 1205 1203 1206 mr_asprintf( tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);1204 mr_asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir); 1207 1205 write_one_liner_data_file(tmp, nfs_client_defgw); 1208 1206 mr_free(nfs_client_defgw); 1209 1207 mr_free(tmp); 1210 1208 1211 mr_asprintf( tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);1209 mr_asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir); 1212 1210 write_one_liner_data_file(tmp, nfs_server_ipaddr); 1213 1211 mr_free(tmp); 1214 1212 mr_free(nfs_server_ipaddr); 1215 1213 1216 mr_asprintf( tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);1214 mr_asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir); 1217 1215 write_one_liner_data_file(tmp, bkpinfo->nfs_mount); 1218 1216 mr_free(tmp); 1219 1217 mr_free(nfs_mount); 1220 1218 1221 mr_asprintf( tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);1219 mr_asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir); 1222 1220 write_one_liner_data_file(tmp, bkpinfo->nfs_remote_dir); 1223 1221 mr_free(tmp); 1224 1222 1225 mr_asprintf( tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);1223 mr_asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir); 1226 1224 write_one_liner_data_file(tmp, bkpinfo->prefix); 1227 1225 mr_free(tmp); -
branches/2.2.10/mondo/src/common/libmondo-fork.c
r2315 r2316 248 248 char *callstr = NULL; 249 249 char incoming[MAX_STR_LEN * 2]; 250 char tmp[MAX_STR_LEN * 2];251 250 char *tmp1 = NULL; 252 char initial_label[MAX_STR_LEN * 2];253 251 254 252 /*@ int ********************************************************* */ 255 253 int res; 256 254 int i; 257 int len;258 255 bool log_if_failure = FALSE; 259 256 bool log_if_success = FALSE; … … 284 281 285 282 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);298 283 res = system(callstr); 299 284 if (((res == 0) && log_if_success) || ((res != 0) && log_if_failure)) { 300 285 log_msg(0, "running: %s", callstr); 301 log_msg(0, 302 "--------------------------------start of output-----------------------------"); 286 log_msg(0, "--------------------------------start of output-----------------------------"); 303 287 } 304 288 mr_free(callstr); -
branches/2.2.10/mondo/src/common/libmondo-mountlist.c
r2306 r2316 59 59 /*@ buffers ******************************************************** */ 60 60 char tmp = NULL; 61 char device[MAX_STR_LEN];61 char *device = NULL; 62 62 char mountpoint[MAX_STR_LEN]; 63 63 … … 90 90 /* check DD */ 91 91 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) { 94 94 foundsome = TRUE; 95 } 96 mr_free(device); 95 97 } 96 98 if (foundsome) { 97 99 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); 99 101 pos = find_device_in_mountlist(mountlist, device); 100 102 if (pos < 0) { 103 mr_free(device); 101 104 continue; 102 105 } … … 156 159 res++; 157 160 } 161 mr_free(device); 162 158 163 amount_allocated += mountlist->el[pos].size / 1024L; 159 164 prev_sp_no = cur_sp_no; … … 163 168 npos = pos = 0; 164 169 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); 166 171 pos = find_device_in_mountlist(mountlist, device); 167 172 npos = 0; 168 173 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) { 171 176 npos++; 172 } 177 } 178 mr_free(tmp); 179 } 180 mr_free(device); 181 173 182 if (((pos >= 0) || npos) && foundsome) { 174 183 mr_strcat(flaws_str, " %s has both DD and PC-style partitions.", drive); … … 176 185 } 177 186 178 build_partition_name(device,drive, curr_part_no);187 device = build_partition_name(drive, curr_part_no); 179 188 strcpy(mountpoint, mountlist->el[pos].mountpoint); 180 189 if (pos > 0 && !npos) { … … 256 265 /* Check subpartitions */ 257 266 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); 259 269 pos = find_device_in_mountlist(mountlist, device); 260 270 if (pos < 0) { … … 321 331 } 322 332 } 333 mr_free(device); 323 334 324 335 /* OK, continue with main loop */ … … 380 391 mr_asprintf(&flaws_str, "%s", ""); 381 392 382 malloc_string(device);383 393 prev_part_no = 0; 384 394 … … 391 401 log_msg(1, tmp); 392 402 mr_free(tmp); 393 goto endoffunc;403 return(flaws_str); 394 404 } else { 395 405 mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size); … … 399 409 400 410 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); 402 412 pos = find_device_in_mountlist(mountlist, device); 403 413 if (pos < 0) { … … 441 451 } 442 452 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); 445 454 if (!strstr(flaws_str, tmp)) { 446 455 log_it(tmp); … … 482 491 amount_allocated += mountlist->el[pos].size / 1024L; 483 492 prev_part_no = curr_part_no; 493 mr_free(device); 484 494 } 485 495 … … 499 509 mr_free(tmp); 500 510 } 501 502 endoffunc:503 paranoid_free(device);504 511 505 512 if (res) { -
branches/2.2.10/mondo/src/common/libmondo-string-EXT.h
r2315 r2316 3 3 */ 4 4 5 extern char *build_partition_name(char *partition, const char *drive, 6 int partno); 5 extern char *build_partition_name(const char *drive, int partno); 7 6 extern void center_string(char *in_out, int width); 8 7 extern char *commarize(char *); -
branches/2.2.10/mondo/src/common/libmondo-string.c
r2315 r2316 34 34 * @param drive The drive basename of the partition name (e.g. /dev/hda) 35 35 * @param partno The partition number (e.g. 1) 36 * @param partition Where to put the partition name (e.g. /dev/hda1)37 36 * @return @p partition. 38 37 * @note If @p drive ends in a digit, then 'p' (on Linux) or 's' (on *BSD) is added before @p partno. 39 38 */ 40 char *build_partition_name(c har *partition, const char *drive, int partno)41 { 42 char * p, *c;43 44 assert(partition != NULL); 39 char *build_partition_name(const char *drive, int partno) 40 { 41 char *c = NULL; 42 char *partition = NULL; 43 45 44 assert_string_is_neither_NULL_nor_zerolength(drive); 46 45 assert(partno >= 0); 47 46 48 p = strcpy(partition, drive);47 mr_asprintf(&partition, drive); 49 48 /* is this a devfs device path? */ 50 49 c = strrchr(partition, '/'); 51 50 if (c && strncmp(c, "/disc", 5) == 0) { 52 51 /* yup it's devfs, return the "part" path */ 52 /* This strcpy is safe */ 53 53 strcpy(c + 1, "part"); 54 p = c + 5;55 54 } else { 56 p += strlen(p); 57 if (isdigit(p[-1])) { 58 *p++ = 55 if (isdigit(partition[-1])) { 56 mr_strcat(partition, 59 57 #ifdef BSD 60 's' ;58 's'); 61 59 #else 62 'p' ;60 'p'); 63 61 #endif 64 62 } 65 63 } 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 } 80 67 81 68 -
branches/2.2.10/mondo/src/common/libmondo-string.h
r2315 r2316 3 3 */ 4 4 5 char *build_partition_name(c har *partition, const char *drive, int partno);5 char *build_partition_name(const char *drive, int partno); 6 6 void center_string(char *in_out, int width); 7 7 char *commarize(char *); -
branches/2.2.10/mondo/src/common/libmondo-verify.h
r1713 r2316 42 42 extern int openin_tape(); 43 43 extern void popup_and_OK(char *); 44 extern bool popup_and_get_string(char *, char *, char *, int);44 extern char *popup_and_get_string(char *, char *, char *); 45 45 extern int read_file_from_tape_to_file(char *, 46 46 long long); -
branches/2.2.10/mondo/src/common/newt-specific-EXT.h
r128 r2316 15 15 extern void log_to_screen(const char *fmt, ...); 16 16 extern void popup_and_OK(char *prompt); 17 extern bool popup_and_get_string(char *title, char *b, char *output, 18 int maxsize); 17 extern char *popup_and_get_string(char *title, char *b, char *input); 19 18 extern bool popup_with_buttons(char *p, char *button1, char *button2); 20 19 extern void refresh_log_screen(); -
branches/2.2.10/mondo/src/common/newt-specific.c
r2296 r2316 358 358 log_msg(0, fatalstr); 359 359 log_msg(0, error_string); 360 // popup_and_OK (error_string);361 360 newtFinished(); 362 361 } … … 400 399 finish(int signal) { 401 400 char *command = NULL; 402 403 /* if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */404 405 /* newtPopHelpLine(); */406 401 407 402 chdir("/"); … … 750 745 * @param title The title of the dialog box. 751 746 * @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) { 758 751 759 752 /*@ newt ************************************************************ */ … … 769 762 770 763 /*@ 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 776 767 assert_string_is_neither_NULL_nor_zerolength(title); 777 768 assert(b != NULL); 778 assert(output != NULL);779 769 780 770 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 } 785 778 if (output[strlen(output) - 1] == '\n') 786 779 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); 792 784 text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0); 793 strcpy(original_contents, output);794 output[0] = '\0';795 785 type_here = 796 786 newtEntry(2, newtTextboxGetNumLines(text) + 2, 797 original_contents, 50,787 input, 50, 798 788 #ifdef __cplusplus 799 789 0, NEWT_FLAG_RETURNEXIT … … 804 794 b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, " OK "); 805 795 b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel"); 806 // newtOpenWindow (8, 5, 54, newtTextboxGetNumLines (text) + 9, title);807 796 newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title); 808 797 myForm = newtForm(NULL, NULL, 0); … … 811 800 newtPushHelpLine(blurb); 812 801 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 } 814 806 newtPopHelpLine(); 815 807 newtFormDestroy(myForm); 816 808 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); 827 812 } 828 813 … … 1179 1164 } else { 1180 1165 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); 1182 1167 1183 1168 center_string(blurb1, 54); -
branches/2.2.10/mondo/src/common/newt-specific.h
r128 r2316 21 21 long max_val); 22 22 void popup_and_OK(char *prompt); 23 bool popup_and_get_string(char *title, char *b, char *output, int maxsize);23 char *popup_and_get_string(char *title, char *b, char *input); 24 24 bool popup_with_buttons(char *p, char *button1, char *button2); 25 25 void refresh_log_screen();
Note:
See TracChangeset
for help on using the changeset viewer.