HAL wiki faq: how to automount hotpluggable devices
Artem Kachitchkine
Artem.Kachitchkin at Sun.COM
Tue Apr 24 15:29:45 PDT 2007
> Hal learns from udev that a device showed up. Hal does all the magic, finding
> out about partions, filesystems and such. It then tells anybody listening,
> that volumes are available for mounting.
Correct.
> Here it gets a bit murky. It seems that in the past it was the applications
> responsibility to do the actual mounting, but I have the feeling that has
> changed, or at least is not the only way it can be done.
It is the application's responsibility to, uh, initiate the act of mounting,
i.e. to ask HAL to perform the mount on its behalf. When using GNOME, the
application will be gnome-volume-manager, which starts as part of the GNOME
session, and lives and dies with the session.
The application calls the Mount() method on one of HAL's DBus interfaces. There
are some associated policies that can allow/disallow you from doing this, but by
default as longs as you're on the local console, you can mount removable disks.
One way to think about it as sudo with a much finer granularity (single
operation vs entire program).
> The existence of .hal-mtab in /media seems to suggest that hal itself can do
> the mounting if asked to (via the Mount() method?).
.hal-mtab HAL's private file, an implementation artifact.
> Is there a way to have a policy .fdi that does the mounting/unmounting without
> third party involvement?
No. If you don't ask HAL to perform the mount, it won't do it (it will, however,
clean up after "surprise removal" of the device). The idea is that HAL does not
enforce device handling policies (which makes sense, since different desktops
may want to do different things depending on the type of media), while
facilitating in implementing said policies.
> This is for an embedded application without any desktop managers involved.
You can use ivman. Or write your own tiny HAL event handler, shouldn't be more
than a thousand LOC of C. If your project is GPL, perhaps you can borrow some
routines from gnome-volume-manager, see src/manager.c: gvm_hal_init(),
hal_device_added(), block_device_added().
-Artem.
More information about the hal
mailing list