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

systemd / systemd / 14554080340

19 Apr 2025 11:46AM UTC coverage: 72.101% (-0.03%) from 72.13%
14554080340

push

github

web-flow
Add two new paragraphs to coding style about header files (#37188)

296880 of 411754 relevant lines covered (72.1%)

687547.52 hits per line

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

88.24
/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
#include "parse-util.h"
10
#include "stat-util.h"
11
#include "string-util.h"
12

13
static int saved_in_initrd = -1;
14

15
bool in_initrd(void) {
1,312,289✔
16
        int r;
1,312,289✔
17

18
        if (saved_in_initrd >= 0)
1,312,289✔
19
                return saved_in_initrd;
1,309,903✔
20

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

25
        r = secure_getenv_bool("SYSTEMD_IN_INITRD");
2,386✔
26
        if (r < 0 && r != -ENXIO)
2,386✔
27
                log_debug_errno(r, "Failed to parse $SYSTEMD_IN_INITRD, ignoring: %m");
×
28

29
        if (r >= 0)
2,386✔
30
                saved_in_initrd = r > 0;
47✔
31
        else {
32
                r = RET_NERRNO(access("/etc/initrd-release", F_OK));
2,339✔
33
                if (r < 0 && r != -ENOENT)
2,339✔
34
                        log_debug_errno(r, "Failed to check if /etc/initrd-release exists, assuming it does not: %m");
×
35
                saved_in_initrd = r >= 0;
2,339✔
36
        }
37

38
        return saved_in_initrd;
2,386✔
39
}
40

41
void in_initrd_force(bool value) {
4✔
42
        saved_in_initrd = value;
4✔
43
}
4✔
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