properly handle return codes
[project/fstools.git] / libblkid-tiny / libblkid-tiny.c
index a01a43e..f66f3a1 100644 (file)
@@ -167,6 +167,7 @@ static const struct blkid_idinfo *idinfos[] =
        &jffs2_idinfo,
        &hfsplus_idinfo,
        &hfs_idinfo,
+       &btrfs_idinfo,
 };
 
 int probe_block(char *block, struct blkid_struct_probe *pr)
@@ -174,7 +175,7 @@ int probe_block(char *block, struct blkid_struct_probe *pr)
        struct stat s;
        int i;
 
-       if (stat(block, &s) || (!S_ISBLK(s.st_mode) && !S_ISREG(s.st_mode)))
+       if (stat(block, &s) || (!S_ISBLK(s.st_mode) && !S_ISREG(s.st_mode) && !strncmp(block, "ubi", 3)))
                return -1;
 
        pr->err = -1;
@@ -196,7 +197,8 @@ int probe_block(char *block, struct blkid_struct_probe *pr)
                        char magic[32] = { 0 };
 
                        lseek(pr->fd, off, SEEK_SET);
-                       read(pr->fd, magic, mag->len);
+                       if (read(pr->fd, magic, mag->len) < 0)
+                               return -1;
 
                        DEBUG("magic: %s %s %d\n", mag->magic, magic, mag->len);
                        if (!memcmp(mag->magic, magic, mag->len))