]> err.no Git - util-linux/commitdiff
libblkid: minor fixes in befs.c
authorKarel Zak <kzak@redhat.com>
Tue, 2 Feb 2010 15:01:28 +0000 (16:01 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 2 Feb 2010 15:01:28 +0000 (16:01 +0100)
The library does not reset the probing result (e.g. LABEL, VERSION)
when the probing function failed (return value != 0). We have to be
absolutely sure that the FS has been properly detected before we set
LABEL or VERSION or so.

Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/superblocks/befs.c

index 0ce84975b46cb2cc5fd8ca63ebb9ebeab0f1856b..b341402ada265d9df42fdc6153ee502d13370894 100644 (file)
@@ -99,6 +99,7 @@ static int probe_befs(blkid_probe pr, const struct blkid_idmag *mag)
        struct small_data *sd;
        int fs_le;
        uint64_t volume_id = 0;
+       const char *version = NULL;
 
        bs = (struct befs_super_block *) blkid_probe_get_buffer(pr,
                                        mag->sboff - B_OS_NAME_LENGTH,
@@ -111,20 +112,15 @@ static int probe_befs(blkid_probe pr, const struct blkid_idmag *mag)
                && le32_to_cpu(bs->magic3) == SUPER_BLOCK_MAGIC3
                && le32_to_cpu(bs->fs_byte_order) == SUPER_BLOCK_FS_ENDIAN) {
                fs_le = 1;
-               blkid_probe_set_version(pr, "little-endian");
+               version = "little-endian";
        } else if (be32_to_cpu(bs->magic1) == SUPER_BLOCK_MAGIC1
                && be32_to_cpu(bs->magic2) == SUPER_BLOCK_MAGIC2
                && be32_to_cpu(bs->magic3) == SUPER_BLOCK_MAGIC3
                && be32_to_cpu(bs->fs_byte_order) == SUPER_BLOCK_FS_ENDIAN) {
                fs_le = 0;
-               blkid_probe_set_version(pr, "big-endian");
-       } else {
+               version = "big-endian";
+       } else
                return -1;
-       }
-
-       if (strlen(bs->name))
-               blkid_probe_set_label(pr, (unsigned char *) bs->name,
-                                                       sizeof(bs->name));
 
        bi = (struct befs_inode *) blkid_probe_get_buffer(pr,
                        (FS32_TO_CPU(bs->root_dir.allocation_group, fs_le)
@@ -140,6 +136,18 @@ static int probe_befs(blkid_probe pr, const struct blkid_idmag *mag)
        if (FS32_TO_CPU(bi->magic1, fs_le) != INODE_MAGIC1)
                return -1;
 
+       /*
+        * all checks pass, set LABEL and VERSION
+        */
+       if (strlen(bs->name))
+               blkid_probe_set_label(pr, (unsigned char *) bs->name,
+                                                       sizeof(bs->name));
+       if (version)
+               blkid_probe_set_version(pr, version);
+
+       /*
+        * search for UUID
+        */
        sd = (struct small_data *) bi->small_data;
 
        do {