2 * Copyright (c) 2010 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Alex Hornung <ahornung@gmail.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/queue.h>
35 #include <libprop/proplib.h>
36 #include <cpu/atomic.h>
39 struct udev_enumerate;
40 struct udev_list_entry;
44 struct udev *udev_new(void);
45 struct udev *udev_ref(struct udev *udev_ctx);
46 void udev_unref(struct udev *udev_ctx);
47 const char *udev_get_dev_path(struct udev *udev_ctx);
48 void *udev_get_userdata(struct udev *udev_ctx);
49 void udev_set_userdata(struct udev *udev_ctx, void *userdata);
50 int udev_get_fd(struct udev *udev_ctx);
52 struct udev_device *udev_device_new_from_dictionary(struct udev *udev_ctx, prop_dictionary_t dict);
53 struct udev_device *udev_device_ref(struct udev_device *udev_device);
54 void udev_device_unref(struct udev_device *udev_device);
55 prop_dictionary_t udev_device_get_dictionary(struct udev_device *udev_device);
56 struct udev *udev_device_get_udev(struct udev_device *udev_device);
57 void udev_device_set_action(struct udev_device *udev_device, int action);
58 const char *udev_device_get_action(struct udev_device *udev_device);
59 dev_t udev_device_get_devnum(struct udev_device *udev_device);
60 const char *udev_device_get_devnode(struct udev_device *udev_device);
61 const char *udev_device_get_property_value(struct udev_device *udev_device,
63 const char *udev_device_get_subsystem(struct udev_device *udev_device);
64 const char *udev_device_get_driver(struct udev_device *udev_device);
65 uint64_t udev_device_get_kptr(struct udev_device *udev_device);
66 int32_t udev_device_get_major(struct udev_device *udev_device);
67 int32_t udev_device_get_minor(struct udev_device *udev_device);
69 struct udev_enumerate *udev_enumerate_new(struct udev *udev_ctx);
70 struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enum);
71 void udev_enumerate_unref(struct udev_enumerate *udev_enum);
72 struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enum);
73 int udev_enumerate_scan_devices(struct udev_enumerate *udev_enum);
74 struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enum);
75 #define udev_list_entry_foreach(list_entry, first_entry) \
76 for(list_entry = first_entry; \
78 list_entry = udev_list_entry_get_next(list_entry))
79 prop_array_t udev_enumerate_get_array(struct udev_enumerate *udev_enum);
80 struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry);
81 prop_dictionary_t udev_list_entry_get_dictionary(struct udev_list_entry *list_entry);
82 struct udev_device *udev_list_entry_get_device(struct udev_list_entry *list_entry);
83 int _udev_enumerate_filter_add_match_gen(struct udev_enumerate *udev_enum,
88 int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enum,
89 const char *subsystem);
90 int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enum,
91 const char *subsystem);
92 int udev_enumerate_add_match_expr(struct udev_enumerate *udev_enum,
95 int udev_enumerate_add_nomatch_expr(struct udev_enumerate *udev_enum,
98 int udev_enumerate_add_match_regex(struct udev_enumerate *udev_enum,
101 int udev_enumerate_add_nomatch_regex(struct udev_enumerate *udev_enum,
104 #define udev_enumerate_add_match_property(a, b) \
105 udev_enumerate_add_match_expr((a), __DECONST(char *, (b)))
107 #define udev_enumerate_add_nomatch_property(a, b) \
108 udev_enumerate_add_nomatch_expr((a), __DECONST(char *, (b)))
110 struct udev_monitor *udev_monitor_new(struct udev *udev_ctx);
111 struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor);
112 void udev_monitor_unref(struct udev_monitor *udev_monitor);
113 struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor);
114 int udev_monitor_get_fd(struct udev_monitor *udev_monitor);
115 struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monitor);
116 int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor);
117 int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor,
118 const char *subsystem,
119 const char *devtype);
120 int udev_monitor_filter_add_match_expr(struct udev_monitor *udev_monitor,
123 int udev_monitor_filter_add_nomatch_expr(struct udev_monitor *udev_monitor,
126 int udev_monitor_filter_add_match_regex(struct udev_monitor *udev_monitor,
129 int udev_monitor_filter_add_nomatch_regex(struct udev_monitor *udev_monitor,
132 int _udev_monitor_filter_add_match_gen(struct udev_monitor *udev_monitor,
137 int _udev_filter_add_match_gen(prop_array_t filters,
143 int send_xml(int s, char *xml);
144 int read_xml(int s, char *buf, size_t buf_sz);
145 int _udev_dict_set_cstr(prop_dictionary_t dict, const char *key, char *str);
146 int _udev_dict_set_int(prop_dictionary_t dict, const char *key, int64_t val);
147 int _udev_dict_set_uint(prop_dictionary_t dict, const char *key, uint64_t val);
148 int conn_local_server(const char *sockfile, int socktype, int nonblock,
150 prop_dictionary_t udevd_get_command_dict(char *command);
151 prop_array_t udevd_request_devs(int s, prop_array_t filters);