summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src
diff options
context:
space:
mode:
authorKarel Zak2010-02-04 22:19:38 +0100
committerKarel Zak2010-02-04 22:19:38 +0100
commit88923b088948446286290651abaca31464f884a8 (patch)
tree9d46df7d6459345b4cb08d7b02ef57110984f46b /shlibs/blkid/src
parentdocs: update TODO file (diff)
downloadkernel-qcow2-util-linux-88923b088948446286290651abaca31464f884a8.tar.gz
kernel-qcow2-util-linux-88923b088948446286290651abaca31464f884a8.tar.xz
kernel-qcow2-util-linux-88923b088948446286290651abaca31464f884a8.zip
libblkid: don't return error on empty files
Currently, the library does not allow to initialize blkid_probe if the file (or block device) is empty. The empty file is reported as an error. That's wrong. The empty file should be interpreted as a file without any FS or PT. It means that blkid_do_{probe,safeprobe,fullprobe}() have to return 1 ("nothing"). Reported-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src')
-rw-r--r--shlibs/blkid/src/partitions/partitions.c2
-rw-r--r--shlibs/blkid/src/probe.c11
-rw-r--r--shlibs/blkid/src/superblocks/superblocks.c2
3 files changed, 10 insertions, 5 deletions
diff --git a/shlibs/blkid/src/partitions/partitions.c b/shlibs/blkid/src/partitions/partitions.c
index 154365d79..e8d031137 100644
--- a/shlibs/blkid/src/partitions/partitions.c
+++ b/shlibs/blkid/src/partitions/partitions.c
@@ -505,7 +505,7 @@ static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id)
int hasmag = 0;
int rc = 1; /* = nothing detected */
- if (id->minsz && id->minsz > pr->size)
+ if (pr->size <= 0 || (id->minsz && id->minsz > pr->size))
goto nothing; /* the device is too small */
mag = id->magics ? &id->magics[0] : NULL;
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c
index 91366851e..e78458162 100644
--- a/shlibs/blkid/src/probe.c
+++ b/shlibs/blkid/src/probe.c
@@ -289,7 +289,7 @@ void *blkid_probe_get_binary_data(blkid_probe pr, struct blkid_chain *chn)
{
int rc;
- if (!pr && !chn)
+ if (!pr || !chn)
return NULL;
pr->cur_chain = chn;
@@ -465,6 +465,9 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr,
struct list_head *p;
struct blkid_bufinfo *bf = NULL;
+ if (pr->size <= 0)
+ return NULL;
+
list_for_each(p, &pr->buffers) {
struct blkid_bufinfo *x =
list_entry(p, struct blkid_bufinfo, bufs);
@@ -605,8 +608,6 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
pr->size -= pr->off;
}
- if (!pr->size)
- goto err;
DBG(DEBUG_LOWPROBE, printf("ready for low-probing, offset=%zd, size=%zd\n",
pr->off, pr->size));
@@ -648,6 +649,10 @@ int blkid_probe_set_dimension(blkid_probe pr,
pr->off = off;
pr->size = size;
+ pr->flags &= ~BLKID_TINY_DEV;
+
+ if (pr->size <= 1440 * 1024 && !S_ISCHR(pr->mode))
+ pr->flags |= BLKID_TINY_DEV;
blkid_probe_reset_buffer(pr);
diff --git a/shlibs/blkid/src/superblocks/superblocks.c b/shlibs/blkid/src/superblocks/superblocks.c
index fd12e5ec2..56b334d03 100644
--- a/shlibs/blkid/src/superblocks/superblocks.c
+++ b/shlibs/blkid/src/superblocks/superblocks.c
@@ -311,7 +311,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
printf("--> starting probing loop [SUBLKS idx=%d]\n",
chn->idx));
- if (pr->size <= 1024 && !S_ISCHR(pr->mode))
+ if (pr->size <= 0 || (pr->size <= 1024 && !S_ISCHR(pr->mode)))
/* Ignore very very small block devices or regular files (e.g.
* extended partitions). Note that size of the UBI char devices
* is 1 byte */