From 417b6d0e2bd62a4de0c8e9f254b69d98ab59fe7a Mon Sep 17 00:00:00 2001 From: Andrew Bird Date: Fri, 28 Nov 2025 14:00:18 +0000 Subject: [PATCH] disk: Set volume label also on BPB update The existing code is only designed to update the serial number, but MS-DOS and DR-DOS also update the volume and filesystem type too. This patch enables updating of the volume field which is the common case, but in the future it may be considered to update the filesystem type also. DOS provides two methods of updating the BPB (int21/6901 and int21/440d/0846), on FreeDOS the same code implements both functions. I have added tests on Dosemu2's test suite to cover serial number, volume and filesystem type, the latter is marked as unsupported. --- kernel/dsk.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index 0b07f7c..8568692 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -709,18 +709,17 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) { struct Gioc_media FAR *gioc = rp->r_gioc; struct FS_info *fs; + BYTE extended_BPB_signature; ret = getbpb(pddt); if (ret != 0) return (ret); + extended_BPB_signature = + DiskTransferBuffer[(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x26 : 0x42)]; /* return error if media lacks extended BPB with serial # */ - { - register BYTE extended_BPB_signature = - DiskTransferBuffer[(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x26 : 0x42)]; - if ((extended_BPB_signature != 0x29) || (extended_BPB_signature != 0x28)) - return failure(E_MEDIA); - } + if ((extended_BPB_signature != 0x29) && (extended_BPB_signature != 0x28)) + return failure(E_MEDIA); /* otherwise, store serial # in extended BPB */ fs = (struct FS_info *)&DiskTransferBuffer @@ -728,6 +727,13 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) fs->serialno = gioc->ioc_serialno; pddt->ddt_serialno = fs->serialno; + /* And volume name if BPB supports it */ + if (extended_BPB_signature == 0x29) + { + fmemcpy(fs->volume, gioc->ioc_volume, 11); + fmemcpy(pddt->ddt_volume, fs->volume, 11); + } + ret = RWzero(pddt, LBA_WRITE); if (ret != 0) return (dskerr(ret));