Hi,

Timo Juhani Lindfors wrote:

> thanks for the report. I can reproduce the problem with the attached
> partition table image.

Thanks.  When I try to reproduce this with "cfdisk parttable1.img"
(also with -g or overriding the C/H/S values), I get "FATAL ERROR:
Cannot get disk size".  I guess I should be testing using a vm, but
I'm lazy. :)

Anyway, how about this patch for squeeze?  Possible changelog entry:

  * From upstream: cfdisk: don't use size of device based on cylinders.
    Closes: #613589

Patch is against commit 5e5f7dac (changelog: release, 2011-01-25) from
git://git.debian.org/~lamont/util-linux.git.  Seems to build fine,
though that doesn't mean much.

-- >8 --
From: Karel Zak <k...@redhat.com>
Date: Mon, 6 Sep 2010 13:30:48 +0200
Subject: cfdisk: don't use size of device based on cylinders

commit 73356e0553bd9ac00f556891a4798064c0ee6849 upstream.

This patch is enough to make cfdisk usable on non-DOS disks where
partitioning is not based on CHS. cfdisk should not print error
messages for such disks.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=630340
Signed-off-by: Karel Zak <k...@redhat.com>
Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 fdisk/cfdisk.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c
index 4fb41529..5b9aaebe 100644
--- a/fdisk/cfdisk.c
+++ b/fdisk/cfdisk.c
@@ -177,7 +177,6 @@ int heads = 0;
 int sectors = 0;
 long long cylinders = 0;
 int cylinder_size = 0;         /* heads * sectors */
-long long total_size = 0;      /* actual_size rounded down */
 long long actual_size = 0;     /* (in 512-byte sectors) - set using ioctl */
                                /* explicitly given user values */
 int user_heads = 0, user_sectors = 0;
@@ -879,7 +878,7 @@ del_part(int i) {
     if (i < num_parts - 1)
        p_info[i].last_sector = p_info[i+1].first_sector - 1;
     else
-       p_info[i].last_sector = total_size - 1;
+       p_info[i].last_sector = actual_size - 1;
 
     p_info[i].offset = 0;
     p_info[i].flags = 0;
@@ -928,7 +927,7 @@ add_part(int num, int id, int flags, long long first, long 
long last,
        return -1;
     }
 
-    if (first >= total_size) {
+    if (first >= actual_size) {
        *errmsg = _("Partition begins after end-of-disk");
        return -1;
     }
@@ -938,11 +937,6 @@ add_part(int num, int id, int flags, long long first, long 
long last,
        return -1;
     }
 
-    if (last >= total_size) {
-       *errmsg = _("Partition ends in the final partial cylinder");
-       return -1;
-    }
-
     for (i = 0; i < num_parts; i++) {
        if (p_info[i].id > 0 && IS_PRIMARY(p_info[i].num))
            pri++;
@@ -1637,8 +1631,7 @@ decide_on_geometry(void) {
     if (user_cylinders > 0)
            cylinders = user_cylinders;
 
-    total_size = cylinder_size*cylinders;
-    if (total_size > actual_size)
+    if (cylinder_size * cylinders > actual_size)
            print_warning(_("You specified more cylinders than fit on disk"));
 }
 
@@ -1646,7 +1639,7 @@ static void
 clear_p_info(void) {
     num_parts = 1;
     p_info[0].first_sector = 0;
-    p_info[0].last_sector = total_size - 1;
+    p_info[0].last_sector = actual_size - 1;
     p_info[0].offset = 0;
     p_info[0].flags = 0;
     p_info[0].id = FREE_SPACE;
@@ -2429,7 +2422,7 @@ change_geometry(void) {
     if (ret_val) {
        long long disk_end;
 
-       disk_end = total_size-1;
+       disk_end = actual_size-1;
 
        if (p_info[num_parts-1].last_sector > disk_end) {
            while (p_info[num_parts-1].first_sector > disk_end) {
-- 
1.7.9.rc2




-- 
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