LCOV - code coverage report
Current view: top level - udev - udev-builtin-btrfs.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 0 14 0.0 %
Date: 2019-08-22 15:41:25 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <fcntl.h>
       4             : #include <linux/btrfs.h>
       5             : #include <stdlib.h>
       6             : #include <sys/ioctl.h>
       7             : 
       8             : #include "device-util.h"
       9             : #include "fd-util.h"
      10             : #include "string-util.h"
      11             : #include "strxcpyx.h"
      12             : #include "udev-builtin.h"
      13             : #include "util.h"
      14             : 
      15           0 : static int builtin_btrfs(sd_device *dev, int argc, char *argv[], bool test) {
      16           0 :         struct btrfs_ioctl_vol_args args = {};
      17           0 :         _cleanup_close_ int fd = -1;
      18             :         int r;
      19             : 
      20           0 :         if (argc != 3 || !streq(argv[1], "ready"))
      21           0 :                 return log_device_error_errno(dev, SYNTHETIC_ERRNO(EINVAL), "Invalid arguments");
      22             : 
      23           0 :         fd = open("/dev/btrfs-control", O_RDWR|O_CLOEXEC);
      24           0 :         if (fd < 0)
      25           0 :                 return log_device_debug_errno(dev, errno, "Failed to open /dev/btrfs-control: %m");
      26             : 
      27           0 :         strscpy(args.name, sizeof(args.name), argv[2]);
      28           0 :         r = ioctl(fd, BTRFS_IOC_DEVICES_READY, &args);
      29           0 :         if (r < 0)
      30           0 :                 return log_device_debug_errno(dev, errno, "Failed to call BTRFS_IOC_DEVICES_READY: %m");
      31             : 
      32           0 :         udev_builtin_add_property(dev, test, "ID_BTRFS_READY", one_zero(r == 0));
      33           0 :         return 0;
      34             : }
      35             : 
      36             : const UdevBuiltin udev_builtin_btrfs = {
      37             :         .name = "btrfs",
      38             :         .cmd = builtin_btrfs,
      39             :         .help = "btrfs volume management",
      40             : };

Generated by: LCOV version 1.14