If (cylinder_times_heads / heads_per_cylinder) has a remainder increase the cylinder...
authorRobert Pengelly <robertapengelly@hotmail.com>
Thu, 20 Mar 2025 16:50:46 +0000 (16:50 +0000)
committerRobert Pengelly <robertapengelly@hotmail.com>
Thu, 20 Mar 2025 16:50:46 +0000 (16:50 +0000)
parted.c

index acb27011bbb12713201e9ceac0282188842896cc..2c3bf27c55e31248b87abebf478d172b2e96459e 100644 (file)
--- a/parted.c
+++ b/parted.c
@@ -141,6 +141,17 @@ static void calculate_geometry (void) {
     }
     
     cylinders = cylinder_times_heads / heads_per_cylinder;
+    
+    if (cylinder_times_heads % heads_per_cylinder) {
+    
+        cylinders++;
+        
+        state->image_size = ((cylinders * heads_per_cylinder) * sectors_per_track);
+        state->image_size += ((heads_per_cylinder - 1) * sectors_per_track);
+        
+        state->image_size = (state->image_size + (sectors_per_track - 1)) * 512;
+    
+    }
 
 }