LCOV - code coverage report
Current view: top level - basic - label.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 6 30 20.0 %
Date: 2019-08-22 15:41:25 Functions: 1 3 33.3 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <errno.h>
       4             : #include <sys/stat.h>
       5             : #include <unistd.h>
       6             : 
       7             : #include "btrfs-util.h"
       8             : #include "label.h"
       9             : #include "macro.h"
      10             : #include "selinux-util.h"
      11             : #include "smack-util.h"
      12             : 
      13          29 : int label_fix(const char *path, LabelFixFlags flags) {
      14             :         int r, q;
      15             : 
      16          29 :         r = mac_selinux_fix(path, flags);
      17          29 :         q = mac_smack_fix(path, flags);
      18             : 
      19          29 :         if (r < 0)
      20           0 :                 return r;
      21          29 :         if (q < 0)
      22           0 :                 return q;
      23             : 
      24          29 :         return 0;
      25             : }
      26             : 
      27           0 : int symlink_label(const char *old_path, const char *new_path) {
      28             :         int r;
      29             : 
      30           0 :         assert(old_path);
      31           0 :         assert(new_path);
      32             : 
      33           0 :         r = mac_selinux_create_file_prepare(new_path, S_IFLNK);
      34           0 :         if (r < 0)
      35           0 :                 return r;
      36             : 
      37           0 :         if (symlink(old_path, new_path) < 0)
      38           0 :                 r = -errno;
      39             : 
      40           0 :         mac_selinux_create_file_clear();
      41             : 
      42           0 :         if (r < 0)
      43           0 :                 return r;
      44             : 
      45           0 :         return mac_smack_fix(new_path, 0);
      46             : }
      47             : 
      48           0 : int btrfs_subvol_make_label(const char *path) {
      49             :         int r;
      50             : 
      51           0 :         assert(path);
      52             : 
      53           0 :         r = mac_selinux_create_file_prepare(path, S_IFDIR);
      54           0 :         if (r < 0)
      55           0 :                 return r;
      56             : 
      57           0 :         r = btrfs_subvol_make(path);
      58           0 :         mac_selinux_create_file_clear();
      59             : 
      60           0 :         if (r < 0)
      61           0 :                 return r;
      62             : 
      63           0 :         return mac_smack_fix(path, 0);
      64             : }

Generated by: LCOV version 1.14