title: Listen for harware change events from the linux kernel or udev
body: <p>I need to run some code on storage device mounting and unmounting.<br>
  How can i listen for these events on linux?  </p>
  
  <ul>
  <li>I was thinking on adding some <a href="http://en.wikipedia.org/wiki/Udev" rel="nofollow noreferrer">udev</a> rules to run some script (any know-how in this matter is appreciated).  </li>
  <li>But I would much rather listen for events from the kernel in some netlink socket with my daemon (just like udev does) or something like that.</li>
  </ul>