summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/probe.c
diff options
context:
space:
mode:
authorKarel Zak2010-01-19 13:43:39 +0100
committerKarel Zak2010-01-19 14:48:22 +0100
commitd0465c3c00f75d7247cbbf02c1b3ff879c3f7bd3 (patch)
tree53335a6354a654014c311b9faae12d03554f16c1 /shlibs/blkid/src/probe.c
parentlibblkid: set minimal size for jfs, reiser, swap and zfs (diff)
downloadkernel-qcow2-util-linux-d0465c3c00f75d7247cbbf02c1b3ff879c3f7bd3.tar.gz
kernel-qcow2-util-linux-d0465c3c00f75d7247cbbf02c1b3ff879c3f7bd3.tar.xz
kernel-qcow2-util-linux-d0465c3c00f75d7247cbbf02c1b3ff879c3f7bd3.zip
libblkid: read whole SB buffer (69kB) on large disks
- on large disks read whole SB buffer - new blkid_probe_is_tiny() version based on flags Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/probe.c')
-rw-r--r--shlibs/blkid/src/probe.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c
index b2c96a6b2..1bd98b55d 100644
--- a/shlibs/blkid/src/probe.c
+++ b/shlibs/blkid/src/probe.c
@@ -470,7 +470,7 @@ int __blkid_probe_filter_types(blkid_probe pr, int chain, int flag, char *names[
return 0;
}
-static int blkid_probe_has_buffer(blkid_probe pr,
+int blkid_probe_has_buffer(blkid_probe pr,
blkid_loff_t off, blkid_loff_t len)
{
return pr && (off + len <= pr->sbbuf_len ||
@@ -494,14 +494,20 @@ static unsigned char *blkid_probe_get_sb_buffer(blkid_probe pr,
/*
* The sbbuf is not completely in memory.
*
- * We don't read whole BLKID_SB_BUFSIZ by one read(), it's too
- * aggresive to small devices (floppies). We read necessary
- * data to complete the current request (off + len) only.
*/
ssize_t ret_read;
-
- blkid_loff_t have = pr->sbbuf_len,
- want = off + len - have;
+ blkid_loff_t want, have = pr->sbbuf_len;
+
+ if (blkid_probe_is_tiny(pr))
+ /* We don't read whole BLKID_SB_BUFSIZ by one read(),
+ * it's too aggresive to small devices (floppies). We
+ * read necessary data to complete the current request
+ * (off + len) only.
+ */
+ want = off + len - have;
+ else
+ /* large disk -- read all SB */
+ want = BLKID_SB_BUFSIZ - have;
DBG(DEBUG_LOWPROBE,
printf("\tsb-buffer read() off=%jd len=%jd\n", have, want));
@@ -606,7 +612,7 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr,
*/
int blkid_probe_is_tiny(blkid_probe pr)
{
- return (pr && pr->size <= 1440 * 1024 && !S_ISCHR(pr->mode));
+ return pr && (pr->flags & BLKID_TINY_DEV);
}
/**
@@ -676,6 +682,10 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
goto err;
DBG(DEBUG_LOWPROBE, printf("ready for low-probing, offset=%zd, size=%zd\n",
pr->off, pr->size));
+
+ if (pr->size <= 1440 * 1024 && !S_ISCHR(pr->mode))
+ pr->flags |= BLKID_TINY_DEV;
+
return 0;
err:
DBG(DEBUG_LOWPROBE,