>What happens when a device is plugged in?

By | July 13, 2012

>

Many times device Plug-in related questions comes in our mind . These questions specially arises when we face challenges to block certain device on the server , or block certain devices for certain users . Let me explain my understanding on this topic.



For newly Plugged-in device , given below steps take place


1. Kernel detect the Plug-in device and export device status to sysfs. You can view exported state via mounted /sys virtual filesystem.


2. Kernel then notify udev about this event via netlink socket.


3. udev process the user-configurable rules (present in /etc/udev/rules.d) and creates device file in /dev.


4. After creating device node , udev notify hald about the event via the socket.


5. HAL probes the device for information.


6. The device object structure populates with the probed information.


7. HAL broadcast Plug-in event.


8. A user-space application then process the information.

In this complete process , We can add our custom hook in udev rules . For example suppose you want to notify administrator via mail about any usb storage device insertion on the system, we can do that by udev rules. In coming posts ,I will explain about writing udev rules.
Share itShare on FacebookEmail this to someoneTweet about this on TwitterShare on Google+Share on LinkedInPrint this page

One thought on “>What happens when a device is plugged in?

  1. Bhaskar Chowdhury

    >HAL is obsolete and it doesn't require anymore..udev/polkit will do the job.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Current month ye@r day *