-
-
Notifications
You must be signed in to change notification settings - Fork 26
fix: fix get sector size on mips64 #138
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
fix: fix get sector size on mips64 #138
Conversation
cc41ab6 to
5d88c52
Compare
|
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/block/ioctl.c?h=v6.14-rc1#n588. I'm still unsure why this only blows up on MIPS64 (FWIW our system is little-endian), I guess it's related to MIPS64 having things like
a limitation that most 64-bit architectures don't have. |
|
Hello and welcome 👋 Wow this sounds like a very specific issue! Would it be possible to call the ioctl with signed 32 bits but then still return a u64? Mostly to avoid API breaking change but also I think it's using u64 internally everywhere in gptman. Would that be convenient for your use? If not we could also use cfg() to limit this change to mips64 only. Let me know your thoughts on this I'm not really knowledgeable for this. @bgilbert I would really love your input on this one if you have time ofc |
Yes, for our use we actually need to cast it to u64: and I'd prefer this way. Technically this is a potential problem for all architectures, so making the fix MIPS64-specific seems not a good idea. The problem is what we should do if we get a negative value. If the kernel is not buggy that should never happen, but in Rust we have to handle the case. Is |
|
I was thinking about .unwrap_or(512) so it's guaranteed to not cause a panic and it's a reasonable value in most cases. What do you think? Don't bother with the checks I will fix it myself I have to change the workflow. |
|
If you update your branch with origin/main you should have less issues with the checks on GitHub. |
5d88c52 to
52d7e0f
Compare
|
LGTM, maybe add a comment to explain 512 should be only used as a fall back in case the kernel goes crazy. |
Good point, something like:
You both agree at 100% with this behavior? It works perfectly for your use case? |
Use `try_into` to try convert i32 to u64, if fail, will use default value (512)
d4b21fb to
693762c
Compare
|
oh sorry I meant for the documentation of the function so the user can see it from the doc. |
I totally agree that this is the way to handle this issue, for our use case we are also using |
693762c to
d2a5c42
Compare
Done |
This PR will fix the
get_sector_sizefunction returningENOTTYon the MIPS64 architecture.