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