Skip to content

Commit 417b6d0

Browse files
andrewbirdPerditionC
authored andcommitted
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.
1 parent 14c6201 commit 417b6d0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

kernel/dsk.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,25 +709,31 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
709709
{
710710
struct Gioc_media FAR *gioc = rp->r_gioc;
711711
struct FS_info *fs;
712+
BYTE extended_BPB_signature;
712713

713714
ret = getbpb(pddt);
714715
if (ret != 0)
715716
return (ret);
716717

718+
extended_BPB_signature =
719+
DiskTransferBuffer[(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x26 : 0x42)];
717720
/* return error if media lacks extended BPB with serial # */
718-
{
719-
register BYTE extended_BPB_signature =
720-
DiskTransferBuffer[(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x26 : 0x42)];
721-
if ((extended_BPB_signature != 0x29) || (extended_BPB_signature != 0x28))
722-
return failure(E_MEDIA);
723-
}
721+
if ((extended_BPB_signature != 0x29) && (extended_BPB_signature != 0x28))
722+
return failure(E_MEDIA);
724723

725724
/* otherwise, store serial # in extended BPB */
726725
fs = (struct FS_info *)&DiskTransferBuffer
727726
[(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x27 : 0x43)];
728727
fs->serialno = gioc->ioc_serialno;
729728
pddt->ddt_serialno = fs->serialno;
730729

730+
/* And volume name if BPB supports it */
731+
if (extended_BPB_signature == 0x29)
732+
{
733+
fmemcpy(fs->volume, gioc->ioc_volume, 11);
734+
fmemcpy(pddt->ddt_volume, fs->volume, 11);
735+
}
736+
731737
ret = RWzero(pddt, LBA_WRITE);
732738
if (ret != 0)
733739
return (dskerr(ret));

0 commit comments

Comments
 (0)