• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 29790165204

20 Jul 2026 10:30PM UTC coverage: 72.837% (-0.05%) from 72.889%
29790165204

push

github

yuwata
hwdb: classify PlayStation controller audio as controller form-factor

Add Sony PlayStation controller entries to 70-sound-card.hwdb so that their
ALSA sound devices are tagged with SOUND_FORM_FACTOR=controller:
 - DualSense (054c:0ce6)
 - DualSense Edge (054c:0df2)
 - DualShock 4 CUH-ZCT1x (054c:05c4)
 - DualShock 4 CUH-ZCT2x (054c:09cc)

These controllers expose USB audio but are neither headsets nor speakers.
Pinning them in the hwdb ensures they are identified correctly before any
fallback matching occurs.

345467 of 474302 relevant lines covered (72.84%)

1388252.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.01
/src/network/networkctl-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <sys/stat.h>
4
#include <unistd.h>
5

6
#include "ansi-color.h"
7
#include "bus-util.h"
8
#include "log.h"
9
#include "networkctl.h"
10
#include "networkctl-util.h"
11
#include "polkit-agent.h"
12
#include "string-util.h"
13
#include "strv.h"
14
#include "varlink-util.h"
15

16
int varlink_connect_networkd(sd_varlink **ret_varlink) {
2,700✔
17
        _cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *vl = NULL;
2,700✔
18
        sd_json_variant *reply;
2,700✔
19
        uint64_t id;
2,700✔
20
        int r;
2,700✔
21

22
        r = sd_varlink_connect_address(&vl, "/run/systemd/netif/io.systemd.Network");
2,700✔
23
        if (r < 0)
2,700✔
24
                return log_error_errno(r, "Failed to connect to network service /run/systemd/netif/io.systemd.Network: %m");
×
25

26
        (void) sd_varlink_set_description(vl, "varlink-network");
2,700✔
27

28
        r = sd_varlink_set_allow_fd_passing_output(vl, true);
2,700✔
29
        if (r < 0)
2,700✔
30
                return log_error_errno(r, "Failed to allow passing file descriptor through varlink: %m");
×
31

32
        r = varlink_call_and_log(vl, "io.systemd.Network.GetNamespaceId", /* parameters= */ NULL, &reply);
2,700✔
33
        if (r < 0)
2,700✔
34
                return r;
35

36
        static const sd_json_dispatch_field dispatch_table[] = {
2,700✔
37
                { "NamespaceId", SD_JSON_VARIANT_UNSIGNED, sd_json_dispatch_uint64, 0, SD_JSON_MANDATORY },
38
                {},
39
        };
40

41
        r = sd_json_dispatch(reply, dispatch_table, SD_JSON_LOG|SD_JSON_ALLOW_EXTENSIONS, &id);
2,700✔
42
        if (r < 0)
2,700✔
43
                return r;
44

45
        if (id == 0)
2,700✔
46
                log_debug("systemd-networkd.service not running in a network namespace (?), skipping netns check.");
×
47
        else {
48
                struct stat st;
2,700✔
49

50
                if (stat("/proc/self/ns/net", &st) < 0)
2,700✔
51
                        return log_error_errno(errno, "Failed to determine our own network namespace ID: %m");
×
52

53
                if (id != st.st_ino)
2,700✔
54
                        return log_error_errno(SYNTHETIC_ERRNO(EREMOTE),
×
55
                                               "networkctl must be invoked in same network namespace as systemd-networkd.service.");
56
        }
57

58
        if (ret_varlink)
2,700✔
59
                *ret_varlink = TAKE_PTR(vl);
2,700✔
60
        return 0;
61
}
62

63
int reload_networkd(bool reconfigure_links) {
157✔
64
        _cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *vl = NULL;
157✔
65
        int r;
157✔
66

67
        r = varlink_connect_networkd(&vl);
157✔
68
        if (r < 0)
157✔
69
                return r;
70

71
        (void) polkit_agent_open_if_enabled(BUS_TRANSPORT_LOCAL, arg_ask_password);
157✔
72

73
        sd_json_variant *reply = NULL;
157✔
74
        const char *error_id = NULL;
157✔
75
        r = sd_varlink_callbo(
157✔
76
                        vl,
77
                        "io.systemd.Network.Reload",
78
                        &reply,
79
                        &error_id,
80
                        SD_JSON_BUILD_PAIR_BOOLEAN("reconfigureLinks", reconfigure_links),
81
                        SD_JSON_BUILD_PAIR_BOOLEAN("allowInteractiveAuthentication", arg_ask_password));
82
        if (r < 0)
157✔
83
                return log_error_errno(r, "Failed to call io.systemd.Network.Reload varlink method: %m");
×
84

85
        if (error_id) {
157✔
86
                if (streq(error_id, SD_VARLINK_ERROR_METHOD_NOT_FOUND)) {
×
87
                        if (!reconfigure_links)
×
88
                                return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
×
89
                                                       "Installed version of systemd-networkd does not support --no-reconfigure.");
90

91
                        /* Older networkd without io.systemd.Network.Reload, fall back to io.systemd.service.Reload. */
92
                        return varlink_callbo_and_log(
×
93
                                        vl,
94
                                        "io.systemd.service.Reload",
95
                                        /* reply= */ NULL,
96
                                        SD_JSON_BUILD_PAIR_BOOLEAN("allowInteractiveAuthentication", arg_ask_password));
97
                }
98

99
                r = sd_varlink_error_to_errno(error_id, reply);
×
100
                if (r != -EBADR)
×
101
                        return log_error_errno(r, "Failed to call io.systemd.Network.Reload varlink method: %m");
×
102
                return log_error_errno(r, "Failed to call io.systemd.Network.Reload varlink method: %s", error_id);
×
103
        }
