From: Karel Zak Date: Tue, 2 Feb 2010 15:01:28 +0000 (+0100) Subject: libblkid: minor fixes in befs.c X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a39ff47a185f23b370f8f5b535dfa69b263e22e3;p=util-linux libblkid: minor fixes in befs.c 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 --- diff --git a/shlibs/blkid/src/superblocks/befs.c b/shlibs/blkid/src/superblocks/befs.c index 0ce84975..b341402a 100644 --- a/shlibs/blkid/src/superblocks/befs.c +++ b/shlibs/blkid/src/superblocks/befs.c @@ -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 {