Reputation: 1806
I've been writing a simple scull_dev device driver to learn about how to program kernel modules and I think I have one completely coded.
I can make it successfully, and I can call sudo insmod scull.ko
without any problems, but the driver never appears in the linux /dev/
folder.
I am now trying to implement .ioctl
, but there is no file for me to open. Isn't the correct way to use ioctl from a user space program to call it with the open fd of the "file" of your device driver? (Don't even really know what this means...)
The whole topic of device drivers is extremely, extremely confusing to me and the book I've been using is in my opinion complete garbage, so I am aware I probably have some major misconceptions here...
Upvotes: 1
Views: 2616
Reputation: 19395
I'm using the alloc_chrdev_region method. So I'm assuming it got 254 ...
You should not assume something without reason. Print *dev
returned by alloc_chrdev_region()
, or use register_chrdev(254, ...)
instead.
my user space program that calls open is just returning a -1
No, it is not just returning -1, open()
is also setting errno
to an appropriate error number from which you can conveniently produce a message by using perror()
.
Upvotes: 1