| 1 | package Udev::FFI::Functions; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | our (@ISA, @EXPORT_OK, %EXPORT_TAGS); | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | require Exporter; | |||||||||||||||||||||||||||
| 9 | 3 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use IPC::Cmd qw(can_run); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use FFI::Platypus; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use FFI::CheckLib; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | use constant { | ||||||||||||||||||||||||||||
| 18 | 3 | UDEVADM_LOCATIONS => [ | |||||||||||||||||||||||||||
| 19 | '/bin/udevadm', | ||||||||||||||||||||||||||||
| 20 | '/sbin/udevadm' | ||||||||||||||||||||||||||||
| 21 | ] | ||||||||||||||||||||||||||||
| 22 | 3 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 3 | my $FUNCTIONS = { | |||||||||||||||||||||||||||
| 27 | # struct udev *udev_new(void); | ||||||||||||||||||||||||||||
| 28 | 'udev_new' => { | ||||||||||||||||||||||||||||
| 29 | ffi_data => [ [], 'opaque' ] | ||||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # struct udev *udev_ref(struct udev *udev); | ||||||||||||||||||||||||||||
| 33 | 'udev_ref' => { | ||||||||||||||||||||||||||||
| 34 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 35 | }, | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # struct udev *udev_unref(struct udev *udev); | ||||||||||||||||||||||||||||
| 38 | 'udev_unref' => { | ||||||||||||||||||||||||||||
| 39 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # access to libudev generated lists ==================================== | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry); | ||||||||||||||||||||||||||||
| 45 | 'udev_list_entry_get_next' => { | ||||||||||||||||||||||||||||
| 46 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name); | ||||||||||||||||||||||||||||
| 50 | 'udev_list_entry_get_by_name' => { | ||||||||||||||||||||||||||||
| 51 | ffi_data => [ ['opaque', 'string'], 'opaque'] | ||||||||||||||||||||||||||||
| 52 | }, | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # const char *udev_list_entry_get_name(struct udev_list_entry *list_entry); | ||||||||||||||||||||||||||||
| 55 | 'udev_list_entry_get_name' => { | ||||||||||||||||||||||||||||
| 56 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 57 | }, | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # const char *udev_list_entry_get_value(struct udev_list_entry *list_entry); | ||||||||||||||||||||||||||||
| 60 | 'udev_list_entry_get_value' => { | ||||||||||||||||||||||||||||
| 61 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # udev_device ========================================================== | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # struct udev_device *udev_device_ref(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 68 | 'udev_device_ref' => { | ||||||||||||||||||||||||||||
| 69 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # struct udev_device *udev_device_unref(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 73 | 'udev_device_unref' => { | ||||||||||||||||||||||||||||
| 74 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 75 | }, | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # struct udev *udev_device_get_udev(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 78 | 'udev_device_get_udev' => { | ||||||||||||||||||||||||||||
| 79 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 80 | }, | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath); | ||||||||||||||||||||||||||||
| 83 | 'udev_device_new_from_syspath' => { | ||||||||||||||||||||||||||||
| 84 | ffi_data => [ ['opaque', 'string'], 'opaque' ] | ||||||||||||||||||||||||||||
| 85 | }, | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | # struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum); | ||||||||||||||||||||||||||||
| 88 | 'udev_device_new_from_devnum' => { | ||||||||||||||||||||||||||||
| 89 | ffi_data => [ ['opaque', 'signed char', 'dev_t'], 'opaque' ] | ||||||||||||||||||||||||||||
| 90 | }, | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | # struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname); | ||||||||||||||||||||||||||||
| 93 | 'udev_device_new_from_subsystem_sysname' => { | ||||||||||||||||||||||||||||
| 94 | ffi_data => [ ['opaque', 'string', 'string'], 'opaque' ] | ||||||||||||||||||||||||||||
| 95 | }, | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | # struct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id); | ||||||||||||||||||||||||||||
| 98 | 'udev_device_new_from_device_id' => { | ||||||||||||||||||||||||||||
| 99 | ffi_data => [ ['opaque', 'string'], 'opaque' ], | ||||||||||||||||||||||||||||
| 100 | since => 189 | ||||||||||||||||||||||||||||
| 101 | }, | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # struct udev_device *udev_device_new_from_environment(struct udev *udev); | ||||||||||||||||||||||||||||
| 104 | 'udev_device_new_from_environment' => { | ||||||||||||||||||||||||||||
| 105 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 106 | }, | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | # struct udev_device *udev_device_get_parent(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 109 | 'udev_device_get_parent' => { | ||||||||||||||||||||||||||||
| 110 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 111 | }, | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | # struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, | ||||||||||||||||||||||||||||
| 114 | # const char *subsystem, const char *devtype); | ||||||||||||||||||||||||||||
| 115 | 'udev_device_get_parent_with_subsystem_devtype' => { | ||||||||||||||||||||||||||||
| 116 | ffi_data => [ ['opaque', 'string', 'string'], 'opaque' ] | ||||||||||||||||||||||||||||
| 117 | }, | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | # retrieve device properties | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | # const char *udev_device_get_devpath(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 122 | 'udev_device_get_devpath' => { | ||||||||||||||||||||||||||||
| 123 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 124 | }, | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # const char *udev_device_get_subsystem(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 127 | 'udev_device_get_subsystem' => { | ||||||||||||||||||||||||||||
| 128 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 129 | }, | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | # const char *udev_device_get_devtype(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 132 | 'udev_device_get_devtype' => { | ||||||||||||||||||||||||||||
| 133 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 134 | }, | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | # const char *udev_device_get_syspath(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 137 | 'udev_device_get_syspath' => { | ||||||||||||||||||||||||||||
| 138 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 139 | }, | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | # const char *udev_device_get_sysname(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 142 | 'udev_device_get_sysname' => { | ||||||||||||||||||||||||||||
| 143 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 144 | }, | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | # const char *udev_device_get_sysnum(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 147 | 'udev_device_get_sysnum' => { | ||||||||||||||||||||||||||||
| 148 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 149 | }, | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | # const char *udev_device_get_devnode(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 152 | 'udev_device_get_devnode' => { | ||||||||||||||||||||||||||||
| 153 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 154 | }, | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | #int udev_device_get_is_initialized(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 157 | 'udev_device_get_is_initialized' => { | ||||||||||||||||||||||||||||
| 158 | ffi_data => [ ['opaque'], 'int' ] | ||||||||||||||||||||||||||||
| 159 | }, | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | # struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 162 | 'udev_device_get_devlinks_list_entry' => { | ||||||||||||||||||||||||||||
| 163 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 164 | }, | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | # struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 167 | 'udev_device_get_properties_list_entry' => { | ||||||||||||||||||||||||||||
| 168 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 169 | }, | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | # struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 172 | 'udev_device_get_tags_list_entry' => { | ||||||||||||||||||||||||||||
| 173 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 174 | }, | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 177 | 'udev_device_get_sysattr_list_entry' => { | ||||||||||||||||||||||||||||
| 178 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 179 | }, | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | #const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key); | ||||||||||||||||||||||||||||
| 182 | 'udev_device_get_property_value' => { | ||||||||||||||||||||||||||||
| 183 | ffi_data => [ ['opaque', 'string'], 'string' ] | ||||||||||||||||||||||||||||
| 184 | }, | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | #const char *udev_device_get_driver(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 187 | 'udev_device_get_driver' => { | ||||||||||||||||||||||||||||
| 188 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 189 | }, | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | # dev_t udev_device_get_devnum(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 192 | 'udev_device_get_devnum' => { | ||||||||||||||||||||||||||||
| 193 | ffi_data => [ ['opaque'], 'dev_t' ] | ||||||||||||||||||||||||||||
| 194 | }, | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | #const char *udev_device_get_action(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 197 | 'udev_device_get_action' => { | ||||||||||||||||||||||||||||
| 198 | ffi_data => [ ['opaque'], 'string' ] | ||||||||||||||||||||||||||||
| 199 | }, | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | #unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 202 | 'udev_device_get_seqnum' => { | ||||||||||||||||||||||||||||
| 203 | ffi_data => [ ['opaque'], 'unsigned long long' ] | ||||||||||||||||||||||||||||
| 204 | }, | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | #unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device); | ||||||||||||||||||||||||||||
| 207 | 'udev_device_get_usec_since_initialized' => { | ||||||||||||||||||||||||||||
| 208 | ffi_data => [ ['opaque'], 'unsigned long long' ] | ||||||||||||||||||||||||||||
| 209 | }, | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | #const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr); | ||||||||||||||||||||||||||||
| 212 | 'udev_device_get_sysattr_value' => { | ||||||||||||||||||||||||||||
| 213 | ffi_data => [ ['opaque', 'string'], 'string' ] | ||||||||||||||||||||||||||||
| 214 | }, | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | #int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value); | ||||||||||||||||||||||||||||
| 217 | 'udev_device_set_sysattr_value' => { | ||||||||||||||||||||||||||||
| 218 | ffi_data => [ ['opaque', 'string', 'string'], 'int' ], | ||||||||||||||||||||||||||||
| 219 | since => 199 | ||||||||||||||||||||||||||||
| 220 | }, | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | #int udev_device_has_tag(struct udev_device *udev_device, const char *tag); | ||||||||||||||||||||||||||||
| 223 | 'udev_device_has_tag' => { | ||||||||||||||||||||||||||||
| 224 | ffi_data => [ ['opaque', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 225 | }, | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | # udev_monitor ========================================================= | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | # access to kernel uevents and udev events | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | # struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor); | ||||||||||||||||||||||||||||
| 233 | 'udev_monitor_ref' => { | ||||||||||||||||||||||||||||
| 234 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 235 | }, | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | # struct udev_monitor *udev_monitor_unref(struct udev_monitor *udev_monitor); | ||||||||||||||||||||||||||||
| 238 | 'udev_monitor_unref' => { | ||||||||||||||||||||||||||||
| 239 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 240 | }, | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | # struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor); | ||||||||||||||||||||||||||||
| 243 | 'udev_monitor_get_udev' => { | ||||||||||||||||||||||||||||
| 244 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 245 | }, | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | #kernel and udev generated events over netlink | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | # struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name); | ||||||||||||||||||||||||||||
| 250 | 'udev_monitor_new_from_netlink' => { | ||||||||||||||||||||||||||||
| 251 | ffi_data => [ ['opaque', 'string'], 'opaque' ] | ||||||||||||||||||||||||||||
| 252 | }, | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | # bind socket | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | # int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor); | ||||||||||||||||||||||||||||
| 257 | 'udev_monitor_enable_receiving' => { | ||||||||||||||||||||||||||||
| 258 | ffi_data => [ ['opaque'], 'int' ] | ||||||||||||||||||||||||||||
| 259 | }, | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | # int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size); | ||||||||||||||||||||||||||||
| 262 | 'udev_monitor_set_receive_buffer_size' => { | ||||||||||||||||||||||||||||
| 263 | ffi_data => [ ['opaque', 'int'], 'int' ] | ||||||||||||||||||||||||||||
| 264 | }, | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | # int udev_monitor_get_fd(struct udev_monitor *udev_monitor); | ||||||||||||||||||||||||||||
| 267 | 'udev_monitor_get_fd' => { | ||||||||||||||||||||||||||||
| 268 | ffi_data => [ ['opaque'], 'int' ] | ||||||||||||||||||||||||||||
| 269 | }, | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | # struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monitor); | ||||||||||||||||||||||||||||
| 272 | 'udev_monitor_receive_device' => { | ||||||||||||||||||||||||||||
| 273 | ffi_data => [ ['opaque'], 'opaque'] | ||||||||||||||||||||||||||||
| 274 | }, | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | # n-kernel socket filters to select messages that get delivered to a listener | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | # int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor, | ||||||||||||||||||||||||||||
| 279 | # const char *subsystem, const char *devtype); | ||||||||||||||||||||||||||||
| 280 | 'udev_monitor_filter_add_match_subsystem_devtype' => { | ||||||||||||||||||||||||||||
| 281 | ffi_data => [ ['opaque', 'string', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 282 | }, | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | # int udev_monitor_filter_add_match_tag(struct udev_monitor *udev_monitor, const char *tag); | ||||||||||||||||||||||||||||
| 285 | 'udev_monitor_filter_add_match_tag' => { | ||||||||||||||||||||||||||||
| 286 | ffi_data => [ ['opaque', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 287 | }, | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | # int udev_monitor_filter_update(struct udev_monitor *udev_monitor); | ||||||||||||||||||||||||||||
| 290 | 'udev_monitor_filter_update' => { | ||||||||||||||||||||||||||||
| 291 | ffi_data => [ ['opaque'], 'int' ] | ||||||||||||||||||||||||||||
| 292 | }, | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | # int udev_monitor_filter_remove(struct udev_monitor *udev_monitor); | ||||||||||||||||||||||||||||
| 295 | 'udev_monitor_filter_remove' => { | ||||||||||||||||||||||||||||
| 296 | ffi_data => [ ['opaque'], 'int' ] | ||||||||||||||||||||||||||||
| 297 | }, | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | # udev_enumerate ======================================================= | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | # search sysfs for specific devices and provide a sorted list | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | # struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enumerate); | ||||||||||||||||||||||||||||
| 305 | 'udev_enumerate_ref' => { | ||||||||||||||||||||||||||||
| 306 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 307 | }, | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | # struct udev_enumerate *udev_enumerate_unref(struct udev_enumerate *udev_enumerate); | ||||||||||||||||||||||||||||
| 310 | 'udev_enumerate_unref' => { | ||||||||||||||||||||||||||||
| 311 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 312 | }, | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | # struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate); | ||||||||||||||||||||||||||||
| 315 | 'udev_enumerate_get_udev' => { | ||||||||||||||||||||||||||||
| 316 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 317 | }, | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | # struct udev_enumerate *udev_enumerate_new(struct udev *udev); | ||||||||||||||||||||||||||||
| 320 | 'udev_enumerate_new' => { | ||||||||||||||||||||||||||||
| 321 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 322 | }, | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | # device properties filter | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | # int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem); | ||||||||||||||||||||||||||||
| 327 | 'udev_enumerate_add_match_subsystem' => { | ||||||||||||||||||||||||||||
| 328 | ffi_data => [ ['opaque', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 329 | }, | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | # int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem); | ||||||||||||||||||||||||||||
| 332 | 'udev_enumerate_add_nomatch_subsystem' => { | ||||||||||||||||||||||||||||
| 333 | ffi_data => [ ['opaque', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 334 | }, | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | # int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value); | ||||||||||||||||||||||||||||
| 337 | 'udev_enumerate_add_match_sysattr' => { | ||||||||||||||||||||||||||||
| 338 | ffi_data => [ ['opaque', 'string', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 339 | }, | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | # int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value); | ||||||||||||||||||||||||||||
| 342 | 'udev_enumerate_add_nomatch_sysattr' => { | ||||||||||||||||||||||||||||
| 343 | ffi_data => [ ['opaque', 'string', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 344 | }, | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | # int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value); | ||||||||||||||||||||||||||||
| 347 | 'udev_enumerate_add_match_property' => { | ||||||||||||||||||||||||||||
| 348 | ffi_data => [ ['opaque', 'string', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 349 | }, | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | # int udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname); | ||||||||||||||||||||||||||||
| 352 | 'udev_enumerate_add_match_sysname' => { | ||||||||||||||||||||||||||||
| 353 | ffi_data => [ ['opaque', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 354 | }, | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | # int udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag); | ||||||||||||||||||||||||||||
| 357 | 'udev_enumerate_add_match_tag' => { | ||||||||||||||||||||||||||||
| 358 | ffi_data => [ ['opaque', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 359 | }, | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | # int udev_enumerate_add_match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *parent); | ||||||||||||||||||||||||||||
| 362 | 'udev_enumerate_add_match_parent' => { | ||||||||||||||||||||||||||||
| 363 | ffi_data => [ ['opaque', 'opaque'], 'int' ] | ||||||||||||||||||||||||||||
| 364 | }, | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | # int udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev_enumerate); | ||||||||||||||||||||||||||||
| 367 | 'udev_enumerate_add_match_is_initialized' => { | ||||||||||||||||||||||||||||
| 368 | ffi_data => [ ['opaque'], 'int' ] | ||||||||||||||||||||||||||||
| 369 | }, | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | # int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath); | ||||||||||||||||||||||||||||
| 372 | 'udev_enumerate_add_syspath' => { | ||||||||||||||||||||||||||||
| 373 | ffi_data => [ ['opaque', 'string'], 'int' ] | ||||||||||||||||||||||||||||
| 374 | }, | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | # run enumeration with active filters | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | # int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate); | ||||||||||||||||||||||||||||
| 379 | 'udev_enumerate_scan_devices' => { | ||||||||||||||||||||||||||||
| 380 | ffi_data => [ ['opaque'], 'int' ] | ||||||||||||||||||||||||||||
| 381 | }, | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | # int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate); | ||||||||||||||||||||||||||||
| 384 | 'udev_enumerate_scan_subsystems' => { | ||||||||||||||||||||||||||||
| 385 | ffi_data => [ ['opaque'], 'int' ] | ||||||||||||||||||||||||||||
| 386 | }, | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | # return device list | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | # struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate); | ||||||||||||||||||||||||||||
| 391 | 'udev_enumerate_get_list_entry' => { | ||||||||||||||||||||||||||||
| 392 | ffi_data => [ ['opaque'], 'opaque' ] | ||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | }; | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 3 | @EXPORT_OK = ( keys(%$FUNCTIONS), qw(get_entries)); | |||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 3 | %EXPORT_TAGS = ( | |||||||||||||||||||||||||||
| 401 | 'all' => \@EXPORT_OK | ||||||||||||||||||||||||||||
| 402 | ); | ||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 3 | my $init = 0; | |||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | sub udev_version { | ||||||||||||||||||||||||||||
| 410 | 3 | ▶ | my $full_path = can_run('udevadm'); | ||||||||||||||||||||||||||
|
Subroutine
udev_version: called CC=8 SCAR=32.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | 3 | ▶ | if(!defined $full_path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 413 | 3 | for(@{ +UDEVADM_LOCATIONS }) { | |||||||||||||||||||||||||||
| 414 | 6 | ▶ | if(-f) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | 0 | $full_path = $_; | |||||||||||||||||||||||||||
| 416 | 0 | last; | |||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 3 | ▶ | if(!defined $full_path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 422 | 3 | $@ = "Can't find `udevadm` utility"; | |||||||||||||||||||||||||||
| 423 | 3 | return undef; | |||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | { | ||||||||||||||||||||||||||||
| 428 | 0 | ▶ | local $SIG{__WARN__} = sub {}; # silence shell output if error | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 0 | ▶ | if(open my $ph, '-|', $full_path, '--version') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 431 | 0 | my $out = <$ph>; | |||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | 0 | ▶ | if(defined($out) && $out =~ /^(\d+)\s*$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $out and $out =~ /^(\d+)\s*$/
MC/DC0%0/2
defined $out and $out =~ /^(\d+)\s*$/
defined $out
$out =~ /^(\d+)\s*$/
Truth table0%0/3
A and B
A= defined $outB= $out =~ /^(\d+)\s*$/
| |||||||||||||||||||||||||||||
| 434 | 0 | return $1; | |||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | 0 | $@ = "Can't get udev version from `udevadm` utility"; | |||||||||||||||||||||||||||
| 438 | 0 | return undef; | |||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | 0 | $@ = "Can't run `udevadm` utility"; | |||||||||||||||||||||||||||
| 443 | 0 | return undef; | |||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | my $_function_not_attach = sub { | ||||||||||||||||||||||||||||
| 449 | 0 | ▶ | my $udev_version = udev_version(); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | 0 | ▶ | die "Function '".$_[0]."' not attached from udev library\n". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 452 | "`udevadm` version: ".(defined($udev_version) ?$udev_version :'unknown')."\n"; | ||||||||||||||||||||||||||||
| 453 | 3 | }; | |||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | sub get_entries { | ||||||||||||||||||||||||||||
| 458 | 0 | ▶ | my $entry = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_entries: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | 0 | ▶ | if(wantarray) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 461 | 0 | my @a = (); | |||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | 0 | ▶ | while(defined($entry)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 464 | 0 | push @a, udev_list_entry_get_name($entry); | |||||||||||||||||||||||||||
| 465 | 0 | $entry = udev_list_entry_get_next($entry); | |||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | 0 | return @a; | |||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | 0 | my %h = (); | |||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | 0 | ▶ | while(defined($entry)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 0 | $h{ udev_list_entry_get_name($entry) } = udev_list_entry_get_value($entry); | |||||||||||||||||||||||||||
| 476 | 0 | $entry = udev_list_entry_get_next($entry); | |||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | 0 | return \%h; | |||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | sub init { | ||||||||||||||||||||||||||||
| 485 | 2 | ▶ | return 1 if $init; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=10 SCAR=31.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | 2 | my ($libudev) = find_lib( | |||||||||||||||||||||||||||
| 489 | lib => 'udev' | ||||||||||||||||||||||||||||
| 490 | ); | ||||||||||||||||||||||||||||
| 491 | 2 | ▶ | if(!$libudev) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 492 | 0 | $@ = "Can't find udev library"; | |||||||||||||||||||||||||||
| 493 | 0 | return 0; | |||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | 2 | ▶ | my $udev_version = udev_version() || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
udev_version() || 0
MC/DC0%0/1
udev_version() || 0
udev_version()
Truth table50%1/2
A
A= udev_version()
| |||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 2 | my $ffi = FFI::Platypus->new; | |||||||||||||||||||||||||||
| 499 | 2 | $ffi->lib($libudev); | |||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | 2 | ▶ | if(!$ffi->type('dev_t')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 502 | 0 | $@ = "Can't find \"dev_t\" type"; | |||||||||||||||||||||||||||
| 503 | 0 | return 0; | |||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | 2 | for my $funct (keys %$FUNCTIONS) { | |||||||||||||||||||||||||||
| 507 | 134 | eval { | |||||||||||||||||||||||||||
| 508 | # attach locks the function and the FFI::Platypus instance into memory permanently, | ||||||||||||||||||||||||||||
| 509 | # since there is no way to deallocate an xsub | ||||||||||||||||||||||||||||
| 510 | 134 | $ffi->attach($funct => $FUNCTIONS->{$funct}{ffi_data}[0] => $FUNCTIONS->{$funct}{ffi_data}[1]); | |||||||||||||||||||||||||||
| 511 | }; | ||||||||||||||||||||||||||||
| 512 | 134 | ▶ | if($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 513 | 0 | ▶ | if(!exists($FUNCTIONS->{$funct}{since}) || $udev_version >= $FUNCTIONS->{$funct}{since}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $FUNCTIONS->{$funct}{"since"} or $udev_version >= $FUNCTIONS->{$funct}{"since"}
MC/DC0%0/2
not exists $FUNCTIONS->{$funct}{"since"} or $udev_version >= $FUNCTIONS->{$funct}{"since"}
not exists $FUNCTIONS->{$funct}{"since"}
$udev_version >= $FUNCTIONS->{$funct}{"since"}
Truth table0%0/3
not(A) or B
A= not exists $FUNCTIONS->{$funct}{"since"}B= $udev_version >= $FUNCTIONS->{$funct}{"since"}
| |||||||||||||||||||||||||||||
| 514 | 0 | ▶ | $@ = $1 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 515 | if $@ =~ m{^(.*)\s+at\s.*line\s\d+.}xms; | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 0 | $@ = "Can't attach '$funct' function from udev library: $@"; | |||||||||||||||||||||||||||
| 518 | 0 | return 0; | |||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 522 | 0 | ▶ | *$funct = sub { $_function_not_attach->($funct) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | # function attached | ||||||||||||||||||||||||||||
| 526 | 134 | delete $FUNCTIONS->{$funct}; | |||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | 2 | return ++$init; | |||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | 3 | 1; | |||||||||||||||||||||||||||