diff options
author | Karel Zak | 2010-02-04 22:19:38 +0100 |
---|---|---|
committer | Karel Zak | 2010-02-04 22:19:38 +0100 |
commit | 88923b088948446286290651abaca31464f884a8 (patch) | |
tree | 9d46df7d6459345b4cb08d7b02ef57110984f46b /shlibs/blkid/src/probe.c | |
parent | docs: update TODO file (diff) | |
download | kernel-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/probe.c')
-rw-r--r-- | shlibs/blkid/src/probe.c | 11 |
1 files changed, 8 insertions, 3 deletions
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); |