Skip to content
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

fuse: fix incorrect len field in command headers #1113

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

cagatay-y
Copy link
Contributor

FUSE seems to expect in the length field of the header the total length of the command without the padding. This PR fixes #1111.

This was referenced Mar 26, 2024
Copy link
Member

@mkroening mkroening 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 swift fix!

I am confused about how this works. When I extract the expression with slice_from_raw_parts_mut into a variable, rust-analyzer reports the type as *mut [u8]. len is not the length of the entire struct, rather the payload, so the slice we create here does not cover the whole struct. I validated this by checking the length of the pointed slice.

The reason I originally used 0 as the slice length was because that was how it was in the previous version of the code, but I think reverting 93fc6cb and using ptr_metadata here may be worth the unstable feature. I included a commit with the reversion in my PR (#1113) for #1111, but I can remove it if you prefer.

len never refers to the length of the entire struct but to the number of elements. For structs with DSTs as the last field, the metadata of the last field is used. So when whe create a pointer with the correct metadata via ptr::slice_from_raw_parts_mut everything should be fine, although it might be confusing at first. References:

I still think ptr_metadata does not improve the situation here, aside from the fact that it will probably take ages to stabilize still. Please remove that commit and then I can merge this. :)

Copy link
Member

@mkroening mkroening left a comment

Choose a reason for hiding this comment

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

Awesome, thanks again! :)

@mkroening mkroening added this pull request to the merge queue Mar 26, 2024
@cagatay-y
Copy link
Contributor Author

No problem, sorry for breaking the code earlier 😅

Merged via the queue into hermit-os:main with commit 4e9c13c Mar 26, 2024
13 checks passed
@mkroening
Copy link
Member

No problem, sorry for breaking the code earlier 😅

No worries, it happens to everybody. :)

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.

Extra zeros at the end of files with FUSE
2 participants