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_subsystem_sysname(
57 const char* subsystem
,
58 const char* sysname
) = 0;
59 virtual udev_device
* udev_device_new_from_syspath(udev
* udev
,
60 const char* syspath
) = 0;
61 virtual void udev_device_unref(udev_device
* udev_device
) = 0;
62 virtual int udev_enumerate_add_match_subsystem(udev_enumerate
* udev_enumerate
,
63 const char* subsystem
) = 0;
64 virtual udev_list_entry
* udev_enumerate_get_list_entry(
65 udev_enumerate
* udev_enumerate
) = 0;
66 virtual udev_enumerate
* udev_enumerate_new(udev
* udev
) = 0;
67 virtual int udev_enumerate_scan_devices(udev_enumerate
* udev_enumerate
) = 0;
68 virtual void udev_enumerate_unref(udev_enumerate
* udev_enumerate
) = 0;
69 virtual udev_list_entry
* udev_list_entry_get_next(
70 udev_list_entry
* list_entry
) = 0;
71 virtual const char* udev_list_entry_get_name(udev_list_entry
* list_entry
) = 0;
72 virtual int udev_monitor_enable_receiving(udev_monitor
* udev_monitor
) = 0;
73 virtual int udev_monitor_filter_add_match_subsystem_devtype(
74 udev_monitor
* udev_monitor
,
75 const char* subsystem
,
76 const char* devtype
) = 0;
77 virtual int udev_monitor_get_fd(udev_monitor
* udev_monitor
) = 0;
78 virtual udev_monitor
* udev_monitor_new_from_netlink(udev
* udev
,
79 const char* name
) = 0;
80 virtual udev_device
* udev_monitor_receive_device(
81 udev_monitor
* udev_monitor
) = 0;
82 virtual void udev_monitor_unref(udev_monitor
* udev_monitor
) = 0;
83 virtual udev
* udev_new() = 0;
84 virtual void udev_set_log_fn(
86 void (*log_fn
)(struct udev
* udev
, int priority
,
87 const char* file
, int line
,
88 const char* fn
, const char* format
, va_list args
)) = 0;
89 virtual void udev_set_log_priority(struct udev
* udev
, int priority
) = 0;
90 virtual void udev_unref(udev
* udev
) = 0;
95 #endif // DEVICE_UDEV_LINUX_UDEV_LOADER_H_