]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-device.h
tree-wide: drop 'This file is part of systemd' blurb
[thirdparty/systemd.git] / src / systemd / sd-device.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
57fa1d09
TG
2#ifndef foosddevicehfoo
3#define foosddevicehfoo
4
5/***
57fa1d09 6 Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
96df036f 7 Copyright 2014-2015 Tom Gundersen <teg@jklm.no>
57fa1d09
TG
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
04c01369 23#include <inttypes.h>
27d13af7 24#include <sys/sysmacros.h>
71d35b6b 25#include <sys/types.h>
57fa1d09
TG
26
27#include "_sd-common.h"
28
29_SD_BEGIN_DECLARATIONS;
30
31typedef struct sd_device sd_device;
96df036f
TG
32typedef struct sd_device_enumerator sd_device_enumerator;
33
34/* device */
57fa1d09
TG
35
36sd_device *sd_device_ref(sd_device *device);
37sd_device *sd_device_unref(sd_device *device);
38
39int sd_device_new_from_syspath(sd_device **ret, const char *syspath);
40int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum);
41int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname);
42int sd_device_new_from_device_id(sd_device **ret, const char *id);
43
44int sd_device_get_parent(sd_device *child, sd_device **ret);
45int sd_device_get_parent_with_subsystem_devtype(sd_device *child, const char *subsystem, const char *devtype, sd_device **ret);
46
47int sd_device_get_syspath(sd_device *device, const char **ret);
48int sd_device_get_subsystem(sd_device *device, const char **ret);
49int sd_device_get_devtype(sd_device *device, const char **ret);
50int sd_device_get_devnum(sd_device *device, dev_t *devnum);
51int sd_device_get_ifindex(sd_device *device, int *ifindex);
52int sd_device_get_driver(sd_device *device, const char **ret);
53int sd_device_get_devpath(sd_device *device, const char **ret);
54int sd_device_get_devname(sd_device *device, const char **ret);
55int sd_device_get_sysname(sd_device *device, const char **ret);
56int sd_device_get_sysnum(sd_device *device, const char **ret);
57
58int sd_device_get_is_initialized(sd_device *device, int *initialized);
59int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec);
60
61const char *sd_device_get_tag_first(sd_device *device);
62const char *sd_device_get_tag_next(sd_device *device);
63const char *sd_device_get_devlink_first(sd_device *device);
64const char *sd_device_get_devlink_next(sd_device *device);
65const char *sd_device_get_property_first(sd_device *device, const char **value);
66const char *sd_device_get_property_next(sd_device *device, const char **value);
67const char *sd_device_get_sysattr_first(sd_device *device);
68const char *sd_device_get_sysattr_next(sd_device *device);
69
70int sd_device_has_tag(sd_device *device, const char *tag);
71int sd_device_get_property_value(sd_device *device, const char *key, const char **value);
72int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value);
73
74int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, char *value);
75
96df036f
TG
76/* device enumerator */
77
78int sd_device_enumerator_new(sd_device_enumerator **ret);
79sd_device_enumerator *sd_device_enumerator_ref(sd_device_enumerator *enumerator);
80sd_device_enumerator *sd_device_enumerator_unref(sd_device_enumerator *enumerator);
81
96df036f
TG
82sd_device *sd_device_enumerator_get_device_first(sd_device_enumerator *enumerator);
83sd_device *sd_device_enumerator_get_device_next(sd_device_enumerator *enumerator);
84sd_device *sd_device_enumerator_get_subsystem_first(sd_device_enumerator *enumerator);
85sd_device *sd_device_enumerator_get_subsystem_next(sd_device_enumerator *enumerator);
86
87int sd_device_enumerator_add_match_subsystem(sd_device_enumerator *enumerator, const char *subsystem, int match);
88int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumerator, const char *sysattr, const char *value, int match);
89int sd_device_enumerator_add_match_property(sd_device_enumerator *enumerator, const char *property, const char *value);
90int sd_device_enumerator_add_match_sysname(sd_device_enumerator *enumerator, const char *sysname);
91int sd_device_enumerator_add_match_tag(sd_device_enumerator *enumerator, const char *tag);
92int sd_device_enumerator_add_match_parent(sd_device_enumerator *enumerator, sd_device *parent);
dee5e0b6 93int sd_device_enumerator_allow_uninitialized(sd_device_enumerator *enumerator);
96df036f 94
4afd3348
LP
95_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device, sd_device_unref);
96_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device_enumerator, sd_device_enumerator_unref);
97
57fa1d09
TG
98_SD_END_DECLARATIONS;
99
100#endif