Re: HAL depreciated, but what replaced it?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2011-10-12 at 19:44 -0500, Richard Shaw wrote:
> I'm the maintainer of a (relatively) simple python utility called
> discspan[1] 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
> down.

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:

P: /devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
...
E: ID_CDROM=1
E: ID_CDROM_CD=1
E: ID_CDROM_CD_R=1
E: ID_CDROM_CD_RW=1
E: ID_CDROM_DVD=1
E: ID_CDROM_DVD_R=1
E: ID_CDROM_DVD_RW=1
E: ID_CDROM_DVD_RAM=1
E: ID_CDROM_DVD_PLUS_R=1
E: ID_CDROM_DVD_PLUS_RW=1
E: ID_CDROM_DVD_PLUS_R_DL=1
E: ID_CDROM_MRW=1
E: ID_CDROM_MRW_W=1

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
> array.
> 
> 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.

UDISKS_PARTITION_SIZE

> The documentation is horrible and the only reason I got this far was
> thinks to a howto[2] I found.

Yeah, there can always be better documentation.  That's clearly
something to push for.

Dan

> Any pointers would be appreciated.
> 
> Thanks,
> Richard
> 
> [1] http://discspan.sourceforge.net/
> [2] http://blogs.codecommunity.org/mindbending/series/python-and-udisks/


-- 
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux