1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="en" />
<title>s6-linux-utils: the s6-uevent-listener program</title>
<meta name="Description" content="s6-linux-utils: the s6-uevent-listener program" />
<meta name="Keywords" content="s6 linux administration root utilities devd mdev udev s6-uevent-listener uevent" />
<!-- <link rel="stylesheet" type="text/css" href="http://skarnet.org/default.css" /> -->
</head>
<body>
<p>
<a href="index.html">s6-linux-utils</a><br />
<a href="http://skarnet.org/software/">Software</a><br />
<a href="http://skarnet.org/">skarnet.org</a>
</p>
<h1> The <tt>s6-uevent-listener</tt> program </h1>
<p>
<tt>s6-uevent-listener</tt> listens to the netlink interface for uevents
(also called "hotplug" or "udev" events), and writes those uevents to
its standard output, using a simple format.
</p>
<h2> Interface </h2>
<pre>
s6-uevent-listener [ -v <em>verbosity</em> ] [ -b kbufsz ]
</pre>
<ul>
<li> s6-uevent-listener binds to the netlink interface and listens for
hotplug events, as the <em>udev</em> program does. </li>
<li> It writes event information to its stdout. The output contains
null characters, so a terminal will not display them correctly. To
properly use s6-uevent-listener, it should be piped into a handler
program such as
<a href="s6-uevent-spawner.html">s6-uevent-spawner</a> or
<a href="mdevd.html">mdevd</a>. </li>
<li> s6-uevent-listener is a long-lived program.
When it receives a SIGTERM, it stops listening; it will
exit as soon as it has flushed its event queue to stdout. </li>
</ul>
<h2> Options </h2>
<ul>
<li> <tt>-v</tt> <em>verbosity</em> : be more or less verbose.
Default verbosity is 1. 0 will only print fatal error messages, 3 will
print warnings every time the netlink interface sends something
unexpected. </li>
<li> <tt>-b</tt> <em>kbufsz</em> : try and reserve a kernel buffer of
<em>kbufsz</em> bytes for the netlink queue. Too large a buffer wastes kernel memory;
too small a buffer risks losing events. The default is 65536 (which is on
the large side). </li>
</ul>
<h2> Protocol </h2>
<ul>
<li> An event is a series of null-terminated strings as they are sent by
the kernel to the netlink; s6-uevent-listener adds a final empty string
(i.e. an additional null character) to mark the end of the series. </li>
<li> The first string is a short description of the event; it normally
contains the string "@/". Other strings after the first are of the form
"VARIABLE=value", and describe the environment which a hotplug helper
for the event (registered in <tt>/proc/sys/kernel/hotplug</tt>) would be
spawned with. </li>
<li> Example (newlines added for clarity): <pre>
add@/class/input/input9/mouse2\0
ACTION=add\0
DEVPATH=/class/input/input9/mouse2\0
SUBSYSTEM=input\0
SEQNUM=106\0
PHYSDEVPATH=/devices/pci0000:00/0000:00:1d.1/usb2/22/22:1.0
PHYSDEVBUS=usb\0
PHYSDEVDRIVER=usbhid\0
MAJOR=13\0
MINOR=34\0
\0 </pre> </li>
</ul>
<h2> Notes </h2>
<ul>
<li> s6-uevent-listener is a daemon; it should be run under a proper supervision system such
as <a href="http://skarnet.org/software/s6/">s6</a>. </li>
<li> If you are running s6-uevent-listener, <em>prog...</em> should be the
only program handling uevents, which means that
<tt>/proc/sys/kernel/hotplug</tt> should be empty. </li>
<li> Examples of valid uses of s6-uevent-listener:
<ul>
<li> <tt>s6-uevent-listener | s6-uevent-spawner mdev</tt> </li>
<li> <tt>s6-uevent-listener | mdevd</tt> </li>
<li> Those examples can be made safer by using a supervision system:
under <a href="http://skarnet.org/software/s6/">s6</a> or
<a href="http://skarnet.org/software/s6-rc/">s6-rc</a>, write a service
pipeline where <tt>s6-uevent-listener</tt> is a producer and
<tt>s6-uevent-spawner mdev</tt> or <tt>mdevd</tt> is a consumer. This
setup has the advantage, among others, that you can restart the netlink
listener and the event handler separately. </li>
</ul>
</li>
</ul>
</body>
</html>
|