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