smbd: Remove unused dptr_SearchDir() and the dir cache
[samba.git] / source3 / smbd / proto.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  Main SMB server routines
4  *
5  *  Copyright (C) Andrew Tridgell                       1992-2002,2006
6  *  Copyright (C) Jeremy Allison                        1992-2010
7  *  Copyright (C) Volker Lendecke                       1993-2009
8  *  Copyright (C) John H Terpstra                       1995-1998
9  *  Copyright (C) Luke Kenneth Casson Leighton          1996-1998
10  *  Copyright (C) Paul Ashton                           1997-1998
11  *  Copyright (C) Tim Potter                            1999-2000
12  *  Copyright (C) T.D.Lee@durham.ac.uk                  1999
13  *  Copyright (C) Ying Chen                             2000
14  *  Copyright (C) Shirish Kalele                        2000
15  *  Copyright (C) Andrew Bartlett                       2001-2003
16  *  Copyright (C) Alexander Bokovoy                     2002,2005
17  *  Copyright (C) Simo Sorce                            2001-2002,2009
18  *  Copyright (C) Andreas Gruenbacher                   2002
19  *  Copyright (C) Jim McDonough <jmcd@us.ibm.com>       2002
20  *  Copyright (C) Martin Pool                           2002
21  *  Copyright (C) Luke Howard                           2003
22  *  Copyright (C) Stefan (metze) Metzmacher             2003,2009
23  *  Copyright (C) Steve French                          2005
24  *  Copyright (C) Gerald (Jerry) Carter                 2006
25  *  Copyright (C) James Peach                           2006-2007
26  *  Copyright (C) Jelmer Vernooij                       2002-2003
27  *  Copyright (C) Michael Adam                          2007
28  *  Copyright (C) Rishi Srivatsavai                     2007
29  *  Copyright (C) Tim Prouty                            2009
30  *  Copyright (C) Gregor Beck                           2011
31  *
32  *  This program is free software; you can redistribute it and/or modify
33  *  it under the terms of the GNU General Public License as published by
34  *  the Free Software Foundation; either version 3 of the License, or
35  *  (at your option) any later version.
36  *
37  *  This program is distributed in the hope that it will be useful,
38  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
39  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40  *  GNU General Public License for more details.
41  *
42  *  You should have received a copy of the GNU General Public License
43  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
44  */
45
46 #ifndef _SMBD_PROTO_H_
47 #define _SMBD_PROTO_H_
48
49 struct smbXsrv_client;
50 struct smbXsrv_connection;
51 struct dcesrv_context;
52
53 /* The following definitions come from smbd/smb2_signing.c */
54
55 bool smb2_srv_init_signing(struct smbXsrv_connection *conn);
56 bool srv_init_signing(struct smbXsrv_connection *conn);
57
58 /* The following definitions come from smbd/aio.c  */
59
60 struct aio_extra;
61 bool aio_write_through_requested(struct aio_extra *aio_ex);
62 NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
63                                 struct smb_request *smbreq,
64                                 files_struct *fsp,
65                                 TALLOC_CTX *ctx,
66                                 DATA_BLOB *preadbuf,
67                                 off_t startpos,
68                                 size_t smb_maxcnt);
69 NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
70                                 struct smb_request *smbreq,
71                                 files_struct *fsp,
72                                 uint64_t in_offset,
73                                 DATA_BLOB in_data,
74                                 bool write_through);
75 bool cancel_smb2_aio(struct smb_request *smbreq);
76 bool aio_add_req_to_fsp(files_struct *fsp, struct tevent_req *req);
77 struct aio_extra *create_aio_extra(TALLOC_CTX *mem_ctx,
78                                    files_struct *fsp,
79                                    size_t buflen);
80 struct tevent_req *pwrite_fsync_send(TALLOC_CTX *mem_ctx,
81                                      struct tevent_context *ev,
82                                      struct files_struct *fsp,
83                                      const void *data,
84                                      size_t n, off_t offset,
85                                      bool write_through);
86 ssize_t pwrite_fsync_recv(struct tevent_req *req, int *perr);
87
88 /* The following definitions come from smbd/blocking.c  */
89
90 NTSTATUS smbd_do_locks_try(
91         struct files_struct *fsp,
92         uint16_t num_locks,
93         struct smbd_lock_element *locks,
94         uint16_t *blocker_idx,
95         struct server_id *blocking_pid,
96         uint64_t *blocking_smblctx);
97 struct tevent_req *smbd_smb1_do_locks_send(
98         TALLOC_CTX *mem_ctx,
99         struct tevent_context *ev,
100         struct smb_request **smbreq, /* talloc_move()d into our state */
101         struct files_struct *fsp,
102         uint32_t lock_timeout,
103         bool large_offset,
104         uint16_t num_locks,
105         struct smbd_lock_element *locks);
106 NTSTATUS smbd_smb1_do_locks_recv(struct tevent_req *req);
107 bool smbd_smb1_do_locks_extract_smbreq(
108         struct tevent_req *req,
109         TALLOC_CTX *mem_ctx,
110         struct smb_request **psmbreq);
111 void smbd_smb1_brl_finish_by_req(struct tevent_req *req, NTSTATUS status);
112 bool smbd_smb1_brl_finish_by_lock(
113         struct files_struct *fsp,
114         bool large_offset,
115         struct smbd_lock_element lock,
116         NTSTATUS finish_status);
117 bool smbd_smb1_brl_finish_by_mid(
118         struct smbd_server_connection *sconn, uint64_t mid);
119
120 /* The following definitions come from smbd/close.c  */
121
122 void set_close_write_time(struct files_struct *fsp, struct timespec ts);
123 NTSTATUS close_file_smb(struct smb_request *req,
124                         struct files_struct *fsp,
125                         enum file_close_type close_type);
126 NTSTATUS close_file_free(struct smb_request *req,
127                          struct files_struct **_fsp,
128                          enum file_close_type close_type);
129 void msg_close_file(struct messaging_context *msg_ctx,
130                     void *private_data,
131                     uint32_t msg_type,
132                     struct server_id server_id,
133                     DATA_BLOB *data);
134 NTSTATUS delete_all_streams(connection_struct *conn,
135                         const struct smb_filename *smb_fname);
136 NTSTATUS recursive_rmdir(TALLOC_CTX *ctx,
137                      connection_struct *conn,
138                      struct smb_filename *smb_dname);
139 bool has_other_nonposix_opens(struct share_mode_lock *lck,
140                               struct files_struct *fsp);
141
142 /* The following definitions come from smbd/conn.c  */
143
144 int conn_num_open(struct smbd_server_connection *sconn);
145 bool conn_snum_used(struct smbd_server_connection *sconn, int snum);
146 connection_struct *conn_new(struct smbd_server_connection *sconn);
147 bool conn_idle_all(struct smbd_server_connection *sconn, time_t t);
148 void conn_clear_vuid_caches(struct smbd_server_connection *sconn, uint64_t vuid);
149 void conn_free(connection_struct *conn);
150 void conn_setup_case_options(connection_struct *conn);
151 void conn_force_tdis(
152         struct smbd_server_connection *sconn,
153         bool (*check_fn)(struct connection_struct *conn,
154                          void *private_data),
155         void *private_data);
156 void msg_force_tdis(struct messaging_context *msg,
157                     void *private_data,
158                     uint32_t msg_type,
159                     struct server_id server_id,
160                     DATA_BLOB *data);
161 void msg_force_tdis_denied(
162         struct messaging_context *msg,
163         void *private_data,
164         uint32_t msg_type,
165         struct server_id server_id,
166         DATA_BLOB *data);
167
168 /* The following definitions come from smbd/connection.c  */
169
170 int count_current_connections(const char *sharename, bool verify);
171 bool connections_snum_used(struct smbd_server_connection *unused, int snum);
172
173 /* The following definitions come from smbd/dfree.c  */
174
175 uint64_t get_dfree_info(connection_struct *conn, struct smb_filename *fname,
176                         uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
177 void flush_dfree_cache(void);
178
179 /* The following definitions come from smbd/dir.c  */
180
181 bool init_dptrs(struct smbd_server_connection *sconn);
182 const char *dptr_path(struct smbd_server_connection *sconn, int key);
183 const char *dptr_wcard(struct smbd_server_connection *sconn, int key);
184 uint16_t dptr_attr(struct smbd_server_connection *sconn, int key);
185 void dptr_closecnum(connection_struct *conn);
186 NTSTATUS dptr_create(connection_struct *conn,
187                 struct smb_request *req,
188                 files_struct *fsp,
189                 bool old_handle,
190                 const char *wcard,
191                 uint32_t attr,
192                 struct dptr_struct **dptr_ret);
193 void dptr_CloseDir(files_struct *fsp);
194 void dptr_RewindDir(struct dptr_struct *dptr);
195 long dptr_TellDir(struct dptr_struct *dptr);
196 unsigned int dptr_FileNumber(struct dptr_struct *dptr);
197 bool dptr_has_wild(struct dptr_struct *dptr);
198 int dptr_dnum(struct dptr_struct *dptr);
199 bool dptr_get_priv(struct dptr_struct *dptr);
200 void dptr_set_priv(struct dptr_struct *dptr);
201 bool dptr_case_sensitive(struct dptr_struct *dptr);
202 char *dptr_ReadDirName(TALLOC_CTX *ctx,
203                        struct dptr_struct *dptr,
204                        long *poffset,
205                        SMB_STRUCT_STAT *pst);
206 struct smb_Dir;
207 struct files_struct *dir_hnd_fetch_fsp(struct smb_Dir *dir_hnd);
208 files_struct *dptr_fetch_lanman2_fsp(struct smbd_server_connection *sconn,
209                                        int dptr_num);
210 struct smb_Dir;
211 bool is_visible_fsp(files_struct *fsp);
212 NTSTATUS OpenDir(TALLOC_CTX *mem_ctx,
213                  connection_struct *conn,
214                  const struct smb_filename *smb_dname,
215                  const char *mask,
216                  uint32_t attr,
217                  struct smb_Dir **_dir_hnd);
218 NTSTATUS OpenDir_from_pathref(TALLOC_CTX *mem_ctx,
219                               struct files_struct *dirfsp,
220                               const char *mask,
221                               uint32_t attr,
222                               struct smb_Dir **_dir_hnd);
223 const char *ReadDirName(struct smb_Dir *dir_hnd, long *poffset,
224                         SMB_STRUCT_STAT *sbuf, char **talloced);
225 void RewindDir(struct smb_Dir *dir_hnd, long *poffset);
226 NTSTATUS can_delete_directory(struct connection_struct *conn,
227                                 const char *dirname);
228 bool have_file_open_below(connection_struct *conn,
229                         const struct smb_filename *name);
230
231 /* The following definitions come from smbd/dmapi.c  */
232
233 const void *dmapi_get_current_session(void);
234 bool dmapi_have_session(void);
235 bool dmapi_new_session(void);
236 bool dmapi_destroy_session(void);
237 uint32_t dmapi_file_flags(const char * const path);
238
239 /* The following definitions come from smbd/dnsregister.c  */
240
241 bool smbd_setup_mdns_registration(struct tevent_context *ev,
242                                   TALLOC_CTX *mem_ctx,
243                                   uint16_t port);
244
245 /* The following definitions come from smbd/dosmode.c  */
246
247 mode_t unix_mode(connection_struct *conn, int dosmode,
248                  const struct smb_filename *smb_fname,
249                  struct files_struct *parent_dirfsp);
250 uint32_t dos_mode_msdfs(connection_struct *conn,
251                       const struct smb_filename *smb_fname);
252 uint32_t fdos_mode(struct files_struct *fsp);
253 struct tevent_req *dos_mode_at_send(TALLOC_CTX *mem_ctx,
254                                     struct tevent_context *ev,
255                                     files_struct *dir_fsp,
256                                     struct smb_filename *smb_fname);
257 NTSTATUS dos_mode_at_recv(struct tevent_req *req, uint32_t *dosmode);
258 int file_set_dosmode(connection_struct *conn,
259                      struct smb_filename *smb_fname,
260                      uint32_t dosmode,
261                      struct smb_filename *parent_dir,
262                      bool newfile);
263 NTSTATUS file_set_sparse(connection_struct *conn,
264                          struct files_struct *fsp,
265                          bool sparse);
266 int file_ntimes(connection_struct *conn,
267                 files_struct *fsp,
268                 struct smb_file_time *ft);
269 bool set_sticky_write_time_path(struct file_id fileid, struct timespec mtime);
270 bool set_sticky_write_time_fsp(struct files_struct *fsp,
271                                struct timespec mtime);
272
273 NTSTATUS fget_ea_dos_attribute(struct files_struct *fsp,
274                               uint32_t *pattr);
275 NTSTATUS set_ea_dos_attribute(connection_struct *conn,
276                               struct smb_filename *smb_fname,
277                               uint32_t dosmode);
278
279 NTSTATUS set_create_timespec_ea(struct files_struct *fsp,
280                                 struct timespec create_time);
281
282 struct timespec get_create_timespec(connection_struct *conn,
283                                 struct files_struct *fsp,
284                                 const struct smb_filename *smb_fname);
285
286 struct timespec get_change_timespec(connection_struct *conn,
287                                 struct files_struct *fsp,
288                                 const struct smb_filename *smb_fname);
289
290 NTSTATUS parse_dos_attribute_blob(struct smb_filename *smb_fname,
291                                   DATA_BLOB blob,
292                                   uint32_t *pattr);
293
294 /* The following definitions come from smbd/error.c  */
295
296 bool use_nt_status(void);
297 void error_packet_set(char *outbuf, uint8_t eclass, uint32_t ecode, NTSTATUS ntstatus, int line, const char *file);
298 size_t error_packet(char *outbuf,
299                     uint8_t eclass,
300                     uint32_t ecode,
301                     NTSTATUS ntstatus,
302                     int line,
303                     const char *file);
304 void reply_nt_error(struct smb_request *req, NTSTATUS ntstatus,
305                     int line, const char *file);
306 void reply_force_dos_error(struct smb_request *req, uint8_t eclass, uint32_t ecode,
307                     int line, const char *file);
308 void reply_both_error(struct smb_request *req, uint8_t eclass, uint32_t ecode,
309                       NTSTATUS status, int line, const char *file);
310 void reply_openerror(struct smb_request *req, NTSTATUS status);
311
312 /* The following definitions come from smbd/file_access.c  */
313
314 bool can_delete_file_in_directory(connection_struct *conn,
315                         struct files_struct *dirfsp,
316                         const struct smb_filename *smb_fname);
317 bool can_write_to_fsp(struct files_struct *fsp);
318 bool directory_has_default_acl_fsp(struct files_struct *fsp);
319 NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode);
320
321 /* The following definitions come from smbd/fileio.c  */
322
323 ssize_t read_file(files_struct *fsp,char *data,off_t pos,size_t n);
324 void fsp_flush_write_time_update(struct files_struct *fsp);
325 void trigger_write_time_update(struct files_struct *fsp);
326 void trigger_write_time_update_immediate(struct files_struct *fsp);
327 void mark_file_modified(files_struct *fsp);
328 ssize_t write_file(struct smb_request *req,
329                         files_struct *fsp,
330                         const char *data,
331                         off_t pos,
332                         size_t n);
333 NTSTATUS sync_file(connection_struct *conn, files_struct *fsp, bool write_through);
334
335 /* The following definitions come from smbd/filename.c  */
336
337 uint32_t ucf_flags_from_smb_request(struct smb_request *req);
338 uint32_t filename_create_ucf_flags(struct smb_request *req, uint32_t create_disposition);
339 NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
340                                     uint32_t ucf_flags,
341                                     NTTIME twrp);
342 NTSTATUS get_real_filename_full_scan_at(struct files_struct *dirfsp,
343                                         const char *name,
344                                         bool mangled,
345                                         TALLOC_CTX *mem_ctx,
346                                         char **found_name);
347 char *get_original_lcomp(TALLOC_CTX *ctx,
348                         connection_struct *conn,
349                         const char *filename_in,
350                         uint32_t ucf_flags);
351 NTSTATUS filename_convert_smb1_search_path(TALLOC_CTX *ctx,
352                                            connection_struct *conn,
353                                            char *name_in,
354                                            uint32_t ucf_flags,
355                                            struct files_struct **_dirfsp,
356                                            struct smb_filename **_smb_fname_out,
357                                            char **_mask_out);
358 NTSTATUS get_real_filename_at(struct files_struct *dirfsp,
359                               const char *name,
360                               TALLOC_CTX *mem_ctx,
361                               char **found_name);
362
363 /* The following definitions come from smbd/files.c  */
364
365 NTSTATUS fsp_new(struct connection_struct *conn, TALLOC_CTX *mem_ctx,
366                  files_struct **result);
367 void fsp_set_gen_id(files_struct *fsp);
368 NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
369                   files_struct **result);
370 NTSTATUS fsp_bind_smb(struct files_struct *fsp, struct smb_request *req);
371 void file_close_conn(connection_struct *conn, enum file_close_type close_type);
372 bool file_init_global(void);
373 bool file_init(struct smbd_server_connection *sconn);
374 void file_close_user(struct smbd_server_connection *sconn, uint64_t vuid);
375 struct files_struct *files_forall(
376         struct smbd_server_connection *sconn,
377         struct files_struct *(*fn)(struct files_struct *fsp,
378                                    void *private_data),
379         void *private_data);
380 files_struct *file_find_fd(struct smbd_server_connection *sconn, int fd);
381 files_struct *file_find_dif(struct smbd_server_connection *sconn,
382                             struct file_id id, unsigned long gen_id);
383 files_struct *file_find_di_first(struct smbd_server_connection *sconn,
384                                  struct file_id id,
385                                  bool need_fsa);
386 files_struct *file_find_di_next(files_struct *start_fsp,
387                                  bool need_fsa);
388 struct files_struct *file_find_one_fsp_from_lease_key(
389         struct smbd_server_connection *sconn,
390         const struct smb2_lease_key *lease_key);
391 bool file_find_subpath(files_struct *dir_fsp);
392 void fsp_unbind_smb(struct smb_request *req, files_struct *fsp);
393 void file_free(struct smb_request *req, files_struct *fsp);
394 files_struct *file_fsp(struct smb_request *req, uint16_t fid);
395 struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req,
396                                   uint64_t persistent_id,
397                                   uint64_t volatile_id);
398 struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
399                                    uint64_t persistent_id,
400                                    uint64_t volatile_id);
401 NTSTATUS dup_file_fsp(
402         files_struct *from,
403         uint32_t access_mask,
404         files_struct *to);
405 NTSTATUS file_name_hash(connection_struct *conn,
406                         const char *name, uint32_t *p_name_hash);
407 NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
408                            const struct smb_filename *smb_fname_in);
409 size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen);
410 void fsp_set_base_fsp(struct files_struct *fsp, struct files_struct *base_fsp);
411 bool fsp_is_alternate_stream(const struct files_struct *fsp);
412 struct files_struct *metadata_fsp(struct files_struct *fsp);
413 bool fsp_search_ask_sharemode(struct files_struct *fsp);
414 bool fsp_getinfo_ask_sharemode(struct files_struct *fsp);
415
416 NTSTATUS create_internal_fsp(connection_struct *conn,
417                              const struct smb_filename *smb_fname,
418                              struct files_struct **_fsp);
419 NTSTATUS create_internal_dirfsp(connection_struct *conn,
420                                 const struct smb_filename *smb_dname,
421                                 struct files_struct **_fsp);
422
423 NTSTATUS open_internal_dirfsp(connection_struct *conn,
424                               const struct smb_filename *smb_dname,
425                               int open_flags,
426                               struct files_struct **_fsp);
427 NTSTATUS openat_internal_dir_from_pathref(
428         struct files_struct *dirfsp,
429         int open_flags,
430         struct files_struct **_fsp);
431
432 NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
433                             struct smb_filename *smb_fname);
434 NTSTATUS open_stream_pathref_fsp(
435         struct files_struct **_base_fsp,
436         struct smb_filename *smb_fname);
437 NTSTATUS openat_pathref_dirfsp_nosymlink(
438         TALLOC_CTX *mem_ctx,
439         struct connection_struct *conn,
440         const char *path_in,
441         NTTIME twrp,
442         bool posix,
443         struct smb_filename **_smb_fname,
444         size_t *unparsed,
445         char **substitute);
446 NTSTATUS readlink_talloc(
447         TALLOC_CTX *mem_ctx,
448         struct files_struct *dirfsp,
449         struct smb_filename *smb_relname,
450         char **_substitute);
451
452 void smb_fname_fsp_unlink(struct smb_filename *smb_fname);
453
454 NTSTATUS move_smb_fname_fsp_link(struct smb_filename *smb_fname_dst,
455                                  struct smb_filename *smb_fname_src);
456
457 NTSTATUS reference_smb_fname_fsp_link(struct smb_filename *smb_fname_dst,
458                                       const struct smb_filename *smb_fname_src);
459
460 NTSTATUS synthetic_pathref(TALLOC_CTX *mem_ctx,
461                            struct files_struct *dirfsp,
462                            const char *base_name,
463                            const char *stream_name,
464                            const SMB_STRUCT_STAT *psbuf,
465                            NTTIME twrp,
466                            uint32_t flags,
467                            struct smb_filename **_smb_fname);
468
469 NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx,
470                         struct files_struct *dirfsp,
471                         const struct smb_filename *smb_fname,
472                         struct smb_filename **_parent,
473                         struct smb_filename **_atname);
474
475 /* The following definitions come from smbd/smb2_ipc.c  */
476
477 NTSTATUS nt_status_np_pipe(NTSTATUS status);
478
479 /* The following definitions come from smbd/mangle.c  */
480
481 void mangle_reset_cache(void);
482 void mangle_change_to_posix(void);
483 bool mangle_is_mangled(const char *s, const struct share_params *p);
484 bool mangle_is_8_3(const char *fname, bool check_case,
485                    const struct share_params *p);
486 bool mangle_is_8_3_wildcards(const char *fname, bool check_case,
487                              const struct share_params *p);
488 bool mangle_must_mangle(const char *fname,
489                    const struct share_params *p);
490 bool mangle_lookup_name_from_8_3(TALLOC_CTX *ctx,
491                         const char *in,
492                         char **out, /* talloced on the given context. */
493                         const struct share_params *p);
494 bool name_to_8_3(const char *in,
495                 char out[13],
496                 bool cache83,
497                 const struct share_params *p);
498
499 /* The following definitions come from smbd/mangle_hash.c  */
500
501 const struct mangle_fns *mangle_hash_init(void);
502
503 /* The following definitions come from smbd/mangle_hash2.c  */
504
505 const struct mangle_fns *mangle_hash2_init(void);
506 const struct mangle_fns *posix_mangle_init(void);
507
508 /* The following definitions come from smbd/msdfs.c  */
509
510 bool parse_msdfs_symlink(TALLOC_CTX *ctx,
511                         bool shuffle_referrals,
512                         const char *target,
513                         struct referral **preflist,
514                         size_t *refcount);
515 bool is_msdfs_link(struct files_struct *dirfsp,
516                    struct smb_filename *smb_fname);
517 struct junction_map;
518 NTSTATUS get_referred_path(TALLOC_CTX *ctx,
519                            struct auth_session_info *session_info,
520                            const char *dfs_path,
521                            const struct tsocket_address *remote_address,
522                            const struct tsocket_address *local_address,
523                            struct junction_map *jucn,
524                            size_t *consumedcntp,
525                            bool *self_referralp);
526 int setup_dfs_referral(connection_struct *orig_conn,
527                         const char *dfs_path,
528                         int max_referral_level,
529                         char **ppdata, NTSTATUS *pstatus);
530 bool create_junction(TALLOC_CTX *ctx,
531                 const char *dfs_path,
532                 struct junction_map *jucn);
533 struct referral;
534 char *msdfs_link_string(TALLOC_CTX *ctx,
535                 const struct referral *reflist,
536                 size_t referral_count);
537 bool create_msdfs_link(const struct junction_map *jucn,
538                        struct auth_session_info *session_info);
539 bool remove_msdfs_link(const struct junction_map *jucn,
540                        struct auth_session_info *session_info);
541
542 struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx,
543                                       struct auth_session_info *session_info,
544                                       size_t *p_num_jn);
545 struct connection_struct;
546 struct smb_filename;
547
548 NTSTATUS create_conn_struct_cwd(TALLOC_CTX *mem_ctx,
549                                 struct tevent_context *ev,
550                                 struct messaging_context *msg,
551                                 const struct auth_session_info *session_info,
552                                 int snum,
553                                 const char *path,
554                                 struct connection_struct **c);
555 struct conn_struct_tos {
556         struct connection_struct *conn;
557         struct smb_filename *oldcwd_fname;
558 };
559 NTSTATUS create_conn_struct_tos(struct messaging_context *msg,
560                                 int snum,
561                                 const char *path,
562                                 const struct auth_session_info *session_info,
563                                 struct conn_struct_tos **_c);
564 NTSTATUS create_conn_struct_tos_cwd(struct messaging_context *msg,
565                                     int snum,
566                                     const char *path,
567                                     const struct auth_session_info *session_info,
568                                     struct conn_struct_tos **_c);
569
570 /* The following definitions come from smbd/notify.c  */
571
572 bool change_notify_fsp_has_changes(struct files_struct *fsp);
573 void change_notify_reply(struct smb_request *req,
574                          NTSTATUS error_code,
575                          uint32_t max_param,
576                          struct notify_change_buf *notify_buf,
577                          void (*reply_fn)(struct smb_request *req,
578                                           NTSTATUS error_code,
579                                           uint8_t *buf, size_t len));
580 void notify_callback(struct smbd_server_connection *sconn,
581                      void *private_data, struct timespec when,
582                      const struct notify_event *e);
583 NTSTATUS change_notify_create(struct files_struct *fsp,
584                               uint32_t max_buffer_size,
585                               uint32_t filter,
586                               bool recursive);
587 NTSTATUS change_notify_add_request(struct smb_request *req,
588                                 uint32_t max_param,
589                                 uint32_t filter, bool recursive,
590                                 struct files_struct *fsp,
591                                 void (*reply_fn)(struct smb_request *req,
592                                         NTSTATUS error_code,
593                                         uint8_t *buf, size_t len));
594 void smbd_notify_cancel_deleted(struct messaging_context *msg,
595                                 void *private_data, uint32_t msg_type,
596                                 struct server_id server_id, DATA_BLOB *data);
597 void smbd_notifyd_restarted(struct messaging_context *msg,
598                             void *private_data, uint32_t msg_type,
599                             struct server_id server_id, DATA_BLOB *data);
600 bool remove_pending_change_notify_requests_by_mid(
601         struct smbd_server_connection *sconn, uint64_t mid);
602 void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
603                                                   NTSTATUS status);
604 void notify_fname(connection_struct *conn, uint32_t action, uint32_t filter,
605                   const char *path);
606 char *notify_filter_string(TALLOC_CTX *mem_ctx, uint32_t filter);
607 struct sys_notify_context *sys_notify_context_create(TALLOC_CTX *mem_ctx,
608                                                      struct tevent_context *ev);
609
610 /* The following definitions come from smbd/notify_inotify.c  */
611
612 int inotify_watch(TALLOC_CTX *mem_ctx,
613                   struct sys_notify_context *ctx,
614                   const char *path,
615                   uint32_t *filter,
616                   uint32_t *subdir_filter,
617                   void (*callback)(struct sys_notify_context *ctx,
618                                    void *private_data,
619                                    struct notify_event *ev,
620                                    uint32_t filter),
621                   void *private_data,
622                   void *handle_p);
623
624 int fam_watch(TALLOC_CTX *mem_ctx,
625               struct sys_notify_context *ctx,
626               const char *path,
627               uint32_t *filter,
628               uint32_t *subdir_filter,
629               void (*callback)(struct sys_notify_context *ctx,
630                                void *private_data,
631                                struct notify_event *ev,
632                                uint32_t filter),
633               void *private_data,
634               void *handle_p);
635
636
637 /* The following definitions come from smbd/notify_internal.c  */
638
639 struct notify_context *notify_init(
640         TALLOC_CTX *mem_ctx, struct messaging_context *msg,
641         struct smbd_server_connection *sconn,
642         void (*callback)(struct smbd_server_connection *sconn,
643                          void *, struct timespec,
644                          const struct notify_event *));
645 NTSTATUS notify_add(struct notify_context *ctx,
646                     const char *path, uint32_t filter, uint32_t subdir_filter,
647                     void *private_data);
648 NTSTATUS notify_remove(struct notify_context *ctx, void *private_data,
649                        char *path);
650 void notify_trigger(struct notify_context *notify,
651                     uint32_t action, uint32_t filter,
652                     const char *dir, const char *path);
653
654 /* The following definitions come from smbd/ntquotas.c  */
655
656 NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype,
657                          struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt);
658 int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt);
659 int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list);
660 void *init_quota_handle(TALLOC_CTX *mem_ctx);
661
662 /* The following definitions come from smbd/smb2_nttrans.c  */
663
664 NTSTATUS set_sd(files_struct *fsp, struct security_descriptor *psd,
665                        uint32_t security_info_sent);
666 NTSTATUS set_sd_blob(files_struct *fsp, uint8_t *data, uint32_t sd_len,
667                        uint32_t security_info_sent);
668 NTSTATUS copy_internals(TALLOC_CTX *ctx,
669                         connection_struct *conn,
670                         struct smb_request *req,
671                         struct files_struct *src_dirfsp,
672                         struct smb_filename *smb_fname_src,
673                         struct files_struct *dst_dirfsp,
674                         struct smb_filename *smb_fname_dst,
675                         uint32_t attrs);
676 NTSTATUS smbd_do_query_security_desc(connection_struct *conn,
677                                         TALLOC_CTX *mem_ctx,
678                                         files_struct *fsp,
679                                         uint32_t security_info_wanted,
680                                         uint32_t max_data_count,
681                                         uint8_t **ppmarshalled_sd,
682                                         size_t *psd_size);
683 #ifdef HAVE_SYS_QUOTAS
684
685 struct smb2_query_quota_info;
686
687 NTSTATUS smbd_do_query_getinfo_quota(TALLOC_CTX *mem_ctx,
688                                      files_struct *fsp,
689                                      bool restart_scan,
690                                      bool return_single,
691                                      uint32_t sid_list_length,
692                                      DATA_BLOB *sidbuffer,
693                                      uint32_t max_data_count,
694                                      uint8_t **p_data,
695                                      uint32_t *p_data_size);
696 #endif
697
698 /* The following definitions come from smbd/open.c  */
699
700 NTSTATUS smbd_check_access_rights_fsp(struct files_struct *dirfsp,
701                                       struct files_struct *fsp,
702                                       bool use_privs,
703                                       uint32_t access_mask);
704 NTSTATUS check_parent_access_fsp(struct files_struct *fsp,
705                                 uint32_t access_mask);
706 NTSTATUS fd_openat(const struct files_struct *dirfsp,
707                    struct smb_filename *smb_fname,
708                    files_struct *fsp,
709                    const struct vfs_open_how *how);
710 NTSTATUS fd_close(files_struct *fsp);
711 bool is_oplock_stat_open(uint32_t access_mask);
712 bool is_lease_stat_open(uint32_t access_mask);
713 NTSTATUS send_break_message(struct messaging_context *msg_ctx,
714                             const struct file_id *id,
715                             const struct share_mode_entry *exclusive,
716                             uint16_t break_to);
717 struct deferred_open_record;
718 bool is_deferred_open_async(const struct deferred_open_record *rec);
719 bool defer_smb1_sharing_violation(struct smb_request *req);
720 NTSTATUS create_directory(connection_struct *conn,
721                           struct smb_request *req,
722                           struct files_struct *dirfsp,
723                           struct smb_filename *smb_dname);
724 void msg_file_was_renamed(struct messaging_context *msg,
725                           void *private_data,
726                           uint32_t msg_type,
727                           struct server_id server_id,
728                           DATA_BLOB *data);
729 struct fsp_lease *find_fsp_lease(struct files_struct *new_fsp,
730                                  const struct smb2_lease_key *key,
731                                  uint32_t current_state,
732                                  uint16_t lease_version,
733                                  uint16_t lease_epoch);
734 NTSTATUS create_file_default(connection_struct *conn,
735                              struct smb_request *req,
736                              struct files_struct *dirfsp,
737                              struct smb_filename * smb_fname,
738                              uint32_t access_mask,
739                              uint32_t share_access,
740                              uint32_t create_disposition,
741                              uint32_t create_options,
742                              uint32_t file_attributes,
743                              uint32_t oplock_request,
744                              const struct smb2_lease *lease,
745                              uint64_t allocation_size,
746                              uint32_t private_flags,
747                              struct security_descriptor *sd,
748                              struct ea_list *ea_list,
749                              files_struct **result,
750                              int *pinfo,
751                              const struct smb2_create_blobs *in_context_blobs,
752                              struct smb2_create_blobs *out_context_blobs);
753
754 /* The following definitions come from smbd/oplock.c  */
755
756 uint32_t get_lease_type(struct share_mode_entry *e, struct file_id id);
757
758 void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp);
759 NTSTATUS set_file_oplock(files_struct *fsp);
760 void release_file_oplock(files_struct *fsp);
761 bool remove_oplock(files_struct *fsp);
762 bool downgrade_oplock(files_struct *fsp);
763 bool fsp_lease_update(struct files_struct *fsp);
764 NTSTATUS downgrade_lease(struct smbXsrv_client *client,
765                         uint32_t num_file_ids,
766                         const struct file_id *ids,
767                         const struct smb2_lease_key *key,
768                         uint32_t lease_state);
769 void contend_level2_oplocks_begin(files_struct *fsp,
770                                   enum level2_contention_type type);
771 void contend_level2_oplocks_end(files_struct *fsp,
772                                 enum level2_contention_type type);
773 void smbd_contend_level2_oplocks_begin(files_struct *fsp,
774                                   enum level2_contention_type type);
775 void smbd_contend_level2_oplocks_end(files_struct *fsp,
776                                 enum level2_contention_type type);
777 void share_mode_entry_to_message(char *msg, const struct file_id *id,
778                                  const struct share_mode_entry *e);
779 void message_to_share_mode_entry(struct file_id *id,
780                                  struct share_mode_entry *e,
781                                  const char *msg);
782 bool init_oplocks(struct smbd_server_connection *sconn);
783 void init_kernel_oplocks(struct smbd_server_connection *sconn);
784
785 /* The following definitions come from smbd/oplock_linux.c  */
786
787 int linux_set_lease_sighandler(int fd);
788 int linux_setlease(int fd, int leasetype);
789 struct kernel_oplocks *linux_init_kernel_oplocks(struct smbd_server_connection *sconn);
790
791 /* The following definitions come from smbd/password.c  */
792
793 void invalidate_vuid(struct smbd_server_connection *sconn, uint64_t vuid);
794 int register_homes_share(const char *username);
795
796 /* The following definitions come from smbd/pipes.c  */
797
798 NTSTATUS open_np_file(struct smb_request *smb_req, const char *name,
799                       struct files_struct **pfsp);
800
801 /* The following definitions come from smbd/posix_acls.c  */
802
803 mode_t unix_perms_to_acl_perms(mode_t mode, int r_mask, int w_mask, int x_mask);
804 int map_acl_perms_to_permset(mode_t mode, SMB_ACL_PERMSET_T *p_permset);
805 uint32_t map_canon_ace_perms(int snum,
806                                 enum security_ace_type *pacl_type,
807                                 mode_t perms,
808                                 bool directory_ace);
809 bool current_user_in_group(connection_struct *conn, gid_t gid);
810 SMB_ACL_T free_empty_sys_acl(connection_struct *conn, SMB_ACL_T the_acl);
811 NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
812                            TALLOC_CTX *mem_ctx,
813                            struct security_descriptor **ppdesc);
814 NTSTATUS chown_if_needed(files_struct *fsp, uint32_t security_info_sent,
815                          const struct security_descriptor *psd,
816                          bool *did_chown);
817 NTSTATUS set_nt_acl(files_struct *fsp, uint32_t security_info_sent, const struct security_descriptor *psd);
818 int get_acl_group_bits(connection_struct *conn,
819                        struct files_struct *fsp,
820                        mode_t *mode);
821 int inherit_access_posix_acl(connection_struct *conn,
822                              struct files_struct *inherit_from_dirfsp,
823                              const struct smb_filename *smb_fname,
824                              mode_t mode);
825 NTSTATUS set_unix_posix_default_acl(connection_struct *conn,
826                                 files_struct *fsp,
827                                 uint16_t num_def_acls, const char *pdata);
828 NTSTATUS set_unix_posix_acl(connection_struct *conn, files_struct *fsp,
829                                 uint16_t num_acls,
830                                 const char *pdata);
831 int posix_sys_acl_blob_get_file(vfs_handle_struct *handle,
832                                 const struct smb_filename *smb_fname,
833                                 TALLOC_CTX *mem_ctx,
834                                 char **blob_description,
835                                 DATA_BLOB *blob);
836 int posix_sys_acl_blob_get_fd(vfs_handle_struct *handle,
837                               files_struct *fsp,
838                               TALLOC_CTX *mem_ctx,
839                               char **blob_description,
840                               DATA_BLOB *blob);
841
842 enum default_acl_style {DEFAULT_ACL_POSIX, DEFAULT_ACL_WINDOWS, DEFAULT_ACL_EVERYONE};
843
844 const struct enum_list *get_default_acl_style_list(void);
845
846 NTSTATUS make_default_filesystem_acl(
847         TALLOC_CTX *ctx,
848         enum default_acl_style acl_style,
849         const char *name,
850         const SMB_STRUCT_STAT *psbuf,
851         struct security_descriptor **ppdesc);
852
853 /* The following definitions come from smbd/smb2_process.c  */
854
855 #if !defined(WITH_SMB1SERVER)
856 bool smb1_srv_send(struct smbXsrv_connection *xconn,
857                    char *buffer,
858                    bool do_signing,
859                    uint32_t seqnum,
860                    bool do_encrypt);
861 #endif
862 size_t srv_smb1_set_message(char *buf,
863                        size_t num_words,
864                        size_t num_bytes,
865                        bool zero);
866 NTSTATUS read_packet_remainder(int fd, char *buffer,
867                                unsigned int timeout, ssize_t len);
868 NTSTATUS receive_smb_talloc(TALLOC_CTX *mem_ctx,
869                             struct smbXsrv_connection *xconn,
870                             int sock,
871                             char **buffer, unsigned int timeout,
872                             size_t *p_unread, bool *p_encrypted,
873                             size_t *p_len,
874                             uint32_t *seqnum,
875                             bool trusted_channel);
876 void remove_deferred_open_message_smb(struct smbXsrv_connection *xconn,
877                                       uint64_t mid);
878 bool schedule_deferred_open_message_smb(struct smbXsrv_connection *xconn,
879                                         uint64_t mid);
880 bool open_was_deferred(struct smbXsrv_connection *xconn, uint64_t mid);
881 bool get_deferred_open_message_state(struct smb_request *smbreq,
882                                 struct timeval *p_request_time,
883                                 struct deferred_open_record **open_rec);
884 bool push_deferred_open_message_smb(struct smb_request *req,
885                                     struct timeval timeout,
886                                     struct file_id id,
887                                     struct deferred_open_record *open_rec);
888 bool create_smb1_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
889                    const uint8_t *inbuf, char **outbuf,
890                    uint8_t num_words, uint32_t num_bytes);
891 void construct_smb1_reply_common_req(struct smb_request *req, char *outbuf);
892 void reply_smb1_outbuf(struct smb_request *req, uint8_t num_words, uint32_t num_bytes);
893 void process_smb(struct smbXsrv_connection *xconn,
894                  uint8_t *inbuf,
895                  size_t nread,
896                  size_t unread_bytes,
897                  uint32_t seqnum,
898                  bool encrypted);
899 void smbd_process(struct tevent_context *ev_ctx,
900                   struct messaging_context *msg_ctx,
901                   int sock_fd,
902                   bool interactive);
903 bool valid_smb1_header(const uint8_t *inbuf);
904 bool init_smb1_request(struct smb_request *req,
905                       struct smbd_server_connection *sconn,
906                       struct smbXsrv_connection *xconn,
907                       const uint8_t *inbuf,
908                       size_t unread_bytes, bool encrypted,
909                       uint32_t seqnum);
910
911 /* The following definitions come from smbd/quotas.c  */
912
913 bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
914                  uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
915
916 /* The following definitions come from smbd/smb2_reply.c  */
917
918 NTSTATUS check_path_syntax(char *path, bool posix);
919 NTSTATUS smb1_strip_dfs_path(TALLOC_CTX *mem_ctx,
920                              uint32_t *ucf_flags,
921                              char **in_path);
922 NTSTATUS smb2_strip_dfs_path(const char *in_path, const char **out_path);
923 size_t srvstr_get_path(TALLOC_CTX *ctx,
924                         const char *inbuf,
925                         uint16_t smb_flags2,
926                         char **pp_dest,
927                         const char *src,
928                         size_t src_len,
929                         int flags,
930                         NTSTATUS *err);
931 size_t srvstr_get_path_posix(TALLOC_CTX *ctx,
932                         const char *inbuf,
933                         uint16_t smb_flags2,
934                         char **pp_dest,
935                         const char *src,
936                         size_t src_len,
937                         int flags,
938                         NTSTATUS *err);
939 size_t srvstr_get_path_req(TALLOC_CTX *mem_ctx, struct smb_request *req,
940                            char **pp_dest, const char *src, int flags,
941                            NTSTATUS *err);
942 size_t srvstr_pull_req_talloc(TALLOC_CTX *ctx, struct smb_request *req,
943                               char **dest, const uint8_t *src, int flags);
944 bool check_fsp_open(connection_struct *conn, struct smb_request *req,
945                     files_struct *fsp);
946 bool check_fsp(connection_struct *conn, struct smb_request *req,
947                files_struct *fsp);
948 bool check_fsp_ntquota_handle(connection_struct *conn, struct smb_request *req,
949                               files_struct *fsp);
950 void reply_special(struct smbXsrv_connection *xconn, char *inbuf, size_t inbuf_size);
951 NTSTATUS unlink_internals(connection_struct *conn,
952                         struct smb_request *req,
953                         uint32_t dirtype,
954                         struct files_struct *dirfsp,
955                         struct smb_filename *smb_fname);
956 ssize_t fake_sendfile(struct smbXsrv_connection *xconn, files_struct *fsp,
957                       off_t startpos, size_t nread);
958 ssize_t sendfile_short_send(struct smbXsrv_connection *xconn,
959                             files_struct *fsp,
960                             ssize_t nread,
961                             size_t headersize,
962                             size_t smb_maxcnt);
963 NTSTATUS rename_internals_fsp(connection_struct *conn,
964                         files_struct *fsp,
965                         struct files_struct *dst_dirfsp,
966                         struct smb_filename *smb_fname_dst_in,
967                         const char *dst_original_lcomp,
968                         uint32_t attrs,
969                         bool replace_if_exists);
970 NTSTATUS rename_internals(TALLOC_CTX *ctx,
971                         connection_struct *conn,
972                         struct smb_request *req,
973                         struct files_struct *src_dirfsp,
974                         struct smb_filename *smb_fname_src,
975                         struct files_struct *dst_dirfsp,
976                         struct smb_filename *smb_fname_dst,
977                         const char *dst_original_lcomp,
978                         uint32_t attrs,
979                         bool replace_if_exists,
980                         uint32_t access_mask);
981 NTSTATUS copy_file(TALLOC_CTX *ctx,
982                         connection_struct *conn,
983                         struct smb_filename *smb_fname_src,
984                         struct smb_filename *smb_fname_dst,
985                         uint32_t new_create_disposition);
986 uint64_t get_lock_offset(const uint8_t *data, int data_offset,
987                          bool large_file_format);
988
989 /* The following definitions come from smbd/seal.c  */
990
991 bool is_encrypted_packet(const uint8_t *inbuf);
992 void srv_free_enc_buffer(struct smbXsrv_connection *xconn, char *buf);
993 NTSTATUS srv_decrypt_buffer(struct smbXsrv_connection *xconn, char *buf);
994 NTSTATUS srv_encrypt_buffer(struct smbXsrv_connection *xconn, char *buf,
995                             char **buf_out);
996 NTSTATUS srv_request_encryption_setup(connection_struct *conn,
997                                         unsigned char **ppdata,
998                                         size_t *p_data_size,
999                                         unsigned char **pparam,
1000                                         size_t *p_param_size);
1001 NTSTATUS srv_encryption_start(connection_struct *conn);
1002 void server_encryption_shutdown(struct smbXsrv_connection *xconn);
1003
1004 /* The following definitions come from smbd/sec_ctx.c  */
1005
1006 bool unix_token_equal(const struct security_unix_token *t1, const struct security_unix_token *t2);
1007 bool push_sec_ctx(void);
1008 void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, const struct security_token *token);
1009 void set_root_sec_ctx(void);
1010 bool pop_sec_ctx(void);
1011 void init_sec_ctx(void);
1012 const struct security_token *sec_ctx_active_token(void);
1013
1014 /* The following definitions come from smbd/server.c  */
1015
1016 struct memcache *smbd_memcache(void);
1017 bool snum_is_shared_printer(int snum);
1018 void delete_and_reload_printers(void);
1019 bool reload_services(struct smbd_server_connection *sconn,
1020                      bool (*snumused) (struct smbd_server_connection *, int),
1021                      bool test);
1022
1023 /* The following definitions come from smbd/server_exit.c  */
1024
1025 void smbd_exit_server(const char *reason) _NORETURN_;
1026 void smbd_exit_server_cleanly(const char *const reason) _NORETURN_;
1027
1028 /* The following definitions come from smbd/smb2_service.c  */
1029
1030 bool set_conn_connectpath(connection_struct *conn, const char *connectpath);
1031 bool canonicalize_connect_path(connection_struct *conn);
1032 NTSTATUS set_conn_force_user_group(connection_struct *conn, int snum);
1033 bool chdir_current_service(connection_struct *conn);
1034 void load_registry_shares(void);
1035 int add_home_service(const char *service, const char *username, const char *homedir);
1036 int find_service(TALLOC_CTX *ctx, const char *service, char **p_service_out);
1037 connection_struct *make_connection_smb2(struct smbd_smb2_request *req,
1038                                         struct smbXsrv_tcon *tcon,
1039                                         int snum,
1040                                         const char *pdev,
1041                                         NTSTATUS *pstatus);
1042 NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn,
1043                               connection_struct *conn,
1044                               int snum,
1045                               struct smbXsrv_session *session,
1046                               const char *pdev);
1047 void close_cnum(connection_struct *conn,
1048                 uint64_t vuid,
1049                 enum file_close_type close_type);
1050
1051 /* The following definitions come from smbd/session.c  */
1052 struct sessionid;
1053 struct smbXsrv_session;
1054 bool session_init(void);
1055 bool session_claim(struct smbXsrv_session *session);
1056 void session_yield(struct smbXsrv_session *session);
1057 int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list);
1058 int find_sessions(TALLOC_CTX *mem_ctx, const char *username,
1059                   const char *machine, struct sessionid **session_list);
1060
1061 /* The following definitions come from smbd/share_access.c  */
1062
1063 bool token_contains_name_in_list(const char *username,
1064                                  const char *domain,
1065                                  const char *sharename,
1066                                  const struct security_token *token,
1067                                  const char **list);
1068 bool user_ok_token(const char *username, const char *domain,
1069                    const struct security_token *token, int snum);
1070 bool is_share_read_only_for_token(const char *username,
1071                                   const char *domain,
1072                                   const struct security_token *token,
1073                                   connection_struct *conn);
1074
1075 /* The following definitions come from smbd/srvstr.c  */
1076
1077 NTSTATUS srvstr_push_fn(const char *base_ptr, uint16_t smb_flags2, void *dest,
1078                       const char *src, int dest_len, int flags, size_t *ret_len);
1079
1080 /* The following definitions come from smbd/statvfs.c  */
1081
1082 int sys_statvfs(const char *path, struct vfs_statvfs_struct *statbuf);
1083
1084 /* The following definitions come from smbd/trans2.c  */
1085
1086 char *store_file_unix_basic(connection_struct *conn,
1087                             char *pdata,
1088                             files_struct *fsp,
1089                             const SMB_STRUCT_STAT *psbuf);
1090 char *store_file_unix_basic_info2(connection_struct *conn,
1091                                   char *pdata,
1092                                   files_struct *fsp,
1093                                   const SMB_STRUCT_STAT *psbuf);
1094 NTSTATUS smb_set_file_disposition_info(connection_struct *conn,
1095                                        const char *pdata,
1096                                        int total_data,
1097                                        files_struct *fsp,
1098                                        struct smb_filename *smb_fname);
1099 NTSTATUS refuse_symlink_fsp(const struct files_struct *fsp);
1100 NTSTATUS check_access_fsp(struct files_struct *fsp,
1101                           uint32_t access_mask);
1102 uint64_t smb_roundup(connection_struct *conn, uint64_t val);
1103 bool samba_private_attr_name(const char *unix_ea_name);
1104 NTSTATUS get_ea_value_fsp(TALLOC_CTX *mem_ctx,
1105                           files_struct *fsp,
1106                           const char *ea_name,
1107                           struct ea_struct *pea);
1108 NTSTATUS get_ea_names_from_fsp(TALLOC_CTX *mem_ctx,
1109                         files_struct *fsp,
1110                         char ***pnames,
1111                         size_t *pnum_names);
1112 NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
1113                 struct ea_list *ea_list);
1114 unsigned char *create_volume_objectid(connection_struct *conn, unsigned char objid[16]);
1115 NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
1116                 connection_struct *conn,
1117                 struct smb_request *req,
1118                 bool overwrite_if_exists,
1119                 struct files_struct *old_dirfsp,
1120                 const struct smb_filename *smb_fname_old,
1121                 struct files_struct *new_dirfsp,
1122                 struct smb_filename *smb_fname_new);
1123 NTSTATUS smb_set_file_time(connection_struct *conn,
1124                            files_struct *fsp,
1125                            struct smb_filename *smb_fname,
1126                            struct smb_file_time *ft,
1127                            bool setting_write_time);
1128 NTSTATUS smb_set_file_size(connection_struct *conn,
1129                            struct smb_request *req,
1130                            files_struct *fsp,
1131                            struct smb_filename *smb_fname,
1132                            const SMB_STRUCT_STAT *psbuf,
1133                            off_t size,
1134                            bool fail_after_createfile);
1135
1136 bool map_info2_flags_to_sbuf(const SMB_STRUCT_STAT *psbuf,
1137                              const uint32_t smb_fflags,
1138                              const uint32_t smb_fmask,
1139                              int *stat_fflags);
1140
1141 enum perm_type {
1142         PERM_NEW_FILE,
1143         PERM_NEW_DIR,
1144         PERM_EXISTING_FILE,
1145         PERM_EXISTING_DIR
1146 };
1147
1148 NTSTATUS unix_perms_from_wire(connection_struct *conn,
1149                               const SMB_STRUCT_STAT *psbuf,
1150                               uint32_t perms,
1151                               enum perm_type ptype,
1152                               mode_t *ret_perms);
1153 struct ea_list *read_ea_list(TALLOC_CTX *ctx, const char *pdata,
1154                              size_t data_size);
1155 unsigned int estimate_ea_size(files_struct *fsp);
1156 NTSTATUS smb_set_fsquota(connection_struct *conn,
1157                          struct smb_request *req,
1158                          files_struct *fsp,
1159                          const DATA_BLOB *qdata);
1160
1161 /* The following definitions come from smbd/uid.c  */
1162
1163 bool change_to_guest(void);
1164 NTSTATUS check_user_share_access(connection_struct *conn,
1165                                 const struct auth_session_info *session_info,
1166                                 uint32_t *p_share_access,
1167                                 bool *p_readonly_share);
1168 bool change_to_user_and_service(connection_struct *conn, uint64_t vuid);
1169 bool change_to_user_and_service_by_fsp(struct files_struct *fsp);
1170 bool smbd_change_to_root_user(void);
1171 bool smbd_become_authenticated_pipe_user(struct auth_session_info *session_info);
1172 bool smbd_unbecome_authenticated_pipe_user(void);
1173 void become_root(void);
1174 void unbecome_root(void);
1175 void smbd_become_root(void);
1176 void smbd_unbecome_root(void);
1177 bool become_user_without_service(connection_struct *conn, uint64_t vuid);
1178 bool become_user_without_service_by_fsp(struct files_struct *fsp);
1179 bool become_user_without_service_by_session(connection_struct *conn,
1180                             const struct auth_session_info *session_info);
1181 bool unbecome_user_without_service(void);
1182 uid_t get_current_uid(connection_struct *conn);
1183 gid_t get_current_gid(connection_struct *conn);
1184 const struct security_unix_token *get_current_utok(connection_struct *conn);
1185 const struct security_token *get_current_nttok(connection_struct *conn);
1186
1187 /* The following definitions come from smbd/utmp.c  */
1188
1189 void sys_utmp_claim(const char *username, const char *hostname,
1190                     const char *id_str, int id_num);
1191 void sys_utmp_yield(const char *username, const char *hostname,
1192                     const char *id_str, int id_num);
1193
1194 /* The following definitions come from smbd/vfs.c  */
1195
1196 bool vfs_init_custom(connection_struct *conn, const char *vfs_object);
1197 bool smbd_vfs_init(connection_struct *conn);
1198 NTSTATUS vfs_file_exist(connection_struct *conn, struct smb_filename *smb_fname);
1199 bool vfs_valid_pread_range(off_t offset, size_t length);
1200 bool vfs_valid_pwrite_range(off_t offset, size_t length);
1201 ssize_t vfs_pwrite_data(struct smb_request *req,
1202                         files_struct *fsp,
1203                         const char *buffer,
1204                         size_t N,
1205                         off_t offset);
1206 int vfs_allocate_file_space(files_struct *fsp, uint64_t len);
1207 int vfs_set_filelen(files_struct *fsp, off_t len);
1208 int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len);
1209 int vfs_fill_sparse(files_struct *fsp, off_t len);
1210 int vfs_set_blocking(files_struct *fsp, bool set);
1211 off_t vfs_transfer_file(files_struct *in, files_struct *out, off_t n);
1212 const char *vfs_readdirname(connection_struct *conn,
1213                             struct files_struct *dirfsp,
1214                             void *p,
1215                             SMB_STRUCT_STAT *sbuf,
1216                             char **talloced);
1217 int vfs_ChDir(connection_struct *conn,
1218                         const struct smb_filename *smb_fname);
1219 struct smb_filename *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn);
1220 int vfs_stat(struct connection_struct *conn,
1221              struct smb_filename *smb_fname);
1222 int vfs_stat_smb_basename(struct connection_struct *conn,
1223                         const struct smb_filename *smb_fname_in,
1224                         SMB_STRUCT_STAT *psbuf);
1225 NTSTATUS vfs_stat_fsp(files_struct *fsp);
1226 NTSTATUS vfs_fstreaminfo(struct files_struct *fsp,
1227                         TALLOC_CTX *mem_ctx,
1228                         unsigned int *num_streams,
1229                         struct stream_struct **streams);
1230 void init_smb_file_time(struct smb_file_time *ft);
1231 int vfs_fake_fd(void);
1232 int vfs_fake_fd_close(int fd);
1233
1234 /* The following definitions come from smbd/avahi_register.c */
1235
1236 void *avahi_start_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1237                            uint16_t port);
1238
1239 /* The following definitions come from smbd/smb2_create.c */
1240
1241 NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp,
1242                                     TALLOC_CTX *mem_ctx,
1243                                     DATA_BLOB *cookie_blob);
1244 NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp,
1245                                         const DATA_BLOB old_cookie,
1246                                         TALLOC_CTX *mem_ctx,
1247                                         DATA_BLOB *new_cookie);
1248 NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
1249                                        struct smb_request *smb1req,
1250                                        struct smbXsrv_open *op,
1251                                        const DATA_BLOB old_cookie,
1252                                        TALLOC_CTX *mem_ctx,
1253                                        files_struct **result,
1254                                        DATA_BLOB *new_cookie);
1255
1256 /* The following definitions come from smbd/smb2_posix.c */
1257 ssize_t smb2_posix_cc_info(
1258         connection_struct *conn,
1259         uint32_t reparse_tag,
1260         const SMB_STRUCT_STAT *psbuf,
1261         const struct dom_sid *owner,
1262         const struct dom_sid *group,
1263         uint8_t *buf,
1264         size_t buflen);
1265 ssize_t store_smb2_posix_info(
1266         connection_struct *conn,
1267         const SMB_STRUCT_STAT *psbuf,
1268         uint32_t reparse_tag,
1269         uint32_t dos_attributes,
1270         uint8_t *buf,
1271         size_t buflen);
1272
1273 #endif /* _SMBD_PROTO_H_ */