summaryrefslogtreecommitdiffstats
path: root/libblkid/src/probe.c
diff options
context:
space:
mode:
authorKarel Zak2015-12-03 12:24:22 +0100
committerKarel Zak2015-12-03 12:24:22 +0100
commit28a2df8dc0a2edd93d816dac04a7ab315dca7c52 (patch)
treea4f6f7ef68186e80017e204cbaf6fba29032c5cd /libblkid/src/probe.c
parentline: keep stdin unbuiffered (diff)
downloadkernel-qcow2-util-linux-28a2df8dc0a2edd93d816dac04a7ab315dca7c52.tar.gz
kernel-qcow2-util-linux-28a2df8dc0a2edd93d816dac04a7ab315dca7c52.tar.xz
kernel-qcow2-util-linux-28a2df8dc0a2edd93d816dac04a7ab315dca7c52.zip
libblkid: fix buffers mapping on 32bit archs
Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/probe.c')
-rw-r--r--libblkid/src/probe.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 97238fc30..e7b7bad5d 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -582,11 +582,11 @@ int __blkid_probe_filter_types(blkid_probe pr, int chain, int flag, char *names[
}
/* align to mmap granularity */
-#define PROBE_ALIGN_OFF(p, o) ((o) & ~((p)->mmap_granularity - 1))
+#define PROBE_ALIGN_OFF(p, o) ((o) & ~((p)->mmap_granularity - 1ULL))
/* default buffer sizes */
-#define PROBE_MMAP_BEGINSIZ (1024 * 1024 * 2) /* begin of the device */
-#define PROBE_MMAP_ENDSIZ (1024 * 1024 * 2) /* end of the device */
-#define PROBE_MMAP_MIDSIZ (1024 * 1024) /* middle of the device */
+#define PROBE_MMAP_BEGINSIZ (1024ULL * 1024ULL * 2ULL) /* begin of the device */
+#define PROBE_MMAP_ENDSIZ (1024ULL * 1024ULL * 2ULL) /* end of the device */
+#define PROBE_MMAP_MIDSIZ (1024ULL * 1024ULL) /* middle of the device */
#define probe_is_mmap_wanted(p) (!S_ISCHR((p)->mode))
@@ -594,7 +594,7 @@ static struct blkid_bufinfo *mmap_buffer(blkid_probe pr,
blkid_loff_t real_off,
blkid_loff_t len)
{
- size_t map_len;
+ blkid_loff_t map_len;
blkid_loff_t map_off = 0;
struct blkid_bufinfo *bf = NULL;
@@ -609,14 +609,17 @@ static struct blkid_bufinfo *mmap_buffer(blkid_probe pr,
/* begin of the device */
if (real_off == 0 || real_off + len < PROBE_MMAP_BEGINSIZ) {
- DBG(BUFFER, ul_debug("\tmapping begin of the device"));
+ DBG(BUFFER, ul_debug("\tmapping begin of the device (max size: %ju)",
+ (uintmax_t) pr->size));
map_off = 0;
map_len = PROBE_MMAP_BEGINSIZ > pr->size ? pr->size : PROBE_MMAP_BEGINSIZ;
/* end of the device */
} else if (real_off > pr->off + pr->size - PROBE_MMAP_ENDSIZ) {
- DBG(BUFFER, ul_debug("\tmapping end of the device"));
+ DBG(BUFFER, ul_debug("\tmapping end of the device (probing area: "
+ "off=%ju, size=%ju)",
+ (uintmax_t) pr->off, (uintmax_t) pr->size));
map_off = PROBE_ALIGN_OFF(pr, pr->off + pr->size - PROBE_MMAP_ENDSIZ);
map_len = pr->off + pr->size - map_off;
@@ -657,8 +660,8 @@ static struct blkid_bufinfo *mmap_buffer(blkid_probe pr,
INIT_LIST_HEAD(&bf->bufs);
DBG(BUFFER, ul_debug("\tmmap %p: off=%ju, len=%ju (%ju pages)",
- bf->data, map_off, map_len,
- map_len / pr->mmap_granularity));
+ bf->data, (uintmax_t) map_off, (uintmax_t) map_len,
+ (uintmax_t) map_len / pr->mmap_granularity));
return bf;
}