Changeset 2316 in MondoRescue for branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
- Timestamp:
- Aug 18, 2009, 2:34:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2299 r2316 1457 1457 1458 1458 /** buffers *********************************************************/ 1459 char *device_str ;1459 char *device_str = NULL; 1460 1460 char *format; 1461 1461 char *tmp = NULL; … … 1466 1466 assert_string_is_neither_NULL_nor_zerolength(drivename); 1467 1467 1468 malloc_string(device_str);1469 1468 malloc_string(format); 1470 1469 … … 1483 1482 if (!pout_to_fdisk) { 1484 1483 log_to_screen("Cannot call parted2fdisk to configure %s", drivename); 1485 paranoid_free(device_str);1486 1484 paranoid_free(format); 1487 1485 return (1); … … 1489 1487 #endif 1490 1488 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); 1492 1490 lino = find_device_in_mountlist(mountlist, device_str); 1493 1491 … … 1518 1516 } 1519 1517 mr_free(command); 1520 paranoid_free(device_str);1518 mr_free(device_str); 1521 1519 paranoid_free(format); 1522 1520 return r; … … 1547 1545 } 1548 1546 } else { 1547 mr_free(device_str); 1549 1548 continue; 1550 1549 } 1551 1550 #else 1551 mr_free(device_str); 1552 1552 continue; 1553 1553 #endif … … 1606 1606 log_to_screen 1607 1607 ("You must leave at least one partition spare as the Extended partition."); 1608 paranoid_free(device_str);1608 mr_free(device_str); 1609 1609 paranoid_free(format); 1610 1610 return (1); … … 1627 1627 } 1628 1628 #endif 1629 mr_free(device_str); 1629 1630 1630 1631 previous_devno = current_devno; … … 1666 1667 } 1667 1668 } 1668 paranoid_free(device_str);1669 1669 paranoid_free(format); 1670 1670 return (retval); … … 1690 1690 /** buffers **********************************************************/ 1691 1691 char *program = NULL; 1692 char *partition_name ;1692 char *partition_name = NULL; 1693 1693 char *tmp = NULL; 1694 1694 char *output = NULL; … … 1701 1701 /** end ***************************************************************/ 1702 1702 1703 malloc_string(partition_name);1704 1705 1703 assert_string_is_neither_NULL_nor_zerolength(drive); 1706 1704 assert(format != NULL); … … 1714 1712 mr_free(tmp); 1715 1713 1716 paranoid_free(partition_name);1717 1714 return (0); 1718 1715 } 1719 build_partition_name(partition_name,drive, partno);1716 partition_name = build_partition_name(drive, partno); 1720 1717 if (partsize <= 0) { 1721 1718 mr_asprintf(&tmp, "Partitioning device %s (max size)", partition_name); … … 1731 1728 log_to_screen(tmp); 1732 1729 mr_free(tmp); 1733 paranoid_free(partition_name);1730 mr_free(partition_name); 1734 1731 return (1); 1735 1732 } … … 1749 1746 if (partno == 5) { 1750 1747 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); 1754 1750 paranoid_free(output); 1755 1751 return (1); … … 1776 1772 log_it(tmp); 1777 1773 mr_free(tmp); 1774 1778 1775 log_it("---fdisk command---"); 1779 1776 log_it(output); … … 1867 1864 } 1868 1865 mr_free(program); 1866 mr_free(partition_name); 1869 1867 paranoid_free(output); 1870 1868 1871 1869 g_current_progress++; 1872 1870 log_it("partition_device() --- leaving"); 1873 paranoid_free(partition_name);1874 1871 return (retval); 1875 1872 } … … 1979 1976 { 1980 1977 /** buffers *********************************************************/ 1981 char *partition ;1978 char *partition = NULL; 1982 1979 char *command = NULL; 1983 1980 char *output = NULL; 1984 1981 char *tmp = NULL; 1985 char *partcode ;1982 char *partcode = NULL; 1986 1983 1987 1984 /** pointers *********************************************************/ … … 1997 1994 assert(format != NULL); 1998 1995 1999 malloc_string(partition); 2000 malloc_string(partcode); 2001 2002 build_partition_name(partition, drive, partno); 1996 partition = build_partition_name(drive, partno); 2003 1997 p = (char *) strrchr(partition, '/'); 2004 1998 if (strcmp(format, "swap") == 0) { 2005 strcpy(partcode, "82");1999 mr_asprintf(&partcode, "82"); 2006 2000 } else if (strcmp(format, "vfat") == 0) { 2007 2001 if (partsize / 1024 > 8192) { 2008 strcpy(partcode, "c");2002 mr_asprintf(&partcode, "c"); 2009 2003 } else { 2010 strcpy(partcode, "b");2004 mr_asprintf(&partcode, "b"); 2011 2005 } 2012 2006 } else if (strcmp(format, "ext2") == 0 … … 2016 2010 || strcmp(format, "xfs") == 0 2017 2011 || strcmp(format, "jfs") == 0) { 2018 strcpy(partcode, "83");2012 mr_asprintf(&partcode, "83"); 2019 2013 } else if (strcmp(format, "minix") == 0) { 2020 strcpy(partcode, "81");2014 mr_asprintf(&partcode, "81"); 2021 2015 } else if (strcmp(format, "vmfs3") == 0) { 2022 strcpy(partcode, "fb");2016 mr_asprintf(&partcode, "fb"); 2023 2017 } else if (strcmp(format, "vmkcore") == 0) { 2024 strcpy(partcode, "fc");2018 mr_asprintf(&partcode, "fc"); 2025 2019 } else if (strcmp(format, "raid") == 0) { 2026 strcpy(partcode, "fd");2020 mr_asprintf(&partcode, "fd"); 2027 2021 } else if (strcmp(format, "ntfs") == 0) { 2028 strcpy(partcode, "7");2022 mr_asprintf(&partcode, "7"); 2029 2023 } else if ((strcmp(format, "ufs") == 0) 2030 2024 || (strcmp(format, "ffs") == 0)) { /* raid autodetect */ 2031 strcpy(partcode, "a5");2025 mr_asprintf(&partcode, "a5"); 2032 2026 } else if (strcmp(format, "lvm") == 0) { 2033 strcpy(partcode, "8e");2027 mr_asprintf(&partcode, "8e"); 2034 2028 } else if (format[0] == '\0') { /* LVM physical partition */ 2035 partcode[0] = '\0';2029 mr_asprintf(&partcode, ""); 2036 2030 } else if (strlen(format) >= 1 && strlen(format) <= 2) { 2037 strcpy(partcode, format);2031 mr_asprintf(&partcode, format); 2038 2032 } else { 2039 2033 /* probably an image */ … … 2042 2036 mr_free(tmp); 2043 2037 #ifdef __FreeBSD__ 2044 strcpy(partcode, format); // was a52038 mr_asprintf(&partcode, format); // was a5 2045 2039 #else 2046 strcpy(partcode, format); // was 832040 mr_asprintf(&partcode, format); // was 83 2047 2041 #endif 2048 2042 } 2049 2043 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 */ 2051 2047 2052 2048 if (pout_to_fdisk) { … … 2104 2100 } 2105 2101 2106 paranoid_free(partition); 2107 paranoid_free(partcode); 2108 2102 mr_free(partcode); 2109 2103 return (res); 2110 2104 }
Note:
See TracChangeset
for help on using the changeset viewer.