Skip to content

Commit

Permalink
Move UD_ACLU to the end of the unit descriptor (#72)
Browse files Browse the repository at this point in the history
The improvement of the cluster chain allocation process performance
introduced a new unit descriptor field, UD_ACLU, in the middle
of the unit descriptor (between UD_MBYTE and UD_CDIR). This caused
severe problems when writing data (weird errors, computer crashes,
even data corruption) because somewhere in the kernel there's code
that assumed that these fields are stored consecutively in memory.

The fix consists of moving UD_ACLU to the end of the unit descriptor.
  • Loading branch information
Konamiman authored Aug 30, 2020
1 parent a616365 commit c73e37e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions source/kernel/bank2/val.mac
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ endif
; Assumes: UPB_DIRT=UPB_VOLID+6 UPB_ID=UPB_DIRT+1
; (UD_CMSK, UD_CSHFT, UD_RES, UD_NFAT, UD_ODE, UD_WDS
; UD_SFAT, UD_SDIR, UD_SDAT, UD_NCLU, UD_DIRT, UD_ID,
; UD_MBYTE and UD_ACLU) must all be sequential.
; and UD_MBYTE) must all be sequential.
;
;
call _NEW_UPB
Expand Down Expand Up @@ -2157,9 +2157,12 @@ upb_dos220:
; from UPB to unit descriptor
ld (hl),a

inc hl ;Initialize next cluster to check for allocation to 2
ld (hl),1 ;(it's stored as value-1)
inc hl
pop hl
push hl
ld bc,UD_ACLU##
add hl,bc
ld (hl),1 ;Initialize next cluster to check for allocation to 2
inc hl ;(it's stored as value-1)
ld (hl),0

pop hl
Expand Down
4 changes: 2 additions & 2 deletions source/kernel/kvar.mac
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ size macro name
field 4,UD_ID ;Current volume ID
field 1,UD_MBYTE ;Media descriptor byte

field 2,UD_ACLU ;Next cluster to check for allocation -1
;
field 2,UD_CDIR ;First cluster of current directory
; -ve => root directory
; 0000h => cluster not known
Expand All @@ -209,6 +207,8 @@ size macro name
;(for device-based drivers this is only used if the driver
; provides configuration, in order to get the default mapping
; for the drive)
field 2,UD_ACLU ;Next cluster to check for allocation -1

;
;--- Extra fields used when mounting files
; This extra space should NOT be allocated unless a file is mounted to the drive
Expand Down

0 comments on commit c73e37e

Please sign in to comment.