]> git.ipfire.org Git - ipfire-3.x.git/blob - multipath-tools/patches/0066-UP-dos-4k-partition-fix.patch
krb5: Update to 1.14.4
[ipfire-3.x.git] / multipath-tools / patches / 0066-UP-dos-4k-partition-fix.patch
1 ---
2 kpartx/dos.c | 17 ++++++++++-------
3 kpartx/gpt.c | 20 +-------------------
4 kpartx/kpartx.c | 12 ++++++++++++
5 kpartx/kpartx.h | 8 ++++++++
6 4 files changed, 31 insertions(+), 26 deletions(-)
7
8 Index: multipath-tools-130222/kpartx/dos.c
9 ===================================================================
10 --- multipath-tools-130222.orig/kpartx/dos.c
11 +++ multipath-tools-130222/kpartx/dos.c
12 @@ -26,7 +26,9 @@ read_extended_partition(int fd, struct p
13 int moretodo = 1;
14 int i, n=0;
15
16 - next = start = le32_to_cpu(ep->start_sect);
17 + int sector_size_mul = get_sector_size(fd)/512;
18 +
19 + next = start = sector_size_mul * le32_to_cpu(ep->start_sect);
20
21 while (moretodo) {
22 here = next;
23 @@ -45,14 +47,14 @@ read_extended_partition(int fd, struct p
24 memcpy(&p, bp + 0x1be + i * sizeof (p), sizeof (p));
25 if (is_extended(p.sys_type)) {
26 if (p.nr_sects && !moretodo) {
27 - next = start + le32_to_cpu(p.start_sect);
28 + next = start + sector_size_mul * le32_to_cpu(p.start_sect);
29 moretodo = 1;
30 }
31 continue;
32 }
33 if (n < ns) {
34 - sp[n].start = here + le32_to_cpu(p.start_sect);
35 - sp[n].size = le32_to_cpu(p.nr_sects);
36 + sp[n].start = here + sector_size_mul * le32_to_cpu(p.start_sect);
37 + sp[n].size = sector_size_mul * le32_to_cpu(p.nr_sects);
38 n++;
39 } else {
40 fprintf(stderr,
41 @@ -76,6 +78,7 @@ read_dos_pt(int fd, struct slice all, st
42 unsigned long offset = all.start;
43 int i, n=4;
44 unsigned char *bp;
45 + int sector_size_mul = get_sector_size(fd)/512;
46
47 bp = (unsigned char *)getblock(fd, offset);
48 if (bp == NULL)
49 @@ -89,8 +92,8 @@ read_dos_pt(int fd, struct slice all, st
50 if (is_gpt(p.sys_type))
51 return 0;
52 if (i < ns) {
53 - sp[i].start = le32_to_cpu(p.start_sect);
54 - sp[i].size = le32_to_cpu(p.nr_sects);
55 + sp[i].start = sector_size_mul * le32_to_cpu(p.start_sect);
56 + sp[i].size = sector_size_mul * le32_to_cpu(p.nr_sects);
57 } else {
58 fprintf(stderr,
59 "dos_partition: too many slices\n");
60 @@ -99,7 +102,7 @@ read_dos_pt(int fd, struct slice all, st
61 if (is_extended(p.sys_type)) {
62 n += read_extended_partition(fd, &p, sp+n, ns-n);
63 /* hide the extended partition itself */
64 - sp[i].size = 2;
65 + sp[i].size = sector_size_mul * 2;
66 }
67 }
68 return n;
69 Index: multipath-tools-130222/kpartx/gpt.c
70 ===================================================================
71 --- multipath-tools-130222.orig/kpartx/gpt.c
72 +++ multipath-tools-130222/kpartx/gpt.c
73 @@ -38,6 +38,7 @@
74 #include <byteswap.h>
75 #include <linux/fs.h>
76 #include "crc32.h"
77 +#include "kpartx.h"
78
79 #if BYTE_ORDER == LITTLE_ENDIAN
80 # define __le16_to_cpu(x) (x)
81 @@ -116,25 +117,6 @@ is_pmbr_valid(legacy_mbr *mbr)
82
83
84 /************************************************************
85 - * get_sector_size
86 - * Requires:
87 - * - filedes is an open file descriptor, suitable for reading
88 - * Modifies: nothing
89 - * Returns:
90 - * sector size, or 512.
91 - ************************************************************/
92 -static int
93 -get_sector_size(int filedes)
94 -{
95 - int rc, sector_size = 512;
96 -
97 - rc = ioctl(filedes, BLKSSZGET, &sector_size);
98 - if (rc)
99 - sector_size = 512;
100 - return sector_size;
101 -}
102 -
103 -/************************************************************
104 * _get_num_sectors
105 * Requires:
106 * - filedes is an open file descriptor, suitable for reading
107 Index: multipath-tools-130222/kpartx/kpartx.c
108 ===================================================================
109 --- multipath-tools-130222.orig/kpartx/kpartx.c
110 +++ multipath-tools-130222/kpartx/kpartx.c
111 @@ -26,6 +26,7 @@
112 #include <string.h>
113 #include <unistd.h>
114 #include <stdint.h>
115 +#include <sys/ioctl.h>
116 #include <sys/stat.h>
117 #include <sys/types.h>
118 #include <ctype.h>
119 @@ -606,3 +607,14 @@ getblock (int fd, unsigned int secnr) {
120
121 return bp->block;
122 }
123 +
124 +int
125 +get_sector_size(int filedes)
126 +{
127 + int rc, sector_size = 512;
128 +
129 + rc = ioctl(filedes, BLKSSZGET, &sector_size);
130 + if (rc)
131 + sector_size = 512;
132 + return sector_size;
133 +}
134 Index: multipath-tools-130222/kpartx/kpartx.h
135 ===================================================================
136 --- multipath-tools-130222.orig/kpartx/kpartx.h
137 +++ multipath-tools-130222/kpartx/kpartx.h
138 @@ -2,6 +2,7 @@
139 #define _KPARTX_H
140
141 #include <stdint.h>
142 +#include <sys/ioctl.h>
143
144 /*
145 * For each partition type there is a routine that takes
146 @@ -18,6 +19,13 @@
147 #define safe_sprintf(var, format, args...) \
148 snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
149
150 +#ifndef BLKSSZGET
151 +#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
152 +#endif
153 +
154 +int
155 +get_sector_size(int filedes);
156 +
157 /*
158 * units: 512 byte sectors
159 */