Results 1 to 2 of 2
Hi all,
I want to know how Linux (userspace) detects removable media insertion and removal.
I've tried automount ( ftp://ftp.kernel.org/pub/linux/daemo...s-5.0.3.tar.gz ). It's doing well for mounting my removable storage just ...
- 04-21-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 7
How Linux detects removable media insert/remove?
Hi all,
I want to know how Linux (userspace) detects removable media insertion and removal.
I've tried automount (ftp://ftp.kernel.org/pub/linux/daemo...s-5.0.3.tar.gz). It's doing well for mounting my removable storage just before reading or writing operations against the media start. But it doesn't help to signal/report about media insertion or removal events.
I found the driver code that relates to insertion and removal of the media in my system. I am thinking about adding some code to kenrel to report media insert/remove states to userspace (like storing media insert/remove states into some variable and let userspace read that variable using character driver "read" function).
But I wonder how Linux userspace programs do that in general or in a "right" way? Like Fedora or Ubuntu can pop up the folder content of some storage media automatically when disk is inserted ... Is there some well defined interface? ...
- 04-21-2008 #2Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Read on udev and hal.
udev
freedesktop.org - Software/hal
Udev is the layer that operates next to the kernel, and populates the /dev filesystem. It can do complex operations to set up the devices when a new device is attached, as long as the kernel has some kind of hotplug support for that device. It also manages devices at startup, of course. It's highly configurable and you can control everything by just writing some rules for udev. For example: you can set the device node based on some specific info about your hardware, so that your photo camera will always be /dev/sdd (or whatever), that and much more.
Hal is just what it's initials imply: a hardware abstraction layer, that sits on top of udev.
I'd say that ALL the modern distros do use udev+hal these days. Automount was just a hack used on the past for a very concrete case, which was mostly IDE stuff. Dbus and hal are two generic interfaces which can do much much more.


Reply With Quote
