HAL depreciated, but what replaced it?
dcbw at redhat.com
Thu Oct 13 01:16:00 UTC 2011
On Wed, 2011-10-12 at 19:44 -0500, Richard Shaw wrote:
> I'm the maintainer of a (relatively) simple python utility called
> discspan which I'd like to package for Fedora.
> It currently relies on HAL via dbus to determine when media is loaded
> and its capacity. I'm trying to remove the dependency on HAL since
> it's been depreciated for some time but the dbus UDisks interface
> seems to be lacking in several ways.
> For one, there doesn't appear to be an easy way to determine which
> devices are CD/DVD writers (or even readers). It has a boolean
> property called "DeviceIsOpticalDisc" that looked promising but it
> only reports true if the device is an optical drive AND there's a disc
> inserted. In HAL I used FindDeviceByCapability which narrowed things
udev replaced HAL, along with some additional helpers. udev has a
database too, much like HAL. You can use libudev or libgudev (if you
use glib) to talk to udev and get information. For example, running:
udevadm info --export-db
and looking at the output shows:
which pretty much gives you what you want here. There's sample code out
there for both libudev and libgudev. You're going to query udev for any
devices in the 'block' subsystem.
> I've worked around that for testing the property
> "DriveMediaCompatibility" > 0 since it returns an array but this would
> also pick up flash card readers, zip, and jaz drives. I'll have to
> modify that to look for "optical" on the front of any members of the
> Second, I can not find any property that reports the disc capacity.
> The only property that looked close is "DriveSize" but for a blank
> disc this reports the same as the SectorSize, 2048.
> The documentation is horrible and the only reason I got this far was
> thinks to a howto I found.
Yeah, there can always be better documentation. That's clearly
something to push for.
> Any pointers would be appreciated.
>  http://discspan.sourceforge.net/
>  http://blogs.codecommunity.org/mindbending/series/python-and-udisks/
More information about the devel