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