]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix parted sector size assumption
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 23 Aug 2011 14:25:28 +0000 (15:25 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 1 Sep 2011 09:46:31 +0000 (10:46 +0100)
Parted does not report disk size in 512 byte units, but
rather the disks' logical sector size, which with modern
drives might be 4k.

* src/storage/parthelper.c: Remove hardcoded 512 byte sector
  size

src/storage/parthelper.c

index acc917190476e406d2bdae4a4e152ccb3b113ef6..964aa780d2a0405ef6df0691386124f507f005c4 100644 (file)
@@ -157,17 +157,17 @@ int main(int argc, char **argv)
                    part->num, '\0',
                    type, '\0',
                    content, '\0',
-                   part->geom.start * 512llu, '\0',
-                   (part->geom.end + 1 ) * 512llu, '\0',
-                   part->geom.length * 512llu, '\0');
+                   part->geom.start * dev->sector_size, '\0',
+                   (part->geom.end + 1 ) * dev->sector_size, '\0',
+                   part->geom.length * dev->sector_size, '\0');
         } else {
             printf("%s%c%s%c%s%c%llu%c%llu%c%llu%c",
                    "-", '\0',
                    type, '\0',
                    content, '\0',
-                   part->geom.start * 512llu, '\0',
-                   (part->geom.end + 1 ) * 512llu, '\0',
-                   part->geom.length * 512llu, '\0');
+                   part->geom.start * dev->sector_size, '\0',
+                   (part->geom.end + 1 ) * dev->sector_size, '\0',
+                   part->geom.length * dev->sector_size, '\0');
         }
         part = ped_disk_next_partition(disk, part);
     }