Bug 261834 - UDisksDevice::queryDeviceInterface has bogus implementation for Block device. Makes k3b not show dvd writers
Summary: UDisksDevice::queryDeviceInterface has bogus implementation for Block device....
Status: RESOLVED FIXED
Alias: None
Product: solid
Classification: Frameworks and Libraries
Component: libsolid-udisks (show other bugs)
Version: unspecified
Platform: Mandriva RPMs Linux
: NOR crash
Target Milestone: ---
Assignee: Lukáš Tinkl
URL:
Keywords:
: 261618 261835 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-01-02 01:28 UTC by cristi.posoiu
Modified: 2011-01-03 13:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cristi.posoiu 2011-01-02 01:28:00 UTC
Version:           unspecified (using KDE 4.5.90) 
OS:                Linux

Started from k3b not showing my dvd drive anymore. Binary from rpm just had the list empty, a self compiled k3b (2.0.1) was segfaulting. Found out it was crashing due to do not receiving a pointer to a Solid::Block interface.

Looking at code, it looks like the UDisksDevice::queryDeviceInterface() is doing a strange check to see if the device is a block device or not: it checks the DeviceBlockSize property. Which seems to be set to 0 for the dvd writer device as long as it doesn't have a written (haven't checked w/ a blank) dvd in it.

Once I put a written dvd in the unit, k3b sees the dvd (DeviceBlockSize is set to something > 0).

Don't have a 'correct' patch to fix it, only 2 suggestions:
a) always return true. Based on the assumption that udisks devices are most probably always block devices
b) do a fstat call on the path given by property DeviceFile and use S_ISBLK(xx)

Found also a report describing the same situation w/ k3b: http://bugs.gentoo.org/show_bug.cgi?id=339032 , see comment #11




Reproducible: Always

Steps to Reproduce:
a) with k3b from Mandriva package: no dvd writer is shown
b) with self compiled k3b - segfault in a call to dev...as<Solig::Block>()->device...




output from udisks --dump, related to the dvd writer:

Showing information for /org/freedesktop/UDisks/devices/sr0
  native-path:                 /sys/devices/pci0000:00/0000:00:1f.1/host4/target4:0:0/4:0:0:0/block/sr0
  device:                      11:0
  device-file:                 /dev/sr0
    presentation:              /dev/sr0
    by-path:                   /dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:0:0
  detected at:                 Sat 01 Jan 2011 06:27:19 PM EET
  system internal:             0
  removable:                   1
  has media:                   0
    detects change:            1
    detection by polling:      1
    detection inhibitable:     1
    detection inhibited:       0
  is read only:                0
  is mounted:                  0
  mount paths:             
  mounted by uid:              0
  presentation hide:           0
  presentation nopolicy:       0
  presentation name:           
  presentation icon:           
  size:                        0
  block size:                  0
  job underway:                no
  usage:                       
  type:                        
  version:                     
  uuid:                        
  label:                       
  drive:
    vendor:                    HL-DT-ST
    model:                     DVDRAM GSA-T20L
    revision:                  NR02
    serial:                    
    WWN:                       
    detachable:                0
    can spindown:              0
    rotational media:          Yes, unknown rate
    write-cache:               unknown
    ejectable:                 1
    adapter:                   /org/freedesktop/UDisks/adapters/0000_3a00_3a1f_2e1
    ports:
      /org/freedesktop/UDisks/adapters/0000_3a00_3a1f_2e1/host4
    similar devices:
    media:                     
      compat:                  optical_cd optical_cd_r optical_cd_rw optical_dvd optical_dvd_r optical_dvd_ram
    interface:                 scsi
    if speed:                  (unknown)
    ATA SMART:                 not available
==========

