diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-07-30 08:40:37 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-07-30 08:40:37 +0000 |
commit | 040f440262b4a435f21f85f782c2d97ecfd6a8e5 (patch) | |
tree | 5cceb4933082e5dce0fb04c2bd9fdc02c5be987b | |
parent | 08804ceaf106cc1aec5d23b529aba31939354fcd (diff) | |
download | busybox-w32-040f440262b4a435f21f85f782c2d97ecfd6a8e5.tar.gz busybox-w32-040f440262b4a435f21f85f782c2d97ecfd6a8e5.tar.bz2 busybox-w32-040f440262b4a435f21f85f782c2d97ecfd6a8e5.zip |
last_patch100 from vidz updating fdisk to 2.12pre
-rw-r--r-- | util-linux/fdisk.c | 647 |
1 files changed, 330 insertions, 317 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 291be4b9b..4fecbbb89 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -7,19 +7,10 @@ | |||
7 | * published by the Free Software Foundation: either version 1 or | 7 | * published by the Free Software Foundation: either version 1 or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * For detailed old history, see older versions. | ||
11 | * Contributions before 2001 by faith@cs.unc.edu, Michael Bischoff, | ||
12 | * LeBlanc@mcc.ac.uk, martin@cs.unc.edu, leisner@sdsp.mc.xerox.com, | ||
13 | * esr@snark.thyrsus.com, aeb@cwi.nl, quinlan@yggdrasil.com, | ||
14 | * fasten@cs.bonn.edu, orschaer@cip.informatik.uni-erlangen.de, | ||
15 | * jj@sunsite.mff.cuni.cz, fasten@shw.com, ANeuper@GUUG.de, | ||
16 | * kgw@suse.de, kalium@gmx.de, dhuggins@linuxcare.com, | ||
17 | * michal@ellpspace.math.ualberta.ca and probably others. | ||
18 | * | ||
19 | * Vladimir Oleynik <dzo@simtreas.ru> 2001,2002 Busybox port | 10 | * Vladimir Oleynik <dzo@simtreas.ru> 2001,2002 Busybox port |
20 | */ | 11 | */ |
21 | 12 | ||
22 | #define UTIL_LINUX_VERSION "2.11z" | 13 | #define UTIL_LINUX_VERSION "2.12pre" |
23 | 14 | ||
24 | #define PROC_PARTITIONS "/proc/partitions" | 15 | #define PROC_PARTITIONS "/proc/partitions" |
25 | 16 | ||
@@ -43,6 +34,7 @@ | |||
43 | 34 | ||
44 | #include <sys/ioctl.h> | 35 | #include <sys/ioctl.h> |
45 | #include <sys/param.h> | 36 | #include <sys/param.h> |
37 | #include <sys/sysmacros.h> /* major */ | ||
46 | 38 | ||
47 | #include <stdint.h> /* for uint32_t, uint16_t, uint8_t, int16_t, etc */ | 39 | #include <stdint.h> /* for uint32_t, uint16_t, uint8_t, int16_t, etc */ |
48 | 40 | ||
@@ -63,7 +55,7 @@ | |||
63 | #define BLKGETSIZE _IO(0x12,96) /* return device size */ | 55 | #define BLKGETSIZE _IO(0x12,96) /* return device size */ |
64 | #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */ | 56 | #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */ |
65 | #define BLKSSZGET _IO(0x12,104) /* get block device sector size */ | 57 | #define BLKSSZGET _IO(0x12,104) /* get block device sector size */ |
66 | 58 | #define BLKGETSIZE64 _IOR(0x12,114,8) /* 8 = sizeof(u64) */ | |
67 | 59 | ||
68 | /* | 60 | /* |
69 | fdisk.h | 61 | fdisk.h |
@@ -117,6 +109,9 @@ struct systypes { | |||
117 | const unsigned char *name; | 109 | const unsigned char *name; |
118 | }; | 110 | }; |
119 | 111 | ||
112 | static uint sector_size = DEFAULT_SECTOR_SIZE, | ||
113 | user_set_sector_size, | ||
114 | sector_offset = 1; | ||
120 | 115 | ||
121 | /* | 116 | /* |
122 | * Raw disk label. For DOS-type partition tables the MBR, | 117 | * Raw disk label. For DOS-type partition tables the MBR, |
@@ -405,8 +400,11 @@ typedef struct { | |||
405 | 400 | ||
406 | /* | 401 | /* |
407 | Changes: | 402 | Changes: |
408 | Sat Mar 20 09:51:38 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 403 | * 1999-03-20 Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
409 | Internationalization | 404 | * Internationalization |
405 | * | ||
406 | * 2003-03-20 Phillip Kesling <pkesling@sgi.com> | ||
407 | * Some fixes | ||
410 | */ | 408 | */ |
411 | 409 | ||
412 | static int aix_other_endian; | 410 | static int aix_other_endian; |
@@ -515,6 +513,9 @@ check_aix_label( void ) | |||
515 | #elif defined (__alpha__) || defined (__powerpc__) || defined (__ia64__) || defined (__hppa__) | 513 | #elif defined (__alpha__) || defined (__powerpc__) || defined (__ia64__) || defined (__hppa__) |
516 | #define BSD_LABELSECTOR 0 | 514 | #define BSD_LABELSECTOR 0 |
517 | #define BSD_LABELOFFSET 64 | 515 | #define BSD_LABELOFFSET 64 |
516 | #elif defined (__s390__) || defined (__s390x__) | ||
517 | #define BSD_LABELSECTOR 1 | ||
518 | #define BSD_LABELOFFSET 0 | ||
518 | #else | 519 | #else |
519 | #error unknown architecture | 520 | #error unknown architecture |
520 | #endif | 521 | #endif |
@@ -830,6 +831,7 @@ typedef struct { | |||
830 | unsigned short csum; /* Label xor'd checksum */ | 831 | unsigned short csum; /* Label xor'd checksum */ |
831 | } sun_partition; | 832 | } sun_partition; |
832 | 833 | ||
834 | |||
833 | #define SUN_LABEL_MAGIC 0xDABE | 835 | #define SUN_LABEL_MAGIC 0xDABE |
834 | #define SUN_LABEL_MAGIC_SWAPPED 0xBEDA | 836 | #define SUN_LABEL_MAGIC_SWAPPED 0xBEDA |
835 | #define sunlabel ((sun_partition *)MBRbuffer) | 837 | #define sunlabel ((sun_partition *)MBRbuffer) |
@@ -1216,7 +1218,8 @@ xbsd_create_disklabel (void) { | |||
1216 | c = read_char (_("Do you want to create a disklabel? (y/n) ")); | 1218 | c = read_char (_("Do you want to create a disklabel? (y/n) ")); |
1217 | if (c == 'y' || c == 'Y') { | 1219 | if (c == 'y' || c == 'Y') { |
1218 | if (xbsd_initlabel ( | 1220 | if (xbsd_initlabel ( |
1219 | #if defined (__alpha__) || defined (__powerpc__) || defined (__hppa__) | 1221 | #if defined (__alpha__) || defined (__powerpc__) || defined (__hppa__) || \ |
1222 | defined (__s390__) || defined (__s390x__) | ||
1220 | NULL, &xbsd_dlabel, 0 | 1223 | NULL, &xbsd_dlabel, 0 |
1221 | #else | 1224 | #else |
1222 | xbsd_part, &xbsd_dlabel, xbsd_part_index | 1225 | xbsd_part, &xbsd_dlabel, xbsd_part_index |
@@ -1557,7 +1560,7 @@ xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d) | |||
1557 | static int | 1560 | static int |
1558 | xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d) | 1561 | xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d) |
1559 | { | 1562 | { |
1560 | int sector; | 1563 | unsigned int sector; |
1561 | 1564 | ||
1562 | #if !defined (__alpha__) && !defined (__powerpc__) && !defined (__hppa__) | 1565 | #if !defined (__alpha__) && !defined (__powerpc__) && !defined (__hppa__) |
1563 | sector = get_start_sect(p) + BSD_LABELSECTOR; | 1566 | sector = get_start_sect(p) + BSD_LABELSECTOR; |
@@ -1663,7 +1666,10 @@ __swap16(unsigned short x) { | |||
1663 | 1666 | ||
1664 | static inline uint32_t | 1667 | static inline uint32_t |
1665 | __swap32(uint32_t x) { | 1668 | __swap32(uint32_t x) { |
1666 | return (((uint32_t)(x) & 0xFF) << 24) | (((uint32_t)(x) & 0xFF00) << 8) | (((uint32_t)(x) & 0xFF0000) >> 8) | (((uint32_t)(x) & 0xFF000000) >> 24); | 1669 | return (((x & 0xFF) << 24) | |
1670 | ((x & 0xFF00) << 8) | | ||
1671 | ((x & 0xFF0000) >> 8) | | ||
1672 | ((x & 0xFF000000) >> 24)); | ||
1667 | } | 1673 | } |
1668 | #endif | 1674 | #endif |
1669 | 1675 | ||
@@ -1689,40 +1695,39 @@ static short sgi_volumes=1; | |||
1689 | * only dealing with free blocks here | 1695 | * only dealing with free blocks here |
1690 | */ | 1696 | */ |
1691 | 1697 | ||
1692 | typedef struct { int first; int last; } freeblocks; | 1698 | typedef struct { unsigned int first; unsigned int last; } freeblocks; |
1693 | static freeblocks freelist[17]; /* 16 partitions can produce 17 vacant slots */ | 1699 | static freeblocks freelist[17]; /* 16 partitions can produce 17 vacant slots */ |
1694 | 1700 | ||
1695 | static void | 1701 | static void |
1696 | setfreelist( int i, int f, int l ) { | 1702 | setfreelist(int i, unsigned int f, unsigned int l) { |
1697 | freelist[i].first = f; | 1703 | freelist[i].first = f; |
1698 | freelist[i].last = l; | 1704 | freelist[i].last = l; |
1699 | } | 1705 | } |
1700 | 1706 | ||
1701 | static void | 1707 | static void |
1702 | add2freelist( int f, int l ) { | 1708 | add2freelist(unsigned int f, unsigned int l) { |
1703 | int i = 0; | 1709 | int i = 0; |
1704 | for( ; i<17 ; i++ ) { | 1710 | for ( ; i < 17 ; i++) |
1705 | if(freelist[i].last==0) break; | 1711 | if (freelist[i].last == 0) |
1706 | } | 1712 | break; |
1707 | setfreelist( i, f, l ); | 1713 | setfreelist(i, f, l); |
1708 | } | 1714 | } |
1709 | 1715 | ||
1710 | static void | 1716 | static void |
1711 | clearfreelist(void) { | 1717 | clearfreelist(void) { |
1712 | int i = 0; | 1718 | int i; |
1713 | for( ; i<17 ; i++ ) { | 1719 | |
1714 | setfreelist( i, 0, 0 ); | 1720 | for (i = 0; i < 17 ; i++) |
1715 | } | 1721 | setfreelist(i, 0, 0); |
1716 | } | 1722 | } |
1717 | 1723 | ||
1718 | static int | 1724 | static unsigned int |
1719 | isinfreelist( int b ) { | 1725 | isinfreelist(unsigned int b) { |
1720 | int i = 0; | 1726 | int i; |
1721 | for( ; i<17 ; i++ ) { | 1727 | |
1722 | if (freelist[i].first <= b && freelist[i].last >= b) { | 1728 | for (i = 0; i < 17 ; i++) |
1729 | if (freelist[i].first <= b && freelist[i].last >= b) | ||
1723 | return freelist[i].last; | 1730 | return freelist[i].last; |
1724 | } | ||
1725 | } | ||
1726 | return 0; | 1731 | return 0; |
1727 | } | 1732 | } |
1728 | /* return last vacant block of this stride (never 0). */ | 1733 | /* return last vacant block of this stride (never 0). */ |
@@ -1764,11 +1769,6 @@ sgi_get_ntrks(void) { | |||
1764 | return SGI_SSWAP16(sgilabel->devparam.ntrks); | 1769 | return SGI_SSWAP16(sgilabel->devparam.ntrks); |
1765 | } | 1770 | } |
1766 | 1771 | ||
1767 | static int | ||
1768 | sgi_get_pcylcount(void) { | ||
1769 | return SGI_SSWAP16(sgilabel->devparam.pcylcount); | ||
1770 | } | ||
1771 | |||
1772 | static void | 1772 | static void |
1773 | sgi_nolabel(void) { | 1773 | sgi_nolabel(void) { |
1774 | sgilabel->magic = 0; | 1774 | sgilabel->magic = 0; |
@@ -1777,13 +1777,13 @@ sgi_nolabel(void) { | |||
1777 | } | 1777 | } |
1778 | 1778 | ||
1779 | static unsigned int | 1779 | static unsigned int |
1780 | two_s_complement_32bit_sum(unsigned int* base, int size /* in bytes */ ) { | 1780 | two_s_complement_32bit_sum(unsigned int* base, int size /* in bytes */) { |
1781 | int i=0; | 1781 | int i=0; |
1782 | unsigned int sum=0; | 1782 | unsigned int sum=0; |
1783 | 1783 | ||
1784 | size = size / sizeof( unsigned int ); | 1784 | size /= sizeof(unsigned int); |
1785 | for( i=0; i<size; i++ ) | 1785 | for (i = 0; i < size; i++) |
1786 | sum = sum - SGI_SSWAP32(base[i]); | 1786 | sum -= SGI_SSWAP32(base[i]); |
1787 | return sum; | 1787 | return sum; |
1788 | } | 1788 | } |
1789 | 1789 | ||
@@ -1807,15 +1807,10 @@ check_sgi_label(void) { | |||
1807 | /* | 1807 | /* |
1808 | * test for correct checksum | 1808 | * test for correct checksum |
1809 | */ | 1809 | */ |
1810 | if( two_s_complement_32bit_sum( (unsigned int*)sgilabel, | 1810 | if (two_s_complement_32bit_sum((unsigned int*)sgilabel, |
1811 | sizeof(*sgilabel) ) ) | 1811 | sizeof(*sgilabel))) { |
1812 | { | 1812 | fprintf(stderr, |
1813 | fprintf( stderr, _("Detected sgi disklabel with wrong checksum.\n")); | 1813 | _("Detected sgi disklabel with wrong checksum.\n")); |
1814 | } else | ||
1815 | { | ||
1816 | heads = sgi_get_ntrks(); | ||
1817 | cylinders = sgi_get_pcylcount(); | ||
1818 | sectors = sgi_get_nsect(); | ||
1819 | } | 1814 | } |
1820 | update_units(); | 1815 | update_units(); |
1821 | sgi_label = 1; | 1816 | sgi_label = 1; |
@@ -1824,18 +1819,18 @@ check_sgi_label(void) { | |||
1824 | return 1; | 1819 | return 1; |
1825 | } | 1820 | } |
1826 | 1821 | ||
1827 | static int | 1822 | static unsigned int |
1828 | sgi_get_start_sector( int i ) { | 1823 | sgi_get_start_sector(int i) { |
1829 | return SGI_SSWAP32(sgilabel->partitions[i].start_sector); | 1824 | return SGI_SSWAP32(sgilabel->partitions[i].start_sector); |
1830 | } | 1825 | } |
1831 | 1826 | ||
1832 | static int | 1827 | static unsigned int |
1833 | sgi_get_num_sectors( int i ) { | 1828 | sgi_get_num_sectors(int i) { |
1834 | return SGI_SSWAP32(sgilabel->partitions[i].num_sectors); | 1829 | return SGI_SSWAP32(sgilabel->partitions[i].num_sectors); |
1835 | } | 1830 | } |
1836 | 1831 | ||
1837 | static int | 1832 | static int |
1838 | sgi_get_sysid( int i ) | 1833 | sgi_get_sysid(int i) |
1839 | { | 1834 | { |
1840 | return SGI_SSWAP32(sgilabel->partitions[i].id); | 1835 | return SGI_SSWAP32(sgilabel->partitions[i].id); |
1841 | } | 1836 | } |
@@ -1853,13 +1848,13 @@ sgi_get_swappartition(void) | |||
1853 | } | 1848 | } |
1854 | 1849 | ||
1855 | static void | 1850 | static void |
1856 | sgi_list_table( int xtra ) { | 1851 | sgi_list_table(int xtra) { |
1857 | int i, w; | 1852 | int i, w; |
1858 | int kpi = 0; /* kernel partition ID */ | 1853 | int kpi = 0; /* kernel partition ID */ |
1859 | 1854 | ||
1860 | w = strlen( disk_device ); | 1855 | w = strlen(disk_device); |
1861 | 1856 | ||
1862 | if( xtra ) { | 1857 | if(xtra) { |
1863 | printf(_("\nDisk %s (SGI disk label): %d heads, %d sectors\n" | 1858 | printf(_("\nDisk %s (SGI disk label): %d heads, %d sectors\n" |
1864 | "%d cylinders, %d physical cylinders\n" | 1859 | "%d cylinders, %d physical cylinders\n" |
1865 | "%d extra sects/cyl, interleave %d:1\n" | 1860 | "%d extra sects/cyl, interleave %d:1\n" |
@@ -1901,14 +1896,13 @@ sgi_list_table( int xtra ) { | |||
1901 | } | 1896 | } |
1902 | printf(_("----- Bootinfo -----\nBootfile: %s\n" | 1897 | printf(_("----- Bootinfo -----\nBootfile: %s\n" |
1903 | "----- Directory Entries -----\n"), | 1898 | "----- Directory Entries -----\n"), |
1904 | sgilabel->boot_file ); | 1899 | sgilabel->boot_file); |
1905 | for (i = 0 ; i < sgi_volumes; i++) | 1900 | for (i = 0 ; i < sgi_volumes; i++) { |
1906 | { | 1901 | if (sgilabel->directory[i].vol_file_size) { |
1907 | if (sgilabel->directory[i].vol_file_size) | ||
1908 | { | ||
1909 | uint32_t start = SGI_SSWAP32(sgilabel->directory[i].vol_file_start); | 1902 | uint32_t start = SGI_SSWAP32(sgilabel->directory[i].vol_file_start); |
1910 | uint32_t len = SGI_SSWAP32(sgilabel->directory[i].vol_file_size); | 1903 | uint32_t len = SGI_SSWAP32(sgilabel->directory[i].vol_file_size); |
1911 | char*name = sgilabel->directory[i].vol_file_name; | 1904 | char*name = sgilabel->directory[i].vol_file_name; |
1905 | |||
1912 | printf(_("%2d: %-10s sector%5u size%8u\n"), | 1906 | printf(_("%2d: %-10s sector%5u size%8u\n"), |
1913 | i, name, (unsigned int) start, (unsigned int) len); | 1907 | i, name, (unsigned int) start, (unsigned int) len); |
1914 | } | 1908 | } |
@@ -1921,7 +1915,7 @@ sgi_set_bootpartition( int i ) | |||
1921 | sgilabel->boot_part = SGI_SSWAP16(((short)i)); | 1915 | sgilabel->boot_part = SGI_SSWAP16(((short)i)); |
1922 | } | 1916 | } |
1923 | 1917 | ||
1924 | static int | 1918 | static unsigned int |
1925 | sgi_get_lastblock(void) { | 1919 | sgi_get_lastblock(void) { |
1926 | return heads * sectors * cylinders; | 1920 | return heads * sectors * cylinders; |
1927 | } | 1921 | } |
@@ -1932,28 +1926,29 @@ sgi_set_swappartition( int i ) { | |||
1932 | } | 1926 | } |
1933 | 1927 | ||
1934 | static int | 1928 | static int |
1935 | sgi_check_bootfile( const char* aFile ) { | 1929 | sgi_check_bootfile(const char* aFile) { |
1936 | if( strlen( aFile ) < 3 ) /* "/a\n" is minimum */ | 1930 | |
1937 | { | 1931 | if (strlen(aFile) < 3) /* "/a\n" is minimum */ { |
1938 | printf( _("\nInvalid Bootfile!\n" | 1932 | printf(_("\nInvalid Bootfile!\n" |
1939 | "\tThe bootfile must be an absolute non-zero pathname,\n" | 1933 | "\tThe bootfile must be an absolute non-zero pathname,\n" |
1940 | "\te.g. \"/unix\" or \"/unix.save\".\n") ); | 1934 | "\te.g. \"/unix\" or \"/unix.save\".\n")); |
1941 | return 0; | 1935 | return 0; |
1942 | } else | 1936 | } else { |
1943 | if( strlen( aFile ) > 16 ) | 1937 | if (strlen(aFile) > 16) { |
1944 | { | 1938 | printf(_("\n\tName of Bootfile too long: " |
1945 | printf( _("\n\tName of Bootfile too long: 16 bytes maximum.\n") ); | 1939 | "16 bytes maximum.\n")); |
1946 | return 0; | 1940 | return 0; |
1947 | } else | 1941 | } else { |
1948 | if( aFile[0] != '/' ) | 1942 | if (aFile[0] != '/') { |
1949 | { | 1943 | printf(_("\n\tBootfile must have a " |
1950 | printf( _("\n\tBootfile must have a fully qualified pathname.\n") ); | 1944 | "fully qualified pathname.\n")); |
1951 | return 0; | 1945 | return 0; |
1952 | } | 1946 | } |
1953 | if( strncmp( aFile, sgilabel->boot_file, 16 ) ) | 1947 | } |
1954 | { | 1948 | } |
1955 | printf( _("\n\tBe aware, that the bootfile is not checked for existence.\n\t" | 1949 | if (strncmp(aFile, sgilabel->boot_file, 16)) { |
1956 | "SGI's default is \"/unix\" and for backup \"/unix.save\".\n") ); | 1950 | printf(_("\n\tBe aware, that the bootfile is not checked for existence.\n\t" |
1951 | "SGI's default is \"/unix\" and for backup \"/unix.save\".\n")); | ||
1957 | /* filename is correct and did change */ | 1952 | /* filename is correct and did change */ |
1958 | return 1; | 1953 | return 1; |
1959 | } | 1954 | } |
@@ -1966,21 +1961,19 @@ sgi_get_bootfile(void) { | |||
1966 | } | 1961 | } |
1967 | 1962 | ||
1968 | static void | 1963 | static void |
1969 | sgi_set_bootfile( const char* aFile ) | 1964 | sgi_set_bootfile(const char* aFile) { |
1970 | { | ||
1971 | int i = 0; | 1965 | int i = 0; |
1972 | if( sgi_check_bootfile( aFile ) ) | 1966 | |
1973 | { | 1967 | if (sgi_check_bootfile(aFile)) { |
1974 | while( i<16 ) | 1968 | while (i < 16) { |
1975 | { | 1969 | if ((aFile[i] != '\n') /* in principle caught again by next line */ |
1976 | if( (aFile[i] != '\n') /* in principle caught again by next line */ | 1970 | && (strlen(aFile) > i)) |
1977 | && (strlen( aFile ) > i ) ) | ||
1978 | sgilabel->boot_file[i] = aFile[i]; | 1971 | sgilabel->boot_file[i] = aFile[i]; |
1979 | else | 1972 | else |
1980 | sgilabel->boot_file[i] = 0; | 1973 | sgilabel->boot_file[i] = 0; |
1981 | i++; | 1974 | i++; |
1982 | } | 1975 | } |
1983 | printf( _("\n\tBootfile is changed to \"%s\".\n"), sgilabel->boot_file ); | 1976 | printf(_("\n\tBootfile is changed to \"%s\".\n"), sgilabel->boot_file); |
1984 | } | 1977 | } |
1985 | } | 1978 | } |
1986 | 1979 | ||
@@ -1988,200 +1981,179 @@ static void | |||
1988 | create_sgiinfo(void) | 1981 | create_sgiinfo(void) |
1989 | { | 1982 | { |
1990 | /* I keep SGI's habit to write the sgilabel to the second block */ | 1983 | /* I keep SGI's habit to write the sgilabel to the second block */ |
1991 | sgilabel->directory[0].vol_file_start = SGI_SSWAP32( 2 ); | 1984 | sgilabel->directory[0].vol_file_start = SGI_SSWAP32(2); |
1992 | sgilabel->directory[0].vol_file_size = SGI_SSWAP32( sizeof( sgiinfo ) ); | 1985 | sgilabel->directory[0].vol_file_size = SGI_SSWAP32(sizeof(sgiinfo)); |
1993 | strncpy( sgilabel->directory[0].vol_file_name, "sgilabel", 8 ); | 1986 | strncpy(sgilabel->directory[0].vol_file_name, "sgilabel", 8); |
1994 | } | 1987 | } |
1995 | 1988 | ||
1996 | static sgiinfo * fill_sgiinfo(void); | 1989 | static sgiinfo *fill_sgiinfo(void); |
1997 | 1990 | ||
1998 | static void | 1991 | static void |
1999 | sgi_write_table(void) | 1992 | sgi_write_table(void) { |
2000 | { | ||
2001 | sgilabel->csum = 0; | 1993 | sgilabel->csum = 0; |
2002 | sgilabel->csum = SGI_SSWAP32( two_s_complement_32bit_sum( | 1994 | sgilabel->csum = SGI_SSWAP32(two_s_complement_32bit_sum( |
2003 | (unsigned int*)sgilabel, | 1995 | (unsigned int*)sgilabel, |
2004 | sizeof(*sgilabel) ) ); | 1996 | sizeof(*sgilabel))); |
2005 | assert( two_s_complement_32bit_sum( | 1997 | assert(two_s_complement_32bit_sum( |
2006 | (unsigned int*)sgilabel, sizeof(*sgilabel) ) == 0 ); | 1998 | (unsigned int*)sgilabel, sizeof(*sgilabel)) == 0); |
2007 | if( lseek(fd, 0, SEEK_SET) < 0 ) | 1999 | if (lseek(fd, 0, SEEK_SET) < 0) |
2008 | fdisk_fatal(unable_to_seek); | 2000 | fdisk_fatal(unable_to_seek); |
2009 | if( write(fd, sgilabel, SECTOR_SIZE) != SECTOR_SIZE ) | 2001 | if (write(fd, sgilabel, SECTOR_SIZE) != SECTOR_SIZE) |
2010 | fdisk_fatal(unable_to_write); | 2002 | fdisk_fatal(unable_to_write); |
2011 | if( ! strncmp( sgilabel->directory[0].vol_file_name, "sgilabel",8 ) ) | 2003 | if (! strncmp(sgilabel->directory[0].vol_file_name, "sgilabel", 8)) { |
2012 | { | ||
2013 | /* | 2004 | /* |
2014 | * keep this habbit of first writing the "sgilabel". | 2005 | * keep this habit of first writing the "sgilabel". |
2015 | * I never tested whether it works without (AN 981002). | 2006 | * I never tested whether it works without (AN 981002). |
2016 | */ | 2007 | */ |
2017 | sgiinfo*info = fill_sgiinfo(); /* fills the block appropriately */ | 2008 | sgiinfo *info = fill_sgiinfo(); |
2018 | int infostartblock = SGI_SSWAP32( sgilabel->directory[0].vol_file_start ); | 2009 | int infostartblock = SGI_SSWAP32(sgilabel->directory[0].vol_file_start); |
2019 | if( lseek(fd, (ext2_loff_t)infostartblock* | 2010 | if (lseek(fd, (long long)infostartblock* |
2020 | SECTOR_SIZE, SEEK_SET) < 0 ) | 2011 | SECTOR_SIZE, SEEK_SET) < 0) |
2021 | fdisk_fatal(unable_to_seek); | 2012 | fdisk_fatal(unable_to_seek); |
2022 | if( write(fd, info, SECTOR_SIZE) != SECTOR_SIZE ) | 2013 | if (write(fd, info, SECTOR_SIZE) != SECTOR_SIZE) |
2023 | fdisk_fatal(unable_to_write); | 2014 | fdisk_fatal(unable_to_write); |
2024 | free( info ); | 2015 | free(info); |
2025 | } | 2016 | } |
2026 | } | 2017 | } |
2027 | 2018 | ||
2028 | static int | 2019 | static int |
2029 | compare_start( int *x, int *y ) { | 2020 | compare_start(int *x, int *y) { |
2030 | /* | 2021 | /* |
2031 | * sort according to start sectors | 2022 | * sort according to start sectors |
2032 | * and prefers largest partition: | 2023 | * and prefers largest partition: |
2033 | * entry zero is entire disk entry | 2024 | * entry zero is entire disk entry |
2034 | */ | 2025 | */ |
2035 | int i = *x; | 2026 | unsigned int i = *x; |
2036 | int j = *y; | 2027 | unsigned int j = *y; |
2037 | int a = sgi_get_start_sector(i); | 2028 | unsigned int a = sgi_get_start_sector(i); |
2038 | int b = sgi_get_start_sector(j); | 2029 | unsigned int b = sgi_get_start_sector(j); |
2039 | int c = sgi_get_num_sectors(i); | 2030 | unsigned int c = sgi_get_num_sectors(i); |
2040 | int d = sgi_get_num_sectors(j); | 2031 | unsigned int d = sgi_get_num_sectors(j); |
2041 | if( a == b ) | 2032 | |
2042 | { | 2033 | if (a == b) |
2043 | return( d - c ); | 2034 | return (d > c) ? 1 : (d == c) ? 0 : -1; |
2044 | } | 2035 | return (a > b) ? 1 : -1; |
2045 | return( a - b ); | ||
2046 | } | 2036 | } |
2047 | 2037 | ||
2048 | 2038 | ||
2049 | static int | 2039 | static int |
2050 | verify_sgi( int verbose ) | 2040 | verify_sgi(int verbose) |
2051 | { | 2041 | { |
2052 | int Index[16]; /* list of valid partitions */ | 2042 | int Index[16]; /* list of valid partitions */ |
2053 | int sortcount = 0; /* number of used partitions, i.e. non-zero lengths */ | 2043 | int sortcount = 0; /* number of used partitions, i.e. non-zero lengths */ |
2054 | int entire = 0, i = 0; /* local counters */ | 2044 | int entire = 0, i = 0; |
2055 | int start = 0; | 2045 | unsigned int start = 0; |
2056 | int gap = 0; /* count unused blocks */ | 2046 | long long gap = 0; /* count unused blocks */ |
2057 | int lastblock = sgi_get_lastblock(); | 2047 | unsigned int lastblock = sgi_get_lastblock(); |
2058 | /* | 2048 | |
2059 | */ | ||
2060 | clearfreelist(); | 2049 | clearfreelist(); |
2061 | for( i=0; i<16; i++ ) | 2050 | for (i=0; i<16; i++) { |
2062 | { | 2051 | if (sgi_get_num_sectors(i) != 0) { |
2063 | if( sgi_get_num_sectors(i)!=0 ) | ||
2064 | { | ||
2065 | Index[sortcount++]=i; | 2052 | Index[sortcount++]=i; |
2066 | if( sgi_get_sysid(i) == ENTIRE_DISK ) | 2053 | if (sgi_get_sysid(i) == ENTIRE_DISK) { |
2067 | { | 2054 | if (entire++ == 1) { |
2068 | if( entire++ == 1 ) | 2055 | if (verbose) |
2069 | { | ||
2070 | if(verbose) | ||
2071 | printf(_("More than one entire disk entry present.\n")); | 2056 | printf(_("More than one entire disk entry present.\n")); |
2072 | } | 2057 | } |
2073 | } | 2058 | } |
2074 | } | 2059 | } |
2075 | } | 2060 | } |
2076 | if( sortcount == 0 ) | 2061 | if (sortcount == 0) { |
2077 | { | 2062 | if (verbose) |
2078 | if(verbose) | ||
2079 | printf(_("No partitions defined\n")); | 2063 | printf(_("No partitions defined\n")); |
2080 | return lastblock; | 2064 | return (lastblock > 0) ? 1 : (lastblock == 0) ? 0 : -1; |
2081 | } | 2065 | } |
2082 | qsort( Index, sortcount, sizeof(Index[0]), (void*)compare_start ); | 2066 | qsort(Index, sortcount, sizeof(Index[0]), (void*)compare_start); |
2083 | if( sgi_get_sysid( Index[0] ) == ENTIRE_DISK ) | 2067 | if (sgi_get_sysid(Index[0]) == ENTIRE_DISK) { |
2084 | { | 2068 | if ((Index[0] != 10) && verbose) |
2085 | if( ( Index[0] != 10 ) && verbose ) | 2069 | printf(_("IRIX likes when Partition 11 covers the entire disk.\n")); |
2086 | printf( _("IRIX likes when Partition 11 covers the entire disk.\n") ); | 2070 | if ((sgi_get_start_sector(Index[0]) != 0) && verbose) |
2087 | if( ( sgi_get_start_sector( Index[0] ) != 0 ) && verbose ) | 2071 | printf(_("The entire disk partition should start " |
2088 | printf( _("The entire disk partition should start at block 0,\nnot " | 2072 | "at block 0,\n" |
2089 | "at diskblock %d.\n"), sgi_get_start_sector(Index[0] ) ); | 2073 | "not at diskblock %d.\n"), |
2090 | if(debug) /* I do not understand how some disks fulfil it */ | 2074 | sgi_get_start_sector(Index[0])); |
2091 | if( ( sgi_get_num_sectors( Index[0] ) != lastblock ) && verbose ) | 2075 | if (debug) /* I do not understand how some disks fulfil it */ |
2092 | printf( _("The entire disk partition is only %d diskblock large,\n" | 2076 | if ((sgi_get_num_sectors(Index[0]) != lastblock) && verbose) |
2077 | printf(_("The entire disk partition is only %d diskblock large,\n" | ||
2093 | "but the disk is %d diskblocks long.\n"), | 2078 | "but the disk is %d diskblocks long.\n"), |
2094 | sgi_get_num_sectors( Index[0] ), lastblock ); | 2079 | sgi_get_num_sectors(Index[0]), lastblock); |
2095 | lastblock = sgi_get_num_sectors( Index[0] ); | 2080 | lastblock = sgi_get_num_sectors(Index[0]); |
2096 | } else | 2081 | } else { |
2097 | { | 2082 | if (verbose) |
2098 | if( verbose ) | 2083 | printf(_("One Partition (#11) should cover the entire disk.\n")); |
2099 | printf( _("One Partition (#11) should cover the entire disk.\n") ); | 2084 | if (debug>2) |
2100 | if(debug>2) | 2085 | printf("sysid=%d\tpartition=%d\n", |
2101 | printf( "sysid=%d\tpartition=%d\n", | 2086 | sgi_get_sysid(Index[0]), Index[0]+1); |
2102 | sgi_get_sysid( Index[0] ), Index[0]+1 ); | ||
2103 | } | 2087 | } |
2104 | for( i=1, start=0; i<sortcount; i++ ) | 2088 | for (i=1, start=0; i<sortcount; i++) { |
2105 | { | ||
2106 | int cylsize = sgi_get_nsect() * sgi_get_ntrks(); | 2089 | int cylsize = sgi_get_nsect() * sgi_get_ntrks(); |
2107 | if( (sgi_get_start_sector( Index[i] ) % cylsize) != 0 ) | 2090 | |
2108 | { | 2091 | if ((sgi_get_start_sector(Index[i]) % cylsize) != 0) { |
2109 | if(debug) /* I do not understand how some disks fulfil it */ | 2092 | if (debug) /* I do not understand how some disks fulfil it */ |
2110 | if( verbose ) | 2093 | if (verbose) |
2111 | printf( _("Partition %d does not start on cylinder boundary.\n"), | 2094 | printf(_("Partition %d does not start on cylinder boundary.\n"), |
2112 | Index[i]+1 ); | 2095 | Index[i]+1); |
2113 | } | 2096 | } |
2114 | if( sgi_get_num_sectors( Index[i] ) % cylsize != 0 ) | 2097 | if (sgi_get_num_sectors(Index[i]) % cylsize != 0) { |
2115 | { | 2098 | if (debug) /* I do not understand how some disks fulfil it */ |
2116 | if(debug) /* I do not understand how some disks fulfil it */ | 2099 | if (verbose) |
2117 | if( verbose ) | 2100 | printf(_("Partition %d does not end on cylinder boundary.\n"), |
2118 | printf( _("Partition %d does not end on cylinder boundary.\n"), | 2101 | Index[i]+1); |
2119 | Index[i]+1 ); | ||
2120 | } | 2102 | } |
2121 | /* We cannot handle several "entire disk" entries. */ | 2103 | /* We cannot handle several "entire disk" entries. */ |
2122 | if( sgi_get_sysid( Index[i] ) == ENTIRE_DISK ) continue; | 2104 | if (sgi_get_sysid(Index[i]) == ENTIRE_DISK) continue; |
2123 | if( start > sgi_get_start_sector( Index[i] ) ) | 2105 | if (start > sgi_get_start_sector(Index[i])) { |
2124 | { | 2106 | if (verbose) |
2125 | if( verbose ) | 2107 | printf(_("The Partition %d and %d overlap by %d sectors.\n"), |
2126 | printf( _("The Partition %d and %d overlap by %d sectors.\n"), | ||
2127 | Index[i-1]+1, Index[i]+1, | 2108 | Index[i-1]+1, Index[i]+1, |
2128 | start - sgi_get_start_sector( Index[i] ) ); | 2109 | start - sgi_get_start_sector(Index[i])); |
2129 | if( gap > 0 ) gap = -gap; | 2110 | if (gap > 0) gap = -gap; |
2130 | if( gap == 0 ) gap = -1; | 2111 | if (gap == 0) gap = -1; |
2131 | } | 2112 | } |
2132 | if( start < sgi_get_start_sector( Index[i] ) ) | 2113 | if (start < sgi_get_start_sector(Index[i])) { |
2133 | { | 2114 | if (verbose) |
2134 | if( verbose ) | 2115 | printf(_("Unused gap of %8u sectors - sectors %8u-%u\n"), |
2135 | printf( _("Unused gap of %8d sectors - sectors %8d-%d\n"), | 2116 | sgi_get_start_sector(Index[i]) - start, |
2136 | sgi_get_start_sector( Index[i] ) - start, | 2117 | start, sgi_get_start_sector(Index[i])-1); |
2137 | start, sgi_get_start_sector( Index[i] )-1 ); | 2118 | gap += sgi_get_start_sector(Index[i]) - start; |
2138 | gap += sgi_get_start_sector( Index[i] ) - start; | 2119 | add2freelist(start, sgi_get_start_sector(Index[i])); |
2139 | add2freelist( start, sgi_get_start_sector( Index[i] ) ); | 2120 | } |
2140 | } | 2121 | start = sgi_get_start_sector(Index[i]) |
2141 | start = sgi_get_start_sector( Index[i] ) | 2122 | + sgi_get_num_sectors(Index[i]); |
2142 | + sgi_get_num_sectors( Index[i] ); | 2123 | if (debug > 1) { |
2143 | if(debug>1) | 2124 | if (verbose) |
2144 | { | 2125 | printf("%2d:%12d\t%12d\t%12d\n", Index[i], |
2145 | if( verbose ) | ||
2146 | printf( "%2d:%12d\t%12d\t%12d\n", Index[i], | ||
2147 | sgi_get_start_sector(Index[i]), | 2126 | sgi_get_start_sector(Index[i]), |
2148 | sgi_get_num_sectors(Index[i]), | 2127 | sgi_get_num_sectors(Index[i]), |
2149 | sgi_get_sysid(Index[i]) ); | 2128 | sgi_get_sysid(Index[i])); |
2150 | } | 2129 | } |
2151 | } | 2130 | } |
2152 | if( ( start < lastblock ) ) | 2131 | if (start < lastblock) { |
2153 | { | 2132 | if (verbose) |
2154 | if( verbose ) | 2133 | printf(_("Unused gap of %8u sectors - sectors %8u-%u\n"), |
2155 | printf( _("Unused gap of %8d sectors - sectors %8d-%d\n"), | 2134 | lastblock - start, start, lastblock-1); |
2156 | lastblock - start, start, lastblock-1 ); | ||
2157 | gap += lastblock - start; | 2135 | gap += lastblock - start; |
2158 | add2freelist( start, lastblock ); | 2136 | add2freelist(start, lastblock); |
2159 | } | 2137 | } |
2160 | /* | 2138 | /* |
2161 | * Done with arithmetics | 2139 | * Done with arithmetics |
2162 | * Go for details now | 2140 | * Go for details now |
2163 | */ | 2141 | */ |
2164 | if( verbose ) | 2142 | if (verbose) { |
2165 | { | 2143 | if (!sgi_get_num_sectors(sgi_get_bootpartition())) { |
2166 | if( !sgi_get_num_sectors( sgi_get_bootpartition() ) ) | 2144 | printf(_("\nThe boot partition does not exist.\n")); |
2167 | { | ||
2168 | printf( _("\nThe boot partition does not exist.\n") ); | ||
2169 | } | ||
2170 | if( !sgi_get_num_sectors( sgi_get_swappartition() ) ) | ||
2171 | { | ||
2172 | printf( _("\nThe swap partition does not exist.\n") ); | ||
2173 | } else | ||
2174 | if( ( sgi_get_sysid( sgi_get_swappartition() ) != SGI_SWAP ) | ||
2175 | && ( sgi_get_sysid( sgi_get_swappartition() ) != LINUX_SWAP ) ) | ||
2176 | { | ||
2177 | printf( _("\nThe swap partition has no swap type.\n") ); | ||
2178 | } | 2145 | } |
2179 | if( sgi_check_bootfile( "/unix" ) ) | 2146 | if (!sgi_get_num_sectors(sgi_get_swappartition())) { |
2180 | { | 2147 | printf(_("\nThe swap partition does not exist.\n")); |
2181 | printf( _("\tYou have chosen an unusual boot file name.\n") ); | 2148 | } else { |
2149 | if ((sgi_get_sysid(sgi_get_swappartition()) != SGI_SWAP) | ||
2150 | && (sgi_get_sysid(sgi_get_swappartition()) != LINUX_SWAP)) | ||
2151 | printf(_("\nThe swap partition has no swap type.\n")); | ||
2182 | } | 2152 | } |
2153 | if (sgi_check_bootfile("/unix")) | ||
2154 | printf(_("\tYou have chosen an unusual boot file name.\n")); | ||
2183 | } | 2155 | } |
2184 | return gap; | 2156 | return (gap > 0) ? 1 : (gap == 0) ? 0 : -1; |
2185 | } | 2157 | } |
2186 | 2158 | ||
2187 | static int | 2159 | static int |
@@ -2221,32 +2193,32 @@ sgi_change_sysid( int i, int sys ) | |||
2221 | /* returns partition index of first entry marked as entire disk */ | 2193 | /* returns partition index of first entry marked as entire disk */ |
2222 | static int | 2194 | static int |
2223 | sgi_entire(void) { | 2195 | sgi_entire(void) { |
2224 | int i=0; | 2196 | int i; |
2225 | for( i=0; i<16; i++ ) | 2197 | |
2226 | if( sgi_get_sysid(i) == SGI_VOLUME ) | 2198 | for(i=0; i<16; i++) |
2199 | if(sgi_get_sysid(i) == SGI_VOLUME) | ||
2227 | return i; | 2200 | return i; |
2228 | return -1; | 2201 | return -1; |
2229 | } | 2202 | } |
2230 | 2203 | ||
2231 | static void | 2204 | static void |
2232 | sgi_set_partition( int i, uint start, uint length, int sys ) { | 2205 | sgi_set_partition(int i, unsigned int start, unsigned int length, int sys) { |
2233 | sgilabel->partitions[i].id = | 2206 | |
2234 | SGI_SSWAP32( sys ); | 2207 | sgilabel->partitions[i].id = SGI_SSWAP32(sys); |
2235 | sgilabel->partitions[i].num_sectors = | 2208 | sgilabel->partitions[i].num_sectors = SGI_SSWAP32(length); |
2236 | SGI_SSWAP32( length ); | 2209 | sgilabel->partitions[i].start_sector = SGI_SSWAP32(start); |
2237 | sgilabel->partitions[i].start_sector = | ||
2238 | SGI_SSWAP32( start ); | ||
2239 | set_changed(i); | 2210 | set_changed(i); |
2240 | if( sgi_gaps() < 0 ) /* rebuild freelist */ | 2211 | if (sgi_gaps() < 0) /* rebuild freelist */ |
2241 | printf(_("Do You know, You got a partition overlap on the disk?\n")); | 2212 | printf(_("Do You know, You got a partition overlap on the disk?\n")); |
2242 | } | 2213 | } |
2243 | 2214 | ||
2244 | static void | 2215 | static void |
2245 | sgi_set_entire(void) { | 2216 | sgi_set_entire(void) { |
2246 | int n; | 2217 | int n; |
2247 | for( n=10; n<partitions; n++ ) { | 2218 | |
2248 | if(!sgi_get_num_sectors( n ) ) { | 2219 | for(n=10; n < partitions; n++) { |
2249 | sgi_set_partition( n, 0, sgi_get_lastblock(), SGI_VOLUME ); | 2220 | if(!sgi_get_num_sectors(n) ) { |
2221 | sgi_set_partition(n, 0, sgi_get_lastblock(), SGI_VOLUME); | ||
2250 | break; | 2222 | break; |
2251 | } | 2223 | } |
2252 | } | 2224 | } |
@@ -2283,34 +2255,28 @@ static void | |||
2283 | sgi_add_partition( int n, int sys ) | 2255 | sgi_add_partition( int n, int sys ) |
2284 | { | 2256 | { |
2285 | char mesg[256]; | 2257 | char mesg[256]; |
2286 | int first=0, last=0; | 2258 | unsigned int first=0, last=0; |
2287 | 2259 | ||
2288 | if( n == 10 ) { | 2260 | if( n == 10 ) { |
2289 | sys = SGI_VOLUME; | 2261 | sys = SGI_VOLUME; |
2290 | } else if ( n == 8 ) { | 2262 | } else if ( n == 8 ) { |
2291 | sys = 0; | 2263 | sys = 0; |
2292 | } | 2264 | } |
2293 | if( sgi_get_num_sectors(n) ) | 2265 | if(sgi_get_num_sectors(n)) { |
2294 | { | ||
2295 | printf(_("Partition %d is already defined. Delete " | 2266 | printf(_("Partition %d is already defined. Delete " |
2296 | "it before re-adding it.\n"), n + 1); | 2267 | "it before re-adding it.\n"), n + 1); |
2297 | return; | 2268 | return; |
2298 | } | 2269 | } |
2299 | if( (sgi_entire() == -1) | 2270 | if( (sgi_entire() == -1) && (sys != SGI_VOLUME) ) { |
2300 | && (sys != SGI_VOLUME) ) | ||
2301 | { | ||
2302 | printf(_("Attempting to generate entire disk entry automatically.\n")); | 2271 | printf(_("Attempting to generate entire disk entry automatically.\n")); |
2303 | sgi_set_entire(); | 2272 | sgi_set_entire(); |
2304 | sgi_set_volhdr(); | 2273 | sgi_set_volhdr(); |
2305 | } | 2274 | } |
2306 | if( (sgi_gaps() == 0) | 2275 | if( (sgi_gaps() == 0) && (sys != SGI_VOLUME) ) { |
2307 | && (sys != SGI_VOLUME) ) | ||
2308 | { | ||
2309 | printf(_("The entire disk is already covered with partitions.\n")); | 2276 | printf(_("The entire disk is already covered with partitions.\n")); |
2310 | return; | 2277 | return; |
2311 | } | 2278 | } |
2312 | if( sgi_gaps() < 0 ) | 2279 | if(sgi_gaps() < 0) { |
2313 | { | ||
2314 | printf(_("You got a partition overlap on the disk. Fix it first!\n")); | 2280 | printf(_("You got a partition overlap on the disk. Fix it first!\n")); |
2315 | return; | 2281 | return; |
2316 | } | 2282 | } |
@@ -2354,48 +2320,62 @@ sgi_add_partition( int n, int sys ) | |||
2354 | sgi_set_partition( n, first, last-first, sys ); | 2320 | sgi_set_partition( n, first, last-first, sys ); |
2355 | } | 2321 | } |
2356 | 2322 | ||
2323 | #ifdef CONFIG_FEATURE_FDISK_ADVANCED | ||
2357 | static void | 2324 | static void |
2358 | create_sgilabel(void) | 2325 | create_sgilabel(void) |
2359 | { | 2326 | { |
2360 | struct hd_geometry geometry; | 2327 | struct hd_geometry geometry; |
2361 | struct { int start; | 2328 | struct { |
2362 | int nsect; | 2329 | unsigned int start; |
2363 | int sysid; } old[4]; | 2330 | unsigned int nsect; |
2331 | int sysid; | ||
2332 | } old[4]; | ||
2364 | int i=0; | 2333 | int i=0; |
2334 | long longsectors; /* the number of sectors on the device */ | ||
2335 | int res; /* the result from the ioctl */ | ||
2336 | int sec_fac; /* the sector factor */ | ||
2337 | |||
2338 | sec_fac = sector_size / 512; /* determine the sector factor */ | ||
2339 | |||
2365 | fprintf( stderr, | 2340 | fprintf( stderr, |
2366 | _("Building a new SGI disklabel. Changes will remain in memory only,\n" | 2341 | _("Building a new SGI disklabel. Changes will remain in memory only,\n" |
2367 | "until you decide to write them. After that, of course, the previous\n" | 2342 | "until you decide to write them. After that, of course, the previous\n" |
2368 | "content will be unrecoverably lost.\n\n")); | 2343 | "content will be unrecoverably lost.\n\n")); |
2369 | 2344 | ||
2370 | sgi_other_endian = (BYTE_ORDER == LITTLE_ENDIAN); | 2345 | sgi_other_endian = (BYTE_ORDER == LITTLE_ENDIAN); |
2371 | 2346 | res = ioctl(fd, BLKGETSIZE, &longsectors); | |
2372 | #ifdef HDIO_REQ | 2347 | if (!ioctl(fd, HDIO_GETGEO, &geometry)) { |
2373 | if (!ioctl(fd, HDIO_REQ, &geometry)) | ||
2374 | #else | ||
2375 | if (!ioctl(fd, HDIO_GETGEO, &geometry)) | ||
2376 | #endif | ||
2377 | { | ||
2378 | heads = geometry.heads; | 2348 | heads = geometry.heads; |
2379 | sectors = geometry.sectors; | 2349 | sectors = geometry.sectors; |
2350 | if (res == 0) { | ||
2351 | /* the get device size ioctl was successful */ | ||
2352 | cylinders = longsectors / (heads * sectors); | ||
2353 | cylinders /= sec_fac; | ||
2354 | } else { | ||
2355 | /* otherwise print error and use truncated version */ | ||
2380 | cylinders = geometry.cylinders; | 2356 | cylinders = geometry.cylinders; |
2357 | fprintf(stderr, | ||
2358 | _("Warning: BLKGETSIZE ioctl failed on %s. " | ||
2359 | "Using geometry cylinder value of %d.\n" | ||
2360 | "This value may be truncated for devices" | ||
2361 | " > 33.8 GB.\n"), disk_device, cylinders); | ||
2381 | } | 2362 | } |
2382 | for (i = 0; i < 4; i++) | 2363 | } |
2383 | { | 2364 | for (i = 0; i < 4; i++) { |
2384 | old[i].sysid = 0; | 2365 | old[i].sysid = 0; |
2385 | if( valid_part_table_flag(MBRbuffer) ) | 2366 | if(valid_part_table_flag(MBRbuffer)) { |
2386 | { | 2367 | if(get_part_table(i)->sys_ind) { |
2387 | if( get_part_table(i)->sys_ind ) | ||
2388 | { | ||
2389 | old[i].sysid = get_part_table(i)->sys_ind; | 2368 | old[i].sysid = get_part_table(i)->sys_ind; |
2390 | old[i].start = get_start_sect( get_part_table(i) ); | 2369 | old[i].start = get_start_sect(get_part_table(i)); |
2391 | old[i].nsect = get_nr_sects( get_part_table(i) ); | 2370 | old[i].nsect = get_nr_sects(get_part_table(i)); |
2392 | printf( _("Trying to keep parameters of partition %d.\n"), i ); | 2371 | printf(_("Trying to keep parameters of partition %d.\n"), i); |
2393 | if( debug ) | 2372 | if (debug) |
2394 | printf( _("ID=%02x\tSTART=%d\tLENGTH=%d\n"), | 2373 | printf(_("ID=%02x\tSTART=%d\tLENGTH=%d\n"), |
2395 | old[i].sysid, old[i].start, old[i].nsect ); | 2374 | old[i].sysid, old[i].start, old[i].nsect); |
2396 | } | 2375 | } |
2397 | } | 2376 | } |
2398 | } | 2377 | } |
2378 | |||
2399 | memset(MBRbuffer, 0, sizeof(MBRbuffer)); | 2379 | memset(MBRbuffer, 0, sizeof(MBRbuffer)); |
2400 | sgilabel->magic = SGI_SSWAP32(SGI_LABEL_MAGIC); | 2380 | sgilabel->magic = SGI_SSWAP32(SGI_LABEL_MAGIC); |
2401 | sgilabel->boot_part = SGI_SSWAP16(0); | 2381 | sgilabel->boot_part = SGI_SSWAP16(0); |
@@ -2438,11 +2418,9 @@ create_sgilabel(void) | |||
2438 | sgi_volumes = 15; | 2418 | sgi_volumes = 15; |
2439 | sgi_set_entire(); | 2419 | sgi_set_entire(); |
2440 | sgi_set_volhdr(); | 2420 | sgi_set_volhdr(); |
2441 | for (i = 0; i < 4; i++) | 2421 | for (i = 0; i < 4; i++) { |
2442 | { | 2422 | if(old[i].sysid) { |
2443 | if( old[i].sysid ) | 2423 | sgi_set_partition(i, old[i].start, old[i].nsect, old[i].sysid); |
2444 | { | ||
2445 | sgi_set_partition( i, old[i].start, old[i].nsect, old[i].sysid ); | ||
2446 | } | 2424 | } |
2447 | } | 2425 | } |
2448 | } | 2426 | } |
@@ -2452,14 +2430,16 @@ sgi_set_xcyl(void) | |||
2452 | { | 2430 | { |
2453 | /* do nothing in the beginning */ | 2431 | /* do nothing in the beginning */ |
2454 | } | 2432 | } |
2433 | #endif /* CONFIG_FEATURE_FDISK_ADVANCED */ | ||
2455 | 2434 | ||
2456 | /* _____________________________________________________________ | 2435 | /* _____________________________________________________________ |
2457 | */ | 2436 | */ |
2458 | 2437 | ||
2459 | static sgiinfo* | 2438 | static sgiinfo * |
2460 | fill_sgiinfo(void) | 2439 | fill_sgiinfo(void) |
2461 | { | 2440 | { |
2462 | sgiinfo*info=calloc( 1, sizeof(sgiinfo) ); | 2441 | sgiinfo *info = calloc(1, sizeof(sgiinfo)); |
2442 | |||
2463 | info->magic=SGI_SSWAP32(SGI_INFO_MAGIC); | 2443 | info->magic=SGI_SSWAP32(SGI_INFO_MAGIC); |
2464 | info->b1=SGI_SSWAP32(-1); | 2444 | info->b1=SGI_SSWAP32(-1); |
2465 | info->b2=SGI_SSWAP16(-1); | 2445 | info->b2=SGI_SSWAP16(-1); |
@@ -2498,6 +2478,7 @@ static int floppy; | |||
2498 | #ifndef IDE1_MAJOR | 2478 | #ifndef IDE1_MAJOR |
2499 | #define IDE1_MAJOR 22 | 2479 | #define IDE1_MAJOR 22 |
2500 | #endif | 2480 | #endif |
2481 | |||
2501 | static void guess_device_type(void) { | 2482 | static void guess_device_type(void) { |
2502 | struct stat bootstat; | 2483 | struct stat bootstat; |
2503 | 2484 | ||
@@ -2505,12 +2486,12 @@ static void guess_device_type(void) { | |||
2505 | scsi_disk = 0; | 2486 | scsi_disk = 0; |
2506 | floppy = 0; | 2487 | floppy = 0; |
2507 | } else if (S_ISBLK(bootstat.st_mode) | 2488 | } else if (S_ISBLK(bootstat.st_mode) |
2508 | && ((bootstat.st_rdev >> 8) == IDE0_MAJOR || | 2489 | && (major(bootstat.st_rdev) == IDE0_MAJOR || |
2509 | (bootstat.st_rdev >> 8) == IDE1_MAJOR)) { | 2490 | major(bootstat.st_rdev) == IDE1_MAJOR)) { |
2510 | scsi_disk = 0; | 2491 | scsi_disk = 0; |
2511 | floppy = 0; | 2492 | floppy = 0; |
2512 | } else if (S_ISBLK(bootstat.st_mode) | 2493 | } else if (S_ISBLK(bootstat.st_mode) |
2513 | && (bootstat.st_rdev >> 8) == FLOPPY_MAJOR) { | 2494 | && major(bootstat.st_rdev) == FLOPPY_MAJOR) { |
2514 | scsi_disk = 0; | 2495 | scsi_disk = 0; |
2515 | floppy = 1; | 2496 | floppy = 1; |
2516 | } else { | 2497 | } else { |
@@ -2736,11 +2717,7 @@ static void create_sunlabel(void) | |||
2736 | } | 2717 | } |
2737 | } | 2718 | } |
2738 | if (!p || floppy) { | 2719 | if (!p || floppy) { |
2739 | #ifdef HDIO_REQ | ||
2740 | if (!ioctl(fd, HDIO_REQ, &geometry)) { | ||
2741 | #else | ||
2742 | if (!ioctl(fd, HDIO_GETGEO, &geometry)) { | 2720 | if (!ioctl(fd, HDIO_GETGEO, &geometry)) { |
2743 | #endif | ||
2744 | heads = geometry.heads; | 2721 | heads = geometry.heads; |
2745 | sectors = geometry.sectors; | 2722 | sectors = geometry.sectors; |
2746 | cylinders = geometry.cylinders; | 2723 | cylinders = geometry.cylinders; |
@@ -3046,15 +3023,16 @@ and is of type `Whole disk'\n"); | |||
3046 | 3023 | ||
3047 | static void | 3024 | static void |
3048 | sun_delete_partition(int i) { | 3025 | sun_delete_partition(int i) { |
3026 | unsigned int nsec; | ||
3027 | |||
3049 | if (i == 2 && sunlabel->infos[i].id == WHOLE_DISK && | 3028 | if (i == 2 && sunlabel->infos[i].id == WHOLE_DISK && |
3050 | !sunlabel->partitions[i].start_cylinder && | 3029 | !sunlabel->partitions[i].start_cylinder && |
3051 | SUN_SSWAP32(sunlabel->partitions[i].num_sectors) | 3030 | (nsec = SUN_SSWAP32(sunlabel->partitions[i].num_sectors)) |
3052 | == heads * sectors * cylinders) | 3031 | == heads * sectors * cylinders) |
3053 | printf(_("If you want to maintain SunOS/Solaris compatibility, " | 3032 | printf(_("If you want to maintain SunOS/Solaris compatibility, " |
3054 | "consider leaving this\n" | 3033 | "consider leaving this\n" |
3055 | "partition as Whole disk (5), starting at 0, with %u " | 3034 | "partition as Whole disk (5), starting at 0, with %u " |
3056 | "sectors\n"), | 3035 | "sectors\n"), nsec); |
3057 | (uint) SUN_SSWAP32(sunlabel->partitions[i].num_sectors)); | ||
3058 | sunlabel->infos[i].id = 0; | 3036 | sunlabel->infos[i].id = 0; |
3059 | sunlabel->partitions[i].num_sectors = 0; | 3037 | sunlabel->partitions[i].num_sectors = 0; |
3060 | } | 3038 | } |
@@ -3132,6 +3110,8 @@ sun_list_table(int xtra) { | |||
3132 | } | 3110 | } |
3133 | } | 3111 | } |
3134 | 3112 | ||
3113 | #ifdef CONFIG_FEATURE_FDISK_ADVANCED | ||
3114 | |||
3135 | static void | 3115 | static void |
3136 | sun_set_alt_cyl(void) { | 3116 | sun_set_alt_cyl(void) { |
3137 | sunlabel->nacyl = | 3117 | sunlabel->nacyl = |
@@ -3171,6 +3151,7 @@ sun_set_pcylcount(void) { | |||
3171 | SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->pcylcount), 65535, 0, | 3151 | SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->pcylcount), 65535, 0, |
3172 | _("Number of physical cylinders"))); | 3152 | _("Number of physical cylinders"))); |
3173 | } | 3153 | } |
3154 | #endif /* CONFIG_FEATURE_FDISK_ADVANCED */ | ||
3174 | 3155 | ||
3175 | static void | 3156 | static void |
3176 | sun_write_table(void) { | 3157 | sun_write_table(void) { |
@@ -3368,11 +3349,8 @@ static uint pt_heads, pt_sectors; | |||
3368 | static uint kern_heads, kern_sectors; | 3349 | static uint kern_heads, kern_sectors; |
3369 | 3350 | ||
3370 | static uint extended_offset; /* offset of link pointers */ | 3351 | static uint extended_offset; /* offset of link pointers */ |
3371 | static uint sector_size = DEFAULT_SECTOR_SIZE, | ||
3372 | user_set_sector_size, | ||
3373 | sector_offset = 1; | ||
3374 | 3352 | ||
3375 | static unsigned long total_number_of_sectors; | 3353 | static unsigned long long total_number_of_sectors; |
3376 | 3354 | ||
3377 | 3355 | ||
3378 | static jmp_buf listingbuf; | 3356 | static jmp_buf listingbuf; |
@@ -3979,7 +3957,7 @@ get_partition_table_geometry(void) { | |||
3979 | void | 3957 | void |
3980 | get_geometry(void) { | 3958 | get_geometry(void) { |
3981 | int sec_fac; | 3959 | int sec_fac; |
3982 | unsigned long longsectors; | 3960 | unsigned long long bytes; /* really u64 */ |
3983 | 3961 | ||
3984 | get_sectorsize(); | 3962 | get_sectorsize(); |
3985 | sec_fac = sector_size / 512; | 3963 | sec_fac = sector_size / 512; |
@@ -3999,20 +3977,25 @@ get_geometry(void) { | |||
3999 | sectors = user_sectors ? user_sectors : | 3977 | sectors = user_sectors ? user_sectors : |
4000 | pt_sectors ? pt_sectors : | 3978 | pt_sectors ? pt_sectors : |
4001 | kern_sectors ? kern_sectors : 63; | 3979 | kern_sectors ? kern_sectors : 63; |
3980 | if (ioctl(fd, BLKGETSIZE64, &bytes) == 0) { | ||
3981 | /* got bytes */ | ||
3982 | } else { | ||
3983 | unsigned long longsectors; | ||
4002 | 3984 | ||
4003 | if (ioctl(fd, BLKGETSIZE, &longsectors)) | 3985 | if (ioctl(fd, BLKGETSIZE, &longsectors)) |
4004 | longsectors = 0; | 3986 | longsectors = 0; |
3987 | bytes = ((unsigned long long) longsectors) << 9; | ||
3988 | } | ||
3989 | |||
3990 | total_number_of_sectors = (bytes >> 9); | ||
4005 | 3991 | ||
4006 | sector_offset = 1; | 3992 | sector_offset = 1; |
4007 | if (dos_compatible_flag) | 3993 | if (dos_compatible_flag) |
4008 | sector_offset = sectors; | 3994 | sector_offset = sectors; |
4009 | 3995 | ||
4010 | cylinders = longsectors / (heads * sectors); | 3996 | cylinders = total_number_of_sectors / (heads * sectors * sec_fac); |
4011 | cylinders /= sec_fac; | ||
4012 | if (!cylinders) | 3997 | if (!cylinders) |
4013 | cylinders = user_cylinders; | 3998 | cylinders = user_cylinders; |
4014 | |||
4015 | total_number_of_sectors = longsectors; | ||
4016 | } | 3999 | } |
4017 | 4000 | ||
4018 | /* | 4001 | /* |
@@ -4198,10 +4181,10 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) | |||
4198 | default_ok = 0; | 4181 | default_ok = 0; |
4199 | 4182 | ||
4200 | if (default_ok) | 4183 | if (default_ok) |
4201 | snprintf(ms, mslen, _("%s (%d-%d, default %d): "), | 4184 | snprintf(ms, mslen, _("%s (%u-%u, default %u): "), |
4202 | mesg, low, high, dflt); | 4185 | mesg, low, high, dflt); |
4203 | else | 4186 | else |
4204 | snprintf(ms, mslen, "%s (%d-%d): ", | 4187 | snprintf(ms, mslen, "%s (%u-%u): ", |
4205 | mesg, low, high); | 4188 | mesg, low, high); |
4206 | 4189 | ||
4207 | while (1) { | 4190 | while (1) { |
@@ -4227,8 +4210,10 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) | |||
4227 | if (!display_in_cyl_units) | 4210 | if (!display_in_cyl_units) |
4228 | i *= heads * sectors; | 4211 | i *= heads * sectors; |
4229 | break; | 4212 | break; |
4230 | case 'k': | ||
4231 | case 'K': | 4213 | case 'K': |
4214 | absolute = 1024; | ||
4215 | break; | ||
4216 | case 'k': | ||
4232 | absolute = 1000; | 4217 | absolute = 1000; |
4233 | break; | 4218 | break; |
4234 | case 'm': | 4219 | case 'm': |
@@ -4263,7 +4248,7 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) | |||
4263 | } | 4248 | } |
4264 | } | 4249 | } |
4265 | if (use_default) | 4250 | if (use_default) |
4266 | printf(_("Using default value %d\n"), i = dflt); | 4251 | printf(_("Using default value %u\n"), i = dflt); |
4267 | if (i >= low && i <= high) | 4252 | if (i >= low && i <= high) |
4268 | break; | 4253 | break; |
4269 | else | 4254 | else |
@@ -4466,7 +4451,18 @@ change_sysid(void) { | |||
4466 | int i, sys, origsys; | 4451 | int i, sys, origsys; |
4467 | struct partition *p; | 4452 | struct partition *p; |
4468 | 4453 | ||
4454 | #ifdef CONFIG_FEATURE_SGI_LABEL | ||
4455 | /* If sgi_label then don't use get_existing_partition, | ||
4456 | let the user select a partition, since get_existing_partition() | ||
4457 | only works for Linux like partition tables. */ | ||
4458 | if (!sgi_label) { | ||
4469 | i = get_existing_partition(0, partitions); | 4459 | i = get_existing_partition(0, partitions); |
4460 | } else { | ||
4461 | i = get_partition(0, partitions); | ||
4462 | } | ||
4463 | #else | ||
4464 | i = get_existing_partition(0, partitions); | ||
4465 | #endif | ||
4470 | if (i == -1) | 4466 | if (i == -1) |
4471 | return; | 4467 | return; |
4472 | p = ptes[i].part_table; | 4468 | p = ptes[i].part_table; |
@@ -4618,7 +4614,7 @@ static void check_consistency(const struct partition *p, int partition) { | |||
4618 | 4614 | ||
4619 | static void | 4615 | static void |
4620 | list_disk_geometry(void) { | 4616 | list_disk_geometry(void) { |
4621 | long long bytes = (long long) total_number_of_sectors * 512; | 4617 | long long bytes = (total_number_of_sectors << 9); |
4622 | long megabytes = bytes/1000000; | 4618 | long megabytes = bytes/1000000; |
4623 | 4619 | ||
4624 | if (megabytes < 10000) | 4620 | if (megabytes < 10000) |
@@ -4630,7 +4626,7 @@ list_disk_geometry(void) { | |||
4630 | printf(_("%d heads, %d sectors/track, %d cylinders"), | 4626 | printf(_("%d heads, %d sectors/track, %d cylinders"), |
4631 | heads, sectors, cylinders); | 4627 | heads, sectors, cylinders); |
4632 | if (units_per_sector == 1) | 4628 | if (units_per_sector == 1) |
4633 | printf(_(", total %lu sectors"), | 4629 | printf(_(", total %llu sectors"), |
4634 | total_number_of_sectors / (sector_size/512)); | 4630 | total_number_of_sectors / (sector_size/512)); |
4635 | printf(_("\nUnits = %s of %d * %d = %d bytes\n\n"), | 4631 | printf(_("\nUnits = %s of %d * %d = %d bytes\n\n"), |
4636 | str_units(PLURAL), | 4632 | str_units(PLURAL), |
@@ -4831,14 +4827,14 @@ list_table(int xtra) { | |||
4831 | if (sector_size > 1024) | 4827 | if (sector_size > 1024) |
4832 | pblocks *= (sector_size / 1024); | 4828 | pblocks *= (sector_size / 1024); |
4833 | printf( | 4829 | printf( |
4834 | "%s %c %9ld %9ld %9ld%c %2x %s\n", | 4830 | "%s %c %11lu %11lu %11lu%c %2x %s\n", |
4835 | partname(disk_device, i+1, w+2), | 4831 | partname(disk_device, i+1, w+2), |
4836 | /* boot flag */ !p->boot_ind ? ' ' : p->boot_ind == ACTIVE_FLAG | 4832 | /* boot flag */ !p->boot_ind ? ' ' : p->boot_ind == ACTIVE_FLAG |
4837 | ? '*' : '?', | 4833 | ? '*' : '?', |
4838 | /* start */ (long) cround(get_partition_start(pe)), | 4834 | /* start */ (unsigned long) cround(get_partition_start(pe)), |
4839 | /* end */ (long) cround(get_partition_start(pe) + psects | 4835 | /* end */ (unsigned long) cround(get_partition_start(pe) + psects |
4840 | - (psects ? 1 : 0)), | 4836 | - (psects ? 1 : 0)), |
4841 | /* odd flag on end */ (long) pblocks, podd ? '+' : ' ', | 4837 | /* odd flag on end */ (unsigned long) pblocks, podd ? '+' : ' ', |
4842 | /* type id */ p->sys_ind, | 4838 | /* type id */ p->sys_ind, |
4843 | /* type name */ partition_type(p->sys_ind)); | 4839 | /* type name */ partition_type(p->sys_ind)); |
4844 | check_consistency(p, i); | 4840 | check_consistency(p, i); |
@@ -4867,7 +4863,7 @@ x_list_table(int extend) { | |||
4867 | pe = &ptes[i]; | 4863 | pe = &ptes[i]; |
4868 | p = (extend ? pe->ext_pointer : pe->part_table); | 4864 | p = (extend ? pe->ext_pointer : pe->part_table); |
4869 | if (p != NULL) { | 4865 | if (p != NULL) { |
4870 | printf("%2d %02x%4d%4d%5d%4d%4d%5d%9d%9d %02x\n", | 4866 | printf("%2d %02x%4d%4d%5d%4d%4d%5d%11u%11u %02x\n", |
4871 | i + 1, p->boot_ind, p->head, | 4867 | i + 1, p->boot_ind, p->head, |
4872 | sector(p->sector), | 4868 | sector(p->sector), |
4873 | cylinder(p->sector, p->cyl), p->end_head, | 4869 | cylinder(p->sector, p->cyl), p->end_head, |
@@ -5007,6 +5003,7 @@ add_partition(int n, int sys) { | |||
5007 | int i, readed = 0; | 5003 | int i, readed = 0; |
5008 | struct partition *p = ptes[n].part_table; | 5004 | struct partition *p = ptes[n].part_table; |
5009 | struct partition *q = ptes[ext_index].part_table; | 5005 | struct partition *q = ptes[ext_index].part_table; |
5006 | long long llimit; | ||
5010 | uint start, stop = 0, limit, temp, | 5007 | uint start, stop = 0, limit, temp, |
5011 | first[partitions], last[partitions]; | 5008 | first[partitions], last[partitions]; |
5012 | 5009 | ||
@@ -5018,10 +5015,13 @@ add_partition(int n, int sys) { | |||
5018 | fill_bounds(first, last); | 5015 | fill_bounds(first, last); |
5019 | if (n < 4) { | 5016 | if (n < 4) { |
5020 | start = sector_offset; | 5017 | start = sector_offset; |
5021 | if (display_in_cyl_units) | 5018 | if (display_in_cyl_units || !total_number_of_sectors) |
5022 | limit = heads * sectors * cylinders - 1; | 5019 | llimit = heads * sectors * cylinders - 1; |
5023 | else | 5020 | else |
5024 | limit = total_number_of_sectors - 1; | 5021 | llimit = total_number_of_sectors - 1; |
5022 | limit = llimit; | ||
5023 | if (limit != llimit) | ||
5024 | limit = 0x7fffffff; | ||
5025 | if (extended_offset) { | 5025 | if (extended_offset) { |
5026 | first[ext_index] = extended_offset; | 5026 | first[ext_index] = extended_offset; |
5027 | last[ext_index] = get_start_sect(q) + | 5027 | last[ext_index] = get_start_sect(q) + |
@@ -5792,7 +5792,20 @@ int fdisk_main(int argc, char **argv) { | |||
5792 | break; | 5792 | break; |
5793 | case 'd': | 5793 | case 'd': |
5794 | { | 5794 | { |
5795 | int j = get_existing_partition(1, partitions); | 5795 | int j; |
5796 | #ifdef CONFIG_FEATURE_SGI_LABEL | ||
5797 | /* If sgi_label then don't use get_existing_partition, | ||
5798 | let the user select a partition, since | ||
5799 | get_existing_partition() only works for Linux-like | ||
5800 | partition tables */ | ||
5801 | if (!sgi_label) { | ||
5802 | j = get_existing_partition(1, partitions); | ||
5803 | } else { | ||
5804 | j = get_partition(1, partitions); | ||
5805 | } | ||
5806 | #else | ||
5807 | j = get_existing_partition(1, partitions); | ||
5808 | #endif | ||
5796 | if (j >= 0) | 5809 | if (j >= 0) |
5797 | delete_partition(j); | 5810 | delete_partition(j); |
5798 | } | 5811 | } |