1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #ifndef foosddevicehfoo
3 #define foosddevicehfoo
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 #include <sys/sysmacros.h>
22 #include <sys/types.h>
26 #include "_sd-common.h"
28 _SD_BEGIN_DECLARATIONS
;
30 typedef struct sd_device sd_device
;
31 typedef struct sd_device_enumerator sd_device_enumerator
;
32 typedef struct sd_device_monitor sd_device_monitor
;
36 typedef int (*sd_device_monitor_handler_t
)(sd_device_monitor
*m
, sd_device
*device
, void *userdata
);
40 sd_device
*sd_device_ref(sd_device
*device
);
41 sd_device
*sd_device_unref(sd_device
*device
);
43 int sd_device_new_from_syspath(sd_device
**ret
, const char *syspath
);
44 int sd_device_new_from_devnum(sd_device
**ret
, char type
, dev_t devnum
);
45 int sd_device_new_from_subsystem_sysname(sd_device
**ret
, const char *subsystem
, const char *sysname
);
46 int sd_device_new_from_device_id(sd_device
**ret
, const char *id
);
48 int sd_device_get_parent(sd_device
*child
, sd_device
**ret
);
49 int sd_device_get_parent_with_subsystem_devtype(sd_device
*child
, const char *subsystem
, const char *devtype
, sd_device
**ret
);
51 int sd_device_get_syspath(sd_device
*device
, const char **ret
);
52 int sd_device_get_subsystem(sd_device
*device
, const char **ret
);
53 int sd_device_get_devtype(sd_device
*device
, const char **ret
);
54 int sd_device_get_devnum(sd_device
*device
, dev_t
*devnum
);
55 int sd_device_get_ifindex(sd_device
*device
, int *ifindex
);
56 int sd_device_get_driver(sd_device
*device
, const char **ret
);
57 int sd_device_get_devpath(sd_device
*device
, const char **ret
);
58 int sd_device_get_devname(sd_device
*device
, const char **ret
);
59 int sd_device_get_sysname(sd_device
*device
, const char **ret
);
60 int sd_device_get_sysnum(sd_device
*device
, const char **ret
);
62 int sd_device_get_is_initialized(sd_device
*device
);
63 int sd_device_get_usec_since_initialized(sd_device
*device
, uint64_t *usec
);
65 const char *sd_device_get_tag_first(sd_device
*device
);
66 const char *sd_device_get_tag_next(sd_device
*device
);
67 const char *sd_device_get_devlink_first(sd_device
*device
);
68 const char *sd_device_get_devlink_next(sd_device
*device
);
69 const char *sd_device_get_property_first(sd_device
*device
, const char **value
);
70 const char *sd_device_get_property_next(sd_device
*device
, const char **value
);
71 const char *sd_device_get_sysattr_first(sd_device
*device
);
72 const char *sd_device_get_sysattr_next(sd_device
*device
);
74 int sd_device_has_tag(sd_device
*device
, const char *tag
);
75 int sd_device_get_property_value(sd_device
*device
, const char *key
, const char **value
);
76 int sd_device_get_sysattr_value(sd_device
*device
, const char *sysattr
, const char **_value
);
78 int sd_device_set_sysattr_value(sd_device
*device
, const char *sysattr
, const char *value
);
80 /* device enumerator */
82 int sd_device_enumerator_new(sd_device_enumerator
**ret
);
83 sd_device_enumerator
*sd_device_enumerator_ref(sd_device_enumerator
*enumerator
);
84 sd_device_enumerator
*sd_device_enumerator_unref(sd_device_enumerator
*enumerator
);
86 sd_device
*sd_device_enumerator_get_device_first(sd_device_enumerator
*enumerator
);
87 sd_device
*sd_device_enumerator_get_device_next(sd_device_enumerator
*enumerator
);
88 sd_device
*sd_device_enumerator_get_subsystem_first(sd_device_enumerator
*enumerator
);
89 sd_device
*sd_device_enumerator_get_subsystem_next(sd_device_enumerator
*enumerator
);
91 int sd_device_enumerator_add_match_subsystem(sd_device_enumerator
*enumerator
, const char *subsystem
, int match
);
92 int sd_device_enumerator_add_match_sysattr(sd_device_enumerator
*enumerator
, const char *sysattr
, const char *value
, int match
);
93 int sd_device_enumerator_add_match_property(sd_device_enumerator
*enumerator
, const char *property
, const char *value
);
94 int sd_device_enumerator_add_match_sysname(sd_device_enumerator
*enumerator
, const char *sysname
);
95 int sd_device_enumerator_add_match_tag(sd_device_enumerator
*enumerator
, const char *tag
);
96 int sd_device_enumerator_add_match_parent(sd_device_enumerator
*enumerator
, sd_device
*parent
);
97 int sd_device_enumerator_allow_uninitialized(sd_device_enumerator
*enumerator
);
101 int sd_device_monitor_new(sd_device_monitor
**ret
);
102 sd_device_monitor
*sd_device_monitor_ref(sd_device_monitor
*m
);
103 sd_device_monitor
*sd_device_monitor_unref(sd_device_monitor
*m
);
105 int sd_device_monitor_set_receive_buffer_size(sd_device_monitor
*m
, size_t size
);
106 int sd_device_monitor_attach_event(sd_device_monitor
*m
, sd_event
*event
);
107 int sd_device_monitor_detach_event(sd_device_monitor
*m
);
108 sd_event
*sd_device_monitor_get_event(sd_device_monitor
*m
);
109 sd_event_source
*sd_device_monitor_get_event_source(sd_device_monitor
*m
);
110 int sd_device_monitor_start(sd_device_monitor
*m
, sd_device_monitor_handler_t callback
, void *userdata
);
111 int sd_device_monitor_stop(sd_device_monitor
*m
);
113 int sd_device_monitor_filter_add_match_subsystem_devtype(sd_device_monitor
*m
, const char *subsystem
, const char *devtype
);
114 int sd_device_monitor_filter_add_match_tag(sd_device_monitor
*m
, const char *tag
);
115 int sd_device_monitor_filter_update(sd_device_monitor
*m
);
116 int sd_device_monitor_filter_remove(sd_device_monitor
*m
);
118 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device
, sd_device_unref
);
119 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device_enumerator
, sd_device_enumerator_unref
);
120 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device_monitor
, sd_device_monitor_unref
);
122 _SD_END_DECLARATIONS
;