Proposed fix for 'hal sometimes creates volumes for raw device and partitions'

Kay Sievers kay.sievers at
Wed Mar 8 07:12:29 PST 2006

On Wed, Mar 08, 2006 at 11:40:25AM +0100, Martin Pitt wrote:
> Hi!
> I finally gave a stab to the bug that hal creates a volume for the raw
> device (/dev/sda) even if there are partitions on it, so that you end
> up with getting both /dev/sda and /dev/sda1 automounted. [1] [2]
> I noticed that probe-{storage,volume} never really calls
> volume_id_probe_msdos_part_table(). It just calls
> volume_id_probe_all() and even expects that this might return
> VOLUME_ID_PARTITIONTABLE, but volume_id_probe_all() does not probe for
> partition tables.
> So I made volume_id_probe_all() call volume_id_probe_msdos_part_table()
> before trying to probe file systems, and voila, it works just great.
> It even seems to be the intended semantics.
> Does anyone see any problem with this approach?

Yeah! The only sane way is to have the kernel to tell you that it has
finished creating partitions, means "scanning the partition table" and not
create any volumes in HAL until that.

We could also delay the announcement of a volume on a main block
device until the point (a few seconds) it is unlikely that partition
events will arrive. If during that time we see partitions created, we can
just invalidate the probed volume on the main device.

Guessing with volume_id if we find a partition table or a fat volume
is not reliable enough and does not work with other partition formats. If
we are going to do this, we should at least use data gathered by libparted
(or a program based on it), which knows about all the other weird partition
formats too.

So we should have:
  the kernel tell us: "finished partition scanning"
  (the only sane solution to get the state of the kernel, which is
  what we are interested in)
  delay announcement of volumes on main devices until it is
  unlikely to see them created
  (very likely too be correct in almost all cases, with a small delay
  for formatted main devices which should be acceptable)
  use libparted to detect a partition table
  (guessing the partition table in general is very unreliable
  and may produce results different from the kernels idea of the device)


More information about the hal mailing list