smbd: Add mem_ctx to {f,}get_nt_acl VFS call
[kamenim/samba-autobuild/.git] / examples / VFS / skel_transparent.c
1 /* 
2  * Skeleton VFS module.  Implements passthrough operation of all VFS
3  * calls to disk functions.
4  *
5  * Copyright (C) Tim Potter, 1999-2000
6  * Copyright (C) Alexander Bokovoy, 2002
7  * Copyright (C) Stefan (metze) Metzmacher, 2003
8  * Copyright (C) Jeremy Allison 2009
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *  
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *  
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, see <http://www.gnu.org/licenses/>.
22  */
23
24
25 #include "../source3/include/includes.h"
26 #include "lib/util/tevent_unix.h"
27
28 /* PLEASE,PLEASE READ THE VFS MODULES CHAPTER OF THE 
29    SAMBA DEVELOPERS GUIDE!!!!!!
30  */
31
32 /* If you take this file as template for your module
33  * please make sure that you remove all skel_XXX() functions you don't
34  * want to implement!! The passthrough operations are not
35  * neccessary in a real module.
36  *
37  * --metze
38  */
39
40 static int skel_connect(vfs_handle_struct *handle,  const char *service, const char *user)    
41 {
42         return SMB_VFS_NEXT_CONNECT(handle, service, user);
43 }
44
45 static void skel_disconnect(vfs_handle_struct *handle)
46 {
47         SMB_VFS_NEXT_DISCONNECT(handle);
48 }
49
50 static uint64_t skel_disk_free(vfs_handle_struct *handle,  const char *path,
51         bool small_query, uint64_t *bsize,
52         uint64_t *dfree, uint64_t *dsize)
53 {
54         return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize, 
55                                          dfree, dsize);
56 }
57
58 static int skel_get_quota(vfs_handle_struct *handle,  enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq)
59 {
60         return SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, dq);
61 }
62
63 static int skel_set_quota(vfs_handle_struct *handle,  enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq)
64 {
65         return SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, dq);
66 }
67
68 static int skel_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, struct shadow_copy_data *shadow_copy_data, bool labels)
69 {
70         return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
71 }
72
73 static int skel_statvfs(struct vfs_handle_struct *handle, const char *path, struct vfs_statvfs_struct *statbuf)
74 {
75         return SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
76 }
77
78 static uint32_t skel_fs_capabilities(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res)
79 {
80         return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
81 }
82
83 static NTSTATUS skel_get_dfs_referrals(struct vfs_handle_struct *handle,
84                                        struct dfs_GetDFSReferral *r)
85 {
86         return SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
87 }
88
89 static DIR *skel_opendir(vfs_handle_struct *handle,  const char *fname, const char *mask, uint32 attr)
90 {
91         return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
92 }
93
94 static DIR *skel_fdopendir(vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32 attr)
95 {
96         return SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
97 }
98
99 static struct dirent *skel_readdir(vfs_handle_struct *handle,
100                                        DIR *dirp,
101                                        SMB_STRUCT_STAT *sbuf)
102 {
103         return SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
104 }
105
106 static void skel_seekdir(vfs_handle_struct *handle,  DIR *dirp, long offset)
107 {
108         SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
109 }
110
111 static long skel_telldir(vfs_handle_struct *handle,  DIR *dirp)
112 {
113         return SMB_VFS_NEXT_TELLDIR(handle, dirp);
114 }
115
116 static void skel_rewind_dir(vfs_handle_struct *handle, DIR *dirp)
117 {
118         SMB_VFS_NEXT_REWINDDIR(handle, dirp);
119 }
120
121 static int skel_mkdir(vfs_handle_struct *handle,  const char *path, mode_t mode)
122 {
123         return SMB_VFS_NEXT_MKDIR(handle, path, mode);
124 }
125
126 static int skel_rmdir(vfs_handle_struct *handle,  const char *path)
127 {
128         return SMB_VFS_NEXT_RMDIR(handle, path);
129 }
130
131 static int skel_closedir(vfs_handle_struct *handle,  DIR *dir)
132 {
133         return SMB_VFS_NEXT_CLOSEDIR(handle, dir);
134 }
135
136 static void skel_init_search_op(struct vfs_handle_struct *handle, DIR *dirp)
137 {
138         SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
139 }
140
141 static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
142                      files_struct *fsp, int flags, mode_t mode)
143 {
144         return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
145 }
146
147 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
148                                 struct smb_request *req,
149                                 uint16_t root_dir_fid,
150                                 struct smb_filename *smb_fname,
151                                 uint32_t access_mask,
152                                 uint32_t share_access,
153                                 uint32_t create_disposition,
154                                 uint32_t create_options,
155                                 uint32_t file_attributes,
156                                 uint32_t oplock_request,
157                                 uint64_t allocation_size,
158                                 uint32_t private_flags,
159                                 struct security_descriptor *sd,
160                                 struct ea_list *ea_list,
161                                 files_struct **result,
162                                 int *pinfo)
163 {
164         return SMB_VFS_NEXT_CREATE_FILE(handle,
165                                 req,
166                                 root_dir_fid,
167                                 smb_fname,
168                                 access_mask,
169                                 share_access,
170                                 create_disposition,
171                                 create_options,
172                                 file_attributes,
173                                 oplock_request,
174                                 allocation_size,
175                                 private_flags,
176                                 sd,
177                                 ea_list,
178                                 result,
179                                 pinfo);
180 }
181
182 static int skel_close_fn(vfs_handle_struct *handle, files_struct *fsp)
183 {
184         return SMB_VFS_NEXT_CLOSE(handle, fsp);
185 }
186
187 static ssize_t skel_vfs_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
188 {
189         return SMB_VFS_NEXT_READ(handle, fsp, data, n);
190 }
191
192 static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n, off_t offset)
193 {
194         return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
195 }
196
197 struct skel_pread_state {
198         ssize_t ret;
199         int err;
200 };
201
202 static void skel_pread_done(struct tevent_req *subreq);
203
204 static struct tevent_req *skel_pread_send(struct vfs_handle_struct *handle,
205                                           TALLOC_CTX *mem_ctx,
206                                           struct tevent_context *ev,
207                                           struct files_struct *fsp,
208                                           void *data, size_t n, off_t offset)
209 {
210         struct tevent_req *req, *subreq;
211         struct skel_pread_state *state;
212
213         req = tevent_req_create(mem_ctx, &state, struct skel_pread_state);
214         if (req == NULL) {
215                 return NULL;
216         }
217         subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
218                                          n, offset);
219         if (tevent_req_nomem(subreq, req)) {
220                 return tevent_req_post(req, ev);
221         }
222         tevent_req_set_callback(subreq, skel_pread_done, req);
223         return req;
224 }
225
226 static void skel_pread_done(struct tevent_req *subreq)
227 {
228         struct tevent_req *req = tevent_req_callback_data(
229                 subreq, struct tevent_req);
230         struct skel_pread_state *state = tevent_req_data(
231                 req, struct skel_pread_state);
232
233         state->ret = SMB_VFS_PREAD_RECV(subreq, &state->err);
234         TALLOC_FREE(subreq);
235         tevent_req_done(req);
236 }
237
238 static ssize_t skel_pread_recv(struct tevent_req *req, int *err)
239 {
240         struct skel_pread_state *state = tevent_req_data(
241                 req, struct skel_pread_state);
242
243         if (tevent_req_is_unix_error(req, err)) {
244                 return -1;
245         }
246         *err = state->err;
247         return state->ret;
248 }
249
250 static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n)
251 {
252         return SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
253 }
254
255 static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n, off_t offset)
256 {
257         return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
258 }
259
260 struct skel_pwrite_state {
261         ssize_t ret;
262         int err;
263 };
264
265 static void skel_pwrite_done(struct tevent_req *subreq);
266
267 static struct tevent_req *skel_pwrite_send(struct vfs_handle_struct *handle,
268                                            TALLOC_CTX *mem_ctx,
269                                            struct tevent_context *ev,
270                                            struct files_struct *fsp,
271                                            const void *data,
272                                            size_t n, off_t offset)
273 {
274         struct tevent_req *req, *subreq;
275         struct skel_pwrite_state *state;
276
277         req = tevent_req_create(mem_ctx, &state, struct skel_pwrite_state);
278         if (req == NULL) {
279                 return NULL;
280         }
281         subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
282                                          n, offset);
283         if (tevent_req_nomem(subreq, req)) {
284                 return tevent_req_post(req, ev);
285         }
286         tevent_req_set_callback(subreq, skel_pwrite_done, req);
287         return req;
288 }
289
290 static void skel_pwrite_done(struct tevent_req *subreq)
291 {
292         struct tevent_req *req = tevent_req_callback_data(
293                 subreq, struct tevent_req);
294         struct skel_pwrite_state *state = tevent_req_data(
295                 req, struct skel_pwrite_state);
296
297         state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->err);
298         TALLOC_FREE(subreq);
299         tevent_req_done(req);
300 }
301
302 static ssize_t skel_pwrite_recv(struct tevent_req *req, int *err)
303 {
304         struct skel_pwrite_state *state = tevent_req_data(
305                 req, struct skel_pwrite_state);
306
307         if (tevent_req_is_unix_error(req, err)) {
308                 return -1;
309         }
310         *err = state->err;
311         return state->ret;
312 }
313
314 static off_t skel_lseek(vfs_handle_struct *handle, files_struct *fsp, off_t offset, int whence)
315 {
316         return SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
317 }
318
319 static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr, off_t offset, size_t n)
320 {
321         return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
322 }
323
324 static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *tofsp, off_t offset, size_t n)
325 {
326         return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
327 }
328
329 static int skel_rename(vfs_handle_struct *handle,
330                        const struct smb_filename *smb_fname_src,
331                        const struct smb_filename *smb_fname_dst)
332 {
333         return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
334 }
335
336 static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
337 {
338         return SMB_VFS_NEXT_FSYNC(handle, fsp);
339 }
340
341 struct skel_fsync_state {
342         int ret;
343         int err;
344 };
345
346 static void skel_fsync_done(struct tevent_req *subreq);
347
348 static struct tevent_req *skel_fsync_send(struct vfs_handle_struct *handle,
349                                           TALLOC_CTX *mem_ctx,
350                                           struct tevent_context *ev,
351                                           struct files_struct *fsp)
352 {
353         struct tevent_req *req, *subreq;
354         struct skel_fsync_state *state;
355
356         req = tevent_req_create(mem_ctx, &state, struct skel_fsync_state);
357         if (req == NULL) {
358                 return NULL;
359         }
360         subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
361         if (tevent_req_nomem(subreq, req)) {
362                 return tevent_req_post(req, ev);
363         }
364         tevent_req_set_callback(subreq, skel_fsync_done, req);
365         return req;
366 }
367
368 static void skel_fsync_done(struct tevent_req *subreq)
369 {
370         struct tevent_req *req = tevent_req_callback_data(
371                 subreq, struct tevent_req);
372         struct skel_fsync_state *state = tevent_req_data(
373                 req, struct skel_fsync_state);
374
375         state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->err);
376         TALLOC_FREE(subreq);
377         tevent_req_done(req);
378 }
379
380 static int skel_fsync_recv(struct tevent_req *req, int *err)
381 {
382         struct skel_fsync_state *state = tevent_req_data(
383                 req, struct skel_fsync_state);
384
385         if (tevent_req_is_unix_error(req, err)) {
386                 return -1;
387         }
388         *err = state->err;
389         return state->ret;
390 }
391
392 static int skel_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
393 {
394         return SMB_VFS_NEXT_STAT(handle, smb_fname);
395 }
396
397 static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
398 {
399         return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
400 }
401
402 static int skel_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
403 {
404         return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
405 }
406
407 static uint64_t skel_get_alloc_size(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
408 {
409         return SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
410 }
411
412 static int skel_unlink(vfs_handle_struct *handle,
413                        const struct smb_filename *smb_fname)
414 {
415         return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
416 }
417
418 static int skel_chmod(vfs_handle_struct *handle,  const char *path, mode_t mode)
419 {
420         return SMB_VFS_NEXT_CHMOD(handle, path, mode);
421 }
422
423 static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
424 {
425         return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
426 }
427
428 static int skel_chown(vfs_handle_struct *handle,  const char *path, uid_t uid, gid_t gid)
429 {
430         return SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
431 }
432
433 static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid)
434 {
435         return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
436 }
437
438 static int skel_lchown(vfs_handle_struct *handle,  const char *path, uid_t uid, gid_t gid)
439 {
440         return SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
441 }
442
443 static int skel_chdir(vfs_handle_struct *handle,  const char *path)
444 {
445         return SMB_VFS_NEXT_CHDIR(handle, path);
446 }
447
448 static char *skel_getwd(vfs_handle_struct *handle)
449 {
450         return SMB_VFS_NEXT_GETWD(handle);
451 }
452
453 static int skel_ntimes(vfs_handle_struct *handle,
454                        const struct smb_filename *smb_fname,
455                        struct smb_file_time *ft)
456 {
457         return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
458 }
459
460 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t offset)
461 {
462         return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
463 }
464
465 static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
466                         enum vfs_fallocate_mode mode,
467                         off_t offset,
468                         off_t len)
469 {
470         return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
471 }
472
473 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op, off_t offset, off_t count, int type)
474 {
475         return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
476 }
477
478 static int skel_kernel_flock(struct vfs_handle_struct *handle, struct files_struct *fsp, uint32 share_mode, uint32 access_mask)
479 {
480         return SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
481 }
482
483 static int skel_linux_setlease(struct vfs_handle_struct *handle, struct files_struct *fsp, int leasetype)
484 {
485         return SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
486 }
487
488 static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid)
489 {
490         return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
491 }
492
493 static int skel_symlink(vfs_handle_struct *handle,  const char *oldpath, const char *newpath)
494 {
495         return SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
496 }
497
498 static int skel_vfs_readlink(vfs_handle_struct *handle, const char *path, char *buf, size_t bufsiz)
499 {
500         return SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
501 }
502
503 static int skel_link(vfs_handle_struct *handle,  const char *oldpath, const char *newpath)
504 {
505         return SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
506 }
507
508 static int skel_mknod(vfs_handle_struct *handle,  const char *path, mode_t mode, SMB_DEV_T dev)
509 {
510         return SMB_VFS_NEXT_MKNOD(handle, path, mode, dev);
511 }
512
513 static char *skel_realpath(vfs_handle_struct *handle,  const char *path)
514 {
515         return SMB_VFS_NEXT_REALPATH(handle, path);
516 }
517
518 static NTSTATUS skel_notify_watch(
519         struct vfs_handle_struct *handle,
520         struct sys_notify_context *ctx,
521         const char *path,
522         uint32_t *filter,
523         uint32_t *subdir_filter,
524         void (*callback)(struct sys_notify_context *ctx, void *private_data,
525                          struct notify_event *ev),
526         void *private_data, void *handle_p)
527 {
528         return SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, path,
529                                          filter, subdir_filter, callback,
530                 private_data, handle_p);
531 }
532
533 static int skel_chflags(vfs_handle_struct *handle,  const char *path, uint flags)
534 {
535         return SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
536 }
537
538 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
539                                           const SMB_STRUCT_STAT *sbuf)
540 {
541         return SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
542 }
543
544 static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
545                                 struct files_struct *fsp,
546                                 const char *fname,
547                                 TALLOC_CTX *mem_ctx,
548                                 unsigned int *num_streams,
549                                 struct stream_struct **streams)
550 {
551         return SMB_VFS_NEXT_STREAMINFO(handle,
552                                         fsp,
553                                         fname,
554                                         mem_ctx,
555                                         num_streams,
556                                         streams);
557 }
558
559 static int skel_get_real_filename(struct vfs_handle_struct *handle,
560                                 const char *path,
561                                 const char *name,
562                                 TALLOC_CTX *mem_ctx,
563                                 char **found_name)
564 {
565         return SMB_VFS_NEXT_GET_REAL_FILENAME(handle,
566                                         path,
567                                         name,
568                                         mem_ctx,
569                                         found_name);
570 }
571
572 static const char *skel_connectpath(struct vfs_handle_struct *handle,
573                                 const char *filename)
574 {
575         return SMB_VFS_NEXT_CONNECTPATH(handle, filename);
576 }
577
578 static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
579                                 struct byte_range_lock *br_lck,
580                                 struct lock_struct *plock,
581                                 bool blocking_lock,
582                                 struct blocking_lock_record *blr)
583 {
584         return SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle,
585                                         br_lck,
586                                         plock,
587                                         blocking_lock,
588                                         blr);
589 }
590
591 static bool skel_brl_unlock_windows(struct vfs_handle_struct *handle,
592                                 struct messaging_context *msg_ctx,
593                                 struct byte_range_lock *br_lck,
594                                 const struct lock_struct *plock)
595 {
596         return SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle,
597                                         msg_ctx,
598                                         br_lck,
599                                         plock);
600 }
601
602 static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
603                                 struct byte_range_lock *br_lck,
604                                 struct lock_struct *plock,
605                                 struct blocking_lock_record *blr)
606 {
607         return SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle,
608                                 br_lck,
609                                 plock,
610                                 blr);
611 }
612
613 static bool skel_strict_lock(struct vfs_handle_struct *handle,
614                                 struct files_struct *fsp,
615                                 struct lock_struct *plock)
616 {
617         return SMB_VFS_NEXT_STRICT_LOCK(handle,
618                                         fsp,
619                                         plock);
620 }
621
622 static void skel_strict_unlock(struct vfs_handle_struct *handle,
623                                 struct files_struct *fsp,
624                                 struct lock_struct *plock)
625 {
626         SMB_VFS_NEXT_STRICT_UNLOCK(handle,
627                                         fsp,
628                                         plock);
629 }
630
631 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
632                                 const char *mapped_name,
633                                 enum vfs_translate_direction direction,
634                                 TALLOC_CTX *mem_ctx,
635                                 char **pmapped_name)
636 {
637         return SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction,
638                                            mem_ctx, pmapped_name);
639 }
640
641 static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
642                         struct files_struct *fsp,
643                         TALLOC_CTX *ctx,
644                         uint32_t function,
645                         uint16_t req_flags,  /* Needed for UNICODE ... */
646                         const uint8_t *_in_data,
647                         uint32_t in_len,
648                         uint8_t **_out_data,
649                         uint32_t max_out_len,
650                         uint32_t *out_len)
651 {
652         return SMB_VFS_NEXT_FSCTL(handle,
653                                 fsp,
654                                 ctx,
655                                 function,
656                                 req_flags,
657                                 _in_data,
658                                 in_len,
659                                 _out_data,
660                                 max_out_len,
661                                 out_len);
662 }
663
664 static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
665                                  uint32 security_info,
666                                  TALLOC_CTX *mem_ctx,
667                                  struct security_descriptor **ppdesc)
668 {
669         return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, mem_ctx, ppdesc);
670 }
671
672 static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle,
673                                 const char *name, uint32 security_info,
674                                 TALLOC_CTX *mem_ctx,
675                                 struct security_descriptor **ppdesc)
676 {
677         return SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, mem_ctx, ppdesc);
678 }
679
680 static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
681         uint32 security_info_sent, const struct security_descriptor *psd)
682 {
683         return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
684 }
685
686 static int skel_chmod_acl(vfs_handle_struct *handle,  const char *name, mode_t mode)
687 {
688         return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode);
689 }
690
691 static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
692 {
693         return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
694 }
695
696 static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle,
697                                        const char *path_p,
698                                        SMB_ACL_TYPE_T type,
699                                        TALLOC_CTX *mem_ctx)
700 {
701         return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type, mem_ctx);
702 }
703
704 static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
705                                      files_struct *fsp,
706                                      TALLOC_CTX *mem_ctx)
707 {
708         return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
709 }
710
711 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,  const char *path_p, SMB_ACL_TYPE_T type,
712                                       TALLOC_CTX *mem_ctx,
713                                       char **blob_description, 
714                                       DATA_BLOB *blob)
715 {
716         return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p, type, mem_ctx, blob_description, blob);
717 }
718
719 static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle, files_struct *fsp,
720                                       TALLOC_CTX *mem_ctx,
721                                       char **blob_description, 
722                                       DATA_BLOB *blob)
723 {
724         return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
725 }
726
727 static int skel_sys_acl_set_file(vfs_handle_struct *handle,  const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
728 {
729         return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype, theacl);
730 }
731
732 static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, SMB_ACL_T theacl)
733 {
734         return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
735 }
736
737 static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,  const char *path)
738 {
739         return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
740 }
741
742 static ssize_t skel_getxattr(vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t size)
743 {
744         return SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
745 }
746
747 static ssize_t skel_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)
748 {
749         return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
750 }
751
752 static ssize_t skel_listxattr(vfs_handle_struct *handle, const char *path, char *list, size_t size)
753 {
754         return SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
755 }
756
757 static ssize_t skel_flistxattr(vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)
758 {
759         return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
760 }
761
762 static int skel_removexattr(vfs_handle_struct *handle, const char *path, const char *name)
763 {
764         return SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
765 }
766
767 static int skel_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name)
768 {
769         return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
770 }
771
772 static int skel_setxattr(vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
773 {
774         return SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size, flags);
775 }
776
777 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags)
778 {
779         return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
780 }
781
782 static bool skel_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
783 {
784         return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
785 }
786
787 static bool skel_is_offline(struct vfs_handle_struct *handle, const struct smb_filename *fname, SMB_STRUCT_STAT *sbuf)
788 {
789         return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
790 }
791
792 static int skel_set_offline(struct vfs_handle_struct *handle, const struct smb_filename *fname)
793 {
794         return SMB_VFS_NEXT_SET_OFFLINE(handle, fname);
795 }
796
797 /* VFS operations structure */
798
799 struct vfs_fn_pointers skel_transparent_fns = {
800         /* Disk operations */
801
802         .connect_fn = skel_connect,
803         .disconnect_fn = skel_disconnect,
804         .disk_free_fn = skel_disk_free,
805         .get_quota_fn = skel_get_quota,
806         .set_quota_fn = skel_set_quota,
807         .get_shadow_copy_data_fn = skel_get_shadow_copy_data,
808         .statvfs_fn = skel_statvfs,
809         .fs_capabilities_fn = skel_fs_capabilities,
810         .get_dfs_referrals_fn = skel_get_dfs_referrals,
811
812         /* Directory operations */
813
814         .opendir_fn = skel_opendir,
815         .fdopendir_fn = skel_fdopendir,
816         .readdir_fn = skel_readdir,
817         .seekdir_fn = skel_seekdir,
818         .telldir_fn = skel_telldir,
819         .rewind_dir_fn = skel_rewind_dir,
820         .mkdir_fn = skel_mkdir,
821         .rmdir_fn = skel_rmdir,
822         .closedir_fn = skel_closedir,
823         .init_search_op_fn = skel_init_search_op,
824
825         /* File operations */
826
827         .open_fn = skel_open,
828         .create_file_fn = skel_create_file,
829         .close_fn = skel_close_fn,
830         .read_fn = skel_vfs_read,
831         .pread_fn = skel_pread,
832         .pread_send_fn = skel_pread_send,
833         .pread_recv_fn = skel_pread_recv,
834         .write_fn = skel_write,
835         .pwrite_fn = skel_pwrite,
836         .pwrite_send_fn = skel_pwrite_send,
837         .pwrite_recv_fn = skel_pwrite_recv,
838         .lseek_fn = skel_lseek,
839         .sendfile_fn = skel_sendfile,
840         .recvfile_fn = skel_recvfile,
841         .rename_fn = skel_rename,
842         .fsync_fn = skel_fsync,
843         .fsync_send_fn = skel_fsync_send,
844         .fsync_recv_fn = skel_fsync_recv,
845         .stat_fn = skel_stat,
846         .fstat_fn = skel_fstat,
847         .lstat_fn = skel_lstat,
848         .get_alloc_size_fn = skel_get_alloc_size,
849         .unlink_fn = skel_unlink,
850         .chmod_fn = skel_chmod,
851         .fchmod_fn = skel_fchmod,
852         .chown_fn = skel_chown,
853         .fchown_fn = skel_fchown,
854         .lchown_fn = skel_lchown,
855         .chdir_fn = skel_chdir,
856         .getwd_fn = skel_getwd,
857         .ntimes_fn = skel_ntimes,
858         .ftruncate_fn = skel_ftruncate,
859         .fallocate_fn = skel_fallocate,
860         .lock_fn = skel_lock,
861         .kernel_flock_fn = skel_kernel_flock,
862         .linux_setlease_fn = skel_linux_setlease,
863         .getlock_fn = skel_getlock,
864         .symlink_fn = skel_symlink,
865         .readlink_fn = skel_vfs_readlink,
866         .link_fn = skel_link,
867         .mknod_fn = skel_mknod,
868         .realpath_fn = skel_realpath,
869         .notify_watch_fn = skel_notify_watch,
870         .chflags_fn = skel_chflags,
871         .file_id_create_fn = skel_file_id_create,
872
873         .streaminfo_fn = skel_streaminfo,
874         .get_real_filename_fn = skel_get_real_filename,
875         .connectpath_fn = skel_connectpath,
876         .brl_lock_windows_fn = skel_brl_lock_windows,
877         .brl_unlock_windows_fn = skel_brl_unlock_windows,
878         .brl_cancel_windows_fn = skel_brl_cancel_windows,
879         .strict_lock_fn = skel_strict_lock,
880         .strict_unlock_fn = skel_strict_unlock,
881         .translate_name_fn = skel_translate_name,
882         .fsctl_fn = skel_fsctl,
883
884         /* NT ACL operations. */
885
886         .fget_nt_acl_fn = skel_fget_nt_acl,
887         .get_nt_acl_fn = skel_get_nt_acl,
888         .fset_nt_acl_fn = skel_fset_nt_acl,
889
890         /* POSIX ACL operations. */
891
892         .chmod_acl_fn = skel_chmod_acl,
893         .fchmod_acl_fn = skel_fchmod_acl,
894
895         .sys_acl_get_file_fn = skel_sys_acl_get_file,
896         .sys_acl_get_fd_fn = skel_sys_acl_get_fd,
897         .sys_acl_blob_get_file_fn = skel_sys_acl_blob_get_file,
898         .sys_acl_blob_get_fd_fn = skel_sys_acl_blob_get_fd,
899         .sys_acl_set_file_fn = skel_sys_acl_set_file,
900         .sys_acl_set_fd_fn = skel_sys_acl_set_fd,
901         .sys_acl_delete_def_file_fn = skel_sys_acl_delete_def_file,
902
903         /* EA operations. */
904         .getxattr_fn = skel_getxattr,
905         .fgetxattr_fn = skel_fgetxattr,
906         .listxattr_fn = skel_listxattr,
907         .flistxattr_fn = skel_flistxattr,
908         .removexattr_fn = skel_removexattr,
909         .fremovexattr_fn = skel_fremovexattr,
910         .setxattr_fn = skel_setxattr,
911         .fsetxattr_fn = skel_fsetxattr,
912
913         /* aio operations */
914         .aio_force_fn = skel_aio_force,
915
916         /* offline operations */
917         .is_offline_fn = skel_is_offline,
918         .set_offline_fn = skel_set_offline
919 };
920
921 NTSTATUS vfs_skel_transparent_init(void)
922 {
923         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "skel_transparent", &skel_transparent_fns);
924 }