104

105
        return 0;
106
}
107

108
int reload_udevd(void) {
1✔
109
        _cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *vl = NULL;
1✔
110
        int r;
1✔
111

112
        r = sd_varlink_connect_address(&vl, "/run/udev/io.systemd.Udev");
1✔
113
        if (r == -ENOENT) {
1✔
114
                log_debug("systemd-udevd is not running, skipping reload.");
1✔
115
                return 0;
116
        }
117
        if (r < 0)
×
118
                return log_error_errno(r, "Failed to connect to udev: %m");
×
119

120
        (void) sd_varlink_set_description(vl, "udev");
×
121

122
        return varlink_call_and_log(vl, "io.systemd.service.Reload", /* parameters= */ NULL, /* reply= */ NULL);
×
123
}
124

125
bool networkd_is_running(void) {
20✔
126
        static int cached = -1;
20✔
127
        int r;
20✔
128

129
        if (cached < 0) {
20✔
130
                r = access("/run/systemd/netif/state", F_OK);
17✔
131
                if (r < 0) {
17✔
132
                        if (errno != ENOENT)
×
133
                                log_debug_errno(errno,
×
134
                                                "Failed to determine whether networkd is running, assuming it's not: %m");
135

136
                        cached = false;
×
137
                } else
138
                        cached = true;
17✔
139
        }
140

141
        return cached;
20✔
142
}
143

144
void operational_state_to_color(const char *name, const char *state, const char **on, const char **off) {
1,484✔
145
        if (STRPTR_IN_SET(state, "routable", "enslaved") ||
1,484✔
146
            (streq_ptr(name, "lo") && streq_ptr(state, "carrier"))) {
628✔
147
                if (on)
861✔
148
                        *on = ansi_highlight_green();
1,722✔
149
                if (off)
861✔
150
                        *off = ansi_normal();
1,716✔
151
        } else if (streq_ptr(state, "degraded")) {
623✔
152
                if (on)
376✔
153
                        *on = ansi_highlight_yellow();
376✔
154
                if (off)
376✔
155
                        *off = ansi_normal();
746✔
156
        } else {
157
                if (on)
247✔
158
                        *on = "";
247✔
159
                if (off)
247✔
160
                        *off = "";
228✔
161
        }
162
}
1,484✔
163

164
void setup_state_to_color(const char *state, const char **on, const char **off) {
1,482✔
165
        if (streq_ptr(state, "configured")) {
1,482✔
166
                if (on)
1,366✔
167
                        *on = ansi_highlight_green();
2,732✔
168
                if (off)
1,366✔
169
                        *off = ansi_normal();
2,720✔
170
        } else if (streq_ptr(state, "configuring")) {
116✔
171
                if (on)
42✔
172
                        *on = ansi_highlight_yellow();
42✔
173
                if (off)
42✔
174
                        *off = ansi_normal();
84✔
175
        } else if (STRPTR_IN_SET(state, "failed", "linger")) {
74✔
176
                if (on)
×
177
                        *on = ansi_highlight_red();
×
178
                if (off)
×
179
                        *off = ansi_normal();
×
180
        } else {
181
                if (on)
74✔
182
                        *on = "";
74✔
183
                if (off)
74✔
184
                        *off = "";
55✔
185
        }
186
}
1,482✔
187

188
void online_state_to_color(const char *state, const char **on, const char **off) {
1,459✔
189
        if (streq_ptr(state, "online")) {
1,459✔
190
                if (on)
1,217✔
191
                        *on = ansi_highlight_green();
2,434✔
192
                if (off)
1,217✔
193
                        *off = ansi_normal();
×
194
        } else if (streq_ptr(state, "partial")) {
242✔
195
                if (on)
×
196
                        *on = ansi_highlight_yellow();
×
197
                if (off)
×
198
                        *off = ansi_normal();
×
199
        } else {
200
                if (on)
242✔
201
                        *on = "";
242✔
202
                if (off)
242✔
203
                        *off = "";
×
204
        }
205
}
1,459✔
206

207
int acquire_link_description(sd_varlink *vl, int ifindex, sd_json_variant **ret) {
1,463✔
208
        int r;
1,463✔
209

210
        assert(vl);
1,463✔
211
        assert(ifindex > 0);
1,463✔
212
        assert(ret);
1,463✔
213

214
        sd_json_variant *v; /* borrowed from vl, do not unref */
1,463✔
215
        r = varlink_callbo_and_log(
1,463✔
216
                        vl,
217
                        "io.systemd.Network.Link.Describe",
218
                        &v,
219
                        SD_JSON_BUILD_PAIR_INTEGER("InterfaceIndex", ifindex));
220
        if (r < 0)
1,463✔
221
                return r;
1,463✔
222

223
        *ret = sd_json_variant_ref(v);
1,463✔
224
        return 0;
1,463✔
225
}
226

227
int json_variant_find_object(sd_json_variant *v, char * const *object_names, sd_json_variant **ret) {
5,846✔
228
        assert(object_names);
5,846✔
229
        assert(ret);
5,846✔
230

231
        if (!v || sd_json_variant_is_null(v))
5,846✔
232
                return -ENODATA;
233

234
        STRV_FOREACH(name, object_names) {
12,374✔
235
                v = sd_json_variant_by_key(v, *name);
12,099✔
236
                if (!v || sd_json_variant_is_null(v))
12,099✔
237
                        return -ENODATA;
238
        }
239

240
        *ret = v;
275✔
241
        return 0;
275✔
242
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc