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

Fix ioctl numbers on BSDs #926

Merged
merged 1 commit into from
Nov 10, 2023
Merged

Conversation

ids1024
Copy link
Contributor

@ids1024 ids1024 commented Nov 9, 2023

<sys/ioccom.h> defines IOC_OUT as 0x40000000UL. But this is "out" from the perspective of the kernel, not the application. So this corresponds to READ rather than WRITE.

Tested on FreeBSD with Smithay/drm-rs#180. This also seems to be correct for NetBSD and OpenBSD.

@sunfishcode
Copy link
Member

@notgull I don't know how these work; do these look right to you?

@notgull
Copy link
Contributor

notgull commented Nov 10, 2023

Yeah those look right to me. I don't know how IOCTL numbers work on BSD. I copied from nix and I must have switched something around

@ids1024
Copy link
Contributor Author

ids1024 commented Nov 10, 2023

The C macro definitions in https://github.com/freebsd/freebsd-src/blob/master/sys/sys/ioccom.h aren't too incomprehensible. compose_opcode here looks like it matches the BSD definition of _IOC. So I think everything should be right on the BSDs after this change.

@sunfishcode
Copy link
Member

Sounds good. Could you add a comment mentioning that (a) those correspond to IOC_IN/IOC_OUT and (b) that the perspective is inverted?

`<sys/ioccom.h>` defines `IOC_OUT` as `0x40000000UL`. But this is "out"
from the perspective of the kernel, not the application. So this
corresponds to `READ` rather than `WRITE`.

Tested on FreeBSD with Smithay/drm-rs#180. This also
seems to be correct for NetBSD and OpenBSD.
@sunfishcode
Copy link
Member

Thanks!

@sunfishcode sunfishcode merged commit cc82ed2 into bytecodealliance:main Nov 10, 2023
43 checks passed
@sunfishcode
Copy link
Member

This is now released in rustix 0.38.22.

@ids1024 ids1024 deleted the ioctl-bsd branch November 13, 2023 22:06
@ids1024 ids1024 mentioned this pull request Nov 13, 2023
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.

3 participants