2 * libudev - interface to udev device information
4 * Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _LIBUDEV_PRIVATE_H_
21 #define _LIBUDEV_PRIVATE_H_
28 #define dbg(udev, arg...) \
29 udev_log(udev, LOG_DEBUG, __FILE__, __LINE__, __FUNCTION__, ## arg)
31 #define dbg(format, arg...) do { } while (0)
32 #endif /* USE_DEBUG */
34 #define info(udev, arg...) \
35 udev_log(udev, LOG_INFO, __FILE__, __LINE__, __FUNCTION__, ## arg)
37 #define err(udev, arg...) \
38 udev_log(udev, LOG_ERR, __FILE__, __LINE__, __FUNCTION__, ## arg)
40 #define dbg(format, arg...) do { } while (0)
41 #define info(format, arg...) do { } while (0)
42 #define err(format, arg...) do { } while (0)
46 void udev_log(struct udev *udev,
47 int priority, const char *file, int line, const char *fn,
48 const char *format, ...)
49 __attribute__ ((format(printf, 6, 7)));
50 extern struct udev_device *device_init(struct udev *udev);
51 extern const char *udev_get_rules_path(struct udev *udev);
52 extern int udev_get_run(struct udev *udev);
55 extern int device_set_syspath(struct udev_device *udev_device, const char *syspath);
56 extern int device_set_subsystem(struct udev_device *udev_device, const char *subsystem);
57 extern int device_set_devnode(struct udev_device *udev_device, const char *devnode);
58 extern int device_add_devlink(struct udev_device *udev_device, const char *devlink);
59 extern int device_add_property(struct udev_device *udev_device, const char *key, const char *value);
60 extern int device_add_property_from_string(struct udev_device *udev_device, const char *property);
61 extern int device_set_action(struct udev_device *udev_device, const char *action);
62 extern int device_set_driver(struct udev_device *udev_device, const char *driver);
63 extern const char *device_get_devpath_old(struct udev_device *udev_device);
64 extern int device_set_devpath_old(struct udev_device *udev_device, const char *devpath_old);
65 extern const char *device_get_physdevpath(struct udev_device *udev_device);
66 extern int device_set_physdevpath(struct udev_device *udev_device, const char *physdevpath);
67 extern int device_get_timeout(struct udev_device *udev_device);
68 extern int device_set_timeout(struct udev_device *udev_device, int timeout);
69 extern int device_get_event_timeout(struct udev_device *udev_device);
70 extern int device_set_event_timeout(struct udev_device *udev_device, int event_timeout);
71 extern int device_set_devnum(struct udev_device *udev_device, dev_t devnum);
72 extern int device_set_seqnum(struct udev_device *udev_device, unsigned long long int seqnum);
73 extern int device_get_num_fake_partitions(struct udev_device *udev_device);
74 extern int device_set_num_fake_partitions(struct udev_device *udev_device, int num);
75 extern int device_get_devlink_priority(struct udev_device *udev_device);
76 extern int device_set_devlink_priority(struct udev_device *udev_device, int prio);
77 extern int device_get_ignore_remove(struct udev_device *udev_device);
78 extern int device_set_ignore_remove(struct udev_device *udev_device, int ignore);
79 extern void device_set_info_loaded(struct udev_device *device);
81 /* libudev-ctrl - daemon runtime setup */
83 extern struct udev_ctrl *udev_ctrl_new_from_socket(struct udev *udev, const char *socket_path);
84 extern int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl);
85 extern struct udev_ctrl *udev_ctrl_ref(struct udev_ctrl *uctrl);
86 extern void udev_ctrl_unref(struct udev_ctrl *uctrl);
87 extern struct udev *udev_ctrl_get_udev(struct udev_ctrl *uctrl);
88 extern int udev_ctrl_get_fd(struct udev_ctrl *uctrl);
89 extern int udev_ctrl_send_set_log_level(struct udev_ctrl *uctrl, int priority);
90 extern int udev_ctrl_send_stop_exec_queue(struct udev_ctrl *uctrl);
91 extern int udev_ctrl_send_start_exec_queue(struct udev_ctrl *uctrl);
92 extern int udev_ctrl_send_reload_rules(struct udev_ctrl *uctrl);
93 extern int udev_ctrl_send_set_env(struct udev_ctrl *uctrl, const char *key);
94 extern int udev_ctrl_send_set_max_childs(struct udev_ctrl *uctrl, int count);
96 extern struct udev_ctrl_msg *udev_ctrl_msg(struct udev_ctrl *uctrl);
97 extern struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl *uctrl);
98 extern struct udev_ctrl_msg *udev_ctrl_msg_ref(struct udev_ctrl_msg *ctrl_msg);
99 extern void udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg);
100 extern int udev_ctrl_get_set_log_level(struct udev_ctrl_msg *ctrl_msg);
101 extern int udev_ctrl_get_stop_exec_queue(struct udev_ctrl_msg *ctrl_msg);
102 extern int udev_ctrl_get_start_exec_queue(struct udev_ctrl_msg *ctrl_msg);
103 extern int udev_ctrl_get_reload_rules(struct udev_ctrl_msg *ctrl_msg);
104 extern const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg);
105 extern int udev_ctrl_get_set_max_childs(struct udev_ctrl_msg *ctrl_msg);
109 struct list_node *next, *prev;
111 extern void list_init(struct list_node *list);
112 extern void list_cleanup(struct udev *udev, struct list_node *name_list);
113 extern struct udev_list_entry *list_entry_add(struct udev *udev, struct list_node *list,
114 const char *name, const char *value,
115 int unique, int sort);
116 extern void list_entry_remove(struct udev_list_entry *entry);
117 extern struct udev_list_entry *list_get_entry(struct list_node *list);
118 extern void list_entry_move_to_end(struct udev_list_entry *list_entry);
119 #define list_entry_foreach_safe(entry, tmp, first) \
120 for (entry = first, \
121 tmp = udev_list_entry_get_next(entry); \
123 entry = tmp, tmp = udev_list_entry_get_next(tmp))
126 #define UTIL_PATH_SIZE 1024
127 #define UTIL_LINE_SIZE 2048
128 #define UTIL_NAME_SIZE 512
129 extern ssize_t util_get_sys_subsystem(struct udev *udev, const char *syspath, char *subsystem, size_t size);
130 extern ssize_t util_get_sys_driver(struct udev *udev, const char *syspath, char *driver, size_t size);
131 extern int util_resolve_sys_link(struct udev *udev, char *syspath, size_t size);
132 extern int util_log_priority(const char *priority);
133 extern size_t util_path_encode(char *s, size_t len);
134 extern size_t util_path_decode(char *s);
135 extern void util_remove_trailing_chars(char *path, char c);
136 extern size_t util_strlcpy(char *dst, const char *src, size_t size);
137 extern size_t util_strlcat(char *dst, const char *src, size_t size);
138 extern int util_replace_chars(char *str, const char *white);