source: project/wiki/eggref/4/udev @ 31163

Last change on this file since 31163 was 31163, checked in by Mario Domenech Goulart, 6 years ago

udev (wiki): initial documentation

File size: 4.1 KB
Line 
1== udev
2
3[[toc:]]
4
5=== Description
6
7[[http://www.freedesktop.org/software/systemd/libudev/|libudev]] bindings
8
9
10=== Author
11
12[[http://www.ossystems.com.br|O.S. Systems]], maintained by
13[[/users/mario-domenech-goulart|Mario Domenech Goulart]]
14
15
16=== Requirements
17
18None
19
20
21=== API
22
23==== udev-device record accessors
24
25<procedure>udev-device?</procedure><br>
26<procedure>udev-device-node</procedure><br>
27<procedure>udev-device-type</procedure><br>
28<procedure>udev-device-subsystem</procedure><br>
29<procedure>udev-device-action</procedure><br>
30<procedure>udev-device-syspath</procedure><br>
31<procedure>udev-device-sysname</procedure><br>
32<procedure>udev-device-sysnum</procedure><br>
33<procedure>udev-device-driver</procedure><br>
34<procedure>udev-device-properties</procedure><br>
35
36Accessors for udev-device records.
37
38
39==== Listing devices
40
41<procedure>(udev-list-devices)</procedure>
42
43Return a list of devices identified by udev, represented by
44udev-device records.
45
46
47==== Monitoring
48
49<procedure>(udev-monitor-start dispatcher #!key (polling-interval 0.2))</procedure>
50
51Start the udev monitor thread.  {{dispatcher}} is a one-argument
52procedure that is is given an udev-device record for each udev event.
53
54This procedure creates an srfi-18 thread which polls udev in
55{{polling-interval}} seconds.
56
57
58<procedure>(udev-monitor-stop! monitor)</procedure>
59
60Stop the udev monitor thread.
61
62
63===== Example:
64
65<enscript highlight=scheme>
66(use udev)
67
68(define (mountable-device? dev)
69  (and (equal? (udev-device-type dev) "partition")
70       (equal? (udev-device-subsystem dev) "block")))
71
72(define (dispatcher dev)
73  (let ((node (udev-device-node dev))
74        (action (udev-device-action dev)))
75    (when (mountable-device? dev)
76      (cond ((equal? action "add")
77             (print "Mounting " node))
78            ((equal? action "remove")
79             (print "Unmounting " node))))))
80
81(thread-join! (udev-monitor-start dispatcher))
82</enscript>
83
84
85
86==== Miscellaneous
87
88<procedure>(udev-device-parent-with-subsystem-devtype dev subsystem devtype)</procedure>
89
90Find the next parent device, with a matching subsystem and devtype
91value, and fill in information from the sys device and the udev
92database entry (from the [[http://www.freedesktop.org/software/systemd/libudev/libudev-udev-device.html#udev-device-get-parent-with-subsystem-devtype|original documentation]]).
93
94{{dev}} is an udev-device record.  {{subsystem}} and {{devtype}} are
95strings.  Returns a udev-device record.
96
97
98<procedure>(make-udev-device node subsystem type action syspath sysname sysnum driver properties)</procedure>
99
100Create a udev-device record.  This procedure is usually only useful
101for mocking udev devices.
102
103
104=== License
105
106  Copyright (c) 2014, O.S. Systems Software LTDA
107  All rights reserved.
108 
109  Redistribution and use in source and binary forms, with or without
110  modification, are permitted provided that the following conditions
111  are met:
112  1. Redistributions of source code must retain the above copyright
113     notice, this list of conditions and the following disclaimer.
114  2. Redistributions in binary form must reproduce the above copyright
115     notice, this list of conditions and the following disclaimer in the
116     documentation and/or other materials provided with the distribution.
117  3. The name of the authors may not be used to endorse or promote products
118     derived from this software without specific prior written permission.
119 
120  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
121  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
122  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
123  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
124  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
125  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
126  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
127  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
128  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
129  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
130  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
131
132
133=== Version history
134
135==== Version 0.0.1
136* Initial release
Note: See TracBrowser for help on using the repository browser.