Kernel driver for 2
Hello,
The following code was copied from: http://true-random.com/homepage/proj...pci_template.c Code:
mknod /dev/pci_template0 c 248 0 mknod /dev/pci_template1 c 248 1 After opening "/dev/pci_template0", if I send IOCTL, how the kernel driver knows that I sent to minor=0 ? Thank you, Zvika |
very generally speaking, the files in /dev/ are not disk files they are sockets in a special file system mounted by the kernel. the drivers read and write from them, and their (file attributes i believe) contain the major minor. the kernel only sends the data you use to a driver who (has opened) the same major minor socket via the kernel's open function.
|
Dear Members,
The solution I found (hope it's right): In /dev I created 2 nodes: mknod my0 c 248 0 mknod my1 c 248 1 In kernel I can extract the minor number with: static int MyOpen (struct inode *inode, struct file *fl) { int Minor = MINOR (inode->i_rdev); } static long MyIoctl (strcut file *file, unsigned int IoctlCode, unsigned long IoctlParam) { int Minor = MINOR (file->f_inode->i_rdev); } In user space I open my? and send IOCTL to the driver. Thank you, Zvika |
All times are GMT -5. The time now is 07:35 AM. |