fix extended partition mapping
PATCH 1/1 fix extended partition mapping
The linux kernel maps the extended partition only
so that LILO can be installed there. The length is always set to two sectors to allow this, and most tools know to ignore the device. kpartx was mapping the entire extended partition, then stacking the logical partitions on top of it. This presented a device that looked like an entirely separate disk that contains only the logical partitions. This patch fixes kpartx to conform with the normal Linux behavior.
--- kpartx/dos.c | 2 ++ kpartx/kpartx.c | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-)
kpartx/dos.c +2 -0
@@ -98,6 +98,8 @@ read_dos_pt(int fd, struct slice all, struct slice *sp, int ns) {break ; }if (is_extended (p.sys_type)) { + sp[i].size =2 ;/* extended partitions only get two +sectors mapped for LILO to install */ n +=read_extended_partition (fd, &p, i, sp+n, ns-n); } }
kpartx/kpartx.c +3 -6
@@ -515,7 +515,6 @@ main(int argc, char **argv){ d = c;while (c) {for (j =0 ; j < n; j++) { -uint64_t start;int k = slices[j].container -1 ;if (slices[j].size ==0 )
@@ -541,11 +540,9 @@ main(int argc, char **argv){ }strip_slash (partname); - start = slices[j].start - slices[k].start; -if (safe_sprintf (params,"%d:%d %" PRIu64, - slices[k].major, - slices[k].minor, - start)) { +if (safe_sprintf (params,"%s %" PRIu64, + device, + slices[j].start)) {fprintf (stderr,"params too small\n" );exit (1 ); }
Signature · 1 line
1.7.10.4
Christophe Varoqui
AppliedQuoted 8 lines · Phillip Susi
The linux kernel maps the extended partition only
so that LILO can be installed there. The length is always set to two sectors to allow this, and most tools know to ignore the device. kpartx was mapping the entire extended partition, then stacking the logical partitions on top of it. This presented a device that looked like an entirely separate disk that contains only the logical partitions. This patch fixes kpartx to conform with the normal Linux behavior.
Applied.
Thanks.
Quoted 45 lines
--- kpartx/dos.c | 2 ++ kpartx/kpartx.c | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-)kpartx/dos.c +2
-0@@ -98,6 +98,8 @@ read_dos_pt(int fd, struct slice all, struct slice *sp, int ns) {break ; }if (is_extended (p.sys_type)) { + sp[i].size =2 ;/* extended partitions only get two +sectors mapped for LILO to install */ n +=read_extended_partition (fd, &p, i, sp+n, ns-n); } }kpartx/kpartx.c +3
-6@@ -515,7 +515,6 @@ main(int argc, char **argv){ d = c;while (c) {for (j =0 ; j < n; j++) { -uint64_t start;int k = slices[j].container -1 ;if (slices[j].size ==0 )@@ -541,11 +540,9 @@ main(int argc, char **argv){ }strip_slash (partname); - start = slices[j].start - slices[k].start; -if (safe_sprintf (params,"%d:%d %" PRIu64, - slices[k].major, - slices[k].minor, - start)) { +if (safe_sprintf (params,"%s %" PRIu64, + device, + slices[j].start)) {fprintf (stderr,"params too small\n" );exit (1 ); }