]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd/sd-device/device-internal.h
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / libsystemd / sd-device / device-internal.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
0ef6f454
LP
2#pragma once
3
dc8bc9ad
YW
4#include "sd-device.h"
5
57fa1d09
TG
6#include "hashmap.h"
7#include "set.h"
dc5042c0 8#include "time-util.h"
57fa1d09
TG
9
10struct sd_device {
cf4b2f99 11 unsigned n_ref;
57fa1d09 12
11c49e6d
ZJS
13 int watch_handle;
14
57fa1d09 15 sd_device *parent;
57fa1d09
TG
16
17 OrderedHashmap *properties;
18 Iterator properties_iterator;
19 uint64_t properties_generation; /* changes whenever the properties are changed */
20 uint64_t properties_iterator_generation; /* generation when iteration was started */
21
13e785f7 22 /* the subset of the properties that should be written to the db */
57fa1d09
TG
23 OrderedHashmap *properties_db;
24
25 Hashmap *sysattr_values; /* cached sysattr values */
26
27 Set *sysattrs; /* names of sysattrs */
28 Iterator sysattrs_iterator;
57fa1d09
TG
29
30 Set *tags;
31 Iterator tags_iterator;
32 uint64_t tags_generation; /* changes whenever the tags are changed */
33 uint64_t tags_iterator_generation; /* generation when iteration was started */
57fa1d09
TG
34
35 Set *devlinks;
36 Iterator devlinks_iterator;
37 uint64_t devlinks_generation; /* changes whenever the devlinks are changed */
38 uint64_t devlinks_iterator_generation; /* generation when iteration was started */
57fa1d09
TG
39 int devlink_priority;
40
11c49e6d
ZJS
41 int ifindex;
42 char *devtype;
43 char *devname;
44 dev_t devnum;
45
57fa1d09
TG
46 char **properties_strv; /* the properties hashmap as a strv */
47 uint8_t *properties_nulstr; /* the same as a nulstr */
48 size_t properties_nulstr_len;
57fa1d09
TG
49
50 char *syspath;
51 const char *devpath;
52 const char *sysnum;
53 char *sysname;
57fa1d09
TG
54
55 char *subsystem;
de7e983e 56 char *driver_subsystem; /* only set for the 'drivers' subsystem */
57fa1d09 57 char *driver;
57fa1d09
TG
58
59 char *id_filename;
60
57fa1d09
TG
61 uint64_t usec_initialized;
62
63 mode_t devmode;
64 uid_t devuid;
65 gid_t devgid;
66
11c49e6d
ZJS
67 bool parent_set:1; /* no need to try to reload parent */
68 bool sysattrs_read:1; /* don't try to re-read sysattrs once read */
69 bool property_tags_outdated:1; /* need to update TAGS= property */
70 bool property_devlinks_outdated:1; /* need to update DEVLINKS= property */
71 bool properties_buf_outdated:1; /* need to reread hashmap */
72 bool sysname_set:1; /* don't reread sysname */
73 bool subsystem_set:1; /* don't reread subsystem */
74 bool driver_subsystem_set:1; /* don't reread subsystem */
75 bool driver_set:1; /* don't reread driver */
76 bool uevent_loaded:1; /* don't reread uevent */
57fa1d09
TG
77 bool db_loaded; /* don't reread db */
78
11c49e6d
ZJS
79 bool is_initialized:1;
80 bool sealed:1; /* don't read more information from uevent/db */
81 bool db_persist:1; /* don't clean up the db when switching from initrd to real root */
57fa1d09
TG
82};
83
84typedef enum DeviceAction {
85 DEVICE_ACTION_ADD,
86 DEVICE_ACTION_REMOVE,
87 DEVICE_ACTION_CHANGE,
88 DEVICE_ACTION_MOVE,
89 DEVICE_ACTION_ONLINE,
90 DEVICE_ACTION_OFFLINE,
9a39e1ce
LP
91 DEVICE_ACTION_BIND,
92 DEVICE_ACTION_UNBIND,
57fa1d09
TG
93 _DEVICE_ACTION_MAX,
94 _DEVICE_ACTION_INVALID = -1,
95} DeviceAction;
96
97int device_new_aux(sd_device **ret);
98int device_add_property_aux(sd_device *device, const char *key, const char *value, bool db);
99int device_add_property_internal(sd_device *device, const char *key, const char *value);
100int device_read_uevent_file(sd_device *device);
101
102int device_set_syspath(sd_device *device, const char *_syspath, bool verify);
103int device_set_ifindex(sd_device *device, const char *ifindex);
104int device_set_devmode(sd_device *device, const char *devmode);
105int device_set_devname(sd_device *device, const char *_devname);
106int device_set_devtype(sd_device *device, const char *_devtype);
107int device_set_devnum(sd_device *device, const char *major, const char *minor);
108int device_set_subsystem(sd_device *device, const char *_subsystem);
109int device_set_driver(sd_device *device, const char *_driver);
dc5042c0 110int device_set_usec_initialized(sd_device *device, usec_t when);
57fa1d09
TG
111
112DeviceAction device_action_from_string(const char *s) _pure_;
113const char *device_action_to_string(DeviceAction a) _const_;