diff options
author | Karel Zak | 2010-02-02 16:01:28 +0100 |
---|---|---|
committer | Karel Zak | 2010-02-02 16:01:28 +0100 |
commit | a39ff47a185f23b370f8f5b535dfa69b263e22e3 (patch) | |
tree | 268fe07699aaad687282412c5efec82986366ca4 | |
parent | tests: add BeFS test image (diff) | |
download | kernel-qcow2-util-linux-a39ff47a185f23b370f8f5b535dfa69b263e22e3.tar.gz kernel-qcow2-util-linux-a39ff47a185f23b370f8f5b535dfa69b263e22e3.tar.xz kernel-qcow2-util-linux-a39ff47a185f23b370f8f5b535dfa69b263e22e3.zip |
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 <kzak@redhat.com>
-rw-r--r-- | shlibs/blkid/src/superblocks/befs.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/shlibs/blkid/src/superblocks/befs.c b/shlibs/blkid/src/superblocks/befs.c index 0ce84975b..b341402ad 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 { |