udisks2 - How to get basic functionality we had in old udisks?

Guy genlist at faert.net
Thu Oct 29 14:51:04 PDT 2015


Hello everybody,

I still am stuck with the same udisks problem (see my previous 
postings): How can I find out the Linux device for each and every drive?

For the first problem, I would have to join DRIVES and BLOCK_DEVICES, 
because only BLOCK_DEVICES inform about the Linux device names (/dev/sde 
for instance). However, I cannot see a clear rule for knowing which 
block_device corresponds to a drive. Example: I have 3 devices:
- a hard drive; it has a partition table and several partitions
- an USB stick; it doesn't have a partition table but it anyway has a 
partition starting directly at sector 0
- the same USB stick, but without partition table nor partition

Attached you see what "udisksctl dump" tells me. Remember, for each 
DRIVE I need to find the corresponding BLOCK_DEVICE in order to get the 
Linux device name (/dev/sdc, for example).

  - For the HDD, two block_devices match:
the first one has interface PartitionTable  (remark: that's the right 
one, it's /dev/sda)
the second one has interfaces FileSystem and Partition (it's /dev/sda1, 
not interested in that one)

- for the USB stick there's one block_device
it has interface Filesystem

- for the empty USB stick there's a block device that has no interface 
at all

The rule would be something like "if there's only one block_device then 
take that one, otherwise it's the one with interface PartitionTable". 
Honestly, I hope this still works for media with partition table but 
unformatted partitions, or media where the partition contains another 
partition table (everything is possible), or RAID devices, or...

This leaves me with a strange feeling... can I rely on udisks2? With old 
udisks I just needed method EnumerateDevices, then I ran through the 
list and queried every property I needed - btw, "device-file" was my 
precious Linux device.

Why not just include property "Device" for drives?

Another problems I saw right now: How can I find out the device's sector 
size?

Many thanks in advance

Guy Voncken

-------------- next part --------------
/org/freedesktop/UDisks2/block_devices/sda:
  org.freedesktop.UDisks2.Block:
    Configuration:              []
    CryptoBackingDevice:        '/'
    Device:                     /dev/sda
    DeviceNumber:               2048
    Drive:                      '/org/freedesktop/UDisks2/drives/OCZ_VERTEX2_OCZ_7PK34B9LK7D33D0H'
    HintAuto:                   false
    HintIconName:               
    HintIgnore:                 false
    HintName:                   
    HintPartitionable:          true
    HintSymbolicIconName:       
    HintSystem:                 true
    Id:                         by-id-ata-OCZ-VERTEX2_OCZ-7PK34B9LK7D33D0H
    IdLabel:                    
    IdType:                     
    IdUUID:                     
    IdUsage:                    
    IdVersion:                  
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/sda
    ReadOnly:                   false
    Size:                       60022480896
    Symlinks:                   /dev/disk/by-id/ata-OCZ-VERTEX2_OCZ-7PK34B9LK7D33D0H
                                /dev/disk/by-id/wwn-0x5e83a97fa99225f0
  org.freedesktop.UDisks2.PartitionTable:
    Type:               dos

/org/freedesktop/UDisks2/block_devices/sda1:
  org.freedesktop.UDisks2.Block:
    Configuration:              [('fstab', {'fsname': <b'UUID=5b4b15d4-0049-4a36-84ea-57b936b738b8'>, 'dir': <b'/'>, 'type': <b'ext4'>, 'opts': <b'discard,noatime,nodiratime,errors=remount-ro,'>, 'freq': <0>, 'passno': <1>})]
    CryptoBackingDevice:        '/'
    Device:                     /dev/sda1
    DeviceNumber:               2049
    Drive:                      '/org/freedesktop/UDisks2/drives/OCZ_VERTEX2_OCZ_7PK34B9LK7D33D0H'
    HintAuto:                   false
    HintIconName:               
    HintIgnore:                 false
    HintName:                   
    HintPartitionable:          true
    HintSymbolicIconName:       
    HintSystem:                 true
    Id:                         by-id-ata-OCZ-VERTEX2_OCZ-7PK34B9LK7D33D0H-part1
    IdLabel:                    
    IdType:                     ext4
    IdUUID:                     5b4b15d4-0049-4a36-84ea-57b936b738b8
    IdUsage:                    filesystem
    IdVersion:                  1.0
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/sda1
    ReadOnly:                   false
    Size:                       56911462400
    Symlinks:                   /dev/disk/by-id/ata-OCZ-VERTEX2_OCZ-7PK34B9LK7D33D0H-part1
                                /dev/disk/by-id/wwn-0x5e83a97fa99225f0-part1
                                /dev/disk/by-uuid/5b4b15d4-0049-4a36-84ea-57b936b738b8
  org.freedesktop.UDisks2.Filesystem:
    MountPoints:        /
  org.freedesktop.UDisks2.Partition:
    Flags:              128
    IsContained:        false
    IsContainer:        false
    Name:               
    Number:             1
    Offset:             1048576
    Size:               56911462400
    Table:              '/org/freedesktop/UDisks2/block_devices/sda'
    Type:               0x83
    UUID:               

/org/freedesktop/UDisks2/drives/OCZ_VERTEX2_OCZ_7PK34B9LK7D33D0H:
  org.freedesktop.UDisks2.Drive:
    CanPowerOff:                false
    Configuration:              {}
    ConnectionBus:              
    Ejectable:                  false
    Id:                         OCZ-VERTEX2-OCZ-7PK34B9LK7D33D0H
    Media:                      
    MediaAvailable:             true
    MediaChangeDetected:        true
    MediaCompatibility:         
    MediaRemovable:             false
    Model:                      OCZ-VERTEX2
    Optical:                    false
    OpticalBlank:               false
    OpticalNumAudioTracks:      0
    OpticalNumDataTracks:       0
    OpticalNumSessions:         0
    OpticalNumTracks:           0
    Removable:                  false
    Revision:                   1.37
    RotationRate:               0
    Seat:                       seat0
    Serial:                     OCZ-7PK34B9LK7D33D0H
    SiblingId:                  
    Size:                       60022480896
    SortKey:                    00coldplug/00fixed/sd____a
    TimeDetected:               1446138875240028
    TimeMediaDetected:          1446138875240028
    Vendor:                     
    WWN:                        0x5e83a97fa99225f0
  org.freedesktop.UDisks2.Drive.Ata:
    AamEnabled:                                 false
    AamSupported:                               false
    AamVendorRecommendedValue:                  0
    ApmEnabled:                                 false
    ApmSupported:                               false
    PmEnabled:                                  true
    PmSupported:                                true
    SecurityEnhancedEraseUnitMinutes:           400
    SecurityEraseUnitMinutes:                   400
    SecurityFrozen:                             true
    SmartEnabled:                               true
    SmartFailing:                               false
    SmartNumAttributesFailedInThePast:          0
    SmartNumAttributesFailing:                  0
    SmartNumBadSectors:                         0
    SmartPowerOnSeconds:                        21592800
    SmartSelftestPercentRemaining:              0
    SmartSelftestStatus:                        success
    SmartSupported:                             true
    SmartTemperature:                           303.15000000000003
    SmartUpdated:                               1446138899
    WriteCacheEnabled:                          true
    WriteCacheSupported:                        true

-------------- next part --------------
/org/freedesktop/UDisks2/block_devices/sdb:
  org.freedesktop.UDisks2.Block:
    Configuration:              []
    CryptoBackingDevice:        '/'
    Device:                     /dev/sdb
    DeviceNumber:               2064
    Drive:                      '/org/freedesktop/UDisks2/drives/USB_Flash_Disk_EAD2608061826524'
    HintAuto:                   true
    HintIconName:               
    HintIgnore:                 false
    HintName:                   
    HintPartitionable:          true
    HintSymbolicIconName:       
    HintSystem:                 false
    Id:                         by-uuid-51BC-0350
    IdLabel:                    TEST
    IdType:                     vfat
    IdUUID:                     51BC-0350
    IdUsage:                    filesystem
    IdVersion:                  FAT32
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/sdb
    ReadOnly:                   false
    Size:                       4009754624
    Symlinks:                   /dev/disk/by-id/usb-USB_Flash_Disk_EAD2608061826524-0:0
                                /dev/disk/by-label/TEST
                                /dev/disk/by-path/pci-0000:00:1a.7-usb-0:1:1.0-scsi-0:0:0:0
                                /dev/disk/by-uuid/51BC-0350
  org.freedesktop.UDisks2.Filesystem:
    MountPoints:        /media/guy/TEST


/org/freedesktop/UDisks2/drives/USB_Flash_Disk_EAD2608061826524:
  org.freedesktop.UDisks2.Drive:
    CanPowerOff:                true
    Configuration:              {}
    ConnectionBus:              usb
    Ejectable:                  true
    Id:                         USB-Flash-Disk-EAD2608061826524
    Media:                      
    MediaAvailable:             true
    MediaChangeDetected:        true
    MediaCompatibility:         
    MediaRemovable:             true
    Model:                      Flash Disk
    Optical:                    false
    OpticalBlank:               false
    OpticalNumAudioTracks:      0
    OpticalNumDataTracks:       0
    OpticalNumSessions:         0
    OpticalNumTracks:           0
    Removable:                  true
    Revision:                   1100
    RotationRate:               -1
    Seat:                       seat0
    Serial:                     EAD2608061826524
    SiblingId:                  /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-1/1-1:1.0
    Size:                       4009754624
    SortKey:                    01hotplug/1446139173897527
    TimeDetected:               1446139173897527
    TimeMediaDetected:          1446139173897527
    Vendor:                     USB
    WWN:                        

-------------- next part --------------
/org/freedesktop/UDisks2/block_devices/sdb:
  org.freedesktop.UDisks2.Block:
    Configuration:              []
    CryptoBackingDevice:        '/'
    Device:                     /dev/sdb
    DeviceNumber:               2064
    Drive:                      '/org/freedesktop/UDisks2/drives/USB_Flash_Disk_EAD2608061826524'
    HintAuto:                   true
    HintIconName:               
    HintIgnore:                 false
    HintName:                   
    HintPartitionable:          true
    HintSymbolicIconName:       
    HintSystem:                 false
    Id:                         
    IdLabel:                    
    IdType:                     
    IdUUID:                     
    IdUsage:                    
    IdVersion:                  
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/sdb
    ReadOnly:                   false
    Size:                       4009754624
    Symlinks:                   /dev/disk/by-id/usb-USB_Flash_Disk_EAD2608061826524-0:0
                                /dev/disk/by-path/pci-0000:00:1a.7-usb-0:1:1.0-scsi-0:0:0:0

/org/freedesktop/UDisks2/drives/USB_Flash_Disk_EAD2608061826524:
  org.freedesktop.UDisks2.Drive:
    CanPowerOff:                true
    Configuration:              {}
    ConnectionBus:              usb
    Ejectable:                  true
    Id:                         USB-Flash-Disk-EAD2608061826524
    Media:                      
    MediaAvailable:             true
    MediaChangeDetected:        true
    MediaCompatibility:         
    MediaRemovable:             true
    Model:                      Flash Disk
    Optical:                    false
    OpticalBlank:               false
    OpticalNumAudioTracks:      0
    OpticalNumDataTracks:       0
    OpticalNumSessions:         0
    OpticalNumTracks:           0
    Removable:                  true
    Revision:                   1100
    RotationRate:               -1
    Seat:                       seat0
    Serial:                     EAD2608061826524
    SiblingId:                  /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-1/1-1:1.0
    Size:                       4009754624
    SortKey:                    01hotplug/1446141034111969
    TimeDetected:               1446141034111969
    TimeMediaDetected:          1446141034111969
    Vendor:                     USB
    WWN:                        



More information about the devkit-devel mailing list