* [PATCH] kpartx: Handle extended partitions correctly
@ 2007-08-06 11:21 Hannes Reinecke
0 siblings, 0 replies; only message in thread
From: Hannes Reinecke @ 2007-08-06 11:21 UTC (permalink / raw)
To: christophe varoqui; +Cc: device-mapper development
[-- Attachment #1: Type: text/plain, Size: 402 bytes --]
Hi Christophe,
there is actually a small bug in kpartx; it calculates the size
for an extended partition relative to the entire disk, not
the contained partition. This patch fixes this.
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
[-- Attachment #2: kpartx-fixup-extended-partitions --]
[-- Type: text/plain, Size: 2516 bytes --]
kpartx: Handle extended partitions correctly
When creating the device-mapper table for an extended partition we
should calculate the size relative to the containing partition, not
to the entire device.
Signed-off-by: Hannes Reinecke <hare@suse.de>
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
index dbe2ee2..f60e5f4 100644
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -265,7 +265,7 @@ main(int argc, char **argv){
}
if (dm_prereq(DM_TARGET, 0, 0, 0) && (what == ADD || what == DELETE)) {
- fprintf(stderr, "device mapper prerequisites not met\n");
+ fprintf(stderr, "device mapper prerequisites not met\n");
exit(1);
}
@@ -387,10 +387,10 @@ main(int argc, char **argv){
slices[j].minor = m++;
start = slices[j].start - slices[k].start;
- printf("%s%s%d : 0 %lu /dev/dm-%d %lu\n",
+ printf("%s%s%d : 0 %lu %s%s%d %lu\n",
mapname, delim, j+1,
(unsigned long) slices[j].size,
- slices[k].minor, start);
+ mapname, delim, k, start);
c--;
}
/* Terminate loop if nothing more to resolve */
@@ -431,7 +431,7 @@ main(int argc, char **argv){
break;
case ADD:
- for (j=0, c = 0; j<n; j++) {
+ for (j = 0, c = 0; j < n; j++) {
if (slices[j].size == 0)
continue;
@@ -477,6 +477,7 @@ main(int argc, char **argv){
d = c;
while (c) {
for (j = 0; j < n; j++) {
+ unsigned long start;
int k = slices[j].container - 1;
if (slices[j].size == 0)
@@ -487,7 +488,7 @@ main(int argc, char **argv){
continue;
/* Skip all simple slices */
- if (k < 0)
+ if (slices[j].container == 0)
continue;
/* Check container slice */
@@ -502,10 +503,11 @@ main(int argc, char **argv){
}
strip_slash(partname);
+ start = slices[j].start - slices[k].start;
if (safe_sprintf(params, "%d:%d %lu",
slices[k].major,
slices[k].minor,
- (unsigned long)slices[j].start)) {
+ start)) {
fprintf(stderr, "params too small\n");
exit(1);
}
@@ -524,9 +526,12 @@ main(int argc, char **argv){
&slices[j].minor);
if (verbose)
- printf("add map %s : 0 %lu %s %s\n",
- partname, slices[j].size,
- DM_TARGET, params);
+ printf("add map %s (%d:%d): 0 %lu %s\n",
+ partname,
+ slices[j].major,
+ slices[j].minor,
+ slices[j].size,
+ params);
c--;
}
/* Terminate loop */
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-08-06 11:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-06 11:21 [PATCH] kpartx: Handle extended partitions correctly Hannes Reinecke
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.