Fix partitions bigger than 2TB
authorDinar Valeev <dvaleev@suse.com>
Sat, 11 May 2013 08:20:10 +0000 (10:20 +0200)
committerTony Breeds <tony@bakeyournoodle.com>
Mon, 13 May 2013 05:03:24 +0000 (15:03 +1000)
Partitions which are bigger than 2TB doesn't fit unsigned long,
change it ot unsigned long long.

Signed-off-by: Dinar Valeev <dvaleev@suse.com>
Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
include/partition.h
second/file.c
second/fs_ext2.c
second/partition.c

index 23c99bae224d9b4cdd3ac27695a7f2ca817b596b..c9c4d0bd584b6741d4bc5a20b6b1f48117872e0e 100644 (file)
@@ -37,8 +37,8 @@ struct partition_t {
        int                     part_number;
        char                    part_type[MAX_PART_NAME];
         char                    part_name[MAX_PART_NAME];
-       unsigned long           part_start; /* In blocks */
-       unsigned long           part_size; /* In blocks */
+       unsigned long long      part_start; /* In blocks */
+       unsigned long long      part_size; /* In blocks */
        unsigned short          blocksize;
        int                     sys_ind; /* fs type */
 };
index 02b187231716e318964dc77681637d000ad2a35a..8412075689e08efa77a6da97b0bbb61490059231 100644 (file)
@@ -590,7 +590,7 @@ file_block_open(    struct boot_file_t*     file,
          prom_printf("no partitions found.\n");
 #endif
      for (p = parts; p && !found; p=p->next) {
-         DEBUG_F("number: %02d, start: 0x%08lx, length: 0x%08lx\n",
+         DEBUG_F("number: %02d, start: 0x%08Lx, length: 0x%08Lx\n",
                  p->part_number, p->part_start, p->part_size );
          if (partition == -1) {
               file->fs = fs_open( file, p, fspec );
index 41a3c79cce2096ac513e9135ccb677b072a67f4f..5d5a5c78d7636fec310c92f40b31c1ed4c244a01 100644 (file)
@@ -164,8 +164,8 @@ ext2_open(  struct boot_file_t*     file,
       */
      doff = dend = 0;
      if (part) {
-         doff = (unsigned long long)(part->part_start) * part->blocksize;
-         dend = doff + (unsigned long long)part->part_size * part->blocksize;
+         doff = part->part_start * part->blocksize;
+         dend = doff + part->part_size * part->blocksize;
      }
      cur_file = file;
 
index 7facbc46b3f68284576b781237b7c7c4a022ae2e..64b4725e78ee392b52ef680f504201fcee504b39 100644 (file)
@@ -68,7 +68,7 @@ static unsigned char block_buffer[MAX_BLOCK_SIZE];
 
 static void
 add_new_partition(struct partition_t** list, int part_number, const char *part_type,
-                 const char *part_name, unsigned long part_start, unsigned long part_size,
+                 const char *part_name, unsigned long long part_start, unsigned long long part_size,
                  unsigned short part_blocksize, int sys_ind)
 {
      struct partition_t*       part;
@@ -452,7 +452,7 @@ get_part_type(char *device, int partition)
          return '\0';
 
      for (p = parts; p && !found; p=p->next) {
-         DEBUG_F("number: %02d, start: 0x%08lx, length: 0x%08lx, type: %s, name: %s\n",
+         DEBUG_F("number: %02d, start: 0x%08Lx, length: 0x%08Lx, type: %s, name: %s\n",
                  p->part_number, p->part_start, p->part_size, p->part_type, p->part_name);
          if ((partition >= 0) && (partition == p->part_number)) {
               type = strdup(p->part_type);