[PATCH ]Re: hal doesn't recognize mounting of devices

Kay Sievers kay.sievers at vrfy.org
Tue Oct 25 08:41:41 PDT 2005


On Tue, Oct 25, 2005 at 05:01:36PM +0200, Danny Kukawka wrote:
> On Tuesday 25 October 2005 16:07, you wrote:
> > Thanks for the patch.  I had to bump the delay to 0.3 seconds to get
> > everything to reliably mount and unmount on my machines.  Other than
> > that it works as expected.
> >
> > I was wondering if this wouldn't be the perfect place to use inotify.
> > Setup an inotify watch on /proc/mounts and block until we get the write
> > finished event.  Just a thought.

Inotify can't work for a lot of files in /proc or /sys, cause the file
content is virtual and only created on read() of the file. The read
function actually does the device operation, sometimes it calls down to
queries the hardware directly. There is no way to know about a state
change in advance.
The "mounts" file is generated on the fly while reading it, there is no way
to know if that has changed without reading it. Nothing touches it
from inside the kernel if nobody reads it. The "mount" uevent exists
exactly for that reason.

> IMO this is only a *workaround* and I wouldn't implement more than needed for 
> the workaround.

Well it's the way to deal with the kernel. It is that way all over
the place. For sysfs it is just hidden into the udev event
handling. sysfs, usbfs, proc, there is nowhere a guarantee that the
files are polulated at event time.

> This is a bug in the kernel and should be fixed there.

I wouldn't call it a bug. :) It would be nice to have it in the right order
and I fixed a lot of the sysfs event timing, but we will never get it for
_all_ the stuff.

And regarding to the "mount" event. It is the "exclusive block device claim"
event we receive, and not a "I have it finally mounted" event. These are
different states that will not be in sync.

Kay


More information about the hal mailing list