Re: cfdisk - possible error ?

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

 



On Fri, 2010-08-06 at 17:42 +0200, J B wrote:
> Hi,
> recently while fixing a disk, I got this error msg:
> # cfdisk -Ps
> FATAL ERROR: Bad primary partition 2: Partition ends in the final partial
> cylinder
> 
> I was a little suspicious about the partition # 2.
> 
> $ yum list util-linux-ng
> Installed Packages
> util-linux-ng.i686                    2.17.2-7.fc13                     @updates
> 
> I looked up the cfdisk.c and saw some logic that may have a bug.
> 
> ...
> static void
> fill_p_info(void) {
> ...
>         for (i = 0; i < 4; i++) {
>             p = & buffer.p.part[i];
>             bs = get_start_sect(p);
>             bsz = get_nr_sects(p);
> 
>             if (p->sys_ind > 0 &&
>                 add_part(i, p->sys_ind, p->boot_ind,
>                          ((bs <= sectors) ? 0 : bs), bs + bsz - 1,
>                          ((bs <= sectors) ? bs : 0), 1, &errmsg)) {
>                     char *bad = _("Bad primary partition");
>                     char *msg = (char *) xmalloc(strlen(bad) +
> strlen(errmsg) + 30);
> /*
> BUG <--------------------------------------------------------------------------
>      i - primary partition index 0-3
>      For display, use i+1 to refer to primary partition number 1-4,
>      which corresponds to e.g. /dev/sda1 thru /dev/sda4.
>      NOTE: this kind of bug may be present in other places here as well.
>                     sprintf(msg, "%s %d: %s", bad, i, errmsg);
> BUG <--------------------------------------------------------------------------
> */
>                     sprintf(msg, "%s %d: %s", bad, i+1, errmsg);     /* fix */
>                     fatal(msg, 4);
>             }
>             if (is_extended(buffer.p.part[i].sys_ind))
>                 tmp_ext = ext_info;
>         }
> ...
> }
> 
> Please verify it and fix it if I am not mistaken.

I was able to reproduce the error on a disk I own, the mentioned fix
just prints a higher value of i, but the error still occurs.

I doubt this is a bug, but a problem with your disk/partition layout. By
using the -z option you can redo the partitions. Fdisk itself does not
have any problems reading the disk cfdisk could not, so you can also try
using that tool.

Davidlohr

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux