]> err.no Git - util-linux/commitdiff
libblkid: cleanup blkid_probe_set_device()
authorKarel Zak <kzak@redhat.com>
Thu, 24 Sep 2009 13:48:13 +0000 (15:48 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 24 Sep 2009 13:48:13 +0000 (15:48 +0200)
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>
shlibs/blkid/src/probe.c

index 89c16a201e0864147bf0a77771c9482a281e2544..86557d00c1ebf5002677613a36da5858fbe4ee8d 100644 (file)
@@ -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,