Skip to content

[fs][fat] fix false EOF error on cluster-aligned reads#507

Closed
leon-chen1127 wants to merge 1 commit into
littlekernel:masterfrom
leon-chen1127:fix-fat-read-eof-overlap
Closed

[fs][fat] fix false EOF error on cluster-aligned reads#507
leon-chen1127 wants to merge 1 commit into
littlekernel:masterfrom
leon-chen1127:fix-fat-read-eof-overlap

Conversation

@leon-chen1127
Copy link
Copy Markdown

When a file read reaches the end of a cluster and the total read length is exactly aligned with the cluster boundary, the iterator speculatively fetches the next sector. This causes the FAT driver to hit the EOF marker in the FAT table, returning ERR_OUT_OF_RANGE.

This patch adds a check to skip the next sector fetch if the target length has already been met.

Tested with a 4KB/8KB file on a FAT12/FAT16/FAT32 image for typical cluster sizes (e.g., 1KB, 2KB, 4KB), ensuring that the cluster boundary condition is triggered regardless of the specific FAT type.

When a file read reaches the end of a cluster and the total read length
is exactly aligned with the cluster boundary, the iterator speculatively
fetches the next sector. This causes the FAT driver to hit the
EOF marker in the FAT table, returning ERR_OUT_OF_RANGE.

This patch adds a check to skip the next sector fetch if the target
length has already been met.

Tested with a 4KB/8KB file on a FAT12/FAT16/FAT32 image for typical
cluster sizes (e.g., 1KB, 2KB, 4KB), ensuring that the cluster boundary
condition is triggered regardless of the specific FAT type.
@travisg
Copy link
Copy Markdown
Member

travisg commented May 6, 2026

Great catch! I'm about to roll a big pile of changes (read-write support) to master from the wip/fat branch but it looks like this would apply on top of it cleanly so I'll hold off merging this in until I get that branch in, which should happen soon.

Thanks!

@travisg
Copy link
Copy Markdown
Member

travisg commented May 9, 2026

@copilot resolve the merge conflicts in this pull request

@travisg
Copy link
Copy Markdown
Member

travisg commented May 9, 2026

Resolved and pushed upstream. It didn't pick up that it completed this pull, but it did. Thanks!

@travisg travisg closed this May 9, 2026
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.

3 participants