Howto retreive the partition table?

Christopher Chittleborough cchittleborough at cluemail.com
Wed May 9 04:08:46 PDT 2012


On Sun, May 6, 2012, at 12:57 PM, Stef Bon wrote:
> Hi,
> 
> when enumerating and monitoring devices from udev, I would like to program
> whether the device (block, when a disk) there are partitions or not present.
> 
> Howto do this? Is this possible in udev or do I have to use udisks(2)??
> 
> Stef

G'day from Australia. I'm not sure I understood your question, but I'll
try to answer it anyway ...

In a udev .rules file, after 80-udisks.rules has run you can check for
variables named UDISKS_PARTITION (which will be 1 if the current device
is a partition on a larger drive) and UDISKS_PARTITION_TABLE (1 if the
current device is a partitioned drive). Examples:
 SUBSYSTEM=="block", ENV{UDISKS_PARTITION}=="1", <handle a partition>
 SUBSYSTEM=="block", ENV{UDISKS_PARTITION_TABLE}=="1",
 <handle-partitioned-drive>

Outside of a rules file, you can use
  udevadm info --query=property --name=/dev/whatever
to get see whether UDISKS_PARTITION_TABLE or UDISKS_PARTITION are set.

Another approach is to query the udisks(7) daemon via d-bus. In udisks
v1.x, you would check the properties DeviceIsPartition and
DeviceIsPartitionTable.

I hope this helps -- Chris[topher] Chittleborough


More information about the devkit-devel mailing list