summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/probe.c
diff options
context:
space:
mode:
authorKarel Zak2009-09-24 15:48:13 +0200
committerKarel Zak2009-09-24 15:48:13 +0200
commit0d17b1cf91f5c1a41660e8f240f9ff11259fcf1a (patch)
treeb2f11c3f4af15764eabda838b6504e93ddc80f0d /shlibs/blkid/src/probe.c
parenttests: add UBIFS test image to blkid test suite (diff)
downloadkernel-qcow2-util-linux-0d17b1cf91f5c1a41660e8f240f9ff11259fcf1a.tar.gz
kernel-qcow2-util-linux-0d17b1cf91f5c1a41660e8f240f9ff11259fcf1a.tar.xz
kernel-qcow2-util-linux-0d17b1cf91f5c1a41660e8f240f9ff11259fcf1a.zip
libblkid: cleanup blkid_probe_set_device()
It does not make sense to use libblkid for anything other than block devices, char devices (UBI only) and regular files. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/probe.c')
-rw-r--r--shlibs/blkid/src/probe.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c
index 89c16a201..86557d00c 100644
--- a/shlibs/blkid/src/probe.c
+++ b/shlibs/blkid/src/probe.c
@@ -518,7 +518,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
struct stat sb;
if (fstat(fd, &sb))
- return -1;
+ goto err;
pr->mode = sb.st_mode;
@@ -526,7 +526,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
blkdev_get_size(fd, (unsigned long long *) &pr->size);
else if (S_ISCHR(sb.st_mode))
pr->size = 1; /* UBI devices are char... */
- else
+ else if (S_ISREG(sb.st_mode))
pr->size = sb.st_size; /* regular file */
if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode))
@@ -534,18 +534,16 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
}
if (!pr->size)
- return -1;
-
- /* read SB to test if the device is readable */
- if (!blkid_probe_get_buffer(pr, 0, 0x200)) {
- DBG(DEBUG_LOWPROBE,
- printf("failed to prepare a device for low-probing\n"));
- return -1;
- }
+ goto err;
DBG(DEBUG_LOWPROBE, printf("ready for low-probing, offset=%zd, size=%zd\n",
pr->off, pr->size));
return 0;
+err:
+ DBG(DEBUG_LOWPROBE,
+ printf("failed to prepare a device for low-probing\n"));
+ return -1;
+
}
int blkid_probe_get_dimension(blkid_probe pr,