Skip to content

ioctl_write_int! wrong data size call #2654

@oletf

Description

@oletf

Greetings,

here's my setup :

  • aarch64-unknown-linux-gnu rust 1.88.0
  • gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
  • ldd (Ubuntu GLIBC 2.35-0ubuntu3.10) 2.35

The C IOCTL is defined with _IOW(IOCTL_MAGIC, 3, ulong)
I'm using ioctl_write_int!, docs specifies that nix::sys::ioctl::ioctl_param_type on linux is libc::c_ulong, which is 8 bytes.

I have checked that

  • on rust side with size_of::<nix::sys::ioctl::ioctl_param_type>(), reports 8 bytes
  • on C side with sizeof(ulong), 8 bytes as well

However the ioctl cmd call I receive in my c driver is 0x4004f003 which decodes to dir=1 type=240 nr=3 size=4.

I couldn't figure where this could be coming from...
My current workaround is to set IOCTL to _IOW(IOCTL_MAGIC, 3, uint) as I'm ok with this type, but I'm confused by the mismatch.

Please let me know if I can bring more info to help !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions