Skip to content

Commit dd2293f

Browse files
ecm-pushbxPerditionC
authored andcommitted
fatfs.c: fix earlier fix, update dir_size in map_cluster loop
Earlier fix was #242 (this got the cluster value to use wrong). Original problem recorded in #241 Reset disk scriptlet: nasm -I ~/proj/lmacros/ ~/proj/bootimg/bootimg.asm \ -D_PAYLOADFILE=::empty -o diskempt.img cp -a ~/proj/kernel/bin/kernel.sys fdkernel.sys Run dosemu2 with -I "floppy { device diskempt.img }" After a test, run /sbin/dosfsck -n diskempt.img The following Script for lDebug files are test cases: === testshrt.sld e 200 "A:\test.dat" 0 f 300 l 100 26 a mov ah, 3C mov cx, 0 mov dx, 200 int 21 xchg bx, ax mov ax, 4200 mov cx, 1000 mov dx, cx int 21 mov dx, 300 mov cx, 10 mov ah, 3F int 21 . r v0 := aao a mov ah, 40 int 21 int3 int3 jmp (v0) . === testfull.sld e 200 "A:\test.dat" 0 f 400 l 400 38 a mov ah, 3C mov cx, 0 mov dx, 200 int 21 xchg bx, ax mov ax, 4200 mov cx, ((#1424 * #1024 - 1) >> 10) mov dx, ((#1424 * #1024 - 1) & FFFF) int 21 mov ah, 40 mov dx, 400 mov cx, 1 int 21 mov ah, 68 int 21 mov ax, 4202 mov cx, -1 mov dx, -10 int 21 mov ah, 40 mov dx, 400 mov cx, 10 int 21 int3 mov ah, 68 int 21 nop int3 nop jmp 100 . === testful2.sld e 200 "A:\test.dat" 0 f 400 l 400 38 a mov ah, 3C mov cx, 0 mov dx, 200 int 21 xchg bx, ax mov ax, 4200 mov cx, ((#1424 * #1024 - #512 - 1) >> 10) mov dx, ((#1424 * #1024 - #512 - 1) & FFFF) int 21 mov ah, 40 mov dx, 400 mov cx, 1 int 21 mov ah, 68 int 21 mov ax, 4202 mov cx, -1 mov dx, -10 int 21 mov ah, 40 mov dx, 400 mov cx, 10 int 21 int3 mov ah, 68 int 21 nop int3 nop jmp 100 . === testful3.sld e 200 "A:\test.dat" 0 f 400 l 400 38 a mov ah, 3C mov cx, 0 mov dx, 200 int 21 xchg bx, ax mov ax, 4200 mov cx, ((#1424 * #1024 - #512) >> 10) mov dx, ((#1424 * #1024 - #512) & FFFF) int 21 mov ah, 40 mov dx, 400 mov cx, 0 int 21 mov ah, 68 int 21 mov ax, 4202 mov cx, -1 mov dx, -10 int 21 mov ah, 40 mov dx, 400 mov cx, 10 int 21 int3 mov ah, 68 int 21 nop int3 nop jmp 100 . ===
1 parent 6734c10 commit dd2293f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/fatfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode)
10291029
fnp->f_cluster = cluster;
10301030
fnp->f_cluster_offset++;
10311031
fnp->f_dir.dir_size =
1032-
((ULONG)fnp->f_cluster
1032+
(((ULONG)fnp->f_cluster_offset + 1)
10331033
* (ULONG)fnp->f_dpb->dpb_secsize)
10341034
<<
10351035
fnp->f_dpb->dpb_shftcnt;

0 commit comments

Comments
 (0)