Skip to content

[kernel] Fix off-by-one error in RAM disk segment offset#2666

Merged
ghaerr merged 1 commit intomasterfrom
rd
May 1, 2026
Merged

[kernel] Fix off-by-one error in RAM disk segment offset#2666
ghaerr merged 1 commit intomasterfrom
rd

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented May 1, 2026

Found by AI in #2646.

It took a while for me to understand why the RAM disk previously worked even with the off-by-one error (despite previous data integrity testing), but found that due to the particular modulo arithmetic and the MINIX filesystem involved, the 128th sector got swapped with the 0th sector and all subsequent sectors slid up by one, so no data errors occurred.

Verified by adding a few new debug statements and running the following script, which copied 124k of data to use multiple segments:

ramdisk /dev/rd0 make 132
mkfs /dev/rd0 132
mount -t minix /dev/rd0 /mnt
cp /bin/memopad /mnt
cmp /bin/memopad /mnt/memopad

@ghaerr ghaerr merged commit 7b2cffb into master May 1, 2026
1 check passed
@ghaerr ghaerr deleted the rd branch May 1, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant