From: Marcel Holtmann <marcel@holtmann.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: Replaying event for a libudev monitor
Date: Fri, 02 Jan 2009 14:04:23 +0000 [thread overview]
Message-ID: <1230905063.15391.35.camel@californication> (raw)
In-Reply-To: <1230884168.15391.8.camel@californication>
Hi Kay,
> > so the enumeration API of libudev is pretty since, but when using a
> > monitor to get add/change/remove events anyway, it is kinda double work.
> >
> > So I have udev rules to select certain events to send to a specific
> > socket and that works great and truly simple with libudev. However when
> > the client starts up, it has to discover the initial state of these
> > events. I can use the enumeration part of libudev, but then I am putting
> > details into a rules file and others into the client.
> >
> > So what I like to have is a way to replay the events for that monitor
> > socket. Something similar to this:
> >
> > ctx = udev_new();
> > mon = udev_monitor_new_from_socket(ctx, "@socket");
> > udev_monitor_enable_receiving(mon);
> >
> > /* setup watch etc. */
> >
> > udev_monitor_replay_events(mon);
> >
> > What do you think? Can we add something like this?
>
> You want something like a "daemon coldplug"?
>
> Something that would parse the rules and tries to match the devices,
> which matches the rule that sends the event? The rule parsingis
> currently not part of libudev. Matching devices might involve running
> programs from rules, so we should not do that in a single serializing
> process, as it might block for too long. We should also not use the
> daemon to trigger events, because global events would be send to all
> other listeners.
>
> Care to explain your idea a bit more, I may miss something here?
I think you get it pretty much. You could describe it is as "daemon
coldplug" for events for a specific RUN=+"socket:*".
Something similar to what you have with "udevadm test" at the moment,
but with the limitation that only this one socket gets the events.
As mentioned before, the reason behind this is that without some kind of
support I have to put matching rules into a *.rules file for runtime
detection and another set of matching logic into the client using
libudev enumeration. I prefer to have both pieces in the *.rules files
since then it is easy changeable.
So I do see your point with the matching rules that run external
programs. I wasn't thinking about them since so far the matching rules
are kinda simple. I do wanna avoid to just send all udev events to the
monitor (like HAL and DeviceKit does) since that is just overhead and
re-implementing the matching code and scripts is just not a good idea.
The things that udev provides right now are perfect.
My current simple idea to solve this would be to add another
udev_ctrl_msg_type that libudev then can use to trigger this.
Looking at the code it seems that you identify the socket already using
udev_ctrl_new_from_socket() and so no need for an extra parameter to
this new command. Maybe UDEV_CTRL_REPLAY_EVENTS and then we wrap this
low-level command around udev_monitor_replay_events() for libudev. And
then udevd is responsible for the threading, invoking of programs and
making sure no other RUN+="socket:*" are executed.
Regards
Marcel
next prev parent reply other threads:[~2009-01-02 14:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-02 8:16 Replaying event for a libudev monitor Marcel Holtmann
2009-01-02 13:00 ` Kay Sievers
2009-01-02 14:04 ` Marcel Holtmann [this message]
2009-01-02 16:05 ` Kay Sievers
2009-01-02 17:45 ` Marcel Holtmann
2009-01-02 17:56 ` David Zeuthen
2009-01-02 17:57 ` Kay Sievers
2009-01-02 18:02 ` Marcel Holtmann
2009-01-02 18:12 ` Kay Sievers
2009-01-02 18:33 ` Marcel Holtmann
2009-01-02 18:36 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1230905063.15391.35.camel@californication \
--to=marcel@holtmann.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).