How to get block device add/remove notification in kernel space ?
I had a block device driver working fine on Ubuntu 10.04 ( kernel version 2.6.32) . It used to hook into uevent_ops to get the device add/remove notification in init_module.
i.e. my_uevent_ops = kset->uevent_ops; kset->uevent_ops = my_uevent_ops_callback; Now I want to port that driver to Ubuntu 12.04 (kernel 3.2.0-32-generic-pae) ,but the kset->uevent_ops is made constant, so it can't hook into it. Is their any way to get add/remove event notifications of block devices in my device driver? Also can I use notifier chain for block devices ? Thanks in advance. |
It would be kind of roundabout, but you could add a udev entry that calls a program to notify your kernel module when a new /sys/block entry is added.
I think USB uses notifier chains because there are many different types of USB devices. I don't think the SCSI device drivers have those. It would work if you only cared about USB drives. |
All times are GMT -5. The time now is 01:55 PM. |