Skip to content

Commit

Permalink
Fix ioctl numbers on BSDs (#926)
Browse files Browse the repository at this point in the history
`<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.
  • Loading branch information
ids1024 committed Nov 10, 2023
1 parent 90b2fbd commit cc82ed2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ioctl/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ pub(super) const fn compose_opcode(
dir | num | (group << 8) | ((size & IOCPARAM_MASK) << 16)
}

// `IOC_VOID`
pub const NONE: RawOpcode = 0x2000_0000;
pub const WRITE: RawOpcode = 0x4000_0000;
pub const READ: RawOpcode = 0x8000_0000;
// `IOC_OUT` ("out" is from the perspective of the kernel)
pub const READ: RawOpcode = 0x4000_0000;
// `IOC_IN`
pub const WRITE: RawOpcode = 0x8000_0000;
pub const IOCPARAM_MASK: RawOpcode = 0x1FFF;

0 comments on commit cc82ed2

Please sign in to comment.