mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Ordering hotplug scripts vs. udev device node creation
@ 2006-10-23 19:26 Aaron Cohen
  2006-10-24  2:45 ` Andrey Borzenkov
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Cohen @ 2006-10-23 19:26 UTC (permalink / raw)
  To: linux-hotplug-devel, linux-kernel

(I sent this email to the linux kernel mailing list a couple of days
ago so the first couple of paragraphs may seem familiary to someone
who reads both lists.  I just found the hotplug list though, and have
some new details added.)

I'm trying to modify the gpsd hotplug script to work better with my
udev setup.  My USB serial devices are added to /dev/tts/USBx by udev
and the default script assumes they are /dev/ttyUSBx.

In any event, my hotplug script uses udevinfo to figure out the device
file to use.  The problem seems to be though that my hotplug script is
getting run before udev has actually created the device node.  Is
there some ordering mechanism I'm missing that would help me out here?

I am now using udev rules exclusively rather than old-style hotplug
rules.  I've created a file in /etc/udev/rules.d called 51-gpsd.rules
which contains:

KERNEL=="ttyUSB[0-9]*", RUN+="/lib/udev/gpsd"

/lib/udev/gpsd is my script that runs udevinfo to figure out the /dev/
file to use and communicates this to gpsd through a control socket.

Adding a USB device seems to work correctly (more or less, my script
is invoked a few too many times but I think I can figure out how to
adjust my rule) using this.  I'm having trouble now with removal
though.  By the time my script runs the device file has been removed
by udev and I can't look it up through udevinfo any longer.  I need to
know what the name of the device file was so I can tell gpsd to stop
monitoring it.

Any ideas?

Thanks,
Aaron

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ordering hotplug scripts vs. udev device node creation
  2006-10-23 19:26 Ordering hotplug scripts vs. udev device node creation Aaron Cohen
@ 2006-10-24  2:45 ` Andrey Borzenkov
  0 siblings, 0 replies; 5+ messages in thread
From: Andrey Borzenkov @ 2006-10-24  2:45 UTC (permalink / raw)
  To: linux-hotplug-devel; +Cc: Aaron Cohen, linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 23 October 2006 23:26, Aaron Cohen wrote:
> Adding a USB device seems to work correctly (more or less, my script
> is invoked a few too many times but I think I can figure out how to
> adjust my rule) using this.  I'm having trouble now with removal
> though.  By the time my script runs the device file has been removed
> by udev and I can't look it up through udevinfo any longer.  I need to
> know what the name of the device file was so I can tell gpsd to stop
> monitoring it.
>
> Any ideas?

udev sets DEVNAME and DEVLINKS environment before calling RUN program. You can 
either pass them directly like

RUN+="/your/program env{DEVNAME} env{DEVLINKS}"

or your program can get them from environment. It unfortunately seems to be 
not documented.

HTH

- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFPX5YR6LMutpd94wRAsDrAJ92kOTrofNo3kg/5xW0C6bzm5TlDACg0/NG
K4R+tBQzCHJSN+XW5WBPghE=
=ZIet
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ordering hotplug scripts vs. udev device node creation
  2006-10-21 17:21 Aaron Cohen
  2006-10-21 18:36 ` Andreas Jellinghaus
@ 2006-10-22 18:49 ` Alistair John Strachan
  1 sibling, 0 replies; 5+ messages in thread
From: Alistair John Strachan @ 2006-10-22 18:49 UTC (permalink / raw)
  To: Aaron Cohen; +Cc: LKML List

On Saturday 21 October 2006 18:21, Aaron Cohen wrote:
> Hope this is a reasonable list to post this to.
>
> I'm trying to modify the gpsd hotplug script to work better with my
> udev setup.  My USB serial devices are added to /dev/tts/USBx by udev
> and the default script assumes they are /dev/ttyUSBx.
>
> In any event, my hotplug script uses udevinfo to figure out the device
> file to use.  The problem seems to be though that my hotplug script is
> getting run before udev has actually created the device node.  Is
> there some ordering mechanism I'm missing that would help me out here?

Some distros have gotten rid of hotplug altogether and now use udev entirely 
for handling plugging events (udevd). It seems like what you could do here 
was write a simple udev rule to symlink the device when it's created.

-- 
Cheers,
Alistair.

Final year Computer Science undergraduate.
1F2 55 South Clerk Street, Edinburgh, UK.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ordering hotplug scripts vs. udev device node creation
  2006-10-21 17:21 Aaron Cohen
@ 2006-10-21 18:36 ` Andreas Jellinghaus
  2006-10-22 18:49 ` Alistair John Strachan
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Jellinghaus @ 2006-10-21 18:36 UTC (permalink / raw)
  To: linux-kernel

not sure, I ran into the same problem with usb device files
(both in /proc and /dev/bus/usb). and my quick hack was to simply
add a "sleep 1".

but there might be a cleaner solution:
with udevmonitor you should see what udev does, and it should
give you the name of the device it creates, so the call to udevinfo
should not be needed. and when that event with the device name
comes in - at least I hope - udev has already created it.

(at least I think it would be right if it creates a file to fire
the event associated with doing that after the mknod.)

maybe give it a try. reporting back here (or on the hotplug mailing
list which might be more appropriate) would be very welcome, as you
are not the only one running into these kind of problems.

good luck!

Andreas


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Ordering hotplug scripts vs. udev device node creation
@ 2006-10-21 17:21 Aaron Cohen
  2006-10-21 18:36 ` Andreas Jellinghaus
  2006-10-22 18:49 ` Alistair John Strachan
  0 siblings, 2 replies; 5+ messages in thread
From: Aaron Cohen @ 2006-10-21 17:21 UTC (permalink / raw)
  To: LKML List

Hope this is a reasonable list to post this to.

I'm trying to modify the gpsd hotplug script to work better with my
udev setup.  My USB serial devices are added to /dev/tts/USBx by udev
and the default script assumes they are /dev/ttyUSBx.

In any event, my hotplug script uses udevinfo to figure out the device
file to use.  The problem seems to be though that my hotplug script is
getting run before udev has actually created the device node.  Is
there some ordering mechanism I'm missing that would help me out here?

Thanks,
Aaron

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-10-24  2:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-23 19:26 Ordering hotplug scripts vs. udev device node creation Aaron Cohen
2006-10-24  2:45 ` Andrey Borzenkov
  -- strict thread matches above, loose matches on Subject: below --
2006-10-21 17:21 Aaron Cohen
2006-10-21 18:36 ` Andreas Jellinghaus
2006-10-22 18:49 ` Alistair John Strachan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome