]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - multipath-tools/patches/0012-RH-RHEL5-style-partitions.patch
paxctl: Update to 0.8.
[people/ms/ipfire-3.x.git] / multipath-tools / patches / 0012-RH-RHEL5-style-partitions.patch
1 ---
2 kpartx/bsd.c | 35 ---------------
3 kpartx/dos.c | 7 +--
4 kpartx/kpartx.c | 123 +++++++-------------------------------------------------
5 kpartx/kpartx.h | 1
6 kpartx/sun.c | 35 ---------------
7 5 files changed, 24 insertions(+), 177 deletions(-)
8
9 Index: multipath-tools-120123/kpartx/bsd.c
10 ===================================================================
11 --- multipath-tools-120123.orig/kpartx/bsd.c
12 +++ multipath-tools-120123/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 }
63 Index: multipath-tools-120123/kpartx/dos.c
64 ===================================================================
65 --- multipath-tools-120123.orig/kpartx/dos.c
66 +++ multipath-tools-120123/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;
95 Index: multipath-tools-120123/kpartx/kpartx.c
96 ===================================================================
97 --- multipath-tools-120123.orig/kpartx/kpartx.c
98 +++ multipath-tools-120123/kpartx/kpartx.c
99 @@ -190,7 +190,7 @@ get_hotplug_device(void)
100
101 int
102 main(int argc, char **argv){
103 - int i, j, m, n, op, off, arg, c, d, ro=0;
104 + int i, j, m, n, op, off, arg, ro=0;
105 int fd = -1;
106 struct slice all;
107 struct pt *ptp;
108 @@ -380,49 +380,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 (m = j + 1; m < n; m++) {
118 + if (slices[m].start > slices[j].start &&
119 + slices[m].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 break;
171
172 @@ -461,16 +442,10 @@ main(int argc, char **argv){
173 case ADD:
174 case UPDATE:
175 /* ADD and UPDATE share the same code that adds new partitions. */
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 @@ -511,72 +486,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, ro, uuid, j+1,
238 - buf.st_mode & 0777,
239 - buf.st_uid, buf.st_gid,
240 - &cookie);
241 -
242 - if (op == DM_DEVICE_RELOAD)
243 - dm_simplecmd(DM_DEVICE_RESUME,
244 - partname, 1,
245 - &cookie);
246 -
247 - dm_devn(partname, &slices[j].major,
248 - &slices[j].minor);
249 -
250 - if (verbose)
251 - printf("add map %s : 0 %" PRIu64 " %s %s\n",
252 - partname, slices[j].size,
253 - DM_TARGET, params);
254 - c--;
255 - }
256 - /* Terminate loop */
257 - if (d == c)
258 - break;
259 - }
260
261 if (what == ADD) {
262 /* Skip code that removes devmappings for deleted partitions */
263 Index: multipath-tools-120123/kpartx/kpartx.h
264 ===================================================================
265 --- multipath-tools-120123.orig/kpartx/kpartx.h
266 +++ multipath-tools-120123/kpartx/kpartx.h
267 @@ -24,7 +24,6 @@
268 struct slice {
269 uint64_t start;
270 uint64_t size;
271 - int container;
272 int major;
273 int minor;
274 };
275 Index: multipath-tools-120123/kpartx/sun.c
276 ===================================================================
277 --- multipath-tools-120123.orig/kpartx/sun.c
278 +++ multipath-tools-120123/kpartx/sun.c
279 @@ -62,8 +62,8 @@ int
280 read_sun_pt(int fd, struct slice all, struct slice *sp, int ns) {
281 struct sun_disk_label *l;
282 struct sun_raw_part *s;
283 - unsigned int offset = all.start, end;
284 - int i, j, n;
285 + unsigned int offset = all.start;
286 + int i, n;
287 char *bp;
288
289 bp = getblock(fd, offset);
290 @@ -95,37 +95,6 @@ read_sun_pt(int fd, struct slice all, st
291 break;
292 }
293 }
294 - /*
295 - * Convention has it that the SUN disklabel will always have
296 - * the 'c' partition spanning the entire disk.
297 - * So we have to check for contained slices.
298 - */
299 - for(i = 0; i < SUN_DISK_MAXPARTITIONS; i++) {
300 - if (sp[i].size == 0)
301 - continue;
302 -
303 - end = sp[i].start + sp[i].size;
304 - for(j = 0; j < SUN_DISK_MAXPARTITIONS; j ++) {
305 - if ( i == j )
306 - continue;
307 - if (sp[j].size == 0)
308 - continue;
309 -
310 - if (sp[i].start < sp[j].start) {
311 - if (end > sp[j].start &&
312 - end < sp[j].start + sp[j].size) {
313 - /* Invalid slice */
314 - fprintf(stderr,
315 - "sun_disklabel: slice %d overlaps with %d\n", i , j);
316 - sp[i].size = 0;
317 - }
318 - } else {
319 - if (end <= sp[j].start + sp[j].size) {
320 - sp[i].container = j + 1;
321 - }
322 - }
323 - }
324 - }
325 return n;
326 }
327