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

systemd / systemd / 15263807472

26 May 2025 08:53PM UTC coverage: 72.046% (-0.002%) from 72.048%
15263807472

push

github

yuwata
src/core/manager.c: log preset activity on first boot

This gives us a little more information about what units were enabled
or disabled on that first boot and will be useful for OS developers
tracking down the source of unit state.

An example with this enabled looks like:

```
NET: Registered PF_VSOCK protocol family
systemd[1]: Applying preset policy.
systemd[1]: Unit /etc/systemd/system/dnsmasq.service is masked, ignoring.
systemd[1]: Unit /etc/systemd/system/systemd-repart.service is masked, ignoring.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket'.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir.mount' → '/etc/systemd/system/var-mnt-workdir.mount'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir\x2dtmp.mount' → '/etc/systemd/system/var-mnt-workdir\x2dtmp.mount'.
systemd[1]: Created symlink '/etc/systemd/system/afterburn-sshkeys.target.requires/afterburn-sshkeys@core.service' → '/usr/lib/systemd/system/afterburn-sshkeys@.service'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket' → '/usr/lib/systemd/system/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket' → '/usr/lib/systemd/system/systemd-resolved-monitor.socket'.
systemd[1]: Populated /etc with preset unit settings.
```

Considering it only happens on first boot and not on every boot I think
the extra information is worth the extra verbosity in the logs just for
that boot.

5 of 6 new or added lines in 1 file covered. (83.33%)

5463 existing lines in 165 files now uncovered.

299151 of 415222 relevant lines covered (72.05%)

702386.45 hits per line

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

96.83
/src/basic/psi-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <stdio.h>
4
#include <threads.h>
5

6
#include "alloc-util.h"
7
#include "errno-util.h"
8
#include "extract-word.h"
9
#include "fd-util.h"
10
#include "fileio.h"
11
#include "parse-util.h"
12
#include "psi-util.h"
13
#include "string-util.h"
14
#include "strv.h"
15

16
int read_resource_pressure(const char *path, PressureType type, ResourcePressure *ret) {
185✔
17
        _cleanup_free_ char *line = NULL;
185✔
18
        _cleanup_fclose_ FILE *f = NULL;
185✔
19
        unsigned field_filled = 0;
185✔
20
        ResourcePressure rp = {};
185✔
21
        const char *t, *cline;
185✔
22
        char *word;
185✔
23
        int r;
185✔
24

25
        assert(path);
185✔
26
        assert(IN_SET(type, PRESSURE_TYPE_SOME, PRESSURE_TYPE_FULL));
185✔
27
        assert(ret);
185✔
28

29
        if (type == PRESSURE_TYPE_SOME)
185✔
30
                t = "some";
31
        else if (type == PRESSURE_TYPE_FULL)
172✔
32
                t = "full";
33
        else
34
                return -EINVAL;
35

36
        r = fopen_unlocked(path, "re", &f);
185✔
37
        if (r < 0)
185✔
38
                return r;
39

40
        for (;;) {
527✔
41
                _cleanup_free_ char *l = NULL;
172✔
42
                char *w;
355✔
43

44
                r = read_line(f, LONG_LINE_MAX, &l);
355✔
45
                if (r < 0)
355✔
UNCOV
46
                        return r;
×
47
                if (r == 0)
355✔
48
                        break;
49

50
                w = first_word(l, t);
353✔
51
                if (w) {
353✔
52
                        line = TAKE_PTR(l);
181✔
53
                        cline = w;
181✔
54
                        break;
181✔
55
                }
56
        }
57

58
        if (!line)
183✔
59
                return -ENODATA;
60

61
        /* extracts either avgX=Y.Z or total=X */
62
        while ((r = extract_first_word(&cline, &word, NULL, 0)) > 0) {
901✔
63
                _cleanup_free_ char *w = word;
722✔
64
                const char *v;
722✔
65

66
                if ((v = startswith(w, "avg10="))) {
722✔
67
                        if (field_filled & (1U << 0))
181✔
68
                                return -EINVAL;
69

70
                        field_filled |= 1U << 0;
181✔
71
                        r = parse_loadavg_fixed_point(v, &rp.avg10);
181✔
72
                } else if ((v = startswith(w, "avg60="))) {
541✔
73
                        if (field_filled & (1U << 1))
181✔
74
                                return -EINVAL;
75

76
                        field_filled |= 1U << 1;
180✔
77
                        r = parse_loadavg_fixed_point(v, &rp.avg60);
180✔
78
                } else if ((v = startswith(w, "avg300="))) {
360✔
79
                        if (field_filled & (1U << 2))
179✔
80
                                return -EINVAL;
81

82
                        field_filled |= 1U << 2;
179✔
83
                        r = parse_loadavg_fixed_point(v, &rp.avg300);
179✔
84
                } else if ((v = startswith(w, "total="))) {
181✔
85
                        if (field_filled & (1U << 3))
179✔
86
                                return -EINVAL;
87

88
                        field_filled |= 1U << 3;
179✔
89
                        r = safe_atou64(v, &rp.total);
179✔
90
                } else
91
                        continue;
2✔
92

93
                if (r < 0)
719✔
94
                        return r;
95
        }
96

97
        if (r < 0)
179✔
98
                return r;
99

100
        if (field_filled != 15U)
179✔
101
                return -EINVAL;
102

103
        *ret = rp;
179✔
104
        return 0;
179✔
105
}
106

107
int is_pressure_supported(void) {
12,181✔
108
        static thread_local int cached = -1;
12,181✔
109
        int r;
12,181✔
110

111
        /* The pressure files, both under /proc/ and in cgroups, will exist even if the kernel has PSI
112
         * support disabled; we have to read the file to make sure it doesn't return -EOPNOTSUPP */
113

114
        if (cached >= 0)
12,181✔
115
                return cached;
116

117
        FOREACH_STRING(p, "/proc/pressure/cpu", "/proc/pressure/io", "/proc/pressure/memory") {
47,564✔
118
                r = read_virtual_file(p, 0, NULL, NULL);
35,673✔
119
                if (r == -ENOENT || ERRNO_IS_NEG_NOT_SUPPORTED(r))
35,673✔
UNCOV
120
                        return (cached = false);
×
121
                if (r < 0)
35,673✔
122
                        return r;
123
        }
124

125
        return (cached = true);
11,891✔
126
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc