Skip to content

Commit c73e37e

Browse files
authored
Move UD_ACLU to the end of the unit descriptor (#72)
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.
1 parent a616365 commit c73e37e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

source/kernel/bank2/val.mac

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ endif
18521852
; Assumes: UPB_DIRT=UPB_VOLID+6 UPB_ID=UPB_DIRT+1
18531853
; (UD_CMSK, UD_CSHFT, UD_RES, UD_NFAT, UD_ODE, UD_WDS
18541854
; UD_SFAT, UD_SDIR, UD_SDAT, UD_NCLU, UD_DIRT, UD_ID,
1855-
; UD_MBYTE and UD_ACLU) must all be sequential.
1855+
; and UD_MBYTE) must all be sequential.
18561856
;
18571857
;
18581858
call _NEW_UPB
@@ -2157,9 +2157,12 @@ upb_dos220:
21572157
; from UPB to unit descriptor
21582158
ld (hl),a
21592159

2160-
inc hl ;Initialize next cluster to check for allocation to 2
2161-
ld (hl),1 ;(it's stored as value-1)
2162-
inc hl
2160+
pop hl
2161+
push hl
2162+
ld bc,UD_ACLU##
2163+
add hl,bc
2164+
ld (hl),1 ;Initialize next cluster to check for allocation to 2
2165+
inc hl ;(it's stored as value-1)
21632166
ld (hl),0
21642167

21652168
pop hl

source/kernel/kvar.mac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ size macro name
193193
field 4,UD_ID ;Current volume ID
194194
field 1,UD_MBYTE ;Media descriptor byte
195195

196-
field 2,UD_ACLU ;Next cluster to check for allocation -1
197-
;
198196
field 2,UD_CDIR ;First cluster of current directory
199197
; -ve => root directory
200198
; 0000h => cluster not known
@@ -209,6 +207,8 @@ size macro name
209207
;(for device-based drivers this is only used if the driver
210208
; provides configuration, in order to get the default mapping
211209
; for the drive)
210+
field 2,UD_ACLU ;Next cluster to check for allocation -1
211+
212212
;
213213
;--- Extra fields used when mounting files
214214
; This extra space should NOT be allocated unless a file is mounted to the drive

0 commit comments

Comments
 (0)