]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-device/device-internal.h
Merge pull request #11927 from poettering/network-namespace-path
[thirdparty/systemd.git] / src / libsystemd / sd-device / device-internal.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include "sd-device.h"
5
6 #include "device-private.h"
7 #include "hashmap.h"
8 #include "set.h"
9 #include "time-util.h"
10
11 struct sd_device {
12 unsigned n_ref;
13
14 int watch_handle;
15
16 sd_device *parent;
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
23 /* the subset of the properties that should be written to the db */
24 OrderedHashmap *properties_db;
25
26 Hashmap *sysattr_values; /* cached sysattr values */
27
28 Set *sysattrs; /* names of sysattrs */
29 Iterator sysattrs_iterator;
30
31 Set *tags;
32 Iterator tags_iterator;
33 uint64_t tags_generation; /* changes whenever the tags are changed */
34 uint64_t tags_iterator_generation; /* generation when iteration was started */
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 */
40 int devlink_priority;
41
42 int ifindex;
43 char *devtype;
44 char *devname;
45 dev_t devnum;
46
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;
50
51 char *syspath;
52 const char *devpath;
53 const char *sysnum;
54 char *sysname;
55
56 char *subsystem;
57 char *driver_subsystem; /* only set for the 'drivers' subsystem */
58 char *driver;
59
60 char *id_filename;
61
62 uint64_t usec_initialized;
63
64 mode_t devmode;
65 uid_t devuid;
66 gid_t devgid;
67
68 /* only set when device is passed through netlink */
69 DeviceAction action;
70 uint64_t seqnum;
71
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 */
74 bool property_tags_outdated:1; /* need to update TAGS= property */
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 */
82 bool db_loaded; /* don't reread db */
83
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 */
87 };
88
89 int device_new_aux(sd_device **ret);
90 int device_add_property_aux(sd_device *device, const char *key, const char *value, bool db);
91 int device_add_property_internal(sd_device *device, const char *key, const char *value);
92 int device_read_uevent_file(sd_device *device);
93
94 int device_set_syspath(sd_device *device, const char *_syspath, bool verify);
95 int device_set_ifindex(sd_device *device, const char *ifindex);
96 int device_set_devmode(sd_device *device, const char *devmode);
97 int device_set_devname(sd_device *device, const char *_devname);
98 int device_set_devtype(sd_device *device, const char *_devtype);
99 int device_set_devnum(sd_device *device, const char *major, const char *minor);
100 int device_set_subsystem(sd_device *device, const char *_subsystem);
101 int device_set_driver(sd_device *device, const char *_driver);
102 int device_set_usec_initialized(sd_device *device, usec_t when);