Merged
Conversation
Earlier fix was FDOS#242 (this got the cluster value to use wrong). Original problem recorded in FDOS#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 . ===
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 is a test case:
=== testsect.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, (#1024 >> 10)
mov dx, (#1024 & FFFF)
int 21
mov ah, 40
mov dx, 400
mov cx, 0
int 21
int3
mov ah, 68
int 21
nop
int3
nop
jmp 100
.
===
9ff74d7 to
c63f9f4
Compare
Contributor
Author
|
I'm not too happy about the calculation in Lines 1031 to 1035 in dd2293f The problem is that OH. I think my current and prior patches are both super wrong in one aspect. They will modify the file size when scanning a file (read or write) before EOF. Proper fix upcoming. |
Contributor
Author
|
Test case to reproduce error: https://pushbx.org/ecm/test/20260422/testtrun.sld |
This was referenced Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #243 and properly fixes #241
This updates the commit from #242 with a correction.
I also added two comments on unexpected corner cases around writes of length 0 trying to extend more than actually needed. There is possibly a fragmentation source if a file is extended to fall exactly on a cluster boundary with 0-length write.