LCOV - code coverage report
Current view: top level - libcli/smb - smb2_posix.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 10 13 76.9 %
Date: 2021-09-23 10:06:22 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Unix SMB/CIFS implementation.
       3             :  *
       4             :  * SMB2 Posix context handling
       5             :  *
       6             :  * Copyright (C) Jeremy Allison 2019
       7             :  *
       8             :  * This program is free software; you can redistribute it and/or modify
       9             :  * it under the terms of the GNU General Public License as published by
      10             :  * the Free Software Foundation; either version 3 of the License, or
      11             :  * (at your option) any later version.
      12             :  *
      13             :  * This program is distributed in the hope that it will be useful,
      14             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :  * GNU General Public License for more details.
      17             :  *
      18             :  * You should have received a copy of the GNU General Public License
      19             :  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             :  */
      21             : 
      22             : #include "replace.h"
      23             : #include "libcli/smb/smb2_posix.h"
      24             : #include "libcli/smb/smb2_constants.h"
      25             : #include "lib/util/byteorder.h"
      26             : 
      27         520 : NTSTATUS make_smb2_posix_create_ctx(
      28             :         TALLOC_CTX *mem_ctx,
      29             :         struct smb2_create_blobs **crb,
      30             :         mode_t mode)
      31             : {
      32         520 :         struct smb2_create_blobs *cblobs = NULL;
      33             :         uint8_t linear_mode[4];
      34         520 :         DATA_BLOB blob = { .data=linear_mode, .length=sizeof(linear_mode) };
      35             :         NTSTATUS status;
      36             : 
      37         520 :         cblobs = talloc_zero(mem_ctx, struct smb2_create_blobs);
      38         520 :         if (cblobs == NULL) {
      39           0 :                 return NT_STATUS_NO_MEMORY;
      40             :         }
      41         520 :         SIVAL(&linear_mode,0, unix_perms_to_wire(mode & ~S_IFMT));
      42             : 
      43         520 :         status = smb2_create_blob_add(
      44             :                 cblobs, cblobs, SMB2_CREATE_TAG_POSIX, blob);
      45         520 :         if (!NT_STATUS_IS_OK(status)) {
      46           0 :                 TALLOC_FREE(cblobs);
      47           0 :                 return status;
      48             :         }
      49         520 :         *crb = cblobs;
      50         520 :         return NT_STATUS_OK;
      51             : }

Generated by: LCOV version 1.13