LCOV - code coverage report
Current view: top level - shared - machine-pool.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 0 21 0.0 %
Date: 2019-08-22 15:41:25 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <errno.h>
       4             : #include <sys/statfs.h>
       5             : 
       6             : #include "btrfs-util.h"
       7             : #include "label.h"
       8             : #include "machine-pool.h"
       9             : #include "missing.h"
      10             : #include "stat-util.h"
      11             : 
      12           0 : static int check_btrfs(void) {
      13             :         struct statfs sfs;
      14             : 
      15           0 :         if (statfs("/var/lib/machines", &sfs) < 0) {
      16           0 :                 if (errno != ENOENT)
      17           0 :                         return -errno;
      18             : 
      19           0 :                 if (statfs("/var/lib", &sfs) < 0)
      20           0 :                         return -errno;
      21             :         }
      22             : 
      23           0 :         return F_TYPE_EQUAL(sfs.f_type, BTRFS_SUPER_MAGIC);
      24             : }
      25             : 
      26           0 : int setup_machine_directory(sd_bus_error *error) {
      27             :         int r;
      28             : 
      29           0 :         r = check_btrfs();
      30           0 :         if (r < 0)
      31           0 :                 return sd_bus_error_set_errnof(error, r, "Failed to determine whether /var/lib/machines is located on btrfs: %m");
      32           0 :         if (r == 0)
      33           0 :                 return 0;
      34             : 
      35           0 :         (void) btrfs_subvol_make_label("/var/lib/machines");
      36             : 
      37           0 :         r = btrfs_quota_enable("/var/lib/machines", true);
      38           0 :         if (r < 0)
      39           0 :                 log_warning_errno(r, "Failed to enable quota for /var/lib/machines, ignoring: %m");
      40             : 
      41           0 :         r = btrfs_subvol_auto_qgroup("/var/lib/machines", 0, true);
      42           0 :         if (r < 0)
      43           0 :                 log_warning_errno(r, "Failed to set up default quota hierarchy for /var/lib/machines, ignoring: %m");
      44             : 
      45           0 :         return 1;
      46             : }

Generated by: LCOV version 1.14