Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 11-26-2012, 08:22 AM   #1
LQ Newbie
Registered: Nov 2012
Posts: 3

Rep: Reputation: Disabled
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.

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.
Old 11-28-2012, 12:03 PM   #2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,279

Rep: Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux Driver - how to read/write a block or character device in kernel space (procfs) stybi Linux - Kernel 1 01-27-2011 07:26 AM
Add/Remove Software App no longer display icon in notification area Borax_Man Fedora 1 10-29-2009 02:16 AM
user-space notification of USB device attached/detached rhardy Linux - Newbie 1 10-25-2006 09:31 AM
user-space notification of USB device attached/detached rhardy Linux - Software 1 10-24-2006 04:17 PM
callback or notification from kernel to user space yhus Programming 5 09-18-2005 10:41 PM

All times are GMT -5. The time now is 12:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration