Detect and convert between endianess of guest
Previously, virtiofsd would simply error out when running a guest of a different endianess as it would receive a header for init that would include a size that is way bigger than it needs to be, and way bigger than we allocate. This makes for a good endianess test.
Now, we guess guest endianess using this size check, as the first header we receive will be < 100 bytes to allocate. Knowing this, we can detect endianess with this size check.
This also wraps all fuse structures with a GuestEndian type that uses a global to decide if they swap their bytes or not.
Resloves #145
Summary by Sourcery
Add support for detecting and converting between guest and host endianness in virtiofsd
New Features:
- Implement endianness detection for guests with different byte order
- Add support for converting FUSE structures between guest and host endianness
Bug Fixes:
- Resolve issue with guests of different endianness causing initialization errors
Enhancements:
- Wrap FUSE structures with a GuestEndian type to handle byte swapping
- Modify type conversions to support endianness conversion
Edited by sourcery-ai