Ioctl

Submitted by Macross
on January 28, 2005 - 5:53am

How to pass to my user space the number returned by the macro _IOR & _IOWR since my driver use dynamic major numbers and I can't set those Macros at my header file:

PS : I've Tryied to use a public variable at my header file for both user space and kernel space modules to work, when I print to the system by the kernel it remains correct , when I print with the user program it remains always 0 ...

independent of major numbers

strcmp
on
January 28, 2005 - 6:22am

As far as I can see, _IOR is indepentent of the major number of your device, the arguments are a random but constant character, some number chosen by you and the size of the arguments. No major number here.

Also I don't understand, why you think declaring a variable in a userspace program magically copies another variable in kernel space into its place. This is not going to happen. Userspace and kernel space are separate address spaces (as the name implies) and divided for security reasons. You have to somehow create a device node in /dev with your major number (using devfs, udev or explicit mknod c after studying some log files or so) and open this with you user space program, to use ioctl()s.

Thanx any way

Macross
on
January 31, 2005 - 5:26am

Sorry for the ignorance, I took a look inside the kernel Linux Device Drivers book 2nd Edition to have reference on what u sad ... the code I was testing just sad about the necessity of using a major number on the Macros and not a defined number about the device type ... Since the text just said to use the field on the macro as a major number I´ve tryied "anything" to take the dynamic major I had initialized ... is the first time i´m walking on ioctl ... no idea in registering specific number to kernel but I accomplished my ioctl with no obstacles

ioctls/major numbers

bitTwiddler (not verified)
on
August 9, 2005 - 11:55am

I have what may be a stupid module question..

I'm taking over the (2.4) device driver responsibility for an engineer who left the company. This is for some custom PCI hardware. Here are the steps I've taken so far and the results I got:

-lspci shows the device on the PCI bus, with valid configuration

-after insmod'ing the module, /var/log/messages output looks good

-I used mknod to create the filesystem device (using the same major number found in the existing code

-using minicom to connect to new device file, I get a ton of these:
"kernel: IOCTL received with invalid major number"

-I then noticed /usr/src/linux-2.4.21-99/Documentation/devices.txt says that the device_major_number that was used is recognized as another device, so I changed all references in the code to 248, since
according to devices.txt it falls under "LOCAL/EXPERIMENTAL USE", and in the local /proc/devices, that number was not being used

-After recompiling and insmod'ing, I *still* see the same error

I've googled and searched all over for information, but no luck. The
tutorials, etc that I've found seem to confirm that what I have should work.. which doesn't help.

Anybody have any ideas?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.