Skip to content

Require F_ALLOCATEALL on Apple fallocate - #1699

Open
mamicicekel wants to merge 1 commit into
bytecodealliance:mainfrom
mamicicekel:fix-apple-fallocate-partial
Open

mamicicekel wants to merge 1 commit into
bytecodealliance:mainfrom
mamicicekel:fix-apple-fallocate-partial

Conversation

@mamicicekel

Copy link
Copy Markdown

Summary

Apple's F_PREALLOCATE without F_ALLOCATEALL may succeed after allocating only part of fst_length and reports the actual amount in fst_bytesalloc. rustix treated any non--1 return as a full reservation, then ftruncated, so fallocate could return Ok(()) after reserving a few MiB of a much larger request.

The contiguous attempt now includes F_ALLOCATEALL. If that fails, the non-contiguous retry still uses F_ALLOCATEALL and no longer ignores a failed fcntl.

Fixes #1682.

Test plan

  • cargo test --features=fs --test fs apple_fallocate on macOS ARM (APFS)

Made with Cursor

F_PREALLOCATE without that flag can return success after reserving
only a few megabytes. The next ftruncate then leaves a sparse file
that later writes can hit ENOSPC on.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Apple fallocate can return Ok after only a partial F_PREALLOCATE allocation

1 participant