]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd/sd-device/device-internal.h
tree-wide: place #pragma once at the same place everywhere
[thirdparty/systemd.git] / src / libsystemd / sd-device / device-internal.h
CommitLineData
0ef6f454
LP
1#pragma once
2
57fa1d09
TG
3/***
4 This file is part of systemd.
5
6 Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
7 Copyright 2014 Tom Gundersen <teg@jklm.no>
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
57fa1d09
TG
23#include "hashmap.h"
24#include "set.h"
25
26struct sd_device {
27 uint64_t n_ref;
28
29 sd_device *parent;
30 bool parent_set; /* no need to try to reload parent */
31
32 OrderedHashmap *properties;
33 Iterator properties_iterator;
34 uint64_t properties_generation; /* changes whenever the properties are changed */
35 uint64_t properties_iterator_generation; /* generation when iteration was started */
36
37 /* the subset of the properties that should be written to the db*/
38 OrderedHashmap *properties_db;
39
40 Hashmap *sysattr_values; /* cached sysattr values */
41
42 Set *sysattrs; /* names of sysattrs */
43 Iterator sysattrs_iterator;
44 bool sysattrs_read; /* don't try to re-read sysattrs once read */
45
46 Set *tags;
47 Iterator tags_iterator;
48 uint64_t tags_generation; /* changes whenever the tags are changed */
49 uint64_t tags_iterator_generation; /* generation when iteration was started */
50 bool property_tags_outdated; /* need to update TAGS= property */
51
52 Set *devlinks;
53 Iterator devlinks_iterator;
54 uint64_t devlinks_generation; /* changes whenever the devlinks are changed */
55 uint64_t devlinks_iterator_generation; /* generation when iteration was started */
56 bool property_devlinks_outdated; /* need to update DEVLINKS= property */
57 int devlink_priority;
58
59 char **properties_strv; /* the properties hashmap as a strv */
60 uint8_t *properties_nulstr; /* the same as a nulstr */
61 size_t properties_nulstr_len;
62 bool properties_buf_outdated; /* need to reread hashmap */
63
64 int watch_handle;
65
66 char *syspath;
67 const char *devpath;
68 const char *sysnum;
69 char *sysname;
70 bool sysname_set; /* don't reread sysname */
71
72 char *devtype;
73 int ifindex;
74 char *devname;
75 dev_t devnum;
76
77 char *subsystem;
78 bool subsystem_set; /* don't reread subsystem */
79 char *driver;
80 bool driver_set; /* don't reread driver */
81
82 char *id_filename;
83
84 bool is_initialized;
85 uint64_t usec_initialized;
86
87 mode_t devmode;
88 uid_t devuid;
89 gid_t devgid;
90
91 bool uevent_loaded; /* don't reread uevent */
92 bool db_loaded; /* don't reread db */
93
94 bool sealed; /* don't read more information from uevent/db */
95 bool db_persist; /* don't clean up the db when switching from initrd to real root */
96};
97
98typedef enum DeviceAction {
99 DEVICE_ACTION_ADD,
100 DEVICE_ACTION_REMOVE,
101 DEVICE_ACTION_CHANGE,
102 DEVICE_ACTION_MOVE,
103 DEVICE_ACTION_ONLINE,
104 DEVICE_ACTION_OFFLINE,
105 _DEVICE_ACTION_MAX,
106 _DEVICE_ACTION_INVALID = -1,
107} DeviceAction;
108
109int device_new_aux(sd_device **ret);
110int device_add_property_aux(sd_device *device, const char *key, const char *value, bool db);
111int device_add_property_internal(sd_device *device, const char *key, const char *value);
112int device_read_uevent_file(sd_device *device);
107f2e25 113int device_read_db_aux(sd_device *device, bool force);
57fa1d09
TG
114
115int device_set_syspath(sd_device *device, const char *_syspath, bool verify);
116int device_set_ifindex(sd_device *device, const char *ifindex);
117int device_set_devmode(sd_device *device, const char *devmode);
118int device_set_devname(sd_device *device, const char *_devname);
119int device_set_devtype(sd_device *device, const char *_devtype);
120int device_set_devnum(sd_device *device, const char *major, const char *minor);
121int device_set_subsystem(sd_device *device, const char *_subsystem);
122int device_set_driver(sd_device *device, const char *_driver);
123int device_set_usec_initialized(sd_device *device, const char *initialized);
124
125DeviceAction device_action_from_string(const char *s) _pure_;
126const char *device_action_to_string(DeviceAction a) _const_;