1 /* SPDX-License-Identifier: LGPL-2.1+ */
8 #include <linux/btrfs.h>
11 #include "device-util.h"
14 #include "string-util.h"
16 #include "udev-builtin.h"
19 static int builtin_btrfs(sd_device
*dev
, int argc
, char *argv
[], bool test
) {
20 struct btrfs_ioctl_vol_args args
= {};
21 _cleanup_close_
int fd
= -1;
24 if (argc
!= 3 || !streq(argv
[1], "ready"))
25 return log_device_error_errno(dev
, EINVAL
, "Invalid arguments");
27 fd
= open("/dev/btrfs-control", O_RDWR
|O_CLOEXEC
);
29 return log_device_debug_errno(dev
, errno
, "Failed to open /dev/btrfs-control: %m");
31 strscpy(args
.name
, sizeof(args
.name
), argv
[2]);
32 r
= ioctl(fd
, BTRFS_IOC_DEVICES_READY
, &args
);
34 return log_device_debug_errno(dev
, errno
, "Failed to call BTRFS_IOC_DEVICES_READY: %m");
36 udev_builtin_add_property(dev
, test
, "ID_BTRFS_READY", one_zero(r
== 0));
40 const struct udev_builtin udev_builtin_btrfs
= {
43 .help
= "btrfs volume management",