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

2011-06-11 Thread Philipp Schmidt
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.0 +0200
+++ gpt.c   2011-06-11 12:09:29.0 +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++;
}



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



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

2011-06-11 Thread Ritesh Raj Sarraf
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.orig2009-08-04 23:34:22.0 +0200
 +++ gpt.c 2011-06-11 12:09:29.0 +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




signature.asc
Description: OpenPGP digital signature