|
|
4728c8 |
---
|
|
|
4728c8 |
kpartx/bsd.c | 35 ---------------
|
|
|
4728c8 |
kpartx/dos.c | 7 +--
|
|
|
4728c8 |
kpartx/kpartx.c | 123 +++++++-------------------------------------------------
|
|
|
4728c8 |
kpartx/kpartx.h | 1
|
|
|
4728c8 |
kpartx/sun.c | 35 ---------------
|
|
|
4728c8 |
5 files changed, 24 insertions(+), 177 deletions(-)
|
|
|
4728c8 |
|
|
|
4728c8 |
Index: multipath-tools-130222/kpartx/bsd.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/kpartx/bsd.c
|
|
|
4728c8 |
+++ multipath-tools-130222/kpartx/bsd.c
|
|
|
4728c8 |
@@ -50,10 +50,10 @@ int
|
|
|
4728c8 |
read_bsd_pt(int fd, struct slice all, struct slice *sp, int ns) {
|
|
|
4728c8 |
struct bsd_disklabel *l;
|
|
|
4728c8 |
struct bsd_partition *p;
|
|
|
4728c8 |
- unsigned int offset = all.start, end;
|
|
|
4728c8 |
+ unsigned int offset = all.start;
|
|
|
4728c8 |
int max_partitions;
|
|
|
4728c8 |
char *bp;
|
|
|
4728c8 |
- int n = 0, i, j;
|
|
|
4728c8 |
+ int n = 0;
|
|
|
4728c8 |
|
|
|
4728c8 |
bp = getblock(fd, offset+1); /* 1 sector suffices */
|
|
|
4728c8 |
if (bp == NULL)
|
|
|
4728c8 |
@@ -79,36 +79,5 @@ read_bsd_pt(int fd, struct slice all, st
|
|
|
4728c8 |
break;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
}
|
|
|
4728c8 |
- /*
|
|
|
4728c8 |
- * Convention has it that the bsd disklabel will always have
|
|
|
4728c8 |
- * the 'c' partition spanning the entire disk.
|
|
|
4728c8 |
- * So we have to check for contained slices.
|
|
|
4728c8 |
- */
|
|
|
4728c8 |
- for(i = 0; i < n; i++) {
|
|
|
4728c8 |
- if (sp[i].size == 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- end = sp[i].start + sp[i].size;
|
|
|
4728c8 |
- for(j = 0; j < n; j ++) {
|
|
|
4728c8 |
- if ( i == j )
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
- if (sp[j].size == 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- if (sp[i].start < sp[j].start) {
|
|
|
4728c8 |
- if (end > sp[j].start &&
|
|
|
4728c8 |
- end < sp[j].start + sp[j].size) {
|
|
|
4728c8 |
- /* Invalid slice */
|
|
|
4728c8 |
- fprintf(stderr,
|
|
|
4728c8 |
- "bsd_disklabel: slice %d overlaps with %d\n", i , j);
|
|
|
4728c8 |
- sp[i].size = 0;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- } else {
|
|
|
4728c8 |
- if (end <= sp[j].start + sp[j].size) {
|
|
|
4728c8 |
- sp[i].container = j + 1;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
return n;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
Index: multipath-tools-130222/kpartx/dos.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/kpartx/dos.c
|
|
|
4728c8 |
+++ multipath-tools-130222/kpartx/dos.c
|
|
|
4728c8 |
@@ -16,7 +16,7 @@ is_extended(int type) {
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
static int
|
|
|
4728c8 |
-read_extended_partition(int fd, struct partition *ep, int en,
|
|
|
4728c8 |
+read_extended_partition(int fd, struct partition *ep,
|
|
|
4728c8 |
struct slice *sp, int ns)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
struct partition p;
|
|
|
4728c8 |
@@ -53,7 +53,6 @@ read_extended_partition(int fd, struct p
|
|
|
4728c8 |
if (n < ns) {
|
|
|
4728c8 |
sp[n].start = here + le32_to_cpu(p.start_sect);
|
|
|
4728c8 |
sp[n].size = le32_to_cpu(p.nr_sects);
|
|
|
4728c8 |
- sp[n].container = en + 1;
|
|
|
4728c8 |
n++;
|
|
|
4728c8 |
} else {
|
|
|
4728c8 |
fprintf(stderr,
|
|
|
4728c8 |
@@ -98,7 +97,9 @@ read_dos_pt(int fd, struct slice all, st
|
|
|
4728c8 |
break;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
if (is_extended(p.sys_type)) {
|
|
|
4728c8 |
- n += read_extended_partition(fd, &p, i, sp+n, ns-n);
|
|
|
4728c8 |
+ n += read_extended_partition(fd, &p, sp+n, ns-n);
|
|
|
4728c8 |
+ /* hide the extended partition itself */
|
|
|
4728c8 |
+ sp[i].size = 2;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
}
|
|
|
4728c8 |
return n;
|
|
|
4728c8 |
Index: multipath-tools-130222/kpartx/kpartx.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/kpartx/kpartx.c
|
|
|
4728c8 |
+++ multipath-tools-130222/kpartx/kpartx.c
|
|
|
4728c8 |
@@ -192,7 +192,7 @@ get_hotplug_device(void)
|
|
|
4728c8 |
|
|
|
4728c8 |
int
|
|
|
4728c8 |
main(int argc, char **argv){
|
|
|
4728c8 |
- int i, j, m, n, op, off, arg, c, d, ro=0;
|
|
|
4728c8 |
+ int i, j, m, n, op, off, arg, ro=0;
|
|
|
4728c8 |
int fd = -1;
|
|
|
4728c8 |
struct slice all;
|
|
|
4728c8 |
struct pt *ptp;
|
|
|
4728c8 |
@@ -381,49 +381,30 @@ main(int argc, char **argv){
|
|
|
4728c8 |
else
|
|
|
4728c8 |
continue;
|
|
|
4728c8 |
|
|
|
4728c8 |
+ /*
|
|
|
4728c8 |
+ * test for overlap, as in the case of an extended partition
|
|
|
4728c8 |
+ * zero their size to avoid mapping
|
|
|
4728c8 |
+ */
|
|
|
4728c8 |
+ for (j = 0; j < n; j++) {
|
|
|
4728c8 |
+ for (m = j + 1; m < n; m++) {
|
|
|
4728c8 |
+ if (slices[m].start > slices[j].start &&
|
|
|
4728c8 |
+ slices[m].start < slices[j].start +
|
|
|
4728c8 |
+ slices[j].size)
|
|
|
4728c8 |
+ slices[j].size = 0;
|
|
|
4728c8 |
+ }
|
|
|
4728c8 |
+ }
|
|
|
4728c8 |
+
|
|
|
4728c8 |
switch(what) {
|
|
|
4728c8 |
case LIST:
|
|
|
4728c8 |
- for (j = 0, c = 0, m = 0; j < n; j++) {
|
|
|
4728c8 |
+ for (j = 0; j < n; j++) {
|
|
|
4728c8 |
if (slices[j].size == 0)
|
|
|
4728c8 |
continue;
|
|
|
4728c8 |
- if (slices[j].container > 0) {
|
|
|
4728c8 |
- c++;
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- slices[j].minor = m++;
|
|
|
4728c8 |
|
|
|
4728c8 |
printf("%s%s%d : 0 %" PRIu64 " %s %" PRIu64"\n",
|
|
|
4728c8 |
mapname, delim, j+1,
|
|
|
4728c8 |
slices[j].size, device,
|
|
|
4728c8 |
slices[j].start);
|
|
|
4728c8 |
}
|
|
|
4728c8 |
- /* Loop to resolve contained slices */
|
|
|
4728c8 |
- d = c;
|
|
|
4728c8 |
- while (c) {
|
|
|
4728c8 |
- for (j = 0; j < n; j++) {
|
|
|
4728c8 |
- uint64_t start;
|
|
|
4728c8 |
- int k = slices[j].container - 1;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- if (slices[j].size == 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
- if (slices[j].minor > 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
- if (slices[j].container == 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
- slices[j].minor = m++;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- start = slices[j].start - slices[k].start;
|
|
|
4728c8 |
- printf("%s%s%d : 0 %" PRIu64 " /dev/dm-%d %" PRIu64 "\n",
|
|
|
4728c8 |
- mapname, delim, j+1,
|
|
|
4728c8 |
- slices[j].size,
|
|
|
4728c8 |
- slices[k].minor, start);
|
|
|
4728c8 |
- c--;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- /* Terminate loop if nothing more to resolve */
|
|
|
4728c8 |
- if (d == c)
|
|
|
4728c8 |
- break;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
|
|
|
4728c8 |
break;
|
|
|
4728c8 |
|
|
|
4728c8 |
@@ -462,16 +443,10 @@ main(int argc, char **argv){
|
|
|
4728c8 |
case ADD:
|
|
|
4728c8 |
case UPDATE:
|
|
|
4728c8 |
/* ADD and UPDATE share the same code that adds new partitions. */
|
|
|
4728c8 |
- for (j = 0, c = 0; j < n; j++) {
|
|
|
4728c8 |
+ for (j = 0; j < n; j++) {
|
|
|
4728c8 |
if (slices[j].size == 0)
|
|
|
4728c8 |
continue;
|
|
|
4728c8 |
|
|
|
4728c8 |
- /* Skip all contained slices */
|
|
|
4728c8 |
- if (slices[j].container > 0) {
|
|
|
4728c8 |
- c++;
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
-
|
|
|
4728c8 |
if (safe_sprintf(partname, "%s%s%d",
|
|
|
4728c8 |
mapname, delim, j+1)) {
|
|
|
4728c8 |
fprintf(stderr, "partname too small\n");
|
|
|
4728c8 |
@@ -512,72 +487,6 @@ main(int argc, char **argv){
|
|
|
4728c8 |
slices[j].minor, slices[j].size,
|
|
|
4728c8 |
DM_TARGET, params);
|
|
|
4728c8 |
}
|
|
|
4728c8 |
- /* Loop to resolve contained slices */
|
|
|
4728c8 |
- d = c;
|
|
|
4728c8 |
- while (c) {
|
|
|
4728c8 |
- for (j = 0; j < n; j++) {
|
|
|
4728c8 |
- uint64_t start;
|
|
|
4728c8 |
- int k = slices[j].container - 1;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- if (slices[j].size == 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- /* Skip all existing slices */
|
|
|
4728c8 |
- if (slices[j].minor > 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- /* Skip all simple slices */
|
|
|
4728c8 |
- if (slices[j].container == 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- /* Check container slice */
|
|
|
4728c8 |
- if (slices[k].size == 0)
|
|
|
4728c8 |
- fprintf(stderr, "Invalid slice %d\n",
|
|
|
4728c8 |
- k);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- if (safe_sprintf(partname, "%s%s%d",
|
|
|
4728c8 |
- mapname, delim, j+1)) {
|
|
|
4728c8 |
- fprintf(stderr, "partname too small\n");
|
|
|
4728c8 |
- exit(1);
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- strip_slash(partname);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- start = slices[j].start - slices[k].start;
|
|
|
4728c8 |
- if (safe_sprintf(params, "%d:%d %" PRIu64,
|
|
|
4728c8 |
- slices[k].major,
|
|
|
4728c8 |
- slices[k].minor,
|
|
|
4728c8 |
- start)) {
|
|
|
4728c8 |
- fprintf(stderr, "params too small\n");
|
|
|
4728c8 |
- exit(1);
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- op = (dm_map_present(partname) ?
|
|
|
4728c8 |
- DM_DEVICE_RELOAD : DM_DEVICE_CREATE);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- dm_addmap(op, partname, DM_TARGET, params,
|
|
|
4728c8 |
- slices[j].size, ro, uuid, j+1,
|
|
|
4728c8 |
- buf.st_mode & 0777,
|
|
|
4728c8 |
- buf.st_uid, buf.st_gid,
|
|
|
4728c8 |
- &cookie);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- if (op == DM_DEVICE_RELOAD)
|
|
|
4728c8 |
- dm_simplecmd(DM_DEVICE_RESUME,
|
|
|
4728c8 |
- partname, 1,
|
|
|
4728c8 |
- &cookie);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- dm_devn(partname, &slices[j].major,
|
|
|
4728c8 |
- &slices[j].minor);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- if (verbose)
|
|
|
4728c8 |
- printf("add map %s : 0 %" PRIu64 " %s %s\n",
|
|
|
4728c8 |
- partname, slices[j].size,
|
|
|
4728c8 |
- DM_TARGET, params);
|
|
|
4728c8 |
- c--;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- /* Terminate loop */
|
|
|
4728c8 |
- if (d == c)
|
|
|
4728c8 |
- break;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
|
|
|
4728c8 |
if (what == ADD) {
|
|
|
4728c8 |
/* Skip code that removes devmappings for deleted partitions */
|
|
|
4728c8 |
Index: multipath-tools-130222/kpartx/kpartx.h
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/kpartx/kpartx.h
|
|
|
4728c8 |
+++ multipath-tools-130222/kpartx/kpartx.h
|
|
|
4728c8 |
@@ -24,7 +24,6 @@
|
|
|
4728c8 |
struct slice {
|
|
|
4728c8 |
uint64_t start;
|
|
|
4728c8 |
uint64_t size;
|
|
|
4728c8 |
- int container;
|
|
|
4728c8 |
int major;
|
|
|
4728c8 |
int minor;
|
|
|
4728c8 |
};
|
|
|
4728c8 |
Index: multipath-tools-130222/kpartx/sun.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/kpartx/sun.c
|
|
|
4728c8 |
+++ multipath-tools-130222/kpartx/sun.c
|
|
|
4728c8 |
@@ -62,8 +62,8 @@ int
|
|
|
4728c8 |
read_sun_pt(int fd, struct slice all, struct slice *sp, int ns) {
|
|
|
4728c8 |
struct sun_disk_label *l;
|
|
|
4728c8 |
struct sun_raw_part *s;
|
|
|
4728c8 |
- unsigned int offset = all.start, end;
|
|
|
4728c8 |
- int i, j, n;
|
|
|
4728c8 |
+ unsigned int offset = all.start;
|
|
|
4728c8 |
+ int i, n;
|
|
|
4728c8 |
char *bp;
|
|
|
4728c8 |
|
|
|
4728c8 |
bp = getblock(fd, offset);
|
|
|
4728c8 |
@@ -95,37 +95,6 @@ read_sun_pt(int fd, struct slice all, st
|
|
|
4728c8 |
break;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
}
|
|
|
4728c8 |
- /*
|
|
|
4728c8 |
- * Convention has it that the SUN disklabel will always have
|
|
|
4728c8 |
- * the 'c' partition spanning the entire disk.
|
|
|
4728c8 |
- * So we have to check for contained slices.
|
|
|
4728c8 |
- */
|
|
|
4728c8 |
- for(i = 0; i < SUN_DISK_MAXPARTITIONS; i++) {
|
|
|
4728c8 |
- if (sp[i].size == 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- end = sp[i].start + sp[i].size;
|
|
|
4728c8 |
- for(j = 0; j < SUN_DISK_MAXPARTITIONS; j ++) {
|
|
|
4728c8 |
- if ( i == j )
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
- if (sp[j].size == 0)
|
|
|
4728c8 |
- continue;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- if (sp[i].start < sp[j].start) {
|
|
|
4728c8 |
- if (end > sp[j].start &&
|
|
|
4728c8 |
- end < sp[j].start + sp[j].size) {
|
|
|
4728c8 |
- /* Invalid slice */
|
|
|
4728c8 |
- fprintf(stderr,
|
|
|
4728c8 |
- "sun_disklabel: slice %d overlaps with %d\n", i , j);
|
|
|
4728c8 |
- sp[i].size = 0;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- } else {
|
|
|
4728c8 |
- if (end <= sp[j].start + sp[j].size) {
|
|
|
4728c8 |
- sp[i].container = j + 1;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
return n;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|