|
|
671555 |
---
|
|
|
671555 |
kpartx/dos.c | 17 ++++++++++-------
|
|
|
671555 |
kpartx/gpt.c | 20 +-------------------
|
|
|
671555 |
kpartx/kpartx.c | 12 ++++++++++++
|
|
|
671555 |
kpartx/kpartx.h | 8 ++++++++
|
|
|
671555 |
4 files changed, 31 insertions(+), 26 deletions(-)
|
|
|
671555 |
|
|
|
671555 |
Index: multipath-tools-130222/kpartx/dos.c
|
|
|
671555 |
===================================================================
|
|
|
671555 |
--- multipath-tools-130222.orig/kpartx/dos.c
|
|
|
671555 |
+++ multipath-tools-130222/kpartx/dos.c
|
|
|
671555 |
@@ -26,7 +26,9 @@ read_extended_partition(int fd, struct p
|
|
|
671555 |
int moretodo = 1;
|
|
|
671555 |
int i, n=0;
|
|
|
671555 |
|
|
|
671555 |
- next = start = le32_to_cpu(ep->start_sect);
|
|
|
671555 |
+ int sector_size_mul = get_sector_size(fd)/512;
|
|
|
671555 |
+
|
|
|
671555 |
+ next = start = sector_size_mul * le32_to_cpu(ep->start_sect);
|
|
|
671555 |
|
|
|
671555 |
while (moretodo) {
|
|
|
671555 |
here = next;
|
|
|
671555 |
@@ -45,14 +47,14 @@ read_extended_partition(int fd, struct p
|
|
|
671555 |
memcpy(&p, bp + 0x1be + i * sizeof (p), sizeof (p));
|
|
|
671555 |
if (is_extended(p.sys_type)) {
|
|
|
671555 |
if (p.nr_sects && !moretodo) {
|
|
|
671555 |
- next = start + le32_to_cpu(p.start_sect);
|
|
|
671555 |
+ next = start + sector_size_mul * le32_to_cpu(p.start_sect);
|
|
|
671555 |
moretodo = 1;
|
|
|
671555 |
}
|
|
|
671555 |
continue;
|
|
|
671555 |
}
|
|
|
671555 |
if (n < ns) {
|
|
|
671555 |
- sp[n].start = here + le32_to_cpu(p.start_sect);
|
|
|
671555 |
- sp[n].size = le32_to_cpu(p.nr_sects);
|
|
|
671555 |
+ sp[n].start = here + sector_size_mul * le32_to_cpu(p.start_sect);
|
|
|
671555 |
+ sp[n].size = sector_size_mul * le32_to_cpu(p.nr_sects);
|
|
|
671555 |
n++;
|
|
|
671555 |
} else {
|
|
|
671555 |
fprintf(stderr,
|
|
|
671555 |
@@ -76,6 +78,7 @@ read_dos_pt(int fd, struct slice all, st
|
|
|
671555 |
unsigned long offset = all.start;
|
|
|
671555 |
int i, n=4;
|
|
|
671555 |
unsigned char *bp;
|
|
|
671555 |
+ int sector_size_mul = get_sector_size(fd)/512;
|
|
|
671555 |
|
|
|
671555 |
bp = (unsigned char *)getblock(fd, offset);
|
|
|
671555 |
if (bp == NULL)
|
|
|
671555 |
@@ -89,8 +92,8 @@ read_dos_pt(int fd, struct slice all, st
|
|
|
671555 |
if (is_gpt(p.sys_type))
|
|
|
671555 |
return 0;
|
|
|
671555 |
if (i < ns) {
|
|
|
671555 |
- sp[i].start = le32_to_cpu(p.start_sect);
|
|
|
671555 |
- sp[i].size = le32_to_cpu(p.nr_sects);
|
|
|
671555 |
+ sp[i].start = sector_size_mul * le32_to_cpu(p.start_sect);
|
|
|
671555 |
+ sp[i].size = sector_size_mul * le32_to_cpu(p.nr_sects);
|
|
|
671555 |
} else {
|
|
|
671555 |
fprintf(stderr,
|
|
|
671555 |
"dos_partition: too many slices\n");
|
|
|
671555 |
@@ -99,7 +102,7 @@ read_dos_pt(int fd, struct slice all, st
|
|
|
671555 |
if (is_extended(p.sys_type)) {
|
|
|
671555 |
n += read_extended_partition(fd, &p, sp+n, ns-n);
|
|
|
671555 |
/* hide the extended partition itself */
|
|
|
671555 |
- sp[i].size = 2;
|
|
|
671555 |
+ sp[i].size = sector_size_mul * 2;
|
|
|
671555 |
}
|
|
|
671555 |
}
|
|
|
671555 |
return n;
|
|
|
671555 |
Index: multipath-tools-130222/kpartx/gpt.c
|
|
|
671555 |
===================================================================
|
|
|
671555 |
--- multipath-tools-130222.orig/kpartx/gpt.c
|
|
|
671555 |
+++ multipath-tools-130222/kpartx/gpt.c
|
|
|
671555 |
@@ -38,6 +38,7 @@
|
|
|
671555 |
#include <byteswap.h>
|
|
|
671555 |
#include <linux/fs.h>
|
|
|
671555 |
#include "crc32.h"
|
|
|
671555 |
+#include "kpartx.h"
|
|
|
671555 |
|
|
|
671555 |
#if BYTE_ORDER == LITTLE_ENDIAN
|
|
|
671555 |
# define __le16_to_cpu(x) (x)
|
|
|
671555 |
@@ -116,25 +117,6 @@ is_pmbr_valid(legacy_mbr *mbr)
|
|
|
671555 |
|
|
|
671555 |
|
|
|
671555 |
/************************************************************
|
|
|
671555 |
- * get_sector_size
|
|
|
671555 |
- * Requires:
|
|
|
671555 |
- * - filedes is an open file descriptor, suitable for reading
|
|
|
671555 |
- * Modifies: nothing
|
|
|
671555 |
- * Returns:
|
|
|
671555 |
- * sector size, or 512.
|
|
|
671555 |
- ************************************************************/
|
|
|
671555 |
-static int
|
|
|
671555 |
-get_sector_size(int filedes)
|
|
|
671555 |
-{
|
|
|
671555 |
- int rc, sector_size = 512;
|
|
|
671555 |
-
|
|
|
671555 |
- rc = ioctl(filedes, BLKSSZGET, §or_size);
|
|
|
671555 |
- if (rc)
|
|
|
671555 |
- sector_size = 512;
|
|
|
671555 |
- return sector_size;
|
|
|
671555 |
-}
|
|
|
671555 |
-
|
|
|
671555 |
-/************************************************************
|
|
|
671555 |
* _get_num_sectors
|
|
|
671555 |
* Requires:
|
|
|
671555 |
* - filedes is an open file descriptor, suitable for reading
|
|
|
671555 |
Index: multipath-tools-130222/kpartx/kpartx.c
|
|
|
671555 |
===================================================================
|
|
|
671555 |
--- multipath-tools-130222.orig/kpartx/kpartx.c
|
|
|
671555 |
+++ multipath-tools-130222/kpartx/kpartx.c
|
|
|
671555 |
@@ -26,6 +26,7 @@
|
|
|
671555 |
#include <string.h>
|
|
|
671555 |
#include <unistd.h>
|
|
|
671555 |
#include <stdint.h>
|
|
|
671555 |
+#include <sys/ioctl.h>
|
|
|
671555 |
#include <sys/stat.h>
|
|
|
671555 |
#include <sys/types.h>
|
|
|
671555 |
#include <ctype.h>
|
|
|
671555 |
@@ -606,3 +607,14 @@ getblock (int fd, unsigned int secnr) {
|
|
|
671555 |
|
|
|
671555 |
return bp->block;
|
|
|
671555 |
}
|
|
|
671555 |
+
|
|
|
671555 |
+int
|
|
|
671555 |
+get_sector_size(int filedes)
|
|
|
671555 |
+{
|
|
|
671555 |
+ int rc, sector_size = 512;
|
|
|
671555 |
+
|
|
|
671555 |
+ rc = ioctl(filedes, BLKSSZGET, §or_size);
|
|
|
671555 |
+ if (rc)
|
|
|
671555 |
+ sector_size = 512;
|
|
|
671555 |
+ return sector_size;
|
|
|
671555 |
+}
|
|
|
671555 |
Index: multipath-tools-130222/kpartx/kpartx.h
|
|
|
671555 |
===================================================================
|
|
|
671555 |
--- multipath-tools-130222.orig/kpartx/kpartx.h
|
|
|
671555 |
+++ multipath-tools-130222/kpartx/kpartx.h
|
|
|
671555 |
@@ -2,6 +2,7 @@
|
|
|
671555 |
#define _KPARTX_H
|
|
|
671555 |
|
|
|
671555 |
#include <stdint.h>
|
|
|
671555 |
+#include <sys/ioctl.h>
|
|
|
671555 |
|
|
|
671555 |
/*
|
|
|
671555 |
* For each partition type there is a routine that takes
|
|
|
671555 |
@@ -18,6 +19,13 @@
|
|
|
671555 |
#define safe_sprintf(var, format, args...) \
|
|
|
671555 |
snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
|
|
|
671555 |
|
|
|
671555 |
+#ifndef BLKSSZGET
|
|
|
671555 |
+#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
|
|
|
671555 |
+#endif
|
|
|
671555 |
+
|
|
|
671555 |
+int
|
|
|
671555 |
+get_sector_size(int filedes);
|
|
|
671555 |
+
|
|
|
671555 |
/*
|
|
|
671555 |
* units: 512 byte sectors
|
|
|
671555 |
*/
|