LCOV - code coverage report
Current view: top level - basic - mkdir-label.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 13 26 50.0 %
Date: 2019-08-22 15:41:25 Functions: 3 5 60.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <stdio.h>
       4             : #include <sys/stat.h>
       5             : #include <sys/types.h>
       6             : #include <unistd.h>
       7             : 
       8             : #include "label.h"
       9             : #include "macro.h"
      10             : #include "mkdir.h"
      11             : #include "selinux-util.h"
      12             : #include "smack-util.h"
      13             : 
      14         125 : int mkdir_label(const char *path, mode_t mode) {
      15             :         int r;
      16             : 
      17         125 :         assert(path);
      18             : 
      19         125 :         r = mac_selinux_create_file_prepare(path, S_IFDIR);
      20         125 :         if (r < 0)
      21           0 :                 return r;
      22             : 
      23         125 :         r = mkdir_errno_wrapper(path, mode);
      24         125 :         mac_selinux_create_file_clear();
      25         125 :         if (r < 0)
      26          95 :                 return r;
      27             : 
      28          30 :         return mac_smack_fix(path, 0);
      29             : }
      30             : 
      31           0 : int mkdirat_label(int dirfd, const char *path, mode_t mode) {
      32             :         int r;
      33             : 
      34           0 :         assert(path);
      35             : 
      36           0 :         r = mac_selinux_create_file_prepare_at(dirfd, path, S_IFDIR);
      37           0 :         if (r < 0)
      38           0 :                 return r;
      39             : 
      40           0 :         r = mkdirat_errno_wrapper(dirfd, path, mode);
      41           0 :         mac_selinux_create_file_clear();
      42           0 :         if (r < 0)
      43           0 :                 return r;
      44             : 
      45           0 :         return mac_smack_fix_at(dirfd, path, 0);
      46             : }
      47             : 
      48           0 : int mkdir_safe_label(const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags) {
      49           0 :         return mkdir_safe_internal(path, mode, uid, gid, flags, mkdir_label);
      50             : }
      51             : 
      52         133 : int mkdir_parents_label(const char *path, mode_t mode) {
      53         133 :         return mkdir_parents_internal(NULL, path, mode, mkdir_label);
      54             : }
      55             : 
      56           1 : int mkdir_p_label(const char *path, mode_t mode) {
      57           1 :         return mkdir_p_internal(NULL, path, mode, mkdir_label);
      58             : }

Generated by: LCOV version 1.14