• 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

91.67
/src/basic/btrfs.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <linux/btrfs.h>
4
#include <sys/ioctl.h>
5

6
#include "alloc-util.h"
7
#include "btrfs.h"
8
#include "errno-util.h"
9
#include "fd-util.h"
10
#include "fs-util.h"
11
#include "path-util.h"
12
#include "string-util.h"
13

14
int btrfs_validate_subvolume_name(const char *name) {
849✔
15

16
        if (!filename_is_valid(name))
849✔
17
                return -EINVAL;
18

19
        if (strlen(name) > BTRFS_SUBVOL_NAME_MAX)
849✔
UNCOV
20
                return -E2BIG;
×
21

22
        return 0;
23
}
24

25
static int extract_subvolume_name(const char *path, char **ret) {
79✔
26
        _cleanup_free_ char *fn = NULL;
79✔
27
        int r;
79✔
28

29
        assert(path);
79✔
30
        assert(ret);
79✔
31

32
        r = path_extract_filename(path, &fn);
79✔
33
        if (r < 0)
79✔
34
                return r;
35

36
        r = btrfs_validate_subvolume_name(fn);
79✔
37
        if (r < 0)
79✔
38
                return r;
39

40
        *ret = TAKE_PTR(fn);
79✔
41
        return 0;
79✔
42
}
43

44
int btrfs_subvol_make(int dir_fd, const char *path) {
79✔
45
        struct btrfs_ioctl_vol_args args = {};
79✔
46
        _cleanup_free_ char *subvolume = NULL, *parent = NULL;
79✔
47
        _cleanup_close_ int fd = -EBADF;
79✔
48
        int r;
79✔
49

50
        assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
79✔
51
        assert(!isempty(path));
79✔
52

53
        r = extract_subvolume_name(path, &subvolume);
79✔
54
        if (r < 0)
79✔
55
                return r;
56

57
        r = path_extract_directory(path, &parent);
79✔
58
        if (r < 0) {
79✔
59
                if (r != -EDESTADDRREQ) /* Propagate error, unless only a filename was specified, which is OK */
67✔
60
                        return r;
61

62
                dir_fd = fd_reopen_condition(dir_fd, O_CLOEXEC, O_PATH, &fd); /* drop O_PATH if it is set */
67✔
63
                if (dir_fd < 0)
67✔
64
                        return dir_fd;
65
        } else {
66
                fd = openat(dir_fd, parent, O_DIRECTORY|O_RDONLY|O_CLOEXEC, 0);
12✔
67
                if (fd < 0)
12✔
UNCOV
68
                        return -errno;
×
69

70
                dir_fd = fd;
71
        }
72

73
        strncpy(args.name, subvolume, sizeof(args.name)-1);
79✔
74

75
        return RET_NERRNO(ioctl(dir_fd, BTRFS_IOC_SUBVOL_CREATE, &args));
158✔
76
}
77

78
int btrfs_subvol_make_fallback(int dir_fd, const char *path, mode_t mode) {
10✔
79
        mode_t old, combined;
10✔
80
        int r;
10✔
81

82
        assert(path);
10✔
83

84
        /* Let's work like mkdir(), i.e. take the specified mode, and mask it with the current umask. */
85
        old = umask(~mode);
10✔
86
        combined = old | ~mode;
10✔
87
        if (combined != ~mode)
10✔
UNCOV
88
                umask(combined);
×
89
        r = btrfs_subvol_make(dir_fd, path);
10✔
90
        umask(old);
10✔
91

92
        if (r >= 0)
10✔
93
                return 1; /* subvol worked */
94
        if (!ERRNO_IS_NOT_SUPPORTED(r))
10✔
95
                return r;
96

97
        if (mkdirat(dir_fd, path, mode) < 0)
10✔
UNCOV
98
                return -errno;
×
99

100
        return 0; /* plain directory */
101
}
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