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