libblkid-tiny: vfat: Change parsing label in special cases
[project/fstools.git] / libblkid-tiny / vfat.c
index 93e40530c897a56f9805ab41c07dd82cb013afe8..e70dd7565f47c391b5e32d56dbb8fd1121db5457 100644 (file)
@@ -305,11 +305,11 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
        struct vfat_super_block *vs;
        struct msdos_super_block *ms;
        unsigned char *vol_label = 0;
+       const unsigned char *boot_label = NULL;
        unsigned char *vol_serno = NULL, vol_label_buf[12] = { 0 };
        uint16_t sector_size = 0, reserved;
        uint32_t cluster_count, fat_size;
        const char *version = NULL;
-       int i;
 
        ms = blkid_probe_get_sb(pr, mag, struct msdos_super_block);
        if (!ms)
@@ -336,8 +336,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
                        vol_label = vol_label_buf;
                }
 
-               if (!vol_label || !memcmp(vol_label, no_name, 11))
-                       vol_label = ms->ms_label;
+               boot_label = ms->ms_label;
                vol_serno = ms->ms_serno;
 
                blkid_probe_set_value(pr, "SEC_TYPE", (unsigned char *) "msdos",
@@ -391,8 +390,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
 
                version = "FAT32";
 
-               if (!vol_label || !memcmp(vol_label, no_name, 11))
-                       vol_label = vs->vs_label;
+               boot_label = vs->vs_label;
                vol_serno = vs->vs_serno;
 
                /*
@@ -421,13 +419,10 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
                }
        }
 
-       for (i = 10; i >= 0; i--) {
-               if (vol_label[i] != ' ')
-                       break;
-               vol_label[i] = '\0';
-       }
+       if (boot_label && memcmp(boot_label, no_name, 11))
+               blkid_probe_set_id_label(pr, "LABEL_FATBOOT", (unsigned char *) boot_label, 11);
 
-       if (vol_label && memcmp(vol_label, no_name, 11))
+       if (vol_label)
                blkid_probe_set_label(pr, (unsigned char *) vol_label, 11);
 
        /* We can't just print them as %04X, because they are unaligned */