[Parted-maintainers] _primary_constraint(): start_geom is uninitialized if min_geom==0 && cylinder_size < dev->length. Debian bug #602568

Jean-Christian de Rivaz jc at eclis.ch
Tue Nov 9 13:01:58 GMT 2010


Jim Meyering a écrit :
> Thank you for the bug report and for tracking down the
> offending commit.
> 
> That change ensures that this unusual condition is
> caught early enough.  Before that change, passing a negative
> length to ped_geometry_init would have triggered a failed
> assertion or something similarly unpleasant.
> Thus, simply reverting it just reintroduces the original problem.
> 
>> commit c79d91ec71882a1673daae0482aa90c514c63cc1
>> Author: Jim Meyering <meyering at redhat.com>
>> Date:   Tue Mar 30 16:50:59 2010 +0200
>>
>>     dos: accommodate very small devices (useful for testing)
>>
>>     * libparted/labels/dos.c (_primary_constraint): Don't pass a negative
>>     "device_length" to ped_geometry_init when the underlying device
>>     has fewer sectors than a "cylinder".
> 
> Here's a patch to solve the problem.
> It relaxes the constraint to use a starting sector of "1",
> if necessary.
> 
> Please let me know if it works for you:

Your patch work fine, thank you for providing it.

root at point:/home/jcdr/parted-git/parted/build-O0# parted/parted /dev/sdb 
print
Model: disk2go PURE II (scsi)
Disk /dev/sdb: 5243kB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End     Size    Type     File system  Flags
  1      5120B  5243kB  5238kB  primary

The debug capture in attachment prove that your logic is the right one 
for this case.

Now I just wonder if parted should display FAT16 in the file system 
field. Because fdisk do it:

root at point:/home/jcdr/parted-git/parted/build-O0# fdisk -l /dev/sdb

Disk /dev/sdb: 5 MB, 5242880 bytes
1 heads, 10 sectors/track, 1024 cylinders
Units = cylinders of 10 * 512 = 5120 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

    Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               2        1024        5115    6  FAT16


And parted do it for the /dev/sdc (the regular storage device of this 
USB key):

root at point:/home/jcdr/parted-git/parted/build-O0# parted/parted /dev/sdc 
print
Model: disk2go PURE II (scsi)
Disk /dev/sdc: 2142MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system  Flags
  1      0.00B  2142MB  2142MB  fat16


Jean-Christian de Rivaz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture-DDD: -home-jcdr-parted-git-parted-libparted-labels-dos.c.png
Type: image/png
Size: 53760 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/parted-maintainers/attachments/20101109/a054ed2f/attachment-0001.png>


More information about the Parted-maintainers mailing list