s3:smbd: let open_file_ntcreate() calculate info = FILE_WAS_* before get_share_mode_l...
[Samba.git] / libcli / smb / smb2_posix.c
blob60be3214da20f529e47b3f3f94feda37500feb8c
1 /*
2 * Unix SMB/CIFS implementation.
4 * SMB2 Posix context handling
6 * Copyright (C) Jeremy Allison 2019
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.
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.
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/>.
22 #include "replace.h"
23 #include "libcli/smb/smb2_posix.h"
24 #include "libcli/smb/smb2_constants.h"
25 #include "lib/util/byteorder.h"
27 NTSTATUS make_smb2_posix_create_ctx(
28 TALLOC_CTX *mem_ctx,
29 struct smb2_create_blobs **crb,
30 mode_t mode)
32 struct smb2_create_blobs *cblobs = NULL;
33 uint8_t linear_mode[4];
34 DATA_BLOB blob = { .data=linear_mode, .length=sizeof(linear_mode) };
35 NTSTATUS status;
37 cblobs = talloc_zero(mem_ctx, struct smb2_create_blobs);
38 if (cblobs == NULL) {
39 return NT_STATUS_NO_MEMORY;
41 SIVAL(&linear_mode,0, unix_perms_to_wire(mode & ~S_IFMT));
43 status = smb2_create_blob_add(
44 cblobs, cblobs, SMB2_CREATE_TAG_POSIX, blob);
45 if (!NT_STATUS_IS_OK(status)) {
46 TALLOC_FREE(cblobs);
47 return status;
49 *crb = cblobs;
50 return NT_STATUS_OK;