s3 OneFS: Add defaults to the fake timestamp parameters
[metze/samba/wip.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_ATIME_NOW          "atime now files"
45 #define PARM_ATIME_NOW_DEFAULT  NULL
46 #define PARM_ATIME_STATIC       "atime static files"
47 #define PARM_ATIME_STATIC_DEFAULT NULL
48 #define PARM_ATIME_SLOP         "atime now slop"
49 #define PARM_ATIME_SLOP_DEFAULT  0
50 #define PARM_CREATOR_OWNER_GETS_FULL_CONTROL "creator owner gets full control"
51 #define PARM_CREATOR_OWNER_GETS_FULL_CONTROL_DEFAULT true
52 #define PARM_CTIME_NOW          "ctime now files"
53 #define PARM_CTIME_NOW_DEFAULT  NULL
54 #define PARM_CTIME_SLOP         "ctime now slop"
55 #define PARM_CTIME_SLOP_DEFAULT 0
56 #define PARM_IGNORE_SACLS "ignore sacls"
57 #define PARM_IGNORE_SACLS_DEFAULT false
58 #define PARM_MTIME_NOW          "mtime now files"
59 #define PARM_MTIME_NOW_DEFAULT  NULL
60 #define PARM_MTIME_STATIC       "mtime static files"
61 #define PARM_MTIME_STATIC_DEFAULT NULL
62 #define PARM_MTIME_SLOP         "mtime now slop"
63 #define PARM_MTIME_SLOP_DEFAULT 0
64 #define PARM_USE_READDIRPLUS "use readdirplus"
65 #define PARM_USE_READDIRPLUS_DEFAULT true
66 #define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE "simple file sharing compatibility mode"
67 #define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE_DEFAULT false
68 #define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE "unmappable sids deny everyone"
69 #define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE_DEFAULT false
70 #define PARM_UNMAPPABLE_SIDS_IGNORE "ignore unmappable sids"
71 #define PARM_UNMAPPABLE_SIDS_IGNORE_DEFAULT false
72 #define PARM_UNMAPPABLE_SIDS_IGNORE_LIST "unmappable sids ignore list"
73 #define PARM_UNMAPPABLE_SIDS_IGNORE_LIST_DEFAULT NULL
74
75 #define IS_CTIME_NOW_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
76         (cfg)->ctime_now_list,(conn)->case_sensitive))
77 #define IS_MTIME_NOW_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
78         (cfg)->mtime_now_list,(conn)->case_sensitive))
79 #define IS_ATIME_NOW_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
80         (cfg)->atime_now_list,(conn)->case_sensitive))
81 #define IS_MTIME_STATIC_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
82         (cfg)->mtime_static_list,(conn)->case_sensitive))
83 #define IS_ATIME_STATIC_PATH(conn,cfg,path)  ((conn) && is_in_path((path),\
84         (cfg)->atime_static_list,(conn)->case_sensitive))
85
86 /*
87  * Store some commonly evaluated parameters to avoid loadparm pain.
88  */
89
90 #define ONEFS_VFS_CONFIG_INITIALIZED    0x00010000
91
92 #define ONEFS_VFS_CONFIG_FAKETIMESTAMPS 0x00000001
93
94 struct onefs_vfs_config
95 {
96         int32 init_flags;
97
98         /* data for fake timestamps */
99         int atime_slop;
100         int ctime_slop;
101         int mtime_slop;
102
103         /* Per-share list of files to fake the create time for. */
104         name_compare_entry *ctime_now_list;
105
106         /* Per-share list of files to fake the modification time for. */
107         name_compare_entry *mtime_now_list;
108
109         /* Per-share list of files to fake the access time for. */
110         name_compare_entry *atime_now_list;
111
112         /* Per-share list of files to fake the modification time for. */
113         name_compare_entry *mtime_static_list;
114
115         /* The access  time  will  equal  the  create  time.  */
116         /* The  modification  time  will  equal  the  create  time.*/
117
118         /* Per-share list of files to fake the access time for. */
119         name_compare_entry *atime_static_list;
120 };
121
122 /*
123  * vfs interface handlers
124  */
125 SMB_STRUCT_DIR *onefs_opendir(struct vfs_handle_struct *handle,
126                               const char *fname, const char *mask,
127                               uint32 attributes);
128
129 SMB_STRUCT_DIRENT *onefs_readdir(struct vfs_handle_struct *handle,
130                                  SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf);
131
132 void onefs_seekdir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp,
133                    long offset);
134
135 long onefs_telldir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
136
137 void onefs_rewinddir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
138
139 int onefs_closedir(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dir);
140
141 void onefs_init_search_op(struct vfs_handle_struct *handle,
142                           SMB_STRUCT_DIR *dirp);
143
144 NTSTATUS onefs_create_file(vfs_handle_struct *handle,
145                            struct smb_request *req,
146                            uint16_t root_dir_fid,
147                            const char *fname,
148                            uint32_t create_file_flags,
149                            uint32_t access_mask,
150                            uint32_t share_access,
151                            uint32_t create_disposition,
152                            uint32_t create_options,
153                            uint32_t file_attributes,
154                            uint32_t oplock_request,
155                            uint64_t allocation_size,
156                            struct security_descriptor *sd,
157                            struct ea_list *ea_list,
158                            files_struct **result,
159                            int *pinfo,
160                            SMB_STRUCT_STAT *psbuf);
161
162 int onefs_close(vfs_handle_struct *handle, struct files_struct *fsp);
163
164 int onefs_rename(vfs_handle_struct *handle, const char *oldname,
165                  const char *newname);
166
167 int onefs_stat(vfs_handle_struct *handle, const char *fname,
168                SMB_STRUCT_STAT *sbuf);
169
170 int onefs_fstat(vfs_handle_struct *handle, struct files_struct *fsp,
171                 SMB_STRUCT_STAT *sbuf);
172
173 int onefs_lstat(vfs_handle_struct *handle, const char *path,
174                 SMB_STRUCT_STAT *sbuf);
175
176 int onefs_unlink(vfs_handle_struct *handle, const char *path);
177
178 int onefs_chflags(vfs_handle_struct *handle, const char *path,
179                   unsigned int flags);
180
181 NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
182                           struct files_struct *fsp,
183                           const char *fname,
184                           TALLOC_CTX *mem_ctx,
185                           unsigned int *num_streams,
186                           struct stream_struct **streams);
187
188 int onefs_vtimes_streams(vfs_handle_struct *handle, const char *fname,
189                          int flags, struct timespec times[3]);
190
191 NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle,
192                                 struct byte_range_lock *br_lck,
193                                 struct lock_struct *plock,
194                                 bool blocking_lock,
195                                 struct blocking_lock_record *blr);
196
197 bool onefs_brl_unlock_windows(vfs_handle_struct *handle,
198                               struct messaging_context *msg_ctx,
199                               struct byte_range_lock *br_lck,
200                               const struct lock_struct *plock);
201
202 bool onefs_brl_cancel_windows(vfs_handle_struct *handle,
203                               struct byte_range_lock *br_lck,
204                               struct lock_struct *plock,
205                               struct blocking_lock_record *blr);
206
207 NTSTATUS onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
208                            uint32 security_info, SEC_DESC **ppdesc);
209
210 NTSTATUS onefs_get_nt_acl(vfs_handle_struct *handle, const char* name,
211                           uint32 security_info, SEC_DESC **ppdesc);
212
213 NTSTATUS onefs_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
214                            uint32 security_info_sent, SEC_DESC *psd);
215
216 /*
217  * Utility functions
218  */
219 NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd,
220                               struct ifs_security_descriptor *sd, int snum);
221
222 NTSTATUS onefs_split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,
223                                       char **pbase, char **pstream);
224
225 bool onefs_get_config(int snum, int config_type,
226                       struct onefs_vfs_config *cfg);
227 /*
228  * System Interfaces
229  */
230 int onefs_sys_create_file(connection_struct *conn,
231                           int base_fd,
232                           const char *path,
233                           uint32_t access_mask,
234                           uint32_t open_access_mask,
235                           uint32_t share_access,
236                           uint32_t create_options,
237                           int flags,
238                           mode_t mode,
239                           int oplock_request,
240                           uint64_t id,
241                           struct security_descriptor *sd,
242                           uint32_t ntfs_flags,
243                           int *granted_oplock);
244
245 ssize_t onefs_sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset,
246                            size_t count);
247
248 #endif /* _ONEFS_H */