snapshot: md5sum return codes are not properly handled
[project/fstools.git] / libblkid-tiny / libblkid-tiny.c
index dc18aa7..9f260eb 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <sys/utsname.h>
 
+#include "libblkid-tiny.h"
 #include "superblocks.h"
 #include "linux_version.h"
 
@@ -163,7 +164,12 @@ static const struct blkid_idinfo *idinfos[] =
        &ext2_idinfo,
        &jbd_idinfo,
        &squashfs_idinfo,
+       &ubifs_idinfo,
        &jffs2_idinfo,
+       &hfsplus_idinfo,
+       &hfs_idinfo,
+       &btrfs_idinfo,
+       &f2fs_idinfo,
 };
 
 int probe_block(char *block, struct blkid_struct_probe *pr)
@@ -171,7 +177,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;
@@ -193,7 +199,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))