-
Notifications
You must be signed in to change notification settings - Fork 391
Implement SetFileInformationByHandle, as well as direct shim test for it #4547
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?
Conversation
Thank you for contributing to Miri! |
☔ The latest upstream changes made this pull request unmergeable. Please resolve the merge conflicts. |
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!
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.
Can you also add a File::create
on a file that already exists somewhere suitable in this file so we ensure we cover that codepath?
@@ -209,7 +208,10 @@ fn test_file_set_len() { | |||
|
|||
// Can't use set_len on a file not opened for writing | |||
let file = OpenOptions::new().read(true).open(&path).unwrap(); | |||
assert_eq!(ErrorKind::InvalidInput, file.set_len(14).unwrap_err().kind()); | |||
assert_eq!( | |||
if cfg!(windows) { ErrorKind::PermissionDenied } else { ErrorKind::InvalidInput }, |
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.
Since we pass through the host OS error, I doubt this will work properly. Just check that it's one of the two (with a comment explaining why).
let ptr = this.deref_pointer_as( | ||
file_information, | ||
this.windows_ty_layout("FILE_END_OF_FILE_INFO"), | ||
)?; |
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.
This re-reads the pointer. Since you already read the pointer, you can just call ptr_to_mplace
directly.
|
||
let class = this.read_scalar(class)?.to_u32()?; | ||
let buffer_size = this.read_scalar(buffer_size)?.to_u32()?; | ||
let file_info = this.read_pointer(file_information)?; |
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.
Please pick a consistent name (file_information
vs file_info
).
CheckInAllocMsg::MemoryAccess, | ||
)?; | ||
|
||
let file = this.read_handle(file, "GetFileInformationByHandle")?; |
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.
let file = this.read_handle(file, "GetFileInformationByHandle")?; | |
let file = this.read_handle(file, "SetFileInformationByHandle")?; |
Happens a few more times below.
@rustbot author There's also a conflict that prevents CI from running, so please rebase to resolve that. |
Reminder, once the PR becomes ready for a review, use |
Fixes #4483