]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blame - multipath-tools/patches/0022-RHBZ-557845-RHEL5-style-partitions.patch
Move all packages to root.
[people/ms/ipfire-3.x.git] / multipath-tools / patches / 0022-RHBZ-557845-RHEL5-style-partitions.patch
CommitLineData
dc01aad8
SS
1---
2 kpartx/bsd.c | 35 ----------------
3 kpartx/dos.c | 7 +--
4 kpartx/kpartx.c | 121 +++++++-------------------------------------------------
5 kpartx/kpartx.h | 1
6 kpartx/sun.c | 35 ----------------
7 5 files changed, 24 insertions(+), 175 deletions(-)
8
9Index: 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;
19 int max_partitions;
20 char *bp;
21- int n = 0, i, j;
22+ int n = 0;
23
24 bp = getblock(fd, offset+1); /* 1 sector suffices */
25 if (bp == NULL)
26@@ -79,36 +79,5 @@ read_bsd_pt(int fd, struct slice all, st
27 break;
28 }
29 }
30- /*
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.
34- */
35- for(i = 0; i < n; i++) {
36- if (sp[i].size == 0)
37- continue;
38-
39- end = sp[i].start + sp[i].size;
40- for(j = 0; j < n; j ++) {
41- if ( i == j )
42- continue;
43- if (sp[j].size == 0)
44- continue;
45-
46- if (sp[i].start < sp[j].start) {
47- if (end > sp[j].start &&
48- end < sp[j].start + sp[j].size) {
49- /* Invalid slice */
50- fprintf(stderr,
51- "bsd_disklabel: slice %d overlaps with %d\n", i , j);
52- sp[i].size = 0;
53- }
54- } else {
55- if (end <= sp[j].start + sp[j].size) {
56- sp[i].container = j + 1;
57- }
58- }
59- }
60- }
61 return n;
62 }
63Index: 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) {
68 }
69
70 static int
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)
74 {
75 struct partition p;
76@@ -53,7 +53,6 @@ read_extended_partition(int fd, struct p
77 if (n < ns) {
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;
81 n++;
82 } else {
83 fprintf(stderr,
84@@ -98,7 +97,9 @@ read_dos_pt(int fd, struct slice all, st
85 break;
86 }
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 */
91+ sp[i].size = 2;
92 }
93 }
94 return n;
95Index: 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)
100
101 int
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;
105 struct slice all;
106 struct pt *ptp;
107 enum action what = LIST;
108@@ -355,49 +355,30 @@ main(int argc, char **argv){
109 else
110 continue;
111
112+ /*
113+ * test for overlap, as in the case of an extended partition
114+ * zero their size to avoid mapping
115+ */
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 +
120+ slices[j].size)
121+ slices[j].size = 0;
122+ }
123+ }
124+
125 switch(what) {
126 case LIST:
127- for (j = 0, c = 0, m = 0; j < n; j++) {
128+ for (j = 0; j < n; j++) {
129 if (slices[j].size == 0)
130 continue;
131- if (slices[j].container > 0) {
132- c++;
133- continue;
134- }
135-
136- slices[j].minor = m++;
137
138 printf("%s%s%d : 0 %" PRIu64 " %s %" PRIu64"\n",
139 mapname, delim, j+1,
140 slices[j].size, device,
141 slices[j].start);
142 }
143- /* Loop to resolve contained slices */
144- d = c;
145- while (c) {
146- for (j = 0; j < n; j++) {
147- uint64_t start;
148- int k = slices[j].container - 1;
149-
150- if (slices[j].size == 0)
151- continue;
152- if (slices[j].minor > 0)
153- continue;
154- if (slices[j].container == 0)
155- continue;
156- slices[j].minor = m++;
157-
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,
161- slices[j].size,
162- slices[k].minor, start);
163- c--;
164- }
165- /* Terminate loop if nothing more to resolve */
166- if (d == c)
167- break;
168- }
169
170 if (loopcreated && S_ISREG (buf.st_mode)) {
171 if (del_loop(device)) {
172@@ -443,16 +424,10 @@ main(int argc, char **argv){
173 break;
174
175 case ADD:
176- for (j = 0, c = 0; j < n; j++) {
177+ for (j = 0; j < n; j++) {
178 if (slices[j].size == 0)
179 continue;
180
181- /* Skip all contained slices */
182- if (slices[j].container > 0) {
183- c++;
184- continue;
185- }
186-
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,
192 DM_TARGET, params);
193 }
194- /* Loop to resolve contained slices */
195- d = c;
196- while (c) {
197- for (j = 0; j < n; j++) {
198- uint64_t start;
199- int k = slices[j].container - 1;
200-
201- if (slices[j].size == 0)
202- continue;
203-
204- /* Skip all existing slices */
205- if (slices[j].minor > 0)
206- continue;
207-
208- /* Skip all simple slices */
209- if (slices[j].container == 0)
210- continue;
211-
212- /* Check container slice */
213- if (slices[k].size == 0)
214- fprintf(stderr, "Invalid slice %d\n",
215- k);
216-
217- if (safe_sprintf(partname, "%s%s%d",
218- mapname, delim, j+1)) {
219- fprintf(stderr, "partname too small\n");
220- exit(1);
221- }
222- strip_slash(partname);
223-
224- start = slices[j].start - slices[k].start;
225- if (safe_sprintf(params, "%d:%d %" PRIu64,
226- slices[k].major,
227- slices[k].minor,
228- start)) {
229- fprintf(stderr, "params too small\n");
230- exit(1);
231- }
232-
233- op = (dm_map_present(partname) ?
234- DM_DEVICE_RELOAD : DM_DEVICE_CREATE);
235-
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);
240-
241- if (op == DM_DEVICE_RELOAD)
242- dm_simplecmd(DM_DEVICE_RESUME,
243- partname, 1);
244-
245- dm_devn(partname, &slices[j].major,
246- &slices[j].minor);
247-
248- if (verbose)
249- printf("add map %s : 0 %" PRIu64 " %s %s\n",
250- partname, slices[j].size,
251- DM_TARGET, params);
252- c--;
253- }
254- /* Terminate loop */
255- if (d == c)
256- break;
257- }
258 break;
259
260 default:
261Index: multipath-tools/kpartx/kpartx.h
262===================================================================
263--- multipath-tools.orig/kpartx/kpartx.h
264+++ multipath-tools/kpartx/kpartx.h
265@@ -24,7 +24,6 @@
266 struct slice {
267 uint64_t start;
268 uint64_t size;
269- int container;
270 int major;
271 int minor;
272 };
273Index: 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;
282- int i, j, n;
283+ unsigned int offset = all.start;
284+ int i, n;
285 char *bp;
286
287 bp = getblock(fd, offset);
288@@ -95,37 +95,6 @@ read_sun_pt(int fd, struct slice all, st
289 break;
290 }
291 }
292- /*
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.
296- */
297- for(i = 0; i < SUN_DISK_MAXPARTITIONS; i++) {
298- if (sp[i].size == 0)
299- continue;
300-
301- end = sp[i].start + sp[i].size;
302- for(j = 0; j < SUN_DISK_MAXPARTITIONS; j ++) {
303- if ( i == j )
304- continue;
305- if (sp[j].size == 0)
306- continue;
307-
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 */
312- fprintf(stderr,
313- "sun_disklabel: slice %d overlaps with %d\n", i , j);
314- sp[i].size = 0;
315- }
316- } else {
317- if (end <= sp[j].start + sp[j].size) {
318- sp[i].container = j + 1;
319- }
320- }
321- }
322- }
323 return n;
324 }
325