[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Fix parted sector size assumption



From: "Daniel P. Berrange" <berrange redhat com>

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 |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
index acc9171..964aa78 100644
--- a/src/storage/parthelper.c
+++ b/src/storage/parthelper.c
@@ -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);
     }
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]