[Parted-maintainers] Bug#902224: parted: bogus rounding of exact sizes

Phillip Susi psusi at ubuntu.com
Mon Jun 25 14:31:57 BST 2018


On 6/23/2018 11:12 AM, Adam Borowski wrote:
> Start? 100mib                                                             
> End? 100%                                                                 
> Warning: You requested a partition from 100MiB to 14772MiB (sectors
> 204800..30253055).
> The closest location we can manage is 100MiB to 14772MiB (sectors
> 204801..30253055).

This is because the first partition includes sector 204800 so the
closest that can be allocated to the new partition is the next sector.
This behavior has been changed upstream already by the following commit,
which was released in parted 3.1, and so should be in debian, so I'm not
sure why you are seeing it:

commit 961abca12d1766264651dbe08284aeec3c0396c6
Author: Petr Uzel <petr.uzel at suse.cz>
Date:   Sat Oct 22 15:22:09 2011 +0200

    parted: mkpart: DWIM for IEC ending sector numbers like 2MiB and 9GiB

    Before, if the user specified start and end in mkpart command using
    IEC units, parted created a partition that starts and ends exactly on
    these positions. With such behavior, it is impossible to create
    partitions as follows: 1MiB-2MiB, 2MiB-3MiB - parted would complain
    that it cannot create the second partition, because the first one
    occupied sectors 2048-4096 and the second one sectors 4096-3072,
    so they would overlap at sector 4096.

    With this patch, if the user uses IEC units to specify end of the
    partition, parted creates the partition which ends one sector before
    the specified position.

    See also
    https://lists.gnu.org/archive/html/bug-parted/2011-10/msg00009.html

    * parted/ui.c (command_line_get_sector): Add parameter to retrieve
    raw input from user.
    * parted/ui.h (command_line_get_sector): Adjust prototype of function.
    * parted/parted.c (_adjust_end_if_iec): New function.
    (_strip_trailing_spaces): New function.
    (_string_ends_with_iec_unit): New function.
    (do_mkpart): Call _adjust_end_if_iec(). Use new parameter of
    command_line_get_sector function.
    (do_rescue): Adjust call to command_line_get_sector.
    * bootstrap.conf (gnulib_modules): Add these: c-ctype, c-strcase.
    * tests/t0207-IEC-binary-notation.sh: Adjust to new semantics.
    * NEWS: Mention the changed behavior.

    Notable adjustments:
    - s/isspace/c_isblank/ so that parsing is locale-independent
    - avoid an array-bounds error:
      * parted/parted.c (_strip_trailing_spaces): Don't deref str[-1]
      for an empty string.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/parted-maintainers/attachments/20180625/c1f445d5/attachment.sig>


More information about the Parted-maintainers mailing list