Re: [code] Unlimited partitions, a try

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Alan Cox <alan@...>
Cc: H. Peter Anvin <hpa@...>, Jan Engelhardt <jengelh@...>, Linux Kernel Mailing List <linux-kernel@...>, Christophe Varoqui <christophe.varoqui@...>
Date: Saturday, October 6, 2007 - 4:36 am

Alan Cox wrote:

Then please fix support for extended partitions in kpartx (part of 
multipath-tools). Debian has an incomplete patch that does the right 
thing on activation, but not on deactivation of partitions, and has an 
obvious off-by-one in the "kpartx -l /dev/sda" output.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Edited by Alexander E. Patrakov to fix incorrect output of "kpartx -l"
Signed-off-by: Alexander E. Patrakov <patrakov@ums.usu.ru>

--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -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+1, 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 */


-- 
Alexander E. Patrakov
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[code] Unlimited partitions, a try, Jan Engelhardt, (Fri Oct 5, 7:50 am)
Re: [code] Unlimited partitions, a try, H. Peter Anvin, (Fri Oct 5, 6:11 pm)
Re: [code] Unlimited partitions, a try, Alan Cox, (Fri Oct 5, 7:29 pm)
Re: [code] Unlimited partitions, a try, Alexander E. Patrakov, (Sat Oct 6, 4:36 am)
Re: [code] Unlimited partitions, a try, H. Peter Anvin, (Fri Oct 5, 7:29 pm)
Re: [code] Unlimited partitions, a try, Bill Davidsen, (Sat Oct 6, 3:33 pm)
Re: [code] Unlimited partitions, a try, Lennart Sorensen, (Tue Oct 9, 2:15 pm)
Re: [code] Unlimited partitions, a try, Jan Engelhardt, (Fri Oct 5, 6:27 pm)
Re: [code] Unlimited partitions, a try, H. Peter Anvin, (Fri Oct 5, 6:57 pm)