ACTION=="remove", ENV{REMOVE_CMD}!="", RUN+="$env{REMOVE_CMD}"
# event to be catched by udevmonitor
-RUN+="socket:/org/kernel/udev/monitor"
+RUN+="socket:@/org/kernel/udev/monitor"
.\" Title: udev
.\" Author:
-.\" Generator: DocBook XSL Stylesheets v1.73.1 <http://docbook.sf.net/>
+.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
.\" Date: August 2005
.\" Manual: udev
.\" Source: udev
\fBRUN\fR
.RS 4
Add a program to the list of programs to be executed for a specific device\. This can only be used for very short running tasks\. Running an event process for a long period of time may block all further events for this or a dependent device\. Long running tasks need to be immediately detached from the event process itself\.
+.sp
+If the specifiefd string starts with
+\fBsocket:\fR\fB\fIpath\fR\fR, all current event values will be passed to the specified socket, as a message in the same format the kernel sends an uevent\. If the first character of the specified path is an @ character, an abstract namespace socket is used, instead of an existing socket file\.
.RE
.PP
\fBLABEL\fR
Written by Greg Kroah\-Hartman
<greg@kroah\.com>
and Kay Sievers
-<kay\.sievers@vrfy\.org>\. With much help from Dan Stekloff
-<dsteklof@us\.ibm\.com>
-and many others\.
+<kay\.sievers@vrfy\.org>\. With much help from Dan Stekloff and many others\.
.SH "SEE ALSO"
.PP
\fBudevd\fR(8),
event process for a long period of time may block all further events for
this or a dependent device. Long running tasks need to be immediately
detached from the event process itself.</para>
+ <para>If the specifiefd string starts with
+ <option>socket:<replaceable>path</replaceable></option>, all current event
+ values will be passed to the specified socket, as a message in the same
+ format the kernel sends an uevent. If the first character of the specified path
+ is an @ character, an abstract namespace socket is used, instead of an existing
+ socket file.</para>
</listitem>
</varlistentry>
<refsect1><title>AUTHOR</title>
<para>Written by Greg Kroah-Hartman <email>greg@kroah.com</email> and
Kay Sievers <email>kay.sievers@vrfy.org</email>. With much help from
- Dan Stekloff <email>dsteklof@us.ibm.com</email> and many others.</para>
+ Dan Stekloff and many others.</para>
</refsect1>
<refsect1>
return rc;
}
-static int pass_env_to_socket(const char *sockname, const char *devpath, const char *action)
+static int pass_env_to_socket(const char *sockpath, const char *devpath, const char *action)
{
int sock;
struct sockaddr_un saddr;
- socklen_t addrlen;
+ socklen_t saddrlen;
+ struct stat stats;
char buf[2048];
size_t bufpos = 0;
int i;
ssize_t count;
int retval = 0;
- dbg("pass environment to socket '%s'", sockname);
+ dbg("pass environment to socket '%s'", sockpath);
sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
memset(&saddr, 0x00, sizeof(struct sockaddr_un));
saddr.sun_family = AF_LOCAL;
- /* abstract namespace only */
- strcpy(&saddr.sun_path[1], sockname);
- addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
+ if (sockpath[0] == '@') {
+ /* abstract namespace socket requested */
+ strlcpy(&saddr.sun_path[1], &sockpath[1], sizeof(saddr.sun_path)-1);
+ saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
+ } else if (stat(sockpath, &stats) == 0 && S_ISSOCK(stats.st_mode)) {
+ /* existing socket file */
+ strlcpy(saddr.sun_path, sockpath, sizeof(saddr.sun_path));
+ saddrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path);
+ } else {
+ /* no socket file, assume abstract namespace socket */
+ strlcpy(&saddr.sun_path[1], sockpath, sizeof(saddr.sun_path)-1);
+ saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
+ }
bufpos = snprintf(buf, sizeof(buf)-1, "%s@%s", action, devpath);
bufpos++;
if (bufpos > sizeof(buf))
bufpos = sizeof(buf);
- count = sendto(sock, &buf, bufpos, 0, (struct sockaddr *)&saddr, addrlen);
+ count = sendto(sock, &buf, bufpos, 0, (struct sockaddr *)&saddr, saddrlen);
if (count < 0)
retval = -1;
- info("passed %zi bytes to socket '%s', ", count, sockname);
+ info("passed %zi bytes to socket '%s', ", count, sockpath);
close(sock);
return retval;
.\" Title: udevadm
.\" Author:
-.\" Generator: DocBook XSL Stylesheets v1.73.1 <http://docbook.sf.net/>
+.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
.\" Date: November 2007
.\" Manual: udevadm
.\" Source: udev
.RE
.SS "udevadm trigger [options]"
.PP
-Request kernel device uevents, usually used to replay events at system coldplug\.
+Request device uevents, usually used to replay events at system coldplug\.
.PP
\fB\-\-verbose\fR
.RS 4
.RS 4
Do not trigger events for devices with a matching sysfs attribute\. If a value is specified along with the attribute name, the content of the attribute is matched against the given value using shell style pattern matching\. If no value is specified, the existence of the sysfs attribute is checked\. This option can be specified multiple times\.
.RE
+.PP
+\fB\-\-socket\fR\fB\fIpath\fR\fR
+.RS 4
+Pass the synthesized events to the specified socket, instead of triggering a global kernel event\. All available event values will be send in the same format the kernel sends an uevent, or
+\fBRUN+="socket:\fR\fB\fIpath\fR\fR\fB"\fR
+sends a message\. If the first character of the specified path is an @ character, an abstract namespace socket is used, instead of an existing socket file\.
+.RE
.SS "udevadm settle [options]"
.PP
Watches the udev event queue, and exits if all current events are handled\.
</refsect2>
<refsect2><title>udevadm trigger <optional>options</optional></title>
- <para>Request kernel device uevents, usually used to replay events at system coldplug.</para>
+ <para>Request device uevents, usually used to replay events at system coldplug.</para>
<variablelist>
<varlistentry>
<term><option>--verbose</option></term>
of the sysfs attribute is checked. This option can be specified multiple times.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--socket<replaceable>path</replaceable></option></term>
+ <listitem>
+ <para>Pass the synthesized events to the specified socket, instead of triggering
+ a global kernel event. All available event values will be send in the same format
+ the kernel sends an uevent, or <option>RUN+="socket:<replaceable>path</replaceable>"</option>
+ sends a message. If the first character of the specified path is an @ character,
+ an abstract namespace socket is used, instead of an existing socket file.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect2>
saddr.sun_family = AF_LOCAL;
/* use abstract namespace for socket path */
strcpy(&saddr.sun_path[1], UDEVD_CTRL_SOCK_PATH);
- addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
+ addrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
retval = sendto(sock, &ctrl_msg, sizeof(ctrl_msg), 0, (struct sockaddr *)&saddr, addrlen);
if (retval == -1) {
.\" Title: udevd
.\" Author:
-.\" Generator: DocBook XSL Stylesheets v1.73.1 <http://docbook.sf.net/>
+.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
.\" Date: August 2005
.\" Manual: udevd
.\" Source: udev
saddr.sun_family = AF_LOCAL;
/* use abstract namespace for socket path */
strcpy(&saddr.sun_path[1], UDEVD_CTRL_SOCK_PATH);
- addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
+ addrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
udevd_sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
if (udevd_sock == -1) {
saddr.sun_family = AF_LOCAL;
/* use abstract namespace for socket path */
strcpy(&saddr.sun_path[1], "/org/kernel/udev/monitor");
- addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
+ addrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
udev_monitor_sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
if (udev_monitor_sock == -1) {
}
if (sockpath != NULL) {
+ struct stat stats;
+
sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
memset(&saddr, 0x00, sizeof(struct sockaddr_un));
saddr.sun_family = AF_LOCAL;
- /* abstract namespace only */
- strlcpy(&saddr.sun_path[1], sockpath, sizeof(saddr.sun_path)-1);
- saddrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
+ if (sockpath[0] == '@') {
+ /* abstract namespace socket requested */
+ strlcpy(&saddr.sun_path[1], &sockpath[1], sizeof(saddr.sun_path)-1);
+ saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
+ } else if (stat(sockpath, &stats) == 0 && S_ISSOCK(stats.st_mode)) {
+ /* existing socket file */
+ strlcpy(saddr.sun_path, sockpath, sizeof(saddr.sun_path));
+ saddrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path);
+ } else {
+ /* no socket file, assume abstract namespace socket */
+ strlcpy(&saddr.sun_path[1], sockpath, sizeof(saddr.sun_path)-1);
+ saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
+ }
}
if (failed) {