dbus/udisks guru? Import record should store information about card

Bug #692449 reported by Jason Gerard DeRose on 2010-12-20
This bug affects 1 person
Affects Status Importance Assigned to Milestone
David Green

Bug Description

The import record should store information about the SD/SDHC/CF card being imported from. This provides a rich audit trail for pro use.

Information should be extracted using the udisks Device interface - http://hal.freedesktop.org/docs/udisks/Device.html

We primarily want to extract information about the disk, not the partition. An example of the sort of information we want to extract:

size: 16005169152
vendor: Lexar
revision: 1000
serial: AA0000000009019

Related branches

Download full text (5.3 KiB)

Are you sure to use udisk? I have actually never heard about this.

I would recommend udev to query it (Don't believe blindly in me, I have pretty much less idea)

$ udevadm info -a -p $(udevadm info -q path -n /dev/sdb)

You get

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host6/target6:0:0/6:0:0:0/block/sdb':
    ATTR{stat}==" 3369 73783 402729 83260 0 0 0 0 0 35968 83252"
    ATTR{inflight}==" 0 0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host6/target6:0:0/6:0:0:0':
    ATTRS{vendor}=="Seagate "
    ATTRS{model}=="Portable "

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host6/target6:0:0':

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host6':

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0':
    ATTRS{bAlternateSetting}==" 0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1':
    ATTRS{bNumInterfaces}==" 1"


Jason Gerard DeRose (jderose) wrote :

I'm pretty sure udisks is the way to go. It uses udev under the hood... udisks just provides a well defined dbus API, other niceties.

The last time I did this sort of thing, HAL was still the thing to use. But now that HAL is deprecated, udisks is what has replaced its storage-related functionality.

udisks is part of the DeviceKit project - http://www.freedesktop.org/wiki/Software/DeviceKit

FYI HAL has been deprecated in favour of DeviceKit an DeviceKit has been deprecated in favour of udev.

After googling I found DeviceKit (and not uev)under the hood of udisks

To add upto the confusion, here is what I got

Changed in dmedia:
importance: Medium → High
Changed in dmedia:
milestone: 0.3 → 0.4
tags: added: bitesize
Changed in dmedia:
milestone: 0.4 → 0.5
Changed in dmedia:
milestone: 0.5 → 0.7
Changed in dmedia:
milestone: 0.7 → 0.8
David Green (david4dev) on 2011-07-18
Changed in dmedia:
assignee: nobody → David Green (david4dev)
David Green (david4dev) on 2011-07-19
Changed in dmedia:
status: Triaged → In Progress
tags: added: udisk
removed: udisks
Changed in dmedia:
milestone: 11.08 → 11.09
Jason Gerard DeRose (jderose) wrote :


Thanks again for all the work you've been doing on this. When you originally proposed the other udisk merge, I didn't have time to dig into the details as much as I wanted to... but you solved lot of tricky problems, so thanks for blazing the trail on this!

I've been experimenting a bit on getting this information using Python3 and PyGI, which I finally got working here:


And I discovered something unfortunate... at least with the card readers I have, udisks isn't giving me the DriveSerial of the card, it's giving me the DriveSerial of the card *reader*... which is worthless as far as the accounting we'd like to do.

I don't know if this is a bug in udisks that could be fixed, or it might even be an issue with the card readers I have... like they're greedy and report there own info instead of the card's. Dunno.

Oh, another hiccup is that it's tricky to find out the physical device info for a ecryptfs home partition. I came up with a work around that seems pretty reliable, but it's probably not the best solution.

So are you busy with school again now?


Changed in dmedia:
milestone: 11.09 → 11.10
Changed in dmedia:
milestone: 11.10 → 11.11
Jason Gerard DeRose (jderose) wrote :

David, so I'm going to close this as Fix Released. Starting with what you had, I do have this basically working now, although because of either some issues with UDisks or the particular card readers I have, it's not really accomplishing what we wanted it to... in my case, UDisks is providing the serial number of the card reader, not the card, which is kinda lame.

I'll open another bug to address this.

Anyway, thanks again for all your work on this... when I said this was "bite-size", I don't know what I was smoking. This was "super-size" :P

Also, I pretty much left your implementation as is because I figure just in case we need to use any of this under Python2 still... and I felt a bit bad messing up your code as I stumbled through getting DBus working with PyGI.

Oh, and as we currently aren't getting a meaningful ID for a card or partition on a card, I'm not creating the drive or partition documents in CouchDB. I think we do probably want them, but I'd like to let that idea slow-roast longer, see how useful it proves once we have correct data from UDisks.

Changed in dmedia:
status: In Progress → Fix Released
Jason Gerard DeRose (jderose) wrote :

Big thanks to @dobey for finding this blog post that confirms it is indeed a hardware issue that apparently all USB card readers suffer from:


To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers