pyldb: avoid segfault when adding an element with no name
[sfrench/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 #include "../source3/include/includes.h"
25 #include "lib/util/tevent_unix.h"
26 #include "lib/util/tevent_ntstatus.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,
41                         const char *user)
42 {
43         return SMB_VFS_NEXT_CONNECT(handle, service, user);
44 }
45
46 static void skel_disconnect(vfs_handle_struct *handle)
47 {
48         SMB_VFS_NEXT_DISCONNECT(handle);
49 }
50
51 static uint64_t skel_disk_free(vfs_handle_struct *handle,
52                                 const struct smb_filename *smb_fname,
53                                 uint64_t *bsize,
54                                 uint64_t *dfree,
55                                 uint64_t *dsize)
56 {
57         return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
58 }
59
60 static int skel_get_quota(vfs_handle_struct *handle,
61                                 const struct smb_filename *smb_fname,
62                                 enum SMB_QUOTA_TYPE qtype,
63                                 unid_t id,
64                                 SMB_DISK_QUOTA *dq)
65 {
66         return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
67 }
68
69 static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
70                           unid_t id, SMB_DISK_QUOTA *dq)
71 {
72         return SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, dq);
73 }
74
75 static int skel_get_shadow_copy_data(vfs_handle_struct *handle,
76                                      files_struct *fsp,
77                                      struct shadow_copy_data *shadow_copy_data,
78                                      bool labels)
79 {
80         return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data,
81                                                  labels);
82 }
83
84 static int skel_statvfs(struct vfs_handle_struct *handle,
85                         const struct smb_filename *smb_fname,
86                         struct vfs_statvfs_struct *statbuf)
87 {
88         return SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf);
89 }
90
91 static uint32_t skel_fs_capabilities(struct vfs_handle_struct *handle,
92                                      enum timestamp_set_resolution *p_ts_res)
93 {
94         return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
95 }
96
97 static NTSTATUS skel_get_dfs_referrals(struct vfs_handle_struct *handle,
98                                        struct dfs_GetDFSReferral *r)
99 {
100         return SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
101 }
102
103 static DIR *skel_opendir(vfs_handle_struct *handle,
104                         const struct smb_filename *smb_fname,
105                         const char *mask,
106                         uint32_t attr)
107 {
108         return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
109 }
110
111 static NTSTATUS skel_snap_check_path(struct vfs_handle_struct *handle,
112                                      TALLOC_CTX *mem_ctx,
113                                      const char *service_path,
114                                      char **base_volume)
115 {
116         return SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
117                                             base_volume);
118 }
119
120 static NTSTATUS skel_snap_create(struct vfs_handle_struct *handle,
121                                  TALLOC_CTX *mem_ctx,
122                                  const char *base_volume,
123                                  time_t *tstamp,
124                                  bool rw,
125                                  char **base_path,
126                                  char **snap_path)
127 {
128         return SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
129                                         rw, base_path, snap_path);
130 }
131
132 static NTSTATUS skel_snap_delete(struct vfs_handle_struct *handle,
133                                  TALLOC_CTX *mem_ctx,
134                                  char *base_path,
135                                  char *snap_path)
136 {
137         return SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path, snap_path);
138 }
139
140 static DIR *skel_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
141                            const char *mask, uint32_t attr)
142 {
143         return SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
144 }
145
146 static struct dirent *skel_readdir(vfs_handle_struct *handle,
147                                    DIR *dirp, SMB_STRUCT_STAT *sbuf)
148 {
149         return SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
150 }
151
152 static void skel_seekdir(vfs_handle_struct *handle, DIR *dirp, long offset)
153 {
154         SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
155 }
156
157 static long skel_telldir(vfs_handle_struct *handle, DIR *dirp)
158 {
159         return SMB_VFS_NEXT_TELLDIR(handle, dirp);
160 }
161
162 static void skel_rewind_dir(vfs_handle_struct *handle, DIR *dirp)
163 {
164         SMB_VFS_NEXT_REWINDDIR(handle, dirp);
165 }
166
167 static int skel_mkdir(vfs_handle_struct *handle,
168                 const struct smb_filename *smb_fname,
169                 mode_t mode)
170 {
171         return SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
172 }
173
174 static int skel_rmdir(vfs_handle_struct *handle,
175                 const struct smb_filename *smb_fname)
176 {
177         return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
178 }
179
180 static int skel_closedir(vfs_handle_struct *handle, DIR *dir)
181 {
182         return SMB_VFS_NEXT_CLOSEDIR(handle, dir);
183 }
184
185 static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
186                      files_struct *fsp, int flags, mode_t mode)
187 {
188         return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
189 }
190
191 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
192                                  struct smb_request *req,
193                                  uint16_t root_dir_fid,
194                                  struct smb_filename *smb_fname,
195                                  uint32_t access_mask,
196                                  uint32_t share_access,
197                                  uint32_t create_disposition,
198                                  uint32_t create_options,
199                                  uint32_t file_attributes,
200                                  uint32_t oplock_request,
201                                  struct smb2_lease *lease,
202                                  uint64_t allocation_size,
203                                  uint32_t private_flags,
204                                  struct security_descriptor *sd,
205                                  struct ea_list *ea_list,
206                                  files_struct ** result, int *pinfo,
207                                  const struct smb2_create_blobs *in_context_blobs,
208                                  struct smb2_create_blobs *out_context_blobs)
209 {
210         return SMB_VFS_NEXT_CREATE_FILE(handle,
211                                         req,
212                                         root_dir_fid,
213                                         smb_fname,
214                                         access_mask,
215                                         share_access,
216                                         create_disposition,
217                                         create_options,
218                                         file_attributes,
219                                         oplock_request,
220                                         lease,
221                                         allocation_size,
222                                         private_flags,
223                                         sd, ea_list, result, pinfo,
224                                         in_context_blobs, out_context_blobs);
225 }
226
227 static int skel_close_fn(vfs_handle_struct *handle, files_struct *fsp)
228 {
229         return SMB_VFS_NEXT_CLOSE(handle, fsp);
230 }
231
232 static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp,
233                           void *data, size_t n, off_t offset)
234 {
235         return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
236 }
237
238 struct skel_pread_state {
239         ssize_t ret;
240         struct vfs_aio_state vfs_aio_state;
241 };
242
243 static void skel_pread_done(struct tevent_req *subreq);
244
245 static struct tevent_req *skel_pread_send(struct vfs_handle_struct *handle,
246                                           TALLOC_CTX *mem_ctx,
247                                           struct tevent_context *ev,
248                                           struct files_struct *fsp,
249                                           void *data, size_t n, off_t offset)
250 {
251         struct tevent_req *req, *subreq;
252         struct skel_pread_state *state;
253
254         req = tevent_req_create(mem_ctx, &state, struct skel_pread_state);
255         if (req == NULL) {
256                 return NULL;
257         }
258         subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
259                                          n, offset);
260         if (tevent_req_nomem(subreq, req)) {
261                 return tevent_req_post(req, ev);
262         }
263         tevent_req_set_callback(subreq, skel_pread_done, req);
264         return req;
265 }
266
267 static void skel_pread_done(struct tevent_req *subreq)
268 {
269         struct tevent_req *req =
270             tevent_req_callback_data(subreq, struct tevent_req);
271         struct skel_pread_state *state =
272             tevent_req_data(req, struct skel_pread_state);
273
274         state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
275         TALLOC_FREE(subreq);
276         tevent_req_done(req);
277 }
278
279 static ssize_t skel_pread_recv(struct tevent_req *req,
280                                struct vfs_aio_state *vfs_aio_state)
281 {
282         struct skel_pread_state *state =
283             tevent_req_data(req, struct skel_pread_state);
284
285         if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
286                 return -1;
287         }
288         *vfs_aio_state = state->vfs_aio_state;
289         return state->ret;
290 }
291
292 static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp,
293                            const void *data, size_t n, off_t offset)
294 {
295         return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
296 }
297
298 struct skel_pwrite_state {
299         ssize_t ret;
300         struct vfs_aio_state vfs_aio_state;
301 };
302
303 static void skel_pwrite_done(struct tevent_req *subreq);
304
305 static struct tevent_req *skel_pwrite_send(struct vfs_handle_struct *handle,
306                                            TALLOC_CTX *mem_ctx,
307                                            struct tevent_context *ev,
308                                            struct files_struct *fsp,
309                                            const void *data,
310                                            size_t n, off_t offset)
311 {
312         struct tevent_req *req, *subreq;
313         struct skel_pwrite_state *state;
314
315         req = tevent_req_create(mem_ctx, &state, struct skel_pwrite_state);
316         if (req == NULL) {
317                 return NULL;
318         }
319         subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
320                                           n, offset);
321         if (tevent_req_nomem(subreq, req)) {
322                 return tevent_req_post(req, ev);
323         }
324         tevent_req_set_callback(subreq, skel_pwrite_done, req);
325         return req;
326 }
327
328 static void skel_pwrite_done(struct tevent_req *subreq)
329 {
330         struct tevent_req *req =
331             tevent_req_callback_data(subreq, struct tevent_req);
332         struct skel_pwrite_state *state =
333             tevent_req_data(req, struct skel_pwrite_state);
334
335         state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
336         TALLOC_FREE(subreq);
337         tevent_req_done(req);
338 }
339
340 static ssize_t skel_pwrite_recv(struct tevent_req *req,
341                                 struct vfs_aio_state *vfs_aio_state)
342 {
343         struct skel_pwrite_state *state =
344             tevent_req_data(req, struct skel_pwrite_state);
345
346         if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
347                 return -1;
348         }
349         *vfs_aio_state = state->vfs_aio_state;
350         return state->ret;
351 }
352
353 static off_t skel_lseek(vfs_handle_struct *handle, files_struct *fsp,
354                         off_t offset, int whence)
355 {
356         return SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
357 }
358
359 static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd,
360                              files_struct *fromfsp, const DATA_BLOB *hdr,
361                              off_t offset, size_t n)
362 {
363         return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
364 }
365
366 static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd,
367                              files_struct *tofsp, off_t offset, size_t n)
368 {
369         return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
370 }
371
372 static int skel_rename(vfs_handle_struct *handle,
373                        const struct smb_filename *smb_fname_src,
374                        const struct smb_filename *smb_fname_dst)
375 {
376         return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
377 }
378
379 struct skel_fsync_state {
380         int ret;
381         struct vfs_aio_state vfs_aio_state;
382 };
383
384 static void skel_fsync_done(struct tevent_req *subreq);
385
386 static struct tevent_req *skel_fsync_send(struct vfs_handle_struct *handle,
387                                           TALLOC_CTX *mem_ctx,
388                                           struct tevent_context *ev,
389                                           struct files_struct *fsp)
390 {
391         struct tevent_req *req, *subreq;
392         struct skel_fsync_state *state;
393
394         req = tevent_req_create(mem_ctx, &state, struct skel_fsync_state);
395         if (req == NULL) {
396                 return NULL;
397         }
398         subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
399         if (tevent_req_nomem(subreq, req)) {
400                 return tevent_req_post(req, ev);
401         }
402         tevent_req_set_callback(subreq, skel_fsync_done, req);
403         return req;
404 }
405
406 static void skel_fsync_done(struct tevent_req *subreq)
407 {
408         struct tevent_req *req =
409             tevent_req_callback_data(subreq, struct tevent_req);
410         struct skel_fsync_state *state =
411             tevent_req_data(req, struct skel_fsync_state);
412
413         state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
414         TALLOC_FREE(subreq);
415         tevent_req_done(req);
416 }
417
418 static int skel_fsync_recv(struct tevent_req *req,
419                            struct vfs_aio_state *vfs_aio_state)
420 {
421         struct skel_fsync_state *state =
422             tevent_req_data(req, struct skel_fsync_state);
423
424         if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
425                 return -1;
426         }
427         *vfs_aio_state = state->vfs_aio_state;
428         return state->ret;
429 }
430
431 static int skel_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
432 {
433         return SMB_VFS_NEXT_STAT(handle, smb_fname);
434 }
435
436 static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp,
437                       SMB_STRUCT_STAT *sbuf)
438 {
439         return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
440 }
441
442 static int skel_lstat(vfs_handle_struct *handle,
443                       struct smb_filename *smb_fname)
444 {
445         return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
446 }
447
448 static uint64_t skel_get_alloc_size(struct vfs_handle_struct *handle,
449                                     struct files_struct *fsp,
450                                     const SMB_STRUCT_STAT *sbuf)
451 {
452         return SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
453 }
454
455 static int skel_unlink(vfs_handle_struct *handle,
456                        const struct smb_filename *smb_fname)
457 {
458         return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
459 }
460
461 static int skel_chmod(vfs_handle_struct *handle,
462                         const struct smb_filename *smb_fname,
463                         mode_t mode)
464 {
465         return SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
466 }
467
468 static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp,
469                        mode_t mode)
470 {
471         return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
472 }
473
474 static int skel_chown(vfs_handle_struct *handle,
475                         const struct smb_filename *smb_fname,
476                         uid_t uid,
477                         gid_t gid)
478 {
479         return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
480 }
481
482 static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp,
483                        uid_t uid, gid_t gid)
484 {
485         return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
486 }
487
488 static int skel_lchown(vfs_handle_struct *handle,
489                         const struct smb_filename *smb_fname,
490                         uid_t uid,
491                         gid_t gid)
492 {
493         return SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
494 }
495
496 static int skel_chdir(vfs_handle_struct *handle,
497                         const struct smb_filename *smb_fname)
498 {
499         return SMB_VFS_NEXT_CHDIR(handle, smb_fname);
500 }
501
502 static struct smb_filename *skel_getwd(vfs_handle_struct *handle,
503                                         TALLOC_CTX *ctx)
504 {
505         return SMB_VFS_NEXT_GETWD(handle, ctx);
506 }
507
508 static int skel_ntimes(vfs_handle_struct *handle,
509                        const struct smb_filename *smb_fname,
510                        struct smb_file_time *ft)
511 {
512         return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
513 }
514
515 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
516                           off_t offset)
517 {
518         return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
519 }
520
521 static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
522                           uint32_t mode, off_t offset, off_t len)
523 {
524         return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
525 }
526
527 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op,
528                       off_t offset, off_t count, int type)
529 {
530         return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
531 }
532
533 static int skel_kernel_flock(struct vfs_handle_struct *handle,
534                              struct files_struct *fsp, uint32_t share_mode,
535                              uint32_t access_mask)
536 {
537         return SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
538 }
539
540 static int skel_linux_setlease(struct vfs_handle_struct *handle,
541                                struct files_struct *fsp, int leasetype)
542 {
543         return SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
544 }
545
546 static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp,
547                          off_t *poffset, off_t *pcount, int *ptype,
548                          pid_t *ppid)
549 {
550         return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
551 }
552
553 static int skel_symlink(vfs_handle_struct *handle,
554                         const char *link_contents,
555                         const struct smb_filename *new_smb_fname)
556 {
557         return SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
558 }
559
560 static int skel_vfs_readlink(vfs_handle_struct *handle,
561                         const struct smb_filename *smb_fname,
562                         char *buf,
563                         size_t bufsiz)
564 {
565         return SMB_VFS_NEXT_READLINK(handle, smb_fname, buf, bufsiz);
566 }
567
568 static int skel_link(vfs_handle_struct *handle,
569                         const struct smb_filename *old_smb_fname,
570                         const struct smb_filename *new_smb_fname)
571 {
572         return SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
573 }
574
575 static int skel_mknod(vfs_handle_struct *handle,
576                         const struct smb_filename *smb_fname,
577                         mode_t mode,
578                         SMB_DEV_T dev)
579 {
580         return SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
581 }
582
583 static struct smb_filename *skel_realpath(vfs_handle_struct *handle,
584                         TALLOC_CTX *ctx,
585                         const struct smb_filename *smb_fname)
586 {
587         return SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
588 }
589
590 static int skel_chflags(vfs_handle_struct *handle,
591                         const struct smb_filename *smb_fname,
592                         uint flags)
593 {
594         return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
595 }
596
597 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
598                                           const SMB_STRUCT_STAT *sbuf)
599 {
600         return SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
601 }
602
603 struct skel_offload_read_state {
604         struct vfs_handle_struct *handle;
605         DATA_BLOB token;
606 };
607
608 static void skel_offload_read_done(struct tevent_req *subreq);
609
610 static struct tevent_req *skel_offload_read_send(
611         TALLOC_CTX *mem_ctx,
612         struct tevent_context *ev,
613         struct vfs_handle_struct *handle,
614         struct files_struct *fsp,
615         uint32_t fsctl,
616         uint32_t ttl,
617         off_t offset,
618         size_t to_copy)
619 {
620         struct tevent_req *req = NULL;
621         struct skel_offload_read_state *state = NULL;
622         struct tevent_req *subreq = NULL;
623
624         req = tevent_req_create(mem_ctx, &state, struct skel_offload_read_state);
625         if (req == NULL) {
626                 return NULL;
627         }
628         *state = (struct skel_offload_read_state) {
629                 .handle = handle,
630         };
631
632         subreq = SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx, ev, handle, fsp,
633                                                 fsctl, ttl, offset, to_copy);
634         if (tevent_req_nomem(subreq, req)) {
635                 return tevent_req_post(req, ev);
636         }
637         tevent_req_set_callback(subreq, skel_offload_read_done, req);
638         return req;
639 }
640
641 static void skel_offload_read_done(struct tevent_req *subreq)
642 {
643         struct tevent_req *req = tevent_req_callback_data(
644                 subreq, struct tevent_req);
645         struct skel_offload_read_state *state = tevent_req_data(
646                 req, struct skel_offload_read_state);
647         NTSTATUS status;
648
649         status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(subreq,
650                                                 state->handle,
651                                                 state,
652                                                 &state->token);
653         TALLOC_FREE(subreq);
654         if (tevent_req_nterror(req, status)) {
655                 return;
656         }
657
658         tevent_req_done(req);
659         return;
660 }
661
662 static NTSTATUS skel_offload_read_recv(struct tevent_req *req,
663                                        struct vfs_handle_struct *handle,
664                                        TALLOC_CTX *mem_ctx,
665                                        DATA_BLOB *_token)
666 {
667         struct skel_offload_read_state *state = tevent_req_data(
668                 req, struct skel_offload_read_state);
669         DATA_BLOB token;
670         NTSTATUS status;
671
672         if (tevent_req_is_nterror(req, &status)) {
673                 tevent_req_received(req);
674                 return status;
675         }
676
677         token = data_blob_talloc(mem_ctx,
678                                  state->token.data,
679                                  state->token.length);
680
681         tevent_req_received(req);
682
683         if (token.data == NULL) {
684                 return NT_STATUS_NO_MEMORY;
685         }
686
687         *_token = token;
688         return NT_STATUS_OK;
689 }
690
691 struct skel_offload_write_state {
692         struct vfs_handle_struct *handle;
693         off_t copied;
694 };
695 static void skel_offload_write_done(struct tevent_req *subreq);
696
697 static struct tevent_req *skel_offload_write_send(struct vfs_handle_struct *handle,
698                                                TALLOC_CTX *mem_ctx,
699                                                struct tevent_context *ev,
700                                                uint32_t fsctl,
701                                                DATA_BLOB *token,
702                                                off_t transfer_offset,
703                                                struct files_struct *dest_fsp,
704                                                off_t dest_off,
705                                                off_t num)
706 {
707         struct tevent_req *req;
708         struct tevent_req *subreq;
709         struct skel_offload_write_state *state;
710
711         req = tevent_req_create(mem_ctx, &state, struct skel_offload_write_state);
712         if (req == NULL) {
713                 return NULL;
714         }
715
716         state->handle = handle;
717         subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle, state, ev,
718                                               fsctl, token, transfer_offset,
719                                               dest_fsp, dest_off, num);
720         if (tevent_req_nomem(subreq, req)) {
721                 return tevent_req_post(req, ev);
722         }
723
724         tevent_req_set_callback(subreq, skel_offload_write_done, req);
725         return req;
726 }
727
728 static void skel_offload_write_done(struct tevent_req *subreq)
729 {
730         struct tevent_req *req = tevent_req_callback_data(
731                 subreq, struct tevent_req);
732         struct skel_offload_write_state *state
733                         = tevent_req_data(req, struct skel_offload_write_state);
734         NTSTATUS status;
735
736         status = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(state->handle,
737                                               subreq,
738                                               &state->copied);
739         TALLOC_FREE(subreq);
740         if (tevent_req_nterror(req, status)) {
741                 return;
742         }
743         tevent_req_done(req);
744 }
745
746 static NTSTATUS skel_offload_write_recv(struct vfs_handle_struct *handle,
747                                      struct tevent_req *req,
748                                      off_t *copied)
749 {
750         struct skel_offload_write_state *state
751                         = tevent_req_data(req, struct skel_offload_write_state);
752         NTSTATUS status;
753
754         *copied = state->copied;
755         if (tevent_req_is_nterror(req, &status)) {
756                 tevent_req_received(req);
757                 return status;
758         }
759
760         tevent_req_received(req);
761         return NT_STATUS_OK;
762 }
763
764 static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
765                                      TALLOC_CTX *mem_ctx,
766                                      struct files_struct *fsp,
767                                      struct smb_filename *smb_fname,
768                                      uint16_t *_compression_fmt)
769 {
770         return SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
771                                             _compression_fmt);
772 }
773
774 static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
775                                      TALLOC_CTX *mem_ctx,
776                                      struct files_struct *fsp,
777                                      uint16_t compression_fmt)
778 {
779         return SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
780                                             compression_fmt);
781 }
782
783 static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
784                                 struct files_struct *fsp,
785                                 const struct smb_filename *smb_fname,
786                                 TALLOC_CTX *mem_ctx,
787                                 unsigned int *num_streams,
788                                 struct stream_struct **streams)
789 {
790         return SMB_VFS_NEXT_STREAMINFO(handle,
791                                 fsp,
792                                 smb_fname,
793                                 mem_ctx,
794                                 num_streams,
795                                 streams);
796 }
797
798 static int skel_get_real_filename(struct vfs_handle_struct *handle,
799                                   const char *path,
800                                   const char *name,
801                                   TALLOC_CTX *mem_ctx, char **found_name)
802 {
803         return SMB_VFS_NEXT_GET_REAL_FILENAME(handle,
804                                               path, name, mem_ctx, found_name);
805 }
806
807 static const char *skel_connectpath(struct vfs_handle_struct *handle,
808                                 const struct smb_filename *smb_fname)
809 {
810         return SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
811 }
812
813 static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
814                                       struct byte_range_lock *br_lck,
815                                       struct lock_struct *plock,
816                                       bool blocking_lock)
817 {
818         return SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle,
819                                              br_lck, plock, blocking_lock);
820 }
821
822 static bool skel_brl_unlock_windows(struct vfs_handle_struct *handle,
823                                     struct messaging_context *msg_ctx,
824                                     struct byte_range_lock *br_lck,
825                                     const struct lock_struct *plock)
826 {
827         return SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck, plock);
828 }
829
830 static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
831                                     struct byte_range_lock *br_lck,
832                                     struct lock_struct *plock)
833 {
834         return SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
835 }
836
837 static bool skel_strict_lock_check(struct vfs_handle_struct *handle,
838                                    struct files_struct *fsp,
839                                    struct lock_struct *plock)
840 {
841         return SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
842 }
843
844 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
845                                     const char *mapped_name,
846                                     enum vfs_translate_direction direction,
847                                     TALLOC_CTX *mem_ctx, char **pmapped_name)
848 {
849         return SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction,
850                                            mem_ctx, pmapped_name);
851 }
852
853 static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
854                            struct files_struct *fsp,
855                            TALLOC_CTX *ctx,
856                            uint32_t function,
857                            uint16_t req_flags,  /* Needed for UNICODE ... */
858                            const uint8_t *_in_data,
859                            uint32_t in_len,
860                            uint8_t ** _out_data,
861                            uint32_t max_out_len, uint32_t *out_len)
862 {
863         return SMB_VFS_NEXT_FSCTL(handle,
864                                   fsp,
865                                   ctx,
866                                   function,
867                                   req_flags,
868                                   _in_data,
869                                   in_len, _out_data, max_out_len, out_len);
870 }
871
872 static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
873                                   const struct smb_filename *fname,
874                                   TALLOC_CTX *mem_ctx,
875                                   struct readdir_attr_data **pattr_data)
876 {
877         return SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
878 }
879
880 static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
881                                 struct smb_filename *smb_fname,
882                                 uint32_t *dosmode)
883 {
884         return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
885                                 smb_fname,
886                                 dosmode);
887 }
888
889 struct skel_get_dos_attributes_state {
890         struct vfs_aio_state aio_state;
891         uint32_t dosmode;
892 };
893
894 static void skel_get_dos_attributes_done(struct tevent_req *subreq);
895
896 static struct tevent_req *skel_get_dos_attributes_send(
897                         TALLOC_CTX *mem_ctx,
898                         struct tevent_context *ev,
899                         struct vfs_handle_struct *handle,
900                         files_struct *dir_fsp,
901                         struct smb_filename *smb_fname)
902 {
903         struct tevent_req *req = NULL;
904         struct skel_get_dos_attributes_state *state = NULL;
905         struct tevent_req *subreq = NULL;
906
907         req = tevent_req_create(mem_ctx, &state,
908                                 struct skel_get_dos_attributes_state);
909         if (req == NULL) {
910                 return NULL;
911         }
912
913         subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
914                                                       ev,
915                                                       handle,
916                                                       dir_fsp,
917                                                       smb_fname);
918         if (tevent_req_nomem(subreq, req)) {
919                 return tevent_req_post(req, ev);
920         }
921         tevent_req_set_callback(subreq, skel_get_dos_attributes_done, req);
922
923         return req;
924 }
925
926 static void skel_get_dos_attributes_done(struct tevent_req *subreq)
927 {
928         struct tevent_req *req =
929                 tevent_req_callback_data(subreq,
930                 struct tevent_req);
931         struct skel_get_dos_attributes_state *state =
932                 tevent_req_data(req,
933                 struct skel_get_dos_attributes_state);
934         NTSTATUS status;
935
936         status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
937                                                       &state->aio_state,
938                                                       &state->dosmode);
939         TALLOC_FREE(subreq);
940         if (tevent_req_nterror(req, status)) {
941                 return;
942         }
943
944         tevent_req_done(req);
945         return;
946 }
947
948 static NTSTATUS skel_get_dos_attributes_recv(struct tevent_req *req,
949                                              struct vfs_aio_state *aio_state,
950                                              uint32_t *dosmode)
951 {
952         struct skel_get_dos_attributes_state *state =
953                 tevent_req_data(req,
954                 struct skel_get_dos_attributes_state);
955         NTSTATUS status;
956
957         if (tevent_req_is_nterror(req, &status)) {
958                 tevent_req_received(req);
959                 return status;
960         }
961
962         *aio_state = state->aio_state;
963         *dosmode = state->dosmode;
964         tevent_req_received(req);
965         return NT_STATUS_OK;
966 }
967
968 static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
969                                 struct files_struct *fsp,
970                                 uint32_t *dosmode)
971 {
972         return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
973                                 fsp,
974                                 dosmode);
975 }
976
977 static NTSTATUS skel_set_dos_attributes(struct vfs_handle_struct *handle,
978                                 const struct smb_filename *smb_fname,
979                                 uint32_t dosmode)
980 {
981         return SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
982                                 smb_fname,
983                                 dosmode);
984 }
985
986 static NTSTATUS skel_fset_dos_attributes(struct vfs_handle_struct *handle,
987                                 struct files_struct *fsp,
988                                 uint32_t dosmode)
989 {
990         return SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
991                                 fsp,
992                                 dosmode);
993 }
994
995 static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
996                                  uint32_t security_info,
997                                  TALLOC_CTX *mem_ctx,
998                                  struct security_descriptor **ppdesc)
999 {
1000         return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, mem_ctx,
1001                                         ppdesc);
1002 }
1003
1004 static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle,
1005                                 const struct smb_filename *smb_fname,
1006                                 uint32_t security_info,
1007                                 TALLOC_CTX *mem_ctx,
1008                                 struct security_descriptor **ppdesc)
1009 {
1010         return SMB_VFS_NEXT_GET_NT_ACL(handle,
1011                                 smb_fname,
1012                                 security_info,
1013                                 mem_ctx,
1014                                 ppdesc);
1015 }
1016
1017 static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1018                                  uint32_t security_info_sent,
1019                                  const struct security_descriptor *psd)
1020 {
1021         return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1022 }
1023
1024 static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle,
1025                                        const struct smb_filename *smb_fname,
1026                                        SMB_ACL_TYPE_T type,
1027                                        TALLOC_CTX *mem_ctx)
1028 {
1029         return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname, type, mem_ctx);
1030 }
1031
1032 static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
1033                                      files_struct *fsp, TALLOC_CTX *mem_ctx)
1034 {
1035         return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
1036 }
1037
1038 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
1039                                 const struct smb_filename *smb_fname,
1040                                 TALLOC_CTX *mem_ctx,
1041                                 char **blob_description,
1042                                 DATA_BLOB *blob)
1043 {
1044         return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname, mem_ctx,
1045                                                   blob_description, blob);
1046 }
1047
1048 static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
1049                                     files_struct *fsp, TALLOC_CTX *mem_ctx,
1050                                     char **blob_description, DATA_BLOB *blob)
1051 {
1052         return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx,
1053                                                 blob_description, blob);
1054 }
1055
1056 static int skel_sys_acl_set_file(vfs_handle_struct *handle,
1057                                 const struct smb_filename *smb_fname,
1058                                 SMB_ACL_TYPE_T acltype,
1059                                 SMB_ACL_T theacl)
1060 {
1061         return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
1062                         acltype, theacl);
1063 }
1064
1065 static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1066                                SMB_ACL_T theacl)
1067 {
1068         return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1069 }
1070
1071 static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
1072                                         const struct smb_filename *smb_fname)
1073 {
1074         return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
1075 }
1076
1077 static ssize_t skel_getxattr(vfs_handle_struct *handle,
1078                                 const struct smb_filename *smb_fname,
1079                                 const char *name,
1080                                 void *value,
1081                                 size_t size)
1082 {
1083         return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
1084 }
1085
1086 struct skel_getxattrat_state {
1087         struct vfs_aio_state aio_state;
1088         ssize_t xattr_size;
1089         uint8_t *xattr_value;
1090 };
1091
1092 static void skel_getxattrat_done(struct tevent_req *subreq);
1093
1094 static struct tevent_req *skel_getxattrat_send(
1095                         TALLOC_CTX *mem_ctx,
1096                         struct tevent_context *ev,
1097                         struct vfs_handle_struct *handle,
1098                         files_struct *dir_fsp,
1099                         const struct smb_filename *smb_fname,
1100                         const char *xattr_name,
1101                         size_t alloc_hint)
1102 {
1103         struct tevent_req *req = NULL;
1104         struct skel_getxattrat_state *state = NULL;
1105         struct tevent_req *subreq = NULL;
1106
1107         req = tevent_req_create(mem_ctx, &state,
1108                                 struct skel_getxattrat_state);
1109         if (req == NULL) {
1110                 return NULL;
1111         }
1112
1113         subreq = SMB_VFS_NEXT_GETXATTRAT_SEND(state,
1114                                               ev,
1115                                               handle,
1116                                               dir_fsp,
1117                                               smb_fname,
1118                                               xattr_name,
1119                                               alloc_hint);
1120         if (tevent_req_nomem(subreq, req)) {
1121                 return tevent_req_post(req, ev);
1122         }
1123         tevent_req_set_callback(subreq, skel_getxattrat_done, req);
1124
1125         return req;
1126 }
1127
1128 static void skel_getxattrat_done(struct tevent_req *subreq)
1129 {
1130         struct tevent_req *req = tevent_req_callback_data(
1131                 subreq, struct tevent_req);
1132         struct skel_getxattrat_state *state = tevent_req_data(
1133                 req, struct skel_getxattrat_state);
1134
1135         state->xattr_size = SMB_VFS_NEXT_GETXATTRAT_RECV(subreq,
1136                                                          &state->aio_state,
1137                                                          state,
1138                                                          &state->xattr_value);
1139         TALLOC_FREE(subreq);
1140         if (state->xattr_size == -1) {
1141                 tevent_req_error(req, state->aio_state.error);
1142                 return;
1143         }
1144
1145         tevent_req_done(req);
1146 }
1147
1148 static ssize_t skel_getxattrat_recv(struct tevent_req *req,
1149                                     struct vfs_aio_state *aio_state,
1150                                     TALLOC_CTX *mem_ctx,
1151                                     uint8_t **xattr_value)
1152 {
1153         struct skel_getxattrat_state *state = tevent_req_data(
1154                 req, struct skel_getxattrat_state);
1155         ssize_t xattr_size;
1156
1157         if (tevent_req_is_unix_error(req, &aio_state->error)) {
1158                 tevent_req_received(req);
1159                 return -1;
1160         }
1161
1162         *aio_state = state->aio_state;
1163         xattr_size = state->xattr_size;
1164         if (xattr_value != NULL) {
1165                 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
1166         }
1167
1168         tevent_req_received(req);
1169         return xattr_size;
1170 }
1171
1172 static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
1173                               struct files_struct *fsp, const char *name,
1174                               void *value, size_t size)
1175 {
1176         return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1177 }
1178
1179 static ssize_t skel_listxattr(vfs_handle_struct *handle,
1180                                 const struct smb_filename *smb_fname,
1181                                 char *list,
1182                                 size_t size)
1183 {
1184         return SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
1185 }
1186
1187 static ssize_t skel_flistxattr(vfs_handle_struct *handle,
1188                                struct files_struct *fsp, char *list,
1189                                size_t size)
1190 {
1191         return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1192 }
1193
1194 static int skel_removexattr(vfs_handle_struct *handle,
1195                         const struct smb_filename *smb_fname,
1196                         const char *name)
1197 {
1198         return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
1199 }
1200
1201 static int skel_fremovexattr(vfs_handle_struct *handle,
1202                              struct files_struct *fsp, const char *name)
1203 {
1204         return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
1205 }
1206
1207 static int skel_setxattr(vfs_handle_struct *handle,
1208                         const struct smb_filename *smb_fname,
1209                         const char *name,
1210                         const void *value,
1211                         size_t size,
1212                         int flags)
1213 {
1214         return SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
1215                         name, value, size, flags);
1216 }
1217
1218 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
1219                           const char *name, const void *value, size_t size,
1220                           int flags)
1221 {
1222         return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
1223 }
1224
1225 static bool skel_aio_force(struct vfs_handle_struct *handle,
1226                            struct files_struct *fsp)
1227 {
1228         return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
1229 }
1230
1231 static NTSTATUS skel_audit_file(struct vfs_handle_struct *handle,
1232                                 struct smb_filename *file,
1233                                 struct security_acl *sacl,
1234                                 uint32_t access_requested,
1235                                 uint32_t access_denied)
1236 {
1237         return SMB_VFS_NEXT_AUDIT_FILE(handle,
1238                                        file,
1239                                        sacl,
1240                                        access_requested,
1241                                        access_denied);
1242 }
1243
1244 static NTSTATUS skel_durable_cookie(struct vfs_handle_struct *handle,
1245                                     struct files_struct *fsp,
1246                                     TALLOC_CTX *mem_ctx,
1247                                     DATA_BLOB *cookie)
1248 {
1249         return SMB_VFS_NEXT_DURABLE_COOKIE(handle,
1250                                            fsp,
1251                                            mem_ctx,
1252                                            cookie);
1253 }
1254
1255 static NTSTATUS skel_durable_disconnect(struct vfs_handle_struct *handle,
1256                                         struct files_struct *fsp,
1257                                         const DATA_BLOB old_cookie,
1258                                         TALLOC_CTX *mem_ctx,
1259                                         DATA_BLOB *new_cookie)
1260 {
1261         return SMB_VFS_NEXT_DURABLE_DISCONNECT(handle,
1262                                                fsp,
1263                                                old_cookie,
1264                                                mem_ctx,
1265                                                new_cookie);
1266 }
1267
1268 static NTSTATUS skel_durable_reconnect(struct vfs_handle_struct *handle,
1269                                        struct smb_request *smb1req,
1270                                        struct smbXsrv_open *op,
1271                                        const DATA_BLOB old_cookie,
1272                                        TALLOC_CTX *mem_ctx,
1273                                        struct files_struct **fsp,
1274                                        DATA_BLOB *new_cookie)
1275 {
1276         return SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
1277                                               smb1req,
1278                                               op,
1279                                               old_cookie,
1280                                               mem_ctx,
1281                                               fsp,
1282                                               new_cookie);
1283 }
1284
1285 /* VFS operations structure */
1286
1287 static struct vfs_fn_pointers skel_transparent_fns = {
1288         /* Disk operations */
1289
1290         .connect_fn = skel_connect,
1291         .disconnect_fn = skel_disconnect,
1292         .disk_free_fn = skel_disk_free,
1293         .get_quota_fn = skel_get_quota,
1294         .set_quota_fn = skel_set_quota,
1295         .get_shadow_copy_data_fn = skel_get_shadow_copy_data,
1296         .statvfs_fn = skel_statvfs,
1297         .fs_capabilities_fn = skel_fs_capabilities,
1298         .get_dfs_referrals_fn = skel_get_dfs_referrals,
1299         .snap_check_path_fn = skel_snap_check_path,
1300         .snap_create_fn = skel_snap_create,
1301         .snap_delete_fn = skel_snap_delete,
1302
1303         /* Directory operations */
1304
1305         .opendir_fn = skel_opendir,
1306         .fdopendir_fn = skel_fdopendir,
1307         .readdir_fn = skel_readdir,
1308         .seekdir_fn = skel_seekdir,
1309         .telldir_fn = skel_telldir,
1310         .rewind_dir_fn = skel_rewind_dir,
1311         .mkdir_fn = skel_mkdir,
1312         .rmdir_fn = skel_rmdir,
1313         .closedir_fn = skel_closedir,
1314
1315         /* File operations */
1316
1317         .open_fn = skel_open,
1318         .create_file_fn = skel_create_file,
1319         .close_fn = skel_close_fn,
1320         .pread_fn = skel_pread,
1321         .pread_send_fn = skel_pread_send,
1322         .pread_recv_fn = skel_pread_recv,
1323         .pwrite_fn = skel_pwrite,
1324         .pwrite_send_fn = skel_pwrite_send,
1325         .pwrite_recv_fn = skel_pwrite_recv,
1326         .lseek_fn = skel_lseek,
1327         .sendfile_fn = skel_sendfile,
1328         .recvfile_fn = skel_recvfile,
1329         .rename_fn = skel_rename,
1330         .fsync_send_fn = skel_fsync_send,
1331         .fsync_recv_fn = skel_fsync_recv,
1332         .stat_fn = skel_stat,
1333         .fstat_fn = skel_fstat,
1334         .lstat_fn = skel_lstat,
1335         .get_alloc_size_fn = skel_get_alloc_size,
1336         .unlink_fn = skel_unlink,
1337         .chmod_fn = skel_chmod,
1338         .fchmod_fn = skel_fchmod,
1339         .chown_fn = skel_chown,
1340         .fchown_fn = skel_fchown,
1341         .lchown_fn = skel_lchown,
1342         .chdir_fn = skel_chdir,
1343         .getwd_fn = skel_getwd,
1344         .ntimes_fn = skel_ntimes,
1345         .ftruncate_fn = skel_ftruncate,
1346         .fallocate_fn = skel_fallocate,
1347         .lock_fn = skel_lock,
1348         .kernel_flock_fn = skel_kernel_flock,
1349         .linux_setlease_fn = skel_linux_setlease,
1350         .getlock_fn = skel_getlock,
1351         .symlink_fn = skel_symlink,
1352         .readlink_fn = skel_vfs_readlink,
1353         .link_fn = skel_link,
1354         .mknod_fn = skel_mknod,
1355         .realpath_fn = skel_realpath,
1356         .chflags_fn = skel_chflags,
1357         .file_id_create_fn = skel_file_id_create,
1358         .offload_read_send_fn = skel_offload_read_send,
1359         .offload_read_recv_fn = skel_offload_read_recv,
1360         .offload_write_send_fn = skel_offload_write_send,
1361         .offload_write_recv_fn = skel_offload_write_recv,
1362         .get_compression_fn = skel_get_compression,
1363         .set_compression_fn = skel_set_compression,
1364
1365         .streaminfo_fn = skel_streaminfo,
1366         .get_real_filename_fn = skel_get_real_filename,
1367         .connectpath_fn = skel_connectpath,
1368         .brl_lock_windows_fn = skel_brl_lock_windows,
1369         .brl_unlock_windows_fn = skel_brl_unlock_windows,
1370         .brl_cancel_windows_fn = skel_brl_cancel_windows,
1371         .strict_lock_check_fn = skel_strict_lock_check,
1372         .translate_name_fn = skel_translate_name,
1373         .fsctl_fn = skel_fsctl,
1374         .readdir_attr_fn = skel_readdir_attr,
1375         .audit_file_fn = skel_audit_file,
1376
1377         /* DOS attributes. */
1378         .get_dos_attributes_fn = skel_get_dos_attributes,
1379         .get_dos_attributes_send_fn = skel_get_dos_attributes_send,
1380         .get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
1381         .fget_dos_attributes_fn = skel_fget_dos_attributes,
1382         .set_dos_attributes_fn = skel_set_dos_attributes,
1383         .fset_dos_attributes_fn = skel_fset_dos_attributes,
1384
1385         /* NT ACL operations. */
1386
1387         .fget_nt_acl_fn = skel_fget_nt_acl,
1388         .get_nt_acl_fn = skel_get_nt_acl,
1389         .fset_nt_acl_fn = skel_fset_nt_acl,
1390
1391         /* POSIX ACL operations. */
1392
1393         .sys_acl_get_file_fn = skel_sys_acl_get_file,
1394         .sys_acl_get_fd_fn = skel_sys_acl_get_fd,
1395         .sys_acl_blob_get_file_fn = skel_sys_acl_blob_get_file,
1396         .sys_acl_blob_get_fd_fn = skel_sys_acl_blob_get_fd,
1397         .sys_acl_set_file_fn = skel_sys_acl_set_file,
1398         .sys_acl_set_fd_fn = skel_sys_acl_set_fd,
1399         .sys_acl_delete_def_file_fn = skel_sys_acl_delete_def_file,
1400
1401         /* EA operations. */
1402         .getxattr_fn = skel_getxattr,
1403         .getxattrat_send_fn = skel_getxattrat_send,
1404         .getxattrat_recv_fn = skel_getxattrat_recv,
1405         .fgetxattr_fn = skel_fgetxattr,
1406         .listxattr_fn = skel_listxattr,
1407         .flistxattr_fn = skel_flistxattr,
1408         .removexattr_fn = skel_removexattr,
1409         .fremovexattr_fn = skel_fremovexattr,
1410         .setxattr_fn = skel_setxattr,
1411         .fsetxattr_fn = skel_fsetxattr,
1412
1413         /* aio operations */
1414         .aio_force_fn = skel_aio_force,
1415
1416         /* durable handle operations */
1417         .durable_cookie_fn = skel_durable_cookie,
1418         .durable_disconnect_fn = skel_durable_disconnect,
1419         .durable_reconnect_fn = skel_durable_reconnect,
1420 };
1421
1422 static_decl_vfs;
1423 NTSTATUS vfs_skel_transparent_init(TALLOC_CTX *ctx)
1424 {
1425         /*
1426          * smb_vfs_assert_all_fns() is only needed in
1427          * order to have a complete example.
1428          *
1429          * A transparent vfs module typically don't
1430          * need to implement every calls.
1431          */
1432         smb_vfs_assert_all_fns(&skel_transparent_fns, "skel_transparent");
1433         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "skel_transparent",
1434                                 &skel_transparent_fns);
1435 }