hal does not detect non-ATAPI CD-ROM drives

Bug #56484 reported by Mika Fischer
58
Affects Status Importance Assigned to Milestone
HAL
Fix Released
Medium
Baltix
Fix Released
Undecided
Unassigned
hal (Ubuntu)
Fix Released
High
Martin Pitt
Dapper
Fix Released
High
Martin Pitt

Bug Description

I have connected a DVD burner to my laptop by USB. The burner is recognized and available as /dev/scd0 and /dev/sg0.

However if I insert a medium in the burner (i.e. a disc with data on it or an audio CD) the disc is not automounted, no icon appears on the desktop. In fact exactly nothing happens.

This is on an up-to-date edgy installation.

Perhaps the root of the problem is that hal detects the drive as a "scsi generic" device.

I can mount CDs by double clicking on CDROM1 in Places->Computer but I have no way of using for instance sound-juicer or banshee because I assume they only look at hal to find the CD drives (and don't find any in my case).

I'll attach the lshal output. The relevant udis start with "/org/freedesktop/Hal/devices/usb_device_5e3_701_noserial_if0"

Let me know if you need more info.

Revision history for this message
In , Zeuthen (zeuthen) wrote :

Is this still an issue with 0.5.7.1 or later and recent udev versions? Or can I
close this as FIXED?

Revision history for this message
In , Daniel Holbach (dholbach) wrote :

The Ubuntu user reports it as fixed. Closing the bug.

Revision history for this message
Mika Fischer (zoop) wrote : hal does not detect media change in USB-DVD-Drive

I have connected a DVD burner to my laptop by USB. The burner is recognized and available as /dev/scd0 and /dev/sg0.

However if I insert a medium in the burner (i.e. a disc with data on it or an audio CD) the disc is not automounted, no icon appears on the desktop. In fact exactly nothing happens.

This is on an up-to-date edgy installation.

Perhaps the root of the problem is that hal detects the drive as a "scsi generic" device.

I can mount CDs by double clicking on CDROM1 in Places->Computer but I have no way of using for instance sound-juicer or banshee because I assume they only look at hal to find the CD drives (and don't find any in my case).

I'll attach the lshal output. The relevant udis start with "/org/freedesktop/Hal/devices/usb_device_5e3_701_noserial_if0"

Let me know if you need more info.

Revision history for this message
Mika Fischer (zoop) wrote :
Revision history for this message
Mika Fischer (zoop) wrote :

An additional note:
When I have mounted the disk by double clicking on CDROM1 in Places->Computer and then right-click on the disk icon on the desktop I have no option to eject the disk only to unmount.
Clicking that unmounts the disk but the tray stays closed.

Revision history for this message
William Grant (wgrant) wrote :

I have the same with my Serial ATA CD drive on my Dell Inspiron 630m. Works fine with Breezy and Dapper, but doesn't after installing Edgy a week or so back. hal can't see the disc, but sees the drive fine.

Changed in hal:
status: Unconfirmed → Confirmed
Revision history for this message
William Grant (wgrant) wrote :

Here I've attached my lshal output.

Revision history for this message
Sivan Greenberg (sivan) wrote :

I can also confirm this. Now, this is breaking hubackup's ability to detect target devices for backups properly. Should I workaround it by rewriting the detection code , or is it going to get fixed ? AFAICS this has to be fixed since just working around this will turn out ot be a hack, while the hal system needs to be backward compatible to its behavior in dapper.

Revision history for this message
Sivan Greenberg (sivan) wrote :

setting to high as this breaks a range of programs relying on HAL to detect media changes and optical devices.

Changed in hal:
importance: Untriaged → High
Changed in hal:
assignee: nobody → pitti
Revision history for this message
In , Martin Pitt (pitti) wrote :

This bug just reappeared for USB DVD drives, and seems to happen fairly
consistently: See https://launchpad.net/bugs/56484.

11:01:20.396 [I] osspec.c:232: SEQNUM=2636, ACTION=add, SUBSYSTEM=scsi_device,
DEVPATH=/sys/class/scsi_device/11:0:0:0, DEVNAME=, IFINDEX=0
11:01:20.397 [I] hotplug.c:205: /sys/class/scsi_device/11:0:0:0 is a class
device (devpath)
11:01:20.397 [I] classdev.c:1378: class_add: subsys=scsi_device
sysfs_path=/sys/class/scsi_device/11:0:0:0 dev= physdev=0x100c86c8
11:01:20.617 [I] osspec.c:232: SEQNUM=2637, ACTION=add, SUBSYSTEM=scsi_generic,
DEVPATH=/sys/class/scsi_generic/sg0, DEVNAME=/dev/sg0, IFINDEX=0
11:01:20.619 [I] hotplug.c:205: /sys/class/scsi_generic/sg0 is a class device
(devpath)
11:01:20.619 [I] classdev.c:1378: class_add: subsys=scsi_generic
sysfs_path=/sys/class/scsi_generic/sg0 dev=/dev/sg0 physdev=0x100c86c8
11:01:20.633 [I] classdev.c:1241: Add callouts completed
udi=/org/freedesktop/Hal/devices/usb_device_409_56_000000000001_if0_scsi_host_scsi_device_lun0_scsi_generic
11:01:20.633 [I] hald.c:82: Added device to GDL;
udi=/org/freedesktop/Hal/devices/usb_device_409_56_000000000001_if0_scsi_host_scsi_device_lun0_scsi_generic

Message from syslogd@localhost at Wed Aug 23 11:01:20 2006 ...
localhost kernel: [33867.200668] sr0: scsi3-mmc drive: 8x/48x writer cd/rw
xa/form2 cdda tray
11:01:27.329 [I] osspec.c:232: SEQNUM=2635, ACTION=add, SUBSYSTEM=block,
DEVPATH=/sys/block/sr0, DEVNAME=/dev/scd0, IFINDEX=0
11:01:27.330 [I] hotplug.c:208: /sys/block/sr0 is a block device (devpath)
11:01:27.331 [I] blockdev.c:589: block_add: sysfs_path=/sys/block/sr0
dev=/dev/scd0 is_part=1, parent=0x00000000
11:01:27.332 [I] blockdev.c:499: get_luks_uuid: device_file=/dev/scd0
11:01:27.332 [I] blockdev.c:625: Ignoring hotplug event - no parent
11:01:27.332 [W] blockdev.c:990: Not adding device object

Thus hal has no idea whatsoever about /dev/sr0, although the device is present
in the system and works quite well.

Revision history for this message
In , Martin Pitt (pitti) wrote :

OK, I think I have an idea about what goes wrong now:

* The kernel creates /sys/block/sr0, which is the block device for the USB CD-ROM.

* ./hald/linux2/hotplug.c, around line 285:

   is_partition = isdigit(hotplug_event->sysfs.sysfs_path[len - 1]) ||
      strstr (hotplug_event->sysfs.sysfs_path, "/fakevolume") ;

  hal assumes that devices ending with a number are partitions on a block
device, which is not the case for SCSI CD-ROMs (i.e. it's not
/sys/block/sra/sra0, SCSI CD-ROMs are enumerated with numbers, not with letters
as ATAPI devices are). Thus is_partition becomes true.

    if (is_partition) {
       gchar *parent_path;
       parent_path = hal_util_get_parent_path (hotplug_event->sysfs.sysfs_path);

sysfs.sysfs_path is /sys/block/sr0, thus parent_path is /sys/block, which is of
course not a device.

       parent = hal_device_store_match_key_value_string (hald_get_gdl (),

"linux.sysfs_path_device", parent_path);

parent becomes NULL here, which is then directly passed to
hotplug_event_begin_add_blockdev(), which throws the event away.

Revision history for this message
In , Martin Pitt (pitti) wrote :

Created an attachment (id=6658)
hack to fix it

I created a small patch that fixes it for now; it's pretty ugly, i. e.
eventually the original is_partition condition should be reworked properly, but
the patch should point out what the actual problem is.

   * Add 16-nonpartitions-ending-in-nums.patch:
     - Hal currently assumes that device names ending in numbers are
       partitions. This patch adds a safe and easy, but slightly ugly
       workaround. (Real fix will be discussed with upstream at
       https://bugs.freedesktop.org/show_bug.cgi?id=5558)
     - This breaks SCSI, USB, and Firewire CD drives, which are usually called
       'scd0', 'sr1', etc.

Revision history for this message
Martin Pitt (pitti) wrote : Re: hal does not detect media change in USB-DVD-Drive

Can you please do

  sudo udevmonitor -e | tee udevmonitor.txt

then connect the drive, wait some seconds until it settled, press Control-C to stop udevmonitor, and then do

  dmesg > dmesg.txt

? Please attach the two logs here.

Changed in hal:
status: Confirmed → Needs Info
Revision history for this message
Oliver Grawert (ogra) wrote :
Revision history for this message
Sivan Greenberg (sivan) wrote :

Added an attachment of hubackup's device detector code. Just save it in a folder, chmod 755 the file and execute it. If you have a CDRW or DVRW or a USB disk attached to the system you should see a listing showing them as entries.

Revision history for this message
Sivan Greenberg (sivan) wrote :
Revision history for this message
Martin Pitt (pitti) wrote :

I can reproduce it here with ogra's USB DVD.

Changed in hal:
status: Needs Info → Confirmed
Revision history for this message
Mika Fischer (zoop) wrote :

The output of udevmonitor seems cut off at the end. I don't know why. It stayed that way for more than 10 seconds, so I quit...

Revision history for this message
Mika Fischer (zoop) wrote :
Revision history for this message
Mika Fischer (zoop) wrote :

Sivan, running your script gives me:

ImportError: No module named fsMisc

Revision history for this message
Martin Pitt (pitti) wrote :

So, the old bug 36274 seems to have reappeared, forwarded upstream.

Revision history for this message
Martin Pitt (pitti) wrote :

Got a workaround now.

Changed in hal:
status: Confirmed → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote :

 hal (0.5.7.1-0ubuntu6) edgy; urgency=low
 .
   * Add 16-nonpartitions-ending-in-nums.patch:
     - Hal currently assumes that device names ending in numbers are
       partitions. This patch adds a safe and easy, but slightly ugly
       workaround. (Real fix will be discussed with upstream at
       https://bugs.freedesktop.org/show_bug.cgi?id=5558)
     - This breaks SCSI, USB, and Firewire CD drives, which are usually called
       'scd0', 'sr1', etc.
     - Closes: LP#56484 and an impressive number of duplicates.

Changed in hal:
status: Fix Committed → Fix Released
Revision history for this message
Mika Fischer (zoop) wrote :

Fixed for me. Thanks a lot!

Revision history for this message
William Grant (wgrant) wrote :

Also fixed for me. Thanks, pitti!

Changed in hal:
status: Unknown → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

High-impact bug with an easy patch (https://bugs.freedesktop.org/attachment.cgi?id=6658), I think we want that in dapper, too.

Changed in hal:
assignee: nobody → pitti
importance: Untriaged → High
status: Unconfirmed → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

Matt, can I please have your blessing for dapper-updates?

Revision history for this message
Martin Pitt (pitti) wrote :
Revision history for this message
Martin Pitt (pitti) wrote : SRU proposal; #56484 hal does not detect non-ATAPI CD-ROM drives

Hi Matt,

I propose to fix https://launchpad.net/bugs/56484 in dapper.

Impact: hal does not detect drives whose device file name ends in
numbers; this particularly affects non-ATAPI CD-ROM devices (/dev/sr0)
and floppies (/dev/fd0). (Please look at the bug duplicates for
confirmation that dapper is affected as well). Apparently this worked
fine in breezy. We have a request from the support center to fix this
in Dapper.

Patch: http://librarian.launchpad.net/4313504/16-nonpartitions-ending-in-nums.patch

While this is not a nice an general solution for future upstream
versions, it is a very conservative and cautios solution. Hal's
current logic is flawed: if a device ends in numbers, then the code
assumes it's a partition on a drive and takes dirname(drive name) as
the parent sysfs device. However, in the case of e. g. /dev/sr0 (which
is a drive and not a partition), the parent of /sys/block/sr0 is
/sys/block which is not a valid sysfs device, and thus the device is
discarded with 'no parent'. According to Scott James Remnant, sysfs
gurarantees that /sys/block/foo are drives and /sys/block/foo/bar are
partitions, thus the patch just special-cases the flawed logic and
re-sets the 'is_partition' flag if the device name is a direct entry
in /sys/block (as opposed to a subdirectory of a /sys/block/ dir).

Status: Applied in Edgy some weeks ago, tested with appropriate
hardware, no reported regressions.

Martin

Revision history for this message
Matt Zimmerman (mdz) wrote :

On Tue, Sep 19, 2006 at 06:44:20PM +0200, Martin Pitt wrote:
> I propose to fix https://launchpad.net/bugs/56484 in dapper.
>
> Impact: hal does not detect drives whose device file name ends in
> numbers; this particularly affects non-ATAPI CD-ROM devices (/dev/sr0)
> and floppies (/dev/fd0). (Please look at the bug duplicates for
> confirmation that dapper is affected as well). Apparently this worked
> fine in breezy. We have a request from the support center to fix this
> in Dapper.
>
> Patch: http://librarian.launchpad.net/4313504/16-nonpartitions-ending-in-nums.patch
>
> While this is not a nice an general solution for future upstream
> versions, it is a very conservative and cautios solution. Hal's
> current logic is flawed: if a device ends in numbers, then the code
> assumes it's a partition on a drive and takes dirname(drive name) as
> the parent sysfs device. However, in the case of e. g. /dev/sr0 (which
> is a drive and not a partition), the parent of /sys/block/sr0 is
> /sys/block which is not a valid sysfs device, and thus the device is
> discarded with 'no parent'. According to Scott James Remnant, sysfs
> gurarantees that /sys/block/foo are drives and /sys/block/foo/bar are
> partitions, thus the patch just special-cases the flawed logic and
> re-sets the 'is_partition' flag if the device name is a direct entry
> in /sys/block (as opposed to a subdirectory of a /sys/block/ dir).
>
> Status: Applied in Edgy some weeks ago, tested with appropriate
> hardware, no reported regressions.

Looks fine, please upload to dapper-proposed.

--
 - mdz

Revision history for this message
Martin Pitt (pitti) wrote :
Revision history for this message
Martin Pitt (pitti) wrote :

Matt Zimmerman [2006-09-19 20:55 -0700]:
> Looks appropriate; please upload to dapper-proposed.

Done:

   * Add 16-nonpartitions-ending-in-nums.patch:
     - Hal currently assumes that device names ending in numbers are
       partitions. This patch adds a safe and easy, but slightly ugly
       workaround. (Real fix will be discussed with upstream at
       https://bugs.freedesktop.org/show_bug.cgi?id=5558)
     - This breaks SCSI, USB, and Firewire CD drives, which are usually called
       'scd0', 'sr1', etc.
     - Closes: LP#56484 and an impressive number of duplicates.

I attached the debdiff to the bug report.

Bug submitters, can you please test this, too, after it's available in
dapper-proposed? Thank you!

Revision history for this message
Tim Müller (t-i-m-zen) wrote :

> Status: Applied in Edgy some weeks ago, tested with
> appropriate hardware, no reported regressions.

I'm running up-to-date edgy and this still does not work for me despite the patch. lshal does not list any of my two internal SCSI disc drives (one DVD drive and one CD burner). The kernel recognises them fine, and the appropriate information can be found in /sys/block/srX/*

Is this supposed to work now for my case as well?
If yes, anything I can provide to help track this down further?

Martin Pitt (pitti)
Changed in hal:
status: In Progress → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote :

Tim, apparently you have a different problem then. Please create a new bug and do the steps on https://wiki.ubuntu.com/DebuggingRemovableDevices . Thanks!

Revision history for this message
Martin Pitt (pitti) wrote :

Package is in dapper-proposed. Testing and feedback would be highly appreciated! It will go into -updates next Wednesday if all goes well.

Revision history for this message
Simon Law (sfllaw) wrote :

Marc Tardif has verified that it does not break on removable CD-ROM drives.

We're waiting for Oliver to confirm that it fixes his bug.

Revision history for this message
Oliver Grawert (ogra) wrote :

works fine here, my usb dvd mounts properly and shows the right icon on the desktop

Revision history for this message
Martin Pitt (pitti) wrote :

Thank you for testing, I did the -updates upload which is now waiting for an archive team member to approve:

 hal (0.5.7-1ubuntu18.2) dapper-updates; urgency=low
 .
   * No-change upload of 0.5.7-1ubuntu18.1 to dapper-updates.
   * Thanks to Simon Law and Oliver Grawert for testing!

Revision history for this message
Colin Watson (cjwatson) wrote :

Accepted into dapper-updates. Per StableReleaseUpdates, Martin, please shout ASAP if there are any regressions.

Changed in hal:
status: Fix Committed → Fix Released
Revision history for this message
Kåre Särs (kare-sars) wrote :

This version breaks Kubuntu media mounting.

See: bug #72869

Revision history for this message
Martin Pitt (pitti) wrote :

I shortly discussed that with Jonathan. It only breaks with the unofficial KDE 3.5.5 packages, not with Dapper's KDE.

<Riddell> pitti: but I'll look into making a suitable hal package for those kubuntu.org packages when I have some spare time
<pitti> Riddell: shall I revert the ubuntu-updates patch for now?
<pitti> it'll break SCSI and USB CD-ROMs again, but...
<Riddell> pitti: I wouldn't revert a fix in ubuntu because it breaks some unsupported packages

Revision history for this message
Martin Pitt (pitti) wrote :

<pitti> Riddell: hm, in dapper's hal there's only a '<policy at_console="true">' policy for the Mount methods, no 'group=plugdev' as in edgy
<pitti> Riddell: so it actually appears that it should fail the same way with dapper final's hal
<pitti> Riddell: the curious thing is that they claimed that downgrading to 18.1 from dapper-proposed fixed it
<pitti> Riddell: but 18.2 is the same as 18.1, just uploaded to dapper-updates
<-- jonh_wendell hat sich getrennt (Client Quit)
<Riddell> pitti: the kubuntu.org kde 3.5.5 archive has a modified version of 0.5.7-1ubuntu18.1
<pitti> Riddell: aah, that explains it then
<pitti> Riddell: so reverting the hal fix in ubuntu would not fix it at all then

So the SRU is ok as it is.

Revision history for this message
In , Danny Kukawka (danny-kukawka) wrote :

This is IIRC fixed in actual HAL versions by check for the range file in sysfs. Close as Fixed

Changed in hal:
status: Confirmed → Fix Released
Przemek K. (azrael)
Changed in baltix:
status: New → Fix Released
Changed in hal:
importance: Unknown → Medium
Changed in hal:
importance: Medium → Unknown
Changed in hal:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.