0

According to the O'Reilly Linux Device Drivers book, the ioctl related callback function (used on the kernel module side) which is part of the file_operations struct is defined as:

int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);

with the last argument being a pointer. Since it's an unsigned long does that mean that ioctl communications use 32 bit pointers? How does this not cause issues when compiled as a 64 bit kernel module?

Harry Muscle
  • 2,247
  • 4
  • 38
  • 62
  • 1
    `unsigned long` isn't universally 32 bits. AFAIK, on all 64-bit Linux systems, `unsigned long` is 64 bits. – Nate Eldredge Oct 16 '21 at 06:08
  • Thanks. I do most of my development on Windows were a long is 32 bits. Didn't realise on Linux it's 64 bits. – Harry Muscle Oct 16 '21 at 18:50
  • The last argument isn't always a pointer. Depending on the ioctl command, it might be an integer. The handler might need to convert from `unsigned long` to the integer type that the command is expected to use (particularly if the ioctl command expects a possibly negative `int` value). – Ian Abbott Oct 18 '21 at 16:12

0 Answers0