Skip to content

Conversation

@LorrensP-2158466
Copy link
Contributor

@LorrensP-2158466 LorrensP-2158466 commented Nov 4, 2025

should close #4464.

I used this man page for the implementation.
Changes included in this pr:

  • impl posix_fallocate and posix_fallocate64 (same as truncate versions because of libc::off_t)
  • use the impl in unix/foreign_items.
  • tests in pass-dep/libc/libc-fs.rs.

@rustbot
Copy link
Collaborator

rustbot commented Nov 4, 2025

Thank you for contributing to Miri!
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Nov 4, 2025
Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Nov 8, 2025
Comment on lines +1241 to +1252
let new_size = match offset.checked_add(len) {
// u64::from(i128) can fail if:
// - the value is negative, but we checed this above with `offset < 0 || len <= 0`
// - the value is too big/small to fit in u64, this should not happen since the callers
// check if the value is a `i32` or `i64`.
// So this unwrap is safe to do.
Some(size) => u64::try_from(size).unwrap(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually unsure if this is allowed in Miri, the callers to check if they fit inside of the layout.size, which can only be libc::off_t(i32) or libc::off64_t(i64).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh so we are adding two i64 here and hence the result fits in a u64?

Is that what the docs say for this function? I would kind of expect that there would be a "too big" error if the result exceeds i64::MAX.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have asked this sooner, excuse me. The docs do not say anything about integer overflows, but it does specify returning "EFBIG" when this size is larger than the maximum file size. I assumed we should thus return "EFBIG" when the addition overflows.

But I don't know how to get the maximum file size in Miri.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the maximum file size is i64::MAX.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then this should be correct right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it seems wrong.

@rustbot
Copy link
Collaborator

rustbot commented Nov 12, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@LorrensP-2158466
Copy link
Contributor Author

Had to rebase because of the new Os enum.

@LorrensP-2158466
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Waiting for a review to complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

posix_fallocate not supported

3 participants