]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemd/sd-device.h
man: remove recommendation to pull in slices from slices.target
[thirdparty/systemd.git] / src / systemd / sd-device.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #ifndef foosddevicehfoo
3 #define foosddevicehfoo
4
5 /***
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.
10
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.
15
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/>.
18 ***/
19
20 #include <inttypes.h>
21 #include <sys/sysmacros.h>
22 #include <sys/types.h>
23
24 #include "_sd-common.h"
25
26 _SD_BEGIN_DECLARATIONS;
27
28 typedef struct sd_device sd_device;
29 typedef struct sd_device_enumerator sd_device_enumerator;
30
31 /* device */
32
33 sd_device *sd_device_ref(sd_device *device);
34 sd_device *sd_device_unref(sd_device *device);
35
36 int sd_device_new_from_syspath(sd_device **ret, const char *syspath);
37 int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum);
38 int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname);
39 int sd_device_new_from_device_id(sd_device **ret, const char *id);
40
41 int sd_device_get_parent(sd_device *child, sd_device **ret);
42 int sd_device_get_parent_with_subsystem_devtype(sd_device *child, const char *subsystem, const char *devtype, sd_device **ret);
43
44 int sd_device_get_syspath(sd_device *device, const char **ret);
45 int sd_device_get_subsystem(sd_device *device, const char **ret);
46 int sd_device_get_devtype(sd_device *device, const char **ret);
47 int sd_device_get_devnum(sd_device *device, dev_t *devnum);
48 int sd_device_get_ifindex(sd_device *device, int *ifindex);
49 int sd_device_get_driver(sd_device *device, const char **ret);
50 int sd_device_get_devpath(sd_device *device, const char **ret);
51 int sd_device_get_devname(sd_device *device, const char **ret);
52 int sd_device_get_sysname(sd_device *device, const char **ret);
53 int sd_device_get_sysnum(sd_device *device, const char **ret);
54
55 int sd_device_get_is_initialized(sd_device *device, int *initialized);
56 int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec);
57
58 const char *sd_device_get_tag_first(sd_device *device);
59 const char *sd_device_get_tag_next(sd_device *device);
60 const char *sd_device_get_devlink_first(sd_device *device);
61 const char *sd_device_get_devlink_next(sd_device *device);
62 const char *sd_device_get_property_first(sd_device *device, const char **value);
63 const char *sd_device_get_property_next(sd_device *device, const char **value);
64 const char *sd_device_get_sysattr_first(sd_device *device);
65 const char *sd_device_get_sysattr_next(sd_device *device);
66
67 int sd_device_has_tag(sd_device *device, const char *tag);
68 int sd_device_get_property_value(sd_device *device, const char *key, const char **value);
69 int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value);
70
71 int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, char *value);
72
73 /* device enumerator */
74
75 int sd_device_enumerator_new(sd_device_enumerator **ret);
76 sd_device_enumerator *sd_device_enumerator_ref(sd_device_enumerator *enumerator);
77 sd_device_enumerator *sd_device_enumerator_unref(sd_device_enumerator *enumerator);
78
79 sd_device *sd_device_enumerator_get_device_first(sd_device_enumerator *enumerator);
80 sd_device *sd_device_enumerator_get_device_next(sd_device_enumerator *enumerator);
81 sd_device *sd_device_enumerator_get_subsystem_first(sd_device_enumerator *enumerator);
82 sd_device *sd_device_enumerator_get_subsystem_next(sd_device_enumerator *enumerator);
83
84 int sd_device_enumerator_add_match_subsystem(sd_device_enumerator *enumerator, const char *subsystem, int match);
85 int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumerator, const char *sysattr, const char *value, int match);
86 int sd_device_enumerator_add_match_property(sd_device_enumerator *enumerator, const char *property, const char *value);
87 int sd_device_enumerator_add_match_sysname(sd_device_enumerator *enumerator, const char *sysname);
88 int sd_device_enumerator_add_match_tag(sd_device_enumerator *enumerator, const char *tag);
89 int sd_device_enumerator_add_match_parent(sd_device_enumerator *enumerator, sd_device *parent);
90 int sd_device_enumerator_allow_uninitialized(sd_device_enumerator *enumerator);
91
92 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device, sd_device_unref);
93 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device_enumerator, sd_device_enumerator_unref);
94
95 _SD_END_DECLARATIONS;
96
97 #endif