hopluggable detection broken since apparently 2.6.20

Andrey Borzenkov arvidjaar at mail.ru
Mon Mar 5 12:25:44 PST 2007


At some point KDE mediamanager applet stopped displaying USB stick. I pointed 
fingers at KDE until today when I noticed that stick apparently had wrong 
MIME type - media/hdd_mounted instead of media/removable_mounted.

Now KDE sets type to media/removable if libhal_drive_is_hotpluggable() is 
true. And this is true iff storage.hotpluggable is true. Which is false on my 
system (relevant part of lshal below).

Further investigation shows that storage.hotpluggable depends on storage bus 
type which now is scsi while I swear that it has been usb at some point.

I am not sure whether something changed in sysfs or in hal. I do not see any 
obvious changes in blockdev.c so I can only assume it sysfs that has changed. 
Currently running 2.6.21-rc2 without SYSFS_DEPRECATED.

The problem seems to be that hal checks for bus == usb (among others) while 
current chain simply does not have it. Short tree:

  pci_10b9_5237
    usb_device_0_0_0000_00_02_0
      usb_device_90c_1000_AA04012700008619
        usb_device_90c_1000_AA04012700008619_if0
        usb_device_90c_1000_AA04012700008619_scsi_host
          usb_device_90c_1000_AA04012700008619_scsi_host_scsi_device_lun0
            storage_serial_090c_Cn_Memory_AA04012700008619
              volume_uuid_C2F8_E4F2

and info.bus (where exists):

  pci
    usb_device
      usb_device
        scsi

Should we check for both "usb" and "usb_device"?

-andrey

lshal:
udi = '/org/freedesktop/Hal/devices/usb_device_0_0_0000_00_02_0'
  info.udi = '/org/freedesktop/Hal/devices/usb_device_0_0_0000_00_02_0'  
(string)
  power_management.can_suspend = false  (bool)
  power_management.can_suspend_to_ram = false  (bool)
  linux.subsystem = 'usb'  (string)
  linux.hotplug_type = 1  (0x1)  (int)
  usb_device.bus_number = 1  (0x1)  (int)
  usb_device.can_wake_up = true  (bool)
  usb_device.is_self_powered = true  (bool)
  usb_device.version_bcd = 272  (0x110)  (int)
  usb_device.speed_bcd = 4608  (0x1200)  (int)
  usb_device.serial = '0000:00:02.0'  (string)
  usb_device.linux.device_number = 1  (0x1)  (int)
  usb_device.num_ports = 3  (0x3)  (int)
  usb_device.max_power = 0  (0x0)  (int)
  usb_device.device_revision_bcd = 518  (0x206)  (int)
  info.product = 'OHCI Host Controller'  (string)
  usb_device.product = 'OHCI Host Controller'  (string)
  info.vendor = 'Linux 2.6.21-rc2-1avb ohci_hcd'  (string)
  usb_device.vendor = 'Linux 2.6.21-rc2-1avb ohci_hcd'  (string)
  usb_device.product_id = 0  (0x0)  (int)
  usb_device.vendor_id = 0  (0x0)  (int)
  usb_device.device_protocol = 0  (0x0)  (int)
  usb_device.device_subclass = 0  (0x0)  (int)
  usb_device.device_class = 9  (0x9)  (int)
  usb_device.num_interfaces = 1  (0x1)  (int)
  usb_device.num_configurations = 1  (0x1)  (int)
  usb_device.configuration_value = 1  (0x1)  (int)
  usb_device.linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:02.0/usb1'  
(string)
  info.linux.driver = 'usb'  (string)
  info.bus = 'usb_device'  (string)
  info.parent = '/org/freedesktop/Hal/devices/pci_10b9_5237'  (string)
  linux.sysfs_path_device = '/sys/devices/pci0000:00/0000:00:02.0/usb1'  
(string)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:02.0/usb1'  (string)

udi = '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619'
  info.udi 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619'  
