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

Re: [libvirt] [PATCH] Fix parted sector size assumption



On Wed, Aug 31, 2011 at 11:04:04AM +0100, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
> 
> Parted does not report disk size in 512 byte units, but
> rather the disks' logical sector size, which with modern
> drives might be 4k.
> 
> * src/storage/parthelper.c: Remove hardcoded 512 byte sector
>   size
> ---
>  src/storage/parthelper.c |   12 ++++++------
>  1 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
> index acc9171..964aa78 100644
> --- a/src/storage/parthelper.c
> +++ b/src/storage/parthelper.c
> @@ -157,17 +157,17 @@ int main(int argc, char **argv)
>                     part->num, '\0',
>                     type, '\0',
>                     content, '\0',
> -                   part->geom.start * 512llu, '\0',
> -                   (part->geom.end + 1 ) * 512llu, '\0',
> -                   part->geom.length * 512llu, '\0');
> +                   part->geom.start * dev->sector_size, '\0',
> +                   (part->geom.end + 1 ) * dev->sector_size, '\0',
> +                   part->geom.length * dev->sector_size, '\0');
>          } else {
>              printf("%s%c%s%c%s%c%llu%c%llu%c%llu%c",
>                     "-", '\0',
>                     type, '\0',
>                     content, '\0',
> -                   part->geom.start * 512llu, '\0',
> -                   (part->geom.end + 1 ) * 512llu, '\0',
> -                   part->geom.length * 512llu, '\0');
> +                   part->geom.start * dev->sector_size, '\0',
> +                   (part->geom.end + 1 ) * dev->sector_size, '\0',
> +                   part->geom.length * dev->sector_size, '\0');
>          }
>          part = ped_disk_next_partition(disk, part);
>      }

  ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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