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

systemd / systemd / 14895667988

07 May 2025 08:57PM UTC coverage: 72.225% (-0.007%) from 72.232%
14895667988

push

github

yuwata
network: log_link_message_debug_errno() automatically append %m if necessary

Follow-up for d28746ef5.
Fixes CID#1609753.

0 of 1 new or added line in 1 file covered. (0.0%)

20297 existing lines in 338 files now uncovered.

297407 of 411780 relevant lines covered (72.22%)

695716.85 hits per line

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

76.74
/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✔
UNCOV
18
                return log_oom();
×
19

20
        r = sd_device_enumerator_add_match_subsystem(e, "block", /* match = */ true);
4✔
21
        if (r < 0)
4✔
UNCOV
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✔
UNCOV
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✔
UNCOV
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
                        const char *dn;
9✔
41

42
                        r = sd_device_get_sysname(dev, &dn);
9✔
43
                        if (r < 0) {
9✔
44
                                log_warning_errno(r, "Failed to get device name of discovered block device '%s', ignoring: %m", node);
×
UNCOV
45
                                continue;
×
46
                        }
47

48
                        if (startswith(dn, "zram"))
9✔
UNCOV
49
                                continue;
×
50
                }
51

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

64
                printf("%s\n", node);
6✔
65

66
                if (FLAGS_SET(flags, BLOCKDEV_LIST_SHOW_SYMLINKS)) {
6✔
67
                        _cleanup_strv_free_ char **list = NULL;
6✔
68

69
                        FOREACH_DEVICE_DEVLINK(dev, l)
54✔
70
                                if (strv_extend(&list, l) < 0)
48✔
UNCOV
71
                                        return log_oom();
×
72

73
                        strv_sort(list);
6✔
74

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

80
        return 0;
81
}
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