(string)
  power_management.can_suspend = false  (bool)
  power_management.can_suspend_to_ram = false  (bool)
  linux.subsystem = 'usb'  (string)
  linux.hotplug_type = 1  (0x1)  (int)
  usb_device.bus_number = 1  (0x1)  (int)
  usb_device.can_wake_up = false  (bool)
  usb_device.is_self_powered = false  (bool)
  usb_device.version_bcd = 512  (0x200)  (int)
  usb_device.speed_bcd = 4608  (0x1200)  (int)
  usb_device.serial = 'AA04012700008619'  (string)
  usb_device.linux.device_number = 2  (0x2)  (int)
  usb_device.num_ports = 0  (0x0)  (int)
  usb_device.max_power = 100  (0x64)  (int)
  usb_device.device_revision_bcd = 4352  (0x1100)  (int)
  info.product = 'Memory Bar'  (string)
  usb_device.product = 'Memory Bar'  (string)
  info.vendor = 'Feiya Technology Corp.'  (string)
  usb_device.vendor = 'Feiya Technology Corp.'  (string)
  usb_device.product_id = 4096  (0x1000)  (int)
  usb_device.vendor_id = 2316  (0x90c)  (int)
  usb_device.device_protocol = 0  (0x0)  (int)
  usb_device.device_subclass = 0  (0x0)  (int)
  usb_device.device_class = 0  (0x0)  (int)
  usb_device.num_interfaces = 1  (0x1)  (int)
  usb_device.num_configurations = 1  (0x1)  (int)
  usb_device.configuration_value = 1  (0x1)  (int)
  usb_device.linux.sysfs_path 
= '/sys/devices/pci0000:00/0000:00:02.0/usb1/1-2'  (string)
  info.linux.driver = 'usb'  (string)
  info.bus = 'usb_device'  (string)
  info.parent = '/org/freedesktop/Hal/devices/usb_device_0_0_0000_00_02_0'  
(string)
  linux.sysfs_path_device = '/sys/devices/pci0000:00/0000:00:02.0/usb1/1-2'  
(string)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:02.0/usb1/1-2'  (string)

udi = '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_if0'
  info.udi 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_if0'  
(string)
  power_management.can_suspend = false  (bool)
  power_management.can_suspend_to_ram = false  (bool)
  linux.subsystem = 'usb'  (string)
  linux.hotplug_type = 1  (0x1)  (int)
  info.product = 'USB Mass Storage Interface'  (string)
  usb.interface.protocol = 80  (0x50)  (int)
  usb.interface.subclass = 6  (0x6)  (int)
  usb.interface.class = 8  (0x8)  (int)
  usb.interface.number = 0  (0x0)  (int)
  info.linux.driver = 'usb-storage'  (string)
  usb.linux.sysfs_path 
= '/sys/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0'  (string)
  usb.configuration_value = 1  (0x1)  (int)
  usb.num_configurations = 1  (0x1)  (int)
  usb.num_interfaces = 1  (0x1)  (int)
  usb.device_class = 0  (0x0)  (int)
  usb.device_subclass = 0  (0x0)  (int)
  usb.device_protocol = 0  (0x0)  (int)
  usb.vendor_id = 2316  (0x90c)  (int)
  usb.product_id = 4096  (0x1000)  (int)
  usb.vendor = 'Feiya Technology Corp.'  (string)
  usb.product = 'USB Mass Storage Interface'  (string)
  usb.device_revision_bcd = 4352  (0x1100)  (int)
  usb.max_power = 100  (0x64)  (int)
  usb.num_ports = 0  (0x0)  (int)
  usb.linux.device_number = 2  (0x2)  (int)
  usb.serial = 'AA04012700008619'  (string)
  usb.speed_bcd = 4608  (0x1200)  (int)
  usb.version_bcd = 512  (0x200)  (int)
  usb.is_self_powered = false  (bool)
  usb.can_wake_up = false  (bool)
  usb.bus_number = 1  (0x1)  (int)
  info.bus = 'usb'  (string)
  info.parent 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619'  
(string)
  linux.sysfs_path_device 
= '/sys/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0'  (string)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0'  
(string)

