Merge branch 'master' of git://git.samba.org/samba into teventfix
[samba.git] / source3 / modules / onefs.h
1 /*
2  * Unix SMB/CIFS implementation.
3  * Support for OneFS
4  *
5  * Copyright (C) Steven Danneman, 2008
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
21 #ifndef _ONEFS_H
22 #define _ONEFS_H
23
24 #include "includes.h"
25 #include "oplock_onefs.h"
26 #include <sys/isi_acl.h>
27
28 /* OneFS Module smb.conf parameters and defaults */
29
30 /**
31 * Specifies when ACLs presented to Windows should be canonicalized
32 * into the ordering which Explorer expects.
33 */
34 enum onefs_acl_wire_format
35 {
36         ACL_FORMAT_RAW, /**< Never canonicalize */
37         ACL_FORMAT_WINDOWS_SD, /**< Only canonicalize synthetic ACLs */
38         ACL_FORMAT_ALWAYS /**< Always canonicalize */
39 };
40
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_DOT_SNAP_CHILD_ACCESSIBLE "dot snap child accessible"
61 #define PARM_DOT_SNAP_CHILD_ACCESSIBLE_DEFAULT true
62 #define PARM_DOT_SNAP_CHILD_VISIBLE "dot snap child visible"
63 #define PARM_DOT_SNAP_CHILD_VISIBLE_DEFAULT false
64 #define PARM_DOT_SNAP_ROOT_ACCESSIBLE "dot snap root accessible"
65 #define PARM_DOT_SNAP_ROOT_ACCESSIBLE_DEFAULT true
66 #define PARM_DOT_SNAP_ROOT_VISIBLE "dot snap root visible"
67 #define PARM_DOT_SNAP_ROOT_VISIBLE_DEFAULT true
68 #define PARM_DOT_SNAP_TILDE "dot snap tilde"
69 #define PARM_DOT_SNAP_TILDE_DEFAULT true
70 #define PARM_IGNORE_SACLS "ignore sacls"
71 #define PARM_IGNORE_SACLS_DEFAULT false
72 #define PARM_MTIME_NOW          "mtime now files"
73 #define PARM_MTIME_NOW_DEFAULT  NULL
74 #define PARM_MTIME_STATIC       "mtime static files"
75 #define PARM_MTIME_STATIC_DEFAULT NULL
76 #define PARM_MTIME_SLOP         "mtime now slop"
77 #define PARM_MTIME_SLOP_DEFAULT 0
78 #define PARM_USE_READDIRPLUS "use readdirplus"
79 #define PARM_USE_READDIRPLUS_DEFAULT true
80 #define PARM_SENDFILE_LARGE_READS "sendfile large reads"
81 #define PARM_SENDFILE_LARGE_READS_DEFAULT false
82 #define PARM_SENDFILE_SAFE "sendfile safe"
83 #define PARM_SENDFILE_SAFE_DEFAULT true
84 #define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE "simple file sharing compatibility mode"
85 #define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE_DEFAULT false
86 #define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE "unmappable sids deny everyone"
87 #define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE_DEFAULT false
88 #define PARM_UNMAPPABLE_SIDS_IGNORE "ignore unmappable sids"
89 #define PARM_UNMAPPABLE_SIDS_IGNORE_DEFAULT false
90 #define PARM_UNMAPPABLE_SIDS_IGNORE_LIST "unmappable sids ignore list"
91 #define PARM_UNMAPPABLE_SIDS_IGNORE_LIST_DEFAULT NULL
92
93 #define IS_CTIME_NOW_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
94         (cfg)->ctime_now_list,(conn)->case_sensitive))
95 #define IS_MTIME_NOW_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
96         (cfg)->mtime_now_list,(conn)->case_sensitive))
97 #define IS_ATIME_NOW_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
98         (cfg)->atime_now_list,(conn)->case_sensitive))
99 #define IS_MTIME_STATIC_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
100         (cfg)->mtime_static_list,(conn)->case_sensitive))
101 #define IS_ATIME_STATIC_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
102         (cfg)->atime_static_list,(conn)->case_sensitive))
103
104 /*
105  * Store some commonly evaluated parameters to avoid loadparm pain.
106  */
107
108 #define ONEFS_VFS_CONFIG_INITIALIZED    0x00010000
109
110 #define ONEFS_VFS_CONFIG_FAKETIMESTAMPS 0x00000001
111
112 struct onefs_vfs_share_config
113 {
114         uint32_t init_flags;
115
116         /* data for fake timestamps */
117         int atime_slop;
118         int ctime_slop;
119         int mtime_slop;
120
121         /* Per-share list of files to fake the create time for. */
122         name_compare_entry *ctime_now_list;
123
124         /* Per-share list of files to fake the modification time for. */
125         name_compare_entry *mtime_now_list;
126
127         /* Per-share list of files to fake the access time for. */
128         name_compare_entry *atime_now_list;
129
130         /* Per-share list of files to fake the modification time for. */
131         name_compare_entry *mtime_static_list;
132
133         /* The access  time  will  equal  the  create  time.  */
134         /* The  modification  time  will  equal  the  create  time.*/
135
136         /* Per-share list of files to fake the access time for. */
137         name_compare_entry *atime_static_list;
138 };
139
140 struct onefs_vfs_global_config
141 {
142         uint32_t init_flags;
143
144         /* Snapshot options */
145         bool dot_snap_child_accessible;
146         bool dot_snap_child_visible;
147         bool dot_snap_root_accessible;
148         bool dot_snap_root_visible;
149         bool dot_snap_tilde;
150 };
151
152 /*
153  * vfs interface handlers
154  */
155 SMB_STRUCT_DIR *onefs_opendir(struct vfs_handle_struct *handle,
156                               const char *fname, const char *mask,
157                               uint32 attributes);
158
159 SMB_STRUCT_DIRENT *onefs_readdir(struct vfs_handle_struct *handle,
160                                  SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf);
161
162 void onefs_seekdir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp,
163                    long offset);
164
165 long onefs_telldir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
166
167 void onefs_rewinddir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
168
169 int onefs_closedir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dir);
170
171 void onefs_init_search_op(struct vfs_handle_struct *handle,
172                           SMB_STRUCT_DIR *dirp);
173
174 NTSTATUS onefs_create_file(vfs_handle_struct *handle,
175                            struct smb_request *req,
176                            uint16_t root_dir_fid,
177                            const char *fname,
178                            uint32_t create_file_flags,
179                            uint32_t access_mask,
180                            uint32_t share_access,
181                            uint32_t create_disposition,
182                            uint32_t create_options,
183                            uint32_t file_attributes,
184                            uint32_t oplock_request,
185                            uint64_t allocation_size,
186                            struct security_descriptor *sd,
187                            struct ea_list *ea_list,
188                            files_struct **result,
189                            int *pinfo,
190                            SMB_STRUCT_STAT *psbuf);
191
192 int onefs_close(vfs_handle_struct *handle, struct files_struct *fsp);
193
194 int onefs_rename(vfs_handle_struct *handle, const char *oldname,
195                  const char *newname);
196
197 int onefs_stat(vfs_handle_struct *handle, const char *fname,
198                SMB_STRUCT_STAT *sbuf);
199
200 int onefs_fstat(vfs_handle_struct *handle, struct files_struct *fsp,
201                 SMB_STRUCT_STAT *sbuf);
202
203 int onefs_lstat(vfs_handle_struct *handle, const char *path,
204                 SMB_STRUCT_STAT *sbuf);
205
206 int onefs_unlink(vfs_handle_struct *handle, const char *path);
207
208 int onefs_chflags(vfs_handle_struct *handle, const char *path,
209                   unsigned int flags);
210
211 NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
212                           struct files_struct *fsp,
213                           const char *fname,
214                           TALLOC_CTX *mem_ctx,
215                           unsigned int *num_streams,
216                           struct stream_struct **streams);
217
218 int onefs_vtimes_streams(vfs_handle_struct *handle, const char *fname,
219                          int flags, struct timespec times[3]);
220
221 NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle,
222                                 struct byte_range_lock *br_lck,
223                                 struct lock_struct *plock,
224                                 bool blocking_lock,
225                                 struct blocking_lock_record *blr);
226
227 bool onefs_brl_unlock_windows(vfs_handle_struct *handle,
228                               struct messaging_context *msg_ctx,
229                               struct byte_range_lock *br_lck,
230                               const struct lock_struct *plock);
231
232 bool onefs_brl_cancel_windows(vfs_handle_struct *handle,
233                               struct byte_range_lock *br_lck,
234                               struct lock_struct *plock,
235                               struct blocking_lock_record *blr);
236
237 NTSTATUS onefs_notify_watch(vfs_handle_struct *vfs_handle,
238                             struct sys_notify_context *ctx,
239                             struct notify_entry *e,
240                             void (*callback)(struct sys_notify_context *ctx,
241                                         void *private_data,
242                                         struct notify_event *ev),
243                             void *private_data,
244                             void *handle_p);
245
246 NTSTATUS onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
247                            uint32 security_info, SEC_DESC **ppdesc);
248
249 NTSTATUS onefs_get_nt_acl(vfs_handle_struct *handle, const char* name,
250                           uint32 security_info, SEC_DESC **ppdesc);
251
252 NTSTATUS onefs_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
253                            uint32 security_info_sent, SEC_DESC *psd);
254
255 /*
256  * Utility functions
257  */
258 NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd,
259                               struct ifs_security_descriptor *sd, int snum);
260
261 NTSTATUS onefs_split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,
262                                       char **pbase, char **pstream);
263
264 bool onefs_get_config(int snum, int config_type,
265                       struct onefs_vfs_share_config *cfg);
266
267 int onefs_rdp_add_dir_state(connection_struct *conn, SMB_STRUCT_DIR *dirp);
268
269 /*
270  * System Interfaces
271  */
272 int onefs_sys_create_file(connection_struct *conn,
273                           int base_fd,
274                           const char *path,
275                           uint32_t access_mask,
276                           uint32_t open_access_mask,
277                           uint32_t share_access,
278                           uint32_t create_options,
279                           int flags,
280                           mode_t mode,
281                           int oplock_request,
282                           uint64_t id,
283                           struct security_descriptor *sd,
284                           uint32_t ntfs_flags,
285                           int *granted_oplock);
286
287 ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
288                            const DATA_BLOB *header, SMB_OFF_T offset,
289                            size_t count);
290
291 ssize_t onefs_sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset,
292                            size_t count);
293
294 void onefs_sys_config_enc(void);
295 void onefs_sys_config_snap_opt(struct onefs_vfs_global_config *global_config);
296 void onefs_sys_config_tilde(struct onefs_vfs_global_config *global_config);
297
298 #endif /* _ONEFS_H */