ctdb/docs: Include ceph rados namespace support in man page
[Samba.git] / source3 / smbd / smb2_posix.c
blob9623e59e43a61b2dc2c6ce4eac8acb14031a934a
1 /*
2 Unix SMB/CIFS implementation.
3 SMB2 POSIX code.
4 Copyright (C) Jeremy Allison 2022
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
21 #include "smbd/smbd.h"
22 #include "passdb/lookup_sid.h"
23 #include "librpc/gen_ndr/ndr_security.h"
24 #include "librpc/gen_ndr/smb3posix.h"
25 #include "libcli/security/security.h"
27 void smb3_file_posix_information_init(
28 connection_struct *conn,
29 const struct stat_ex *st,
30 uint32_t reparse_tag,
31 uint32_t dos_attributes,
32 struct smb3_file_posix_information *dst)
34 *dst = (struct smb3_file_posix_information) {
35 .end_of_file = get_file_size_stat(st),
36 .allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,NULL,st),
37 .inode = SMB_VFS_FS_FILE_ID(conn, st),
38 .device = st->st_ex_dev,
39 .creation_time = unix_timespec_to_nt_time(st->st_ex_btime),
40 .last_access_time = unix_timespec_to_nt_time(st->st_ex_atime),
41 .last_write_time = unix_timespec_to_nt_time(st->st_ex_mtime),
42 .change_time = unix_timespec_to_nt_time(st->st_ex_ctime),
43 .cc.nlinks = st->st_ex_nlink,
44 .cc.reparse_tag = reparse_tag,
45 .cc.posix_perms = unix_perms_to_wire(st->st_ex_mode & ~S_IFMT),
46 .cc.owner = global_sid_NULL,
47 .cc.group = global_sid_NULL,
50 if (st->st_ex_uid != (uid_t)-1) {
51 uid_to_sid(&dst->cc.owner, st->st_ex_uid);
53 if (st->st_ex_gid != (uid_t)-1) {
54 gid_to_sid(&dst->cc.group, st->st_ex_gid);
57 switch (st->st_ex_mode & S_IFMT) {
58 case S_IFREG:
59 dst->file_attributes = dos_attributes;
60 break;
61 case S_IFDIR:
62 dst->file_attributes = dos_attributes | FILE_ATTRIBUTE_DIRECTORY;
63 break;
64 default:
66 * All non-directory or regular files are reported
67 * as reparse points. Client may or may not be able
68 * to access these.
70 dst->file_attributes = FILE_ATTRIBUTE_REPARSE_POINT;
71 break;