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

systemd / systemd / 15057632786

15 May 2025 09:01PM UTC coverage: 72.267% (+0.02%) from 72.244%
15057632786

push

github

bluca
man: document how to hook stuff into system wakeup

Fixes: #6364

298523 of 413084 relevant lines covered (72.27%)

738132.88 hits per line

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

76.19
/src/shared/blockdev-list.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "sd-device.h"
4

5
#include "ansi-color.h"
6
#include "blockdev-list.h"
7
#include "blockdev-util.h"
8
#include "device-util.h"
9
#include "macro.h"
10
#include "strv.h"
11
#include "terminal-util.h"
12

13
int blockdev_list(BlockDevListFlags flags) {
4✔
14
        _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
4✔
15
        int r;
4✔
16

17
        if (sd_device_enumerator_new(&e) < 0)
4✔
18
                return log_oom();
×
19

20
        r = sd_device_enumerator_add_match_subsystem(e, "block", /* match = */ true);
4✔
21
        if (r < 0)
4✔
22
                return log_error_errno(r, "Failed to add subsystem match: %m");
×
23

24
        if (FLAGS_SET(flags, BLOCKDEV_LIST_REQUIRE_LUKS)) {
4✔
25
                r = sd_device_enumerator_add_match_property(e, "ID_FS_TYPE", "crypto_LUKS");
1✔
26
                if (r < 0)
1✔
27
                        return log_error_errno(r, "Failed to add match for LUKS block devices: %m");
×
28
        }
29

30
        FOREACH_DEVICE(e, dev) {
14✔
31
                const char *node;
10✔
32

33
                r = sd_device_get_devname(dev, &node);
10✔
34
                if (r < 0) {
10✔
35
                        log_warning_errno(r, "Failed to get device node of discovered block device, ignoring: %m");
×
36
                        continue;
4✔
37
                }
38

39
                if (FLAGS_SET(flags, BLOCKDEV_LIST_IGNORE_ZRAM)) {
10✔
40
                        r = device_sysname_startswith(dev, "zram");
9✔
41
                        if (r < 0) {
9✔
42
                                log_warning_errno(r, "Failed to check device name of discovered block device '%s', ignoring: %m", node);
×
43
                                continue;
×
44
                        }
45
                        if (r > 0)
9✔
46
                                continue;
×
47
                }
48

49
                if (FLAGS_SET(flags, BLOCKDEV_LIST_REQUIRE_PARTITION_SCANNING)) {
10✔
50
                        r = blockdev_partscan_enabled(dev);
6✔
51
                        if (r < 0) {
6✔
52
                                log_warning_errno(r, "Unable to determine whether '%s' supports partition scanning, skipping device: %m", node);
×
53
                                continue;
×
54
                        }
55
                        if (r == 0) {
6✔
56
                                log_debug("Device '%s' does not support partition scanning, skipping.", node);
4✔
57
                                continue;
4✔
58
                        }
59
                }
60

61
                printf("%s\n", node);
6✔
62

63
                if (FLAGS_SET(flags, BLOCKDEV_LIST_SHOW_SYMLINKS)) {
6✔
64
                        _cleanup_strv_free_ char **list = NULL;
6✔
65

66
                        FOREACH_DEVICE_DEVLINK(dev, l)
54✔
67
                                if (strv_extend(&list, l) < 0)
48✔
68
                                        return log_oom();
×
69

70
                        strv_sort(list);
6✔
71

72
                        STRV_FOREACH(i, list)
54✔
73
                                printf("%s%s%s%s\n", on_tty() ? "    " : "", ansi_grey(), *i, ansi_normal());
144✔
74
                }
75
        }
76

77
        return 0;
78
}
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