• 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

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

3
#include <string.h>
4
#include <sys/stat.h>
5
#include <sys/sysmacros.h>
6

7
#include "alloc-util.h"
8
#include "chase.h"
9
#include "devnum-util.h"
10
#include "parse-util.h"
11
#include "path-util.h"
12
#include "stdio-util.h"
13
#include "string-util.h"
14

15
int parse_devnum(const char *s, dev_t *ret) {
11,730✔
16
        const char *major;
11,730✔
17
        unsigned x, y;
11,730✔
18
        size_t n;
11,730✔
19
        int r;
11,730✔
20

21
        n = strspn(s, DIGITS);
11,730✔
22
        if (n == 0)
11,730✔
23
                return -EINVAL;
11,730✔
24
        if (n > DECIMAL_STR_MAX(dev_t))
11,726✔
25
                return -EINVAL;
26
        if (s[n] != ':')
11,726✔
27
                return -EINVAL;
28

29
        major = strndupa_safe(s, n);
11,724✔
30
        r = safe_atou(major, &x);
11,724✔
31
        if (r < 0)
11,724✔
32
                return r;
33

34
        r = safe_atou(s + n + 1, &y);
11,724✔
35
        if (r < 0)
11,724✔
36
                return r;
37

38
        if (!DEVICE_MAJOR_VALID(x) || !DEVICE_MINOR_VALID(y))
11,723✔
39
                return -ERANGE;
40

41
        *ret = makedev(x, y);
11,723✔
42
        return 0;
11,723✔
43
}
44

45
int device_path_make_major_minor(mode_t mode, dev_t devnum, char **ret) {
53,798✔
46
        const char *t;
53,798✔
47

48
        /* Generates the /dev/{char|block}/MAJOR:MINOR path for a dev_t */
49

50
        if (S_ISCHR(mode))
53,798✔
51
                t = "char";
52
        else if (S_ISBLK(mode))
40,703✔
53
                t = "block";
54
        else
55
                return -ENODEV;
56

57
        if (asprintf(ret, "/dev/%s/" DEVNUM_FORMAT_STR, t, DEVNUM_FORMAT_VAL(devnum)) < 0)
53,798✔
UNCOV
58
                return -ENOMEM;
×
59

60
        return 0;
61
}
62

63
int device_path_make_inaccessible(mode_t mode, char **ret) {
6✔
64
        const char *s;
6✔
65

66
        assert(ret);
6✔
67

68
        if (S_ISCHR(mode))
6✔
69
                s = "/run/systemd/inaccessible/chr";
70
        else if (S_ISBLK(mode))
3✔
71
                s = "/run/systemd/inaccessible/blk";
72
        else
73
                return -ENODEV;
74

75
        return strdup_to(ret, s);
6✔
76
}
77

78
int device_path_make_canonical(mode_t mode, dev_t devnum, char **ret) {
15✔
79
        _cleanup_free_ char *p = NULL;
15✔
80
        int r;
15✔
81

82
        /* Finds the canonical path for a device, i.e. resolves the /dev/{char|block}/MAJOR:MINOR path to the end. */
83

84
        assert(ret);
15✔
85

86
        if (devnum_is_zero(devnum))
15✔
87
                /* A special hack to make sure our 'inaccessible' device nodes work. They won't have symlinks in
88
                 * /dev/block/ and /dev/char/, hence we handle them specially here. */
89
                return device_path_make_inaccessible(mode, ret);
2✔
90

91
        r = device_path_make_major_minor(mode, devnum, &p);
13✔
92
        if (r < 0)
13✔
93
                return r;
94

95
        return chase(p, NULL, 0, ret, NULL);
13✔
96
}
97

98
int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret_devnum) {
311,148✔
99
        mode_t mode;
311,148✔
100
        dev_t devnum;
311,148✔
101
        int r;
311,148✔
102

103
        /* Tries to extract the major/minor directly from the device path if we can. Handles /dev/block/ and /dev/char/
104
         * paths, as well out synthetic inaccessible device nodes. Never goes to disk. Returns -ENODEV if the device
105
         * path cannot be parsed like this.  */
106

107
        if (path_equal(path, "/run/systemd/inaccessible/chr")) {
311,148✔
108
                mode = S_IFCHR;
155✔
109
                devnum = makedev(0, 0);
155✔
110
        } else if (path_equal(path, "/run/systemd/inaccessible/blk")) {
310,993✔
111
                mode = S_IFBLK;
155✔
112
                devnum = makedev(0, 0);
155✔
113
        } else {
114
                const char *w;
310,838✔
115

116
                w = path_startswith(path, "/dev/block/");
310,838✔
117
                if (w)
310,838✔
118
                        mode = S_IFBLK;
119
                else {
120
                        w = path_startswith(path, "/dev/char/");
310,823✔
121
                        if (!w)
310,823✔
122
                                return -ENODEV;
311,148✔
123

124
                        mode = S_IFCHR;
125
                }
126

127
                r = parse_devnum(w, &devnum);
368✔
128
                if (r < 0)
368✔
129
                        return r;
130
        }
131

132
        if (ret_mode)
678✔
133
                *ret_mode = mode;
678✔
134
        if (ret_devnum)
678✔
135
                *ret_devnum = devnum;
678✔
136

137
        return 0;
138
}
139

140
char* format_devnum(dev_t d, char buf[static DEVNUM_STR_MAX]) {
4,423✔
141
        return ASSERT_PTR(snprintf_ok(buf, DEVNUM_STR_MAX, DEVNUM_FORMAT_STR, DEVNUM_FORMAT_VAL(d)));
4,423✔
142
}
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