From: Karel Zak Date: Thu, 24 Sep 2009 13:48:13 +0000 (+0200) Subject: libblkid: cleanup blkid_probe_set_device() X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d17b1cf91f5c1a41660e8f240f9ff11259fcf1a;p=util-linux 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 --- diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index 89c16a20..86557d00 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,