output from solid-hardware (see there's no Block.* property):

udi = '/org/freedesktop/UDisks/devices/sr0'
  parent = '/org/freedesktop/UDisks'  (string)
  vendor = 'HL-DT-ST'  (string)
  product = 'DVDRAM GSA-T20L'  (string)
  description = 'CD-RW/DVD-RAM Drive'  (string)
  StorageDrive.bus = 'Scsi'  (0x3)  (enum)
  StorageDrive.driveType = 'CdromDrive'  (0x1)  (enum)
  StorageDrive.removable = true  (bool)
  StorageDrive.hotpluggable = false  (bool)
  StorageDrive.inUse = false  (bool)
  StorageDrive.size = 0  (0x0)  (qulonglong)
  OpticalDrive.supportedMedia = 'Cdr|Cdrw|Dvd|Dvdr|Dvdram'  (0x2f)  (flag)
  OpticalDrive.readSpeed = 4234  (0x108a)  (int)
  OpticalDrive.writeSpeed = 4234  (0x108a)  (int)
  OpticalDrive.writeSpeeds = {4234,2822,1764,706} (int list)
=====
solid-hardware output with a written dvd in it:

udi = '/org/freedesktop/UDisks/devices/sr0'
  parent = '/org/freedesktop/UDisks'  (string)
  vendor = 'HL-DT-ST'  (string)
  product = 'DVDRAM GSA-T20L'  (string)
  description = 'CD-RW/DVD±RW DL Drive'  (string)
  Block.major = 11  (0xb)  (int)
  Block.minor = 0  (0x0)  (int)
  Block.device = '/dev/sr0'  (string)
  StorageDrive.bus = 'Scsi'  (0x3)  (enum)
  StorageDrive.driveType = 'CdromDrive'  (0x1)  (enum)
  StorageDrive.removable = true  (bool)
  StorageDrive.hotpluggable = false  (bool)
  StorageDrive.inUse = true  (bool)
  StorageDrive.size = 1245184  (0x130000)  (qulonglong)
  OpticalDrive.supportedMedia = 'Cdr|Cdrw|Dvd|Dvdr|Dvdrw|Dvdram|Dvdplusr|Dvdplusrw|Dvdplusdl'  (0x1ff)  (flag)
  OpticalDrive.readSpeed = 11080  (0x2b48)  (int)
  OpticalDrive.writeSpeed = 11080  (0x2b48)  (int)
  OpticalDrive.writeSpeeds = {11080,5540} (int list)
Comment 1 Lukáš Tinkl 2011-01-02 20:27:23 UTC
SVN commit 1210957 by lukas:

don't ignore an empty optical disc

BUG: 261834


 M  +1 -1      udisksdevice.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1210957
Comment 2 Lukáš Tinkl 2011-01-02 20:36:02 UTC
*** Bug 261618 has been marked as a duplicate of this bug. ***
Comment 3 cristi.posoiu 2011-01-03 11:14:59 UTC
I'm not sure I understand the fix.
Was this tested - i.e. does k3b now show the drive always, *regardless* of the unit having anything put in it? 
To me it looks like it won't since k3b will still won't be able to get a Solid::Block interface from it. I.e. I still see that returning that interface is conditioned by the value of DeviceBlockSize udisk property - which in turn I don't think it is having anything to do with the isDeviceBlacklisted function.
I consider that the Solid::Block interface should be available (since the device is always present there, /dev/sro in my case) regardless of the unit having or not something in it (blank or not blank).

Unfortunately I don't have yet a way to test kde from svn so that I test the fix so all my comments are based solely on the code.
Comment 4 Lukáš Tinkl 2011-01-03 12:53:48 UTC
*** Bug 261835 has been marked as a duplicate of this bug. ***
Comment 5 Lukáš Tinkl 2011-01-03 12:55:03 UTC
Yes, I tested it with both blank CD and DVD in the drive, K3b correctly reported it as such.
Comment 6 cristi.posoiu 2011-01-03 12:57:49 UTC
I was talking about k3b seeing the writer *without* anything in it.
Comment 7 Lukáš Tinkl 2011-01-03 12:58:57 UTC
Oh, sry for the misunderstanding :) Gonna test again
Comment 8 Lukáš Tinkl 2011-01-03 13:37:55 UTC
SVN commit 1211252 by lukas:

fix the check for a Block device, according to the udisks docu
(fixes k3b not seeing an empty writer, w/o CD or DVD)

BUG: 261834


 M  +1 -1      udisksdevice.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1211252
Comment 9 cristi.posoiu 2011-01-03 13:45:52 UTC
This change might fix it (it is kind of the 'always return true' suggestion)
Thanks!