Proposed fix for 'hal sometimes creates volumes for raw device
and partitions'
Kay Sievers
kay.sievers at vrfy.org
Sun Apr 16 08:26:47 PDT 2006
On Sat, Mar 25, 2006 at 12:59:29PM +0300, Andrey Borzenkov wrote:
> On Tuesday 21 March 2006 17:49, Kay Sievers wrote:
> > On Wed, Mar 08, 2006 at 04:12:29PM +0100, Kay Sievers wrote:
> > > On Wed, Mar 08, 2006 at 11:40:25AM +0100, Martin Pitt wrote:
> > > > 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.
> >
> > The attached patch to the kernel delays all events belonging to a block
> > device until the partition table is completely scanned and all devices
> > (disk and partitions) are already created by the kernel. The disk device
> > in sysfs will have an attribute "partitioned", which will tell if there
> > are child devices to expect.
> >
> > That way we can just skip probing for a filesystem on the disk device
> > if the event for the disk tells us that we can expect partition events.
> >
> > Would be nice, if someone can play around with this and see if that can
> > work to properly solve that old and nasty problem.
> >
>
> I do not have "bad" devices but attached patch skips probing of FS on
> partitioned device:
>
> 14337: 12:51:11.081: probe-storage.c:374: Skipping file system check on
> partitioned device /dev/sda
>
> At least, my USB stick continues to work with it (mounting partition 1 as
> before).
>
> The patch is ugly, it is more a proof of concept; I'd prefer using functions
> from hald/util.c but it needs Makefile modifications and I am not as intimate
> with automake.
>
> Would be nice if someone could test it on a "bad" USB stick.
Just an update:
The kernel patch made it upstream but for now without the "partitioned"
sysfs attribute:
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=d4d7e5dffc4844ef51fe11f497bd774c04413a00
Without the attribute, we need to look for an existing subdirectory with
the same name as the blockdevice and a number appended. The partition
devices will already be there at the time the event for the disk is send
out, so this should work fine, just a bit less elegant.
Thanks,
Kay
More information about the hal
mailing list