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.
This commit is contained in:
Andrew Bird 2025-11-28 14:00:18 +00:00 committed by Kenneth J Davis
parent 14c6201ceb
commit 417b6d0e2b

View File

@ -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));