Skip to content

Commit 0bd9928

Browse files
authored
Merge pull request #127 from douglasmun/fix/fat32-volume-label-precision
fat32: print the volume label instead of the literal "%.11s"
2 parents e83f2eb + c9b3998 commit 0bd9928

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/fat32.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,13 @@ int fat32_mount(void) {
750750
kprintf("[FAT32] Data starts at sector %u\n", data_start_sector);
751751
kprintf("[FAT32] Root directory cluster: %u\n", root_dir_cluster);
752752
kprintf("[FAT32] Sectors per cluster: %u\n", sectors_per_cluster);
753-
kprintf("[FAT32] Volume label: %.11s\n", boot_sector.volume_label);
753+
/* vformat has no precision support, so "%.11s" printed literally on every
754+
* successful mount. The field is a non-NUL-terminated uint8_t[11], so plain
755+
* %s would read past it -- copy and terminate instead. */
756+
char vol_label[12];
757+
memcpy(vol_label, boot_sector.volume_label, 11);
758+
vol_label[11] = '\0';
759+
kprintf("[FAT32] Volume label: %s\n", vol_label);
754760

755761
fat32_mounted = true;
756762
kprintf("[FAT32] Mount successful [OK]\n");

0 commit comments

Comments
 (0)