2 * Unix SMB/CIFS implementation.
5 * Copyright (C) Steven Danneman, 2008
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
25 #include "oplock_onefs.h"
26 #include <sys/isi_acl.h>
28 /* OneFS Module smb.conf parameters and defaults */
31 * Specifies when ACLs presented to Windows should be canonicalized
32 * into the ordering which Explorer expects.
34 enum onefs_acl_wire_format
36 ACL_FORMAT_RAW, /**< Never canonicalize */
37 ACL_FORMAT_WINDOWS_SD, /**< Only canonicalize synthetic ACLs */
38 ACL_FORMAT_ALWAYS /**< Always canonicalize */
41 #define PARM_ONEFS_TYPE "onefs"
42 #define PARM_ACL_WIRE_FORMAT "acl wire format"
43 #define PARM_ACL_WIRE_FORMAT_DEFAULT ACL_FORMAT_WINDOWS_SD
44 #define PARM_ALLOW_EXECUTE_ALWAYS "allow execute always"
45 #define PARM_ALLOW_EXECUTE_ALWAYS_DEFAULT false
46 #define PARM_ATIME_NOW "atime now files"
47 #define PARM_ATIME_NOW_DEFAULT NULL
48 #define PARM_ATIME_STATIC "atime static files"
49 #define PARM_ATIME_STATIC_DEFAULT NULL
50 #define PARM_ATIME_SLOP "atime now slop"
51 #define PARM_ATIME_SLOP_DEFAULT 0
52 #define PARM_ATOMIC_SENDFILE "atomic sendfile"
53 #define PARM_ATOMIC_SENDFILE_DEFAULT true
54 #define PARM_CREATOR_OWNER_GETS_FULL_CONTROL "creator owner gets full control"
55 #define PARM_CREATOR_OWNER_GETS_FULL_CONTROL_DEFAULT true
56 #define PARM_CTIME_NOW "ctime now files"
57 #define PARM_CTIME_NOW_DEFAULT NULL
58 #define PARM_CTIME_SLOP "ctime now slop"
59 #define PARM_CTIME_SLOP_DEFAULT 0
60 #define PARM_IGNORE_SACLS "ignore sacls"
61 #define PARM_IGNORE_SACLS_DEFAULT false
62 #define PARM_MTIME_NOW "mtime now files"
63 #define PARM_MTIME_NOW_DEFAULT NULL
64 #define PARM_MTIME_STATIC "mtime static files"
65 #define PARM_MTIME_STATIC_DEFAULT NULL
66 #define PARM_MTIME_SLOP "mtime now slop"
67 #define PARM_MTIME_SLOP_DEFAULT 0
68 #define PARM_USE_READDIRPLUS "use readdirplus"
69 #define PARM_USE_READDIRPLUS_DEFAULT true
70 #define PARM_SENDFILE_LARGE_READS "sendfile large reads"
71 #define PARM_SENDFILE_LARGE_READS_DEFAULT false
72 #define PARM_SENDFILE_SAFE "sendfile safe"
73 #define PARM_SENDFILE_SAFE_DEFAULT true
74 #define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE "simple file sharing compatibility mode"
75 #define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE_DEFAULT false
76 #define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE "unmappable sids deny everyone"
77 #define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE_DEFAULT false
78 #define PARM_UNMAPPABLE_SIDS_IGNORE "ignore unmappable sids"
79 #define PARM_UNMAPPABLE_SIDS_IGNORE_DEFAULT false
80 #define PARM_UNMAPPABLE_SIDS_IGNORE_LIST "unmappable sids ignore list"
81 #define PARM_UNMAPPABLE_SIDS_IGNORE_LIST_DEFAULT NULL
83 #define IS_CTIME_NOW_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
84 (cfg)->ctime_now_list,(conn)->case_sensitive))
85 #define IS_MTIME_NOW_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
86 (cfg)->mtime_now_list,(conn)->case_sensitive))
87 #define IS_ATIME_NOW_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
88 (cfg)->atime_now_list,(conn)->case_sensitive))
89 #define IS_MTIME_STATIC_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
90 (cfg)->mtime_static_list,(conn)->case_sensitive))
91 #define IS_ATIME_STATIC_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
92 (cfg)->atime_static_list,(conn)->case_sensitive))
95 * Store some commonly evaluated parameters to avoid loadparm pain.
98 #define ONEFS_VFS_CONFIG_INITIALIZED 0x00010000
100 #define ONEFS_VFS_CONFIG_FAKETIMESTAMPS 0x00000001
102 struct onefs_vfs_config
106 /* data for fake timestamps */
111 /* Per-share list of files to fake the create time for. */
112 name_compare_entry *ctime_now_list;
114 /* Per-share list of files to fake the modification time for. */
115 name_compare_entry *mtime_now_list;
117 /* Per-share list of files to fake the access time for. */
118 name_compare_entry *atime_now_list;
120 /* Per-share list of files to fake the modification time for. */
121 name_compare_entry *mtime_static_list;
123 /* The access time will equal the create time. */
124 /* The modification time will equal the create time.*/
126 /* Per-share list of files to fake the access time for. */
127 name_compare_entry *atime_static_list;
131 * vfs interface handlers
133 SMB_STRUCT_DIR *onefs_opendir(struct vfs_handle_struct *handle,
134 const char *fname, const char *mask,
137 SMB_STRUCT_DIRENT *onefs_readdir(struct vfs_handle_struct *handle,
138 SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf);
140 void onefs_seekdir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp,
143 long onefs_telldir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
145 void onefs_rewinddir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
147 int onefs_closedir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dir);
149 void onefs_init_search_op(struct vfs_handle_struct *handle,
150 SMB_STRUCT_DIR *dirp);
152 NTSTATUS onefs_create_file(vfs_handle_struct *handle,
153 struct smb_request *req,
154 uint16_t root_dir_fid,
156 uint32_t create_file_flags,
157 uint32_t access_mask,
158 uint32_t share_access,
159 uint32_t create_disposition,
160 uint32_t create_options,
161 uint32_t file_attributes,
162 uint32_t oplock_request,
163 uint64_t allocation_size,
164 struct security_descriptor *sd,
165 struct ea_list *ea_list,
166 files_struct **result,
168 SMB_STRUCT_STAT *psbuf);
170 int onefs_close(vfs_handle_struct *handle, struct files_struct *fsp);
172 int onefs_rename(vfs_handle_struct *handle, const char *oldname,
173 const char *newname);
175 int onefs_stat(vfs_handle_struct *handle, const char *fname,
176 SMB_STRUCT_STAT *sbuf);
178 int onefs_fstat(vfs_handle_struct *handle, struct files_struct *fsp,
179 SMB_STRUCT_STAT *sbuf);
181 int onefs_lstat(vfs_handle_struct *handle, const char *path,
182 SMB_STRUCT_STAT *sbuf);
184 int onefs_unlink(vfs_handle_struct *handle, const char *path);
186 int onefs_chflags(vfs_handle_struct *handle, const char *path,
189 NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
190 struct files_struct *fsp,
193 unsigned int *num_streams,
194 struct stream_struct **streams);
196 int onefs_vtimes_streams(vfs_handle_struct *handle, const char *fname,
197 int flags, struct timespec times[3]);
199 NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle,
200 struct byte_range_lock *br_lck,
201 struct lock_struct *plock,
203 struct blocking_lock_record *blr);
205 bool onefs_brl_unlock_windows(vfs_handle_struct *handle,
206 struct messaging_context *msg_ctx,
207 struct byte_range_lock *br_lck,
208 const struct lock_struct *plock);
210 bool onefs_brl_cancel_windows(vfs_handle_struct *handle,
211 struct byte_range_lock *br_lck,
212 struct lock_struct *plock,
213 struct blocking_lock_record *blr);
215 NTSTATUS onefs_notify_watch(vfs_handle_struct *vfs_handle,
216 struct sys_notify_context *ctx,
217 struct notify_entry *e,
218 void (*callback)(struct sys_notify_context *ctx,
220 struct notify_event *ev),
224 NTSTATUS onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
225 uint32 security_info, SEC_DESC **ppdesc);
227 NTSTATUS onefs_get_nt_acl(vfs_handle_struct *handle, const char* name,
228 uint32 security_info, SEC_DESC **ppdesc);
230 NTSTATUS onefs_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
231 uint32 security_info_sent, SEC_DESC *psd);
236 NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd,
237 struct ifs_security_descriptor *sd, int snum);
239 NTSTATUS onefs_split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,
240 char **pbase, char **pstream);
242 bool onefs_get_config(int snum, int config_type,
243 struct onefs_vfs_config *cfg);
245 int onefs_rdp_add_dir_state(connection_struct *conn, SMB_STRUCT_DIR *dirp);
250 int onefs_sys_create_file(connection_struct *conn,
253 uint32_t access_mask,
254 uint32_t open_access_mask,
255 uint32_t share_access,
256 uint32_t create_options,
261 struct security_descriptor *sd,
263 int *granted_oplock);
265 ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
266 const DATA_BLOB *header, SMB_OFF_T offset,
269 ssize_t onefs_sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset,
272 #endif /* _ONEFS_H */