-
Notifications
You must be signed in to change notification settings - Fork 404
Implement posix_fallocate with set_len() functionality
#4664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Implement posix_fallocate with set_len() functionality
#4664
Conversation
|
Thank you for contributing to Miri! |
There was a problem hiding this 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!
| 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(), |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it seems wrong.
2d8cb4d to
21651ee
Compare
|
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. |
|
Had to rebase because of the new |
|
@rustbot ready |
should close #4464.
I used this man page for the implementation.
Changes included in this pr:
posix_fallocateandposix_fallocate64(same as truncate versions because of libc::off_t)unix/foreign_items.pass-dep/libc/libc-fs.rs.