Bug#630130: kpartx creates wrong partition mappings for gpt with sector size != 512bytes

Ritesh Raj Sarraf rrs at debian.org
Sat Jun 11 12:14:38 UTC 2011


Hello Philipp,

Have you discussed this upstream?

On 06/11/2011 03:55 PM, Philipp Schmidt wrote:
> Package: kpartx
> Version: 0.4.8+git0.761c66f
> Severity: important
> Tags: upstream
>
> Hello,
>
> kpartx creates wrong partiton mappings for gpt partition tables when the
> sector size ist not 512 bytes (e.g. 4k exported by an fcal array). This
> may lead to data corruption when trying to write to the created devices.
>
> I have attached a patch fixing the problem.
>
> --- gpt.c.orig	2009-08-04 23:34:22.000000000 +0200
> +++ gpt.c	2011-06-11 12:09:29.000000000 +0200
> @@ -619,6 +619,7 @@
>  	uint32_t i;
>  	int n = 0;
>  	int last_used_index=-1;
> +	int sector_size_mul = get_sector_size(fd)/512;
>  
>  	if (!find_valid_gpt (fd, &gpt, &ptes) || !gpt || !ptes) {
>  		if (gpt)
> @@ -634,9 +635,9 @@
>  			sp[n].size = 0;
>  			n++;
>  		} else {
> -			sp[n].start = __le64_to_cpu(ptes[i].starting_lba);
> -			sp[n].size  = __le64_to_cpu(ptes[i].ending_lba) -
> -				__le64_to_cpu(ptes[i].starting_lba) + 1;
> +			sp[n].start = __le64_to_cpu(ptes[i].starting_lba)*sector_size_mul;
> +			sp[n].size  = (__le64_to_cpu(ptes[i].ending_lba) -
> +				__le64_to_cpu(ptes[i].starting_lba) + 1)*sector_size_mul;
>                          last_used_index=n;
>  			n++;
>  		}
>
>
>


-- 
Ritesh Raj Sarraf | http://people.debian.org/~rrs
Debian - The Universal Operating System


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-lvm-maintainers/attachments/20110611/1f718aca/attachment-0001.pgp>


More information about the pkg-lvm-maintainers mailing list