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

systemd / systemd / 29132483780

10 Jul 2026 08:43PM UTC coverage: 72.912% (+0.2%) from 72.702%
29132483780

push

github

bluca
man: run forgotten 'update-man-rules'

344600 of 472622 relevant lines covered (72.91%)

1365091.83 hits per line

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

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

3
#include <unistd.h>
4

5
#include "env-util.h"
6
#include "errno-util.h"
7
#include "initrd-util.h"
8
#include "log.h"
9

10
static int saved_in_initrd = -1;
11

12
bool in_initrd(void) {
2,007,411✔
13
        int r;
2,007,411✔
14

15
        if (saved_in_initrd >= 0)
2,007,411✔
16
                return saved_in_initrd;
2,003,611✔
17

18
        /* If /etc/initrd-release exists, we're in an initrd.
19
         * This can be overridden by setting SYSTEMD_IN_INITRD=0|1.
20
         */
21

22
        r = secure_getenv_bool("SYSTEMD_IN_INITRD");
3,800✔
23
        if (r < 0 && r != -ENXIO)
3,800✔
24
                log_debug_errno(r, "Failed to parse $SYSTEMD_IN_INITRD, ignoring: %m");
×
25

26
        if (r >= 0)
3,800✔
27
                saved_in_initrd = r > 0;
51✔
28
        else {
29
                r = RET_NERRNO(access("/etc/initrd-release", F_OK));
3,749✔
30
                if (r < 0 && r != -ENOENT)
3,749✔
31
                        log_debug_errno(r, "Failed to check if /etc/initrd-release exists, assuming it does not: %m");
×
32
                saved_in_initrd = r >= 0;
3,749✔
33
        }
34

35
        return saved_in_initrd;
3,800✔
36
}
37

38
void in_initrd_force(bool value) {
4✔
39
        saved_in_initrd = value;
4✔
40
}
4✔
41

42
int in_first_boot(void) {
110✔
43
        static int first_boot_env_parse_cached = -1;
110✔
44
        int r;
110✔
45

46
        if (first_boot_env_parse_cached >= 0)
110✔
47
                return first_boot_env_parse_cached;
48

49
        r = secure_getenv_bool("SYSTEMD_FIRST_BOOT");
110✔
50
        if (r >= 0)
110✔
51
                return (first_boot_env_parse_cached = r);
2✔
52
        if (r != -ENXIO)
108✔
53
                log_debug_errno(r, "Failed to parse $SYSTEMD_FIRST_BOOT, ignoring: %m");
×
54

55
        /* This is not cached and must *never* be cached, other parts of systemd write it to signal
56
         * an update to the first-boot state. */
57
        r = RET_NERRNO(access("/run/systemd/first-boot", F_OK));
108✔
58
        if (r >= 0)
62✔
59
                return true;
60
        if (r == -ENOENT)
62✔
61
                return false;
62

63
        return log_debug_errno(r, "Failed to check /run/systemd/first-boot: %m");
×
64
}
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