udi 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host'
  info.linux.driver = 'sd'  (string)
  info.udi 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host'  
(string)
  power_management.can_suspend = false  (bool)
  power_management.can_suspend_to_ram = false  (bool)
  linux.subsystem = 'scsi_host'  (string)
  linux.hotplug_type = 2  (0x2)  (int)
  scsi_host.host = 2  (0x2)  (int)
  info.product = 'SCSI Host Adapter'  (string)
  info.capabilities = {'scsi_host'} (string list)
  info.category = 'scsi_host'  (string)
  info.parent 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619'  
(string)
  linux.sysfs_path_device 
= '/sys/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0/host2'  (string)
  linux.sysfs_path = '/sys/class/scsi_host/host2'  (string)

udi 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host_scsi_device_lun0'
  info.udi 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host_scsi_device_lun0'  
(string)
  power_management.can_suspend = false  (bool)
  power_management.can_suspend_to_ram = false  (bool)
  linux.subsystem = 'scsi'  (string)
  linux.hotplug_type = 1  (0x1)  (int)
  scsi.type = 'disk'  (string)
  scsi.vendor = ''  (string)
  scsi.model = 'Cn Memory'  (string)
  info.product = 'SCSI Device'  (string)
  info.linux.driver = 'sd'  (string)
  scsi.lun = 0  (0x0)  (int)
  scsi.target = 0  (0x0)  (int)
  scsi.bus = 0  (0x0)  (int)
  scsi.host = 2  (0x2)  (int)
  info.parent 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host'  
(string)
  info.bus = 'scsi'  (string)
  linux.sysfs_path_device 
= '/sys/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0/host2/target2:0:0/2:0:0:0'  
(string)
  linux.sysfs_path 
= '/sys/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0/host2/target2:0:0/2:0:0:0'  
(string)

udi 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host_scsi_device_lun0_scsi_generic'
  info.udi 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host_scsi_device_lun0_scsi_generic'  
(string)
  power_management.can_suspend = false  (bool)
  power_management.can_suspend_to_ram = false  (bool)
  linux.device_file = '/dev/sg2'  (string)
  linux.subsystem = 'scsi_generic'  (string)
  linux.hotplug_type = 2  (0x2)  (int)
  scsi_generic.device = '/dev/sg2'  (string)
  info.product = 'SCSI Generic Interface'  (string)
  info.capabilities = {'scsi_generic'} (string list)
  info.category = 'scsi_generic'  (string)
  info.parent 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host_scsi_device_lun0'  
(string)
  linux.sysfs_path = '/sys/class/scsi_generic/sg2'  (string)

udi 
= '/org/freedesktop/Hal/devices/storage_serial_090c_Cn_Memory_AA04012700008619'
  power_management.can_suspend = false  (bool)
  power_management.can_suspend_to_ram = false  (bool)
  info.addons = {'hald-addon-storage'} (string list)
  block.storage_device 
= '/org/freedesktop/Hal/devices/storage_serial_090c_Cn_Memory_AA04012700008619'  
(string)
  info.udi 
= '/org/freedesktop/Hal/devices/storage_serial_090c_Cn_Memory_AA04012700008619'  
(string)
  storage.partitioning_scheme = 'mbr'  (string)
  storage.removable.media_size = 2079850496  (0x7bf80000)  (uint64)
  storage.requires_eject = false  (bool)
  storage.hotpluggable = false  (bool)
  info.capabilities = {'storage', 'block'} (string list)
  info.category = 'storage'  (string)
  info.product = 'Cn Memory'  (string)
  info.vendor = ''  (string)
  storage.size = 0  (0x0)  (uint64)
  storage.removable = true  (bool)
  storage.removable.media_available = true  (bool)
  storage.physical_device 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host_scsi_device_lun0'  
(string)
  storage.lun = 0  (0x0)  (int)
  storage.firmware_version = '1100'  (string)
  storage.serial = '090c_Cn_Memory_AA04012700008619'  (string)
  storage.vendor = ''  (string)
  storage.model = 'Cn Memory'  (string)
  storage.drive_type = 'disk'  (string)
  storage.automount_enabled_hint = true  (bool)
  storage.media_check_enabled = true  (bool)
  storage.no_partitions_hint = false  (bool)
  storage.bus = 'scsi'  (string)
  block.is_volume = false  (bool)
  block.minor = 16  (0x10)  (int)
  block.major = 8  (0x8)  (int)
  block.device = '/dev/sdb'  (string)
  linux.hotplug_type = 3  (0x3)  (int)
  info.parent 
= '/org/freedesktop/Hal/devices/usb_device_90c_1000_AA04012700008619_scsi_host_scsi_device_lun0'  
(string)
  linux.sysfs_path_device = '/sys/block/sdb'  (string)
  linux.sysfs_path = '/sys/block/sdb'  (string)

udi = '/org/freedesktop/Hal/devices/volume_uuid_C2F8_E4F2'
  power_management.can_suspend = false  (bool)
  power_management.can_suspend_to_ram = false  (bool)
  volume.policy.mount_option.dirsync = true  (bool)
  volume.policy.mount_option.codepage=866 = true  (bool)
  volume.policy.mount_option.iocharset=utf8 = true  (bool)
  volume.unmount.valid_options = {'lazy'} (string list)
  volume.mount.valid_options = 
{'ro', 'sync', 'dirsync', 'noatime', 'nodiratime', 'noexec', 'quiet', 'remount', 'exec', 'utf8', 'shortname=', 'codepage=', 'iocharset=', 'umask=', 'dmask=', 'fmask=', 'uid=', 'flush'} 
(string list)
  org.freedesktop.Hal.Device.Volume.method_execpaths = 
{'hal-storage-mount', 'hal-storage-unmount', 'hal-storage-eject'} (string 
list)
  org.freedesktop.Hal.Device.Volume.method_argnames = {'mount_point fstype 
extra_options', 'extra_options', 'extra_options'} (string list)
  org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'} 
(string list)
  org.freedesktop.Hal.Device.Volume.method_names = 
{'Mount', 'Unmount', 'Eject'} (string list)
  info.interfaces = {'org.freedesktop.Hal.Device.Volume'} (string list)
  volume.ignore = false  (bool)
  info.udi = '/org/freedesktop/Hal/devices/volume_uuid_C2F8_E4F2'  (string)
  volume.partition.flags = {} (string list)
  volume.partition.uuid = ''  (string)
  volume.partition.label = ''  (string)
  volume.partition.type = '0x06'  (string)
  volume.partition.scheme = 'mbr'  (string)
  info.product = 'USB DISK'  (string)
  volume.partition.media_size = 2079850496  (0x7bf80000)  (uint64)
  volume.partition.start = 16384  (0x4000)  (uint64)
  volume.size = 2079834112  (0x7bf7c000)  (uint64)
  volume.num_blocks = 4062176  (0x3dfbe0)  (int)
  volume.block_size = 512  (0x200)  (int)
  volume.partition.number = 1  (0x1)  (int)
  info.capabilities = {'volume', 'block'} (string list)
  info.category = 'volume'  (string)
  volume.is_partition = true  (bool)
  volume.is_disc = false  (bool)
  volume.linux.is_device_mapper = false  (bool)
  volume.is_mounted_read_only = false  (bool)
  volume.is_mounted = true  (bool)
  volume.mount_point = '/media/USB DISK'  (string)
  volume.label = 'USB DISK'  (string)
  volume.uuid = 'C2F8-E4F2'  (string)
  volume.fsversion = 'FAT16'  (string)
  volume.fsusage = 'filesystem'  (string)
  volume.fstype = 'vfat'  (string)
  storage.model = ''  (string)
  block.storage_device 
= '/org/freedesktop/Hal/devices/storage_serial_090c_Cn_Memory_AA04012700008619'  
(string)
  block.is_volume = true  (bool)
  block.minor = 17  (0x11)  (int)
  block.major = 8  (0x8)  (int)
  block.device = '/dev/sdb1'  (string)
  linux.hotplug_type = 3  (0x3)  (int)
  info.parent 
= '/org/freedesktop/Hal/devices/storage_serial_090c_Cn_Memory_AA04012700008619'  
(string)
  linux.sysfs_path_device = '/sys/block/sdb/sdb1'  (string)
  linux.sysfs_path = '/sys/block/sdb/sdb1'  (string)

sysfs:

{pts/1}% udevinfo --attribute-walk -n sdb

Udevinfo 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 '/block/sdb':
    KERNEL=="sdb"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{stat}=="      56       16      345      900        0        0        
0        0        0      750      900"
    ATTR{size}=="4062208"
    ATTR{removable}=="1"
    ATTR{range}=="16"
    ATTR{dev}=="8:16"

  looking at parent 
device '/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0/host2/target2:0:0/2:0:0:0':
    KERNELS=="2:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{ioerr_cnt}=="0x2"
    ATTRS{iodone_cnt}=="0x381"
    ATTRS{iorequest_cnt}=="0x381"
    ATTRS{iocounterbits}=="32"
    ATTRS{timeout}=="30"
    ATTRS{state}=="running"
    ATTRS{rev}=="1100"
    ATTRS{model}=="Cn Memory       "
    ATTRS{vendor}=="        "
    ATTRS{scsi_level}=="0"
    ATTRS{type}=="0"
    ATTRS{queue_type}=="none"
    ATTRS{queue_depth}=="1"
    ATTRS{device_blocked}=="0"
    ATTRS{max_sectors}=="240"

  looking at parent 
device '/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0/host2/target2:0:0':
    KERNELS=="target2:0:0"
    SUBSYSTEMS==""
    DRIVERS==""

  looking at parent 
device '/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0/host2':
    KERNELS=="host2"
    SUBSYSTEMS==""
    DRIVERS==""

  looking at parent 
device '/devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0':
    KERNELS=="1-2:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb-storage"
    ATTRS{modalias}=="usb:v090Cp1000d1100dc00dsc00dp00ic08isc06ip50"
    ATTRS{bInterfaceProtocol}=="50"
    ATTRS{bInterfaceSubClass}=="06"
    ATTRS{bInterfaceClass}=="08"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:02.0/usb1/1-2':
    KERNELS=="1-2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{serial}=="AA04012700008619"
    ATTRS{product}=="Cn Memory"
    ATTRS{quirks}=="0x0"
    ATTRS{maxchild}=="0"
    ATTRS{version}==" 2.00"
    ATTRS{devnum}=="2"
    ATTRS{speed}=="12"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bcdDevice}=="1100"
    ATTRS{idProduct}=="1000"
    ATTRS{idVendor}=="090c"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{bmAttributes}=="80"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{configuration}==""

  looking at parent device '/devices/pci0000:00/0000:00:02.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{serial}=="0000:00:02.0"
    ATTRS{product}=="OHCI Host Controller"
    ATTRS{manufacturer}=="Linux 2.6.21-rc2-1avb ohci_hcd"
    ATTRS{quirks}=="0x0"
    ATTRS{maxchild}=="3"
    ATTRS{version}==" 1.10"
    ATTRS{devnum}=="1"
    ATTRS{speed}=="12"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="0206"
    ATTRS{idProduct}=="0000"
    ATTRS{idVendor}=="0000"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{configuration}==""

  looking at parent device '/devices/pci0000:00/0000:00:02.0':
    KERNELS=="0000:00:02.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ohci_hcd"
    ATTRS{msi_bus}==""
    ATTRS{broken_parity_status}=="0"
    ATTRS{modalias}=="pci:v000010B9d00005237sv00001179sd00000004bc0Csc03i10"
    ATTRS{local_cpus}=="1"
    ATTRS{irq}=="11"
    ATTRS{class}=="0x0c0310"
    ATTRS{subsystem_device}=="0x0004"
    ATTRS{subsystem_vendor}=="0x1179"
    ATTRS{device}=="0x5237"
    ATTRS{vendor}=="0x10b9"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/hal/attachments/20070305/3b466261/attachment.pgp


More information about the hal mailing list