2 kpartx/bsd.c | 35 ----------------
4 kpartx/kpartx.c | 121 +++++++-------------------------------------------------
6 kpartx/sun.c | 35 ----------------
7 5 files changed, 24 insertions(+), 175 deletions(-)
9 Index: multipath-tools/kpartx/bsd.c
10 ===================================================================
11 --- multipath-tools.orig/kpartx/bsd.c
12 +++ multipath-tools/kpartx/bsd.c
13 @@ -50,10 +50,10 @@ int
14 read_bsd_pt(int fd, struct slice all, struct slice *sp, int ns) {
15 struct bsd_disklabel *l;
16 struct bsd_partition *p;
17 - unsigned int offset = all.start, end;
18 + unsigned int offset = all.start;
24 bp = getblock(fd, offset+1); /* 1 sector suffices */
26 @@ -79,36 +79,5 @@ read_bsd_pt(int fd, struct slice all, st
31 - * Convention has it that the bsd disklabel will always have
32 - * the 'c' partition spanning the entire disk.
33 - * So we have to check for contained slices.
35 - for(i = 0; i < n; i++) {
36 - if (sp[i].size == 0)
39 - end = sp[i].start + sp[i].size;
40 - for(j = 0; j < n; j ++) {
43 - if (sp[j].size == 0)
46 - if (sp[i].start < sp[j].start) {
47 - if (end > sp[j].start &&
48 - end < sp[j].start + sp[j].size) {
51 - "bsd_disklabel: slice %d overlaps with %d\n", i , j);
55 - if (end <= sp[j].start + sp[j].size) {
56 - sp[i].container = j + 1;
63 Index: multipath-tools/kpartx/dos.c
64 ===================================================================
65 --- multipath-tools.orig/kpartx/dos.c
66 +++ multipath-tools/kpartx/dos.c
67 @@ -16,7 +16,7 @@ is_extended(int type) {
71 -read_extended_partition(int fd, struct partition *ep, int en,
72 +read_extended_partition(int fd, struct partition *ep,
73 struct slice *sp, int ns)
76 @@ -53,7 +53,6 @@ read_extended_partition(int fd, struct p
78 sp[n].start = here + le32_to_cpu(p.start_sect);
79 sp[n].size = le32_to_cpu(p.nr_sects);
80 - sp[n].container = en + 1;
84 @@ -98,7 +97,9 @@ read_dos_pt(int fd, struct slice all, st
87 if (is_extended(p.sys_type)) {
88 - n += read_extended_partition(fd, &p, i, sp+n, ns-n);
89 + n += read_extended_partition(fd, &p, sp+n, ns-n);
90 + /* hide the extended partition itself */
95 Index: multipath-tools/kpartx/kpartx.c
96 ===================================================================
97 --- multipath-tools.orig/kpartx/kpartx.c
98 +++ multipath-tools/kpartx/kpartx.c
99 @@ -185,7 +185,7 @@ get_hotplug_device(void)
102 main(int argc, char **argv){
103 - int fd, i, j, m, n, op, off, arg, c, d;
104 + int fd, i, j, k, n, op, off, arg;
107 enum action what = LIST;
108 @@ -355,49 +355,30 @@ main(int argc, char **argv){
113 + * test for overlap, as in the case of an extended partition
114 + * zero their size to avoid mapping
116 + for (j = 0; j < n; j++) {
117 + for (k = j + 1; k < n; k++) {
118 + if (slices[k].start > slices[j].start &&
119 + slices[k].start < slices[j].start +
121 + slices[j].size = 0;
127 - for (j = 0, c = 0, m = 0; j < n; j++) {
128 + for (j = 0; j < n; j++) {
129 if (slices[j].size == 0)
131 - if (slices[j].container > 0) {
136 - slices[j].minor = m++;
138 printf("%s%s%d : 0 %" PRIu64 " %s %" PRIu64"\n",
140 slices[j].size, device,
143 - /* Loop to resolve contained slices */
146 - for (j = 0; j < n; j++) {
148 - int k = slices[j].container - 1;
150 - if (slices[j].size == 0)
152 - if (slices[j].minor > 0)
154 - if (slices[j].container == 0)
156 - slices[j].minor = m++;
158 - start = slices[j].start - slices[k].start;
159 - printf("%s%s%d : 0 %" PRIu64 " /dev/dm-%d %" PRIu64 "\n",
160 - mapname, delim, j+1,
162 - slices[k].minor, start);
165 - /* Terminate loop if nothing more to resolve */
170 if (loopcreated && S_ISREG (buf.st_mode)) {
171 if (del_loop(device)) {
172 @@ -443,16 +424,10 @@ main(int argc, char **argv){
176 - for (j = 0, c = 0; j < n; j++) {
177 + for (j = 0; j < n; j++) {
178 if (slices[j].size == 0)
181 - /* Skip all contained slices */
182 - if (slices[j].container > 0) {
187 if (safe_sprintf(partname, "%s%s%d",
188 mapname, delim, j+1)) {
189 fprintf(stderr, "partname too small\n");
190 @@ -493,70 +468,6 @@ main(int argc, char **argv){
191 slices[j].minor, slices[j].size,
194 - /* Loop to resolve contained slices */
197 - for (j = 0; j < n; j++) {
199 - int k = slices[j].container - 1;
201 - if (slices[j].size == 0)
204 - /* Skip all existing slices */
205 - if (slices[j].minor > 0)
208 - /* Skip all simple slices */
209 - if (slices[j].container == 0)
212 - /* Check container slice */
213 - if (slices[k].size == 0)
214 - fprintf(stderr, "Invalid slice %d\n",
217 - if (safe_sprintf(partname, "%s%s%d",
218 - mapname, delim, j+1)) {
219 - fprintf(stderr, "partname too small\n");
222 - strip_slash(partname);
224 - start = slices[j].start - slices[k].start;
225 - if (safe_sprintf(params, "%d:%d %" PRIu64,
229 - fprintf(stderr, "params too small\n");
233 - op = (dm_map_present(partname) ?
234 - DM_DEVICE_RELOAD : DM_DEVICE_CREATE);
236 - dm_addmap(op, partname, DM_TARGET, params,
237 - slices[j].size, uuid, j+1,
238 - buf.st_mode & 0777,
239 - buf.st_uid, buf.st_gid);
241 - if (op == DM_DEVICE_RELOAD)
242 - dm_simplecmd(DM_DEVICE_RESUME,
245 - dm_devn(partname, &slices[j].major,
249 - printf("add map %s : 0 %" PRIu64 " %s %s\n",
250 - partname, slices[j].size,
251 - DM_TARGET, params);
254 - /* Terminate loop */
261 Index: multipath-tools/kpartx/kpartx.h
262 ===================================================================
263 --- multipath-tools.orig/kpartx/kpartx.h
264 +++ multipath-tools/kpartx/kpartx.h
273 Index: multipath-tools/kpartx/sun.c
274 ===================================================================
275 --- multipath-tools.orig/kpartx/sun.c
276 +++ multipath-tools/kpartx/sun.c
277 @@ -62,8 +62,8 @@ int
278 read_sun_pt(int fd, struct slice all, struct slice *sp, int ns) {
279 struct sun_disk_label *l;
280 struct sun_raw_part *s;
281 - unsigned int offset = all.start, end;
283 + unsigned int offset = all.start;
287 bp = getblock(fd, offset);
288 @@ -95,37 +95,6 @@ read_sun_pt(int fd, struct slice all, st
293 - * Convention has it that the SUN disklabel will always have
294 - * the 'c' partition spanning the entire disk.
295 - * So we have to check for contained slices.
297 - for(i = 0; i < SUN_DISK_MAXPARTITIONS; i++) {
298 - if (sp[i].size == 0)
301 - end = sp[i].start + sp[i].size;
302 - for(j = 0; j < SUN_DISK_MAXPARTITIONS; j ++) {
305 - if (sp[j].size == 0)
308 - if (sp[i].start < sp[j].start) {
309 - if (end > sp[j].start &&
310 - end < sp[j].start + sp[j].size) {
311 - /* Invalid slice */
313 - "sun_disklabel: slice %d overlaps with %d\n", i , j);
317 - if (end <= sp[j].start + sp[j].size) {
318 - sp[i].container = j + 1;