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

systemd / systemd / 25893429527

14 May 2026 09:08PM UTC coverage: 72.364% (-0.2%) from 72.584%
25893429527

push

github

bluca
ci: switch SUSE mkosi mirror to cdn.o.o

The cdn mirror is preferred by SUSE for clouds/CIs. There have been issues with some
mirrors, which fail to download from GHA quite often lately, so hopefully this will
make it reliable again.

328159 of 453485 relevant lines covered (72.36%)

1405869.02 hits per line

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

93.18
/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
#include <sys/stat.h>
6

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

15
int btrfs_validate_subvolume_name(const char *name) {
953✔
16

17
        if (!filename_is_valid(name))
953✔
18
                return -EINVAL;
19

20
        if (strlen(name) > BTRFS_SUBVOL_NAME_MAX)
953✔
21
                return -E2BIG;
×
22

23
        return 0;
24
}
25

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

30
        assert(path);
84✔
31
        assert(ret);
84✔
32

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

37
        r = btrfs_validate_subvolume_name(fn);
84✔
38
        if (r < 0)
84✔
39
                return r;
40

41
        *ret = TAKE_PTR(fn);
84✔
42
        return 0;
84✔
43
}
44

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

51
        assert(dir_fd >= 0 || IN_SET(dir_fd, AT_FDCWD, XAT_FDROOT));
84✔
52
        assert(!isempty(path));
84✔
53

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

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

62
        fd = xopenat(dir_fd, parent ?: ".", O_DIRECTORY|O_RDONLY|O_CLOEXEC);
84✔
63
        if (fd < 0)
84✔
64
                return fd;
65

66
        strncpy(args.name, subvolume, sizeof(args.name)-1);
84✔
67

68
        return RET_NERRNO(ioctl(fd, BTRFS_IOC_SUBVOL_CREATE, &args));
168✔
69
}
70

71
int btrfs_subvol_make_fallback(int dir_fd, const char *path, mode_t mode) {
15✔
72
        mode_t old, combined;
15✔
73
        int r;
15✔
74

75
        assert(path);
15✔
76

77
        /* Let's work like mkdir(), i.e. take the specified mode, and mask it with the current umask. */
78
        old = umask(~mode);
15✔
79
        combined = old | ~mode;
15✔
80
        if (combined != ~mode)
15✔
81
                umask(combined);
×
82
        r = btrfs_subvol_make(dir_fd, path);
15✔
83
        umask(old);
15✔
84

85
        if (r >= 0)
15✔
86
                return 1; /* subvol worked */
87
        if (!ERRNO_IS_NOT_SUPPORTED(r))
15✔
88
                return r;
89

90
        if (mkdirat(dir_fd, path, mode) < 0)
15✔
91
                return -errno;
×
92

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