1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef DEVICE_UDEV_LINUX_UDEV_LOADER_H_
6 #define DEVICE_UDEV_LINUX_UDEV_LOADER_H_
12 #if !defined(USE_UDEV)
13 #error "USE_UDEV not defined"
18 struct udev_enumerate
;
19 struct udev_list_entry
;
24 // Interface to libudev. Accessed through the static Get() function, which
25 // will try to load libudev1 first and then libudev0 on first use. If neither
26 // libraries load successfully, the program will fail with a crash.
28 // All the methods have the same signatures as libudev's functions. e.g.
29 // udev_monitor_get_fd(mon) simply becomes device::udev_monitor_get_fd(mon).
32 static UdevLoader
* Get();
34 virtual ~UdevLoader();
36 virtual bool Init() = 0;
38 virtual const char* udev_device_get_action(udev_device
* udev_device
) = 0;
39 virtual const char* udev_device_get_devnode(udev_device
* udev_device
) = 0;
40 virtual udev_device
* udev_device_get_parent(udev_device
* udev_device
) = 0;
41 virtual udev_device
* udev_device_get_parent_with_subsystem_devtype(
42 udev_device
* udev_device
,
43 const char* subsystem
,
44 const char* devtype
) = 0;
45 virtual const char* udev_device_get_property_value(udev_device
* udev_device
,
47 virtual const char* udev_device_get_subsystem(udev_device
* udev_device
) = 0;
48 virtual const char* udev_device_get_sysattr_value(udev_device
* udev_device
,
49 const char* sysattr
) = 0;
50 virtual const char* udev_device_get_sysname(udev_device
* udev_device
) = 0;
51 virtual const char* udev_device_get_syspath(udev_device
* udev_device
) = 0;
52 virtual udev_device
* udev_device_new_from_devnum(udev
* udev
,
55 virtual udev_device
* udev_device_new_from_syspath(udev
* udev
,
56 const char* syspath
) = 0;
57 virtual void udev_device_unref(udev_device
* udev_device
) = 0;
58 virtual int udev_enumerate_add_match_subsystem(udev_enumerate
* udev_enumerate
,
59 const char* subsystem
) = 0;
60 virtual udev_list_entry
* udev_enumerate_get_list_entry(
61 udev_enumerate
* udev_enumerate
) = 0;
62 virtual udev_enumerate
* udev_enumerate_new(udev
* udev
) = 0;
63 virtual int udev_enumerate_scan_devices(udev_enumerate
* udev_enumerate
) = 0;
64 virtual void udev_enumerate_unref(udev_enumerate
* udev_enumerate
) = 0;
65 virtual udev_list_entry
* udev_list_entry_get_next(
66 udev_list_entry
* list_entry
) = 0;
67 virtual const char* udev_list_entry_get_name(udev_list_entry
* list_entry
) = 0;
68 virtual int udev_monitor_enable_receiving(udev_monitor
* udev_monitor
) = 0;
69 virtual int udev_monitor_filter_add_match_subsystem_devtype(
70 udev_monitor
* udev_monitor
,
71 const char* subsystem
,
72 const char* devtype
) = 0;
73 virtual int udev_monitor_get_fd(udev_monitor
* udev_monitor
) = 0;
74 virtual udev_monitor
* udev_monitor_new_from_netlink(udev
* udev
,
75 const char* name
) = 0;
76 virtual udev_device
* udev_monitor_receive_device(
77 udev_monitor
* udev_monitor
) = 0;
78 virtual void udev_monitor_unref(udev_monitor
* udev_monitor
) = 0;
79 virtual udev
* udev_new() = 0;
80 virtual void udev_set_log_fn(
82 void (*log_fn
)(struct udev
* udev
, int priority
,
83 const char* file
, int line
,
84 const char* fn
, const char* format
, va_list args
)) = 0;
85 virtual void udev_set_log_priority(struct udev
* udev
, int priority
) = 0;
86 virtual void udev_unref(udev
* udev
) = 0;
91 #endif // DEVICE_UDEV_LINUX_UDEV_LOADER_H_