Hi,

same problem here, fdisk does not accept sector numbers above 2^31 - 1 on input. While looking at it, I found some more missing long long conversions when moving the start of a partition. The following patch works here--it is not thoroughly tested though.

Regards,
Stephan

commit 3e7462f85d6e4ce5205f6907f5568b07d1a3a95a
Author: Stephan Springl <stephan-fd...@bfw-online.de>
Date:   2011-03-09 17:21:33 +0100

    more long longs for large sector numbers

diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 1d7196e..8ab6217 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -1371,11 +1371,12 @@ read_hex(struct systypes *sys)
         }
 }

-static unsigned int
-read_int_sx(unsigned int low, unsigned int dflt, unsigned int high,
-        unsigned int base, char *mesg, int *suffix)
+static unsigned long long
+read_int_sx(unsigned long long low, unsigned long long dflt,
+        unsigned long long high, unsigned long long base, char *mesg,
+        int *suffix)
 {
-       unsigned int i;
+       unsigned long long i;
        int default_ok = 1;
        static char *ms = NULL;
        static int mslen = 0;
@@ -1390,10 +1391,10 @@ read_int_sx(unsigned int low, unsigned int dflt, 
unsigned int high,
                default_ok = 0;

        if (default_ok)
-               snprintf(ms, mslen, _("%s (%u-%u, default %u): "),
+               snprintf(ms, mslen, _("%s (%Lu-%Lu, default %Lu): "),
                         mesg, low, high, dflt);
        else
-               snprintf(ms, mslen, "%s (%u-%u): ",
+               snprintf(ms, mslen, "%s (%Lu-%Lu): ",
                         mesg, low, high);

        while (1) {
@@ -1409,7 +1410,7 @@ read_int_sx(unsigned int low, unsigned int dflt, unsigned 
int high,
                        int absolute = 0;
                        int suflen;

-                       i = atoi(line_ptr+1);
+                       i = atoll(line_ptr+1);

                        while (isdigit(*++line_ptr))
                                use_default = 0;
@@ -1479,14 +1480,14 @@ read_int_sx(unsigned int low, unsigned int dflt, 
unsigned int high,
                                i = -i;
                        i += base;
                } else {
-                       i = atoi(line_ptr);
+                       i = atoll(line_ptr);
                        while (isdigit(*line_ptr)) {
                                line_ptr++;
                                use_default = 0;
                        }
                }
                if (use_default)
-                       printf(_("Using default value %u\n"), i = dflt);
+                       printf(_("Using default value %Lu\n"), i = dflt);
                if (i >= low && i <= high)
                        break;
                else
@@ -1502,9 +1503,9 @@ read_int_sx(unsigned int low, unsigned int dflt, unsigned 
int high,
  *
  * There is no default if DFLT is not between LOW and HIGH.
  */
-unsigned int
-read_int(unsigned int low, unsigned int dflt, unsigned int high,
-        unsigned int base, char *mesg)
+unsigned long long
+read_int(unsigned long long low, unsigned long long dflt,
+        unsigned long long high, unsigned long long base, char *mesg)
 {
        return read_int_sx(low, dflt, high, base, mesg, NULL);
 }
@@ -2643,7 +2644,7 @@ static void
 move_begin(int i) {
        struct pte *pe = &ptes[i];
        struct partition *p = pe->part_table;
-       unsigned int new, first;
+       unsigned long long new, first;

        if (warn_geometry())
                return;
diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h
index 1a89beb..7e156ef 100644
--- a/fdisk/fdisk.h
+++ b/fdisk/fdisk.h
@@ -73,8 +73,10 @@ extern int read_hex(struct systypes *sys);
 extern void reread_partition_table(int leave);
 extern struct partition *get_part_table(int);
 extern int valid_part_table_flag(unsigned char *b);
-extern unsigned int read_int(unsigned int low, unsigned int dflt,
-                            unsigned int high, unsigned int base, char *mesg);
+extern unsigned long long read_int(unsigned long long low,
+                                  unsigned long long dflt,
+                                  unsigned long long high,
+                                  unsigned long long base, char *mesg);

 extern unsigned char *MBRbuffer;
 extern void zeroize_mbr_buffer(void);



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to