Visit Jeremy's Blog.
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, 07: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, 11:03 AM   #2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,813

Rep: Reputation: 749Reputation: 749Reputation: 749Reputation: 749Reputation: 749Reputation: 749Reputation: 749
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 06:26 AM
Add/Remove Software App no longer display icon in notification area Borax_Man Fedora 1 10-29-2009 01:16 AM
user-space notification of USB device attached/detached rhardy Linux - Newbie 1 10-25-2006 08:31 AM
user-space notification of USB device attached/detached rhardy Linux - Software 1 10-24-2006 03:17 PM
callback or notification from kernel to user space yhus Programming 5 09-18-2005 09:41 PM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 03:05 PM.

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