s3/vfs: change fallocate mode flags from enum->uint32_t
[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 #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, const char *path,
52                                uint64_t *bsize,
53                                uint64_t *dfree, uint64_t *dsize)
54 {
55         return SMB_VFS_NEXT_DISK_FREE(handle, path, bsize, dfree, dsize);
56 }
57
58 static int skel_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
59                           unid_t id, SMB_DISK_QUOTA *dq)
60 {
61         return SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, dq);
62 }
63
64 static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
65                           unid_t id, SMB_DISK_QUOTA *dq)
66 {
67         return SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, dq);
68 }
69
70 static int skel_get_shadow_copy_data(vfs_handle_struct *handle,
71                                      files_struct *fsp,
72                                      struct shadow_copy_data *shadow_copy_data,
73                                      bool labels)
74 {
75         return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data,
76                                                  labels);
77 }
78
79 static int skel_statvfs(struct vfs_handle_struct *handle, const char *path,
80                         struct vfs_statvfs_struct *statbuf)
81 {
82         return SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
83 }
84
85 static uint32_t skel_fs_capabilities(struct vfs_handle_struct *handle,
86                                      enum timestamp_set_resolution *p_ts_res)
87 {
88         return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
89 }
90
91 static NTSTATUS skel_get_dfs_referrals(struct vfs_handle_struct *handle,
92                                        struct dfs_GetDFSReferral *r)
93 {
94         return SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
95 }
96
97 static DIR *skel_opendir(vfs_handle_struct *handle, const char *fname,
98                          const char *mask, uint32 attr)
99 {
100         return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
101 }
102
103 static DIR *skel_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
104                            const char *mask, uint32 attr)
105 {
106         return SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
107 }
108
109 static struct dirent *skel_readdir(vfs_handle_struct *handle,
110                                    DIR *dirp, SMB_STRUCT_STAT *sbuf)
111 {
112         return SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
113 }
114
115 static void skel_seekdir(vfs_handle_struct *handle, DIR *dirp, long offset)
116 {
117         SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
118 }
119
120 static long skel_telldir(vfs_handle_struct *handle, DIR *dirp)
121 {
122         return SMB_VFS_NEXT_TELLDIR(handle, dirp);
123 }
124
125 static void skel_rewind_dir(vfs_handle_struct *handle, DIR *dirp)
126 {
127         SMB_VFS_NEXT_REWINDDIR(handle, dirp);
128 }
129
130 static int skel_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode)
131 {
132         return SMB_VFS_NEXT_MKDIR(handle, path, mode);
133 }
134
135 static int skel_rmdir(vfs_handle_struct *handle, const char *path)
136 {
137         return SMB_VFS_NEXT_RMDIR(handle, path);
138 }
139
140 static int skel_closedir(vfs_handle_struct *handle, DIR *dir)
141 {
142         return SMB_VFS_NEXT_CLOSEDIR(handle, dir);
143 }
144
145 static void skel_init_search_op(struct vfs_handle_struct *handle, DIR *dirp)
146 {
147         SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
148 }
149
150 static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
151                      files_struct *fsp, int flags, mode_t mode)
152 {
153         return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
154 }
155
156 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
157                                  struct smb_request *req,
158                                  uint16_t root_dir_fid,
159                                  struct smb_filename *smb_fname,
160                                  uint32_t access_mask,
161                                  uint32_t share_access,
162                                  uint32_t create_disposition,
163                                  uint32_t create_options,
164                                  uint32_t file_attributes,
165                                  uint32_t oplock_request,
166                                  struct smb2_lease *lease,
167                                  uint64_t allocation_size,
168                                  uint32_t private_flags,
169                                  struct security_descriptor *sd,
170                                  struct ea_list *ea_list,
171                                  files_struct ** result, int *pinfo,
172                                  const struct smb2_create_blobs *in_context_blobs,
173                                  struct smb2_create_blobs *out_context_blobs)
174 {
175         return SMB_VFS_NEXT_CREATE_FILE(handle,
176                                         req,
177                                         root_dir_fid,
178                                         smb_fname,
179                                         access_mask,
180                                         share_access,
181                                         create_disposition,
182                                         create_options,
183                                         file_attributes,
184                                         oplock_request,
185                                         lease,
186                                         allocation_size,
187                                         private_flags,
188                                         sd, ea_list, result, pinfo,
189                                         in_context_blobs, out_context_blobs);
190 }
191
192 static int skel_close_fn(vfs_handle_struct *handle, files_struct *fsp)
193 {
194         return SMB_VFS_NEXT_CLOSE(handle, fsp);
195 }
196
197 static ssize_t skel_vfs_read(vfs_handle_struct *handle, files_struct *fsp,
198                              void *data, size_t n)
199 {
200         return SMB_VFS_NEXT_READ(handle, fsp, data, n);
201 }
202
203 static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp,
204                           void *data, size_t n, off_t offset)
205 {
206         return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
207 }
208
209 struct skel_pread_state {
210         ssize_t ret;
211         int err;
212 };
213
214 static void skel_pread_done(struct tevent_req *subreq);
215
216 static struct tevent_req *skel_pread_send(struct vfs_handle_struct *handle,
217                                           TALLOC_CTX *mem_ctx,
218                                           struct tevent_context *ev,
219                                           struct files_struct *fsp,
220                                           void *data, size_t n, off_t offset)
221 {
222         struct tevent_req *req, *subreq;
223         struct skel_pread_state *state;
224
225         req = tevent_req_create(mem_ctx, &state, struct skel_pread_state);
226         if (req == NULL) {
227                 return NULL;
228         }
229         subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
230                                          n, offset);
231         if (tevent_req_nomem(subreq, req)) {
232                 return tevent_req_post(req, ev);
233         }
234         tevent_req_set_callback(subreq, skel_pread_done, req);
235         return req;
236 }
237
238 static void skel_pread_done(struct tevent_req *subreq)
239 {
240         struct tevent_req *req =
241             tevent_req_callback_data(subreq, struct tevent_req);
242         struct skel_pread_state *state =
243             tevent_req_data(req, struct skel_pread_state);
244
245         state->ret = SMB_VFS_PREAD_RECV(subreq, &state->err);
246         TALLOC_FREE(subreq);
247         tevent_req_done(req);
248 }
249
250 static ssize_t skel_pread_recv(struct tevent_req *req, int *err)
251 {
252         struct skel_pread_state *state =
253             tevent_req_data(req, struct skel_pread_state);
254
255         if (tevent_req_is_unix_error(req, err)) {
256                 return -1;
257         }
258         *err = state->err;
259         return state->ret;
260 }
261
262 static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp,
263                           const void *data, size_t n)
264 {
265         return SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
266 }
267
268 static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp,
269                            const void *data, size_t n, off_t offset)
270 {
271         return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
272 }
273
274 struct skel_pwrite_state {
275         ssize_t ret;
276         int err;
277 };
278
279 static void skel_pwrite_done(struct tevent_req *subreq);
280
281 static struct tevent_req *skel_pwrite_send(struct vfs_handle_struct *handle,
282                                            TALLOC_CTX *mem_ctx,
283                                            struct tevent_context *ev,
284                                            struct files_struct *fsp,
285                                            const void *data,
286                                            size_t n, off_t offset)
287 {
288         struct tevent_req *req, *subreq;
289         struct skel_pwrite_state *state;
290
291         req = tevent_req_create(mem_ctx, &state, struct skel_pwrite_state);
292         if (req == NULL) {
293                 return NULL;
294         }
295         subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
296                                           n, offset);
297         if (tevent_req_nomem(subreq, req)) {
298                 return tevent_req_post(req, ev);
299         }
300         tevent_req_set_callback(subreq, skel_pwrite_done, req);
301         return req;
302 }
303
304 static void skel_pwrite_done(struct tevent_req *subreq)
305 {
306         struct tevent_req *req =
307             tevent_req_callback_data(subreq, struct tevent_req);
308         struct skel_pwrite_state *state =
309             tevent_req_data(req, struct skel_pwrite_state);
310
311         state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->err);
312         TALLOC_FREE(subreq);
313         tevent_req_done(req);
314 }
315
316 static ssize_t skel_pwrite_recv(struct tevent_req *req, int *err)
317 {
318         struct skel_pwrite_state *state =
319             tevent_req_data(req, struct skel_pwrite_state);
320
321         if (tevent_req_is_unix_error(req, err)) {
322                 return -1;
323         }
324         *err = state->err;
325         return state->ret;
326 }
327
328 static off_t skel_lseek(vfs_handle_struct *handle, files_struct *fsp,
329                         off_t offset, int whence)
330 {
331         return SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
332 }
333
334 static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd,
335                              files_struct *fromfsp, const DATA_BLOB *hdr,
336                              off_t offset, size_t n)
337 {
338         return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
339 }
340
341 static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd,
342                              files_struct *tofsp, off_t offset, size_t n)
343 {
344         return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
345 }
346
347 static int skel_rename(vfs_handle_struct *handle,
348                        const struct smb_filename *smb_fname_src,
349                        const struct smb_filename *smb_fname_dst)
350 {
351         return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
352 }
353
354 static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
355 {
356         return SMB_VFS_NEXT_FSYNC(handle, fsp);
357 }
358
359 struct skel_fsync_state {
360         int ret;
361         int err;
362 };
363
364 static void skel_fsync_done(struct tevent_req *subreq);
365
366 static struct tevent_req *skel_fsync_send(struct vfs_handle_struct *handle,
367                                           TALLOC_CTX *mem_ctx,
368                                           struct tevent_context *ev,
369                                           struct files_struct *fsp)
370 {
371         struct tevent_req *req, *subreq;
372         struct skel_fsync_state *state;
373
374         req = tevent_req_create(mem_ctx, &state, struct skel_fsync_state);
375         if (req == NULL) {
376                 return NULL;
377         }
378         subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
379         if (tevent_req_nomem(subreq, req)) {
380                 return tevent_req_post(req, ev);
381         }
382         tevent_req_set_callback(subreq, skel_fsync_done, req);
383         return req;
384 }
385
386 static void skel_fsync_done(struct tevent_req *subreq)
387 {
388         struct tevent_req *req =
389             tevent_req_callback_data(subreq, struct tevent_req);
390         struct skel_fsync_state *state =
391             tevent_req_data(req, struct skel_fsync_state);
392
393         state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->err);
394         TALLOC_FREE(subreq);
395         tevent_req_done(req);
396 }
397
398 static int skel_fsync_recv(struct tevent_req *req, int *err)
399 {
400         struct skel_fsync_state *state =
401             tevent_req_data(req, struct skel_fsync_state);
402
403         if (tevent_req_is_unix_error(req, err)) {
404                 return -1;
405         }
406         *err = state->err;
407         return state->ret;
408 }
409
410 static int skel_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
411 {
412         return SMB_VFS_NEXT_STAT(handle, smb_fname);
413 }
414
415 static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp,
416                       SMB_STRUCT_STAT *sbuf)
417 {
418         return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
419 }
420
421 static int skel_lstat(vfs_handle_struct *handle,
422                       struct smb_filename *smb_fname)
423 {
424         return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
425 }
426
427 static uint64_t skel_get_alloc_size(struct vfs_handle_struct *handle,
428                                     struct files_struct *fsp,
429                                     const SMB_STRUCT_STAT *sbuf)
430 {
431         return SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
432 }
433
434 static int skel_unlink(vfs_handle_struct *handle,
435                        const struct smb_filename *smb_fname)
436 {
437         return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
438 }
439
440 static int skel_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
441 {
442         return SMB_VFS_NEXT_CHMOD(handle, path, mode);
443 }
444
445 static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp,
446                        mode_t mode)
447 {
448         return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
449 }
450
451 static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid,
452                       gid_t gid)
453 {
454         return SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
455 }
456
457 static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp,
458                        uid_t uid, gid_t gid)
459 {
460         return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
461 }
462
463 static int skel_lchown(vfs_handle_struct *handle, const char *path, uid_t uid,
464                        gid_t gid)
465 {
466         return SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
467 }
468
469 static int skel_chdir(vfs_handle_struct *handle, const char *path)
470 {
471         return SMB_VFS_NEXT_CHDIR(handle, path);
472 }
473
474 static char *skel_getwd(vfs_handle_struct *handle)
475 {
476         return SMB_VFS_NEXT_GETWD(handle);
477 }
478
479 static int skel_ntimes(vfs_handle_struct *handle,
480                        const struct smb_filename *smb_fname,
481                        struct smb_file_time *ft)
482 {
483         return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
484 }
485
486 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
487                           off_t offset)
488 {
489         return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
490 }
491
492 static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
493                           uint32_t mode, off_t offset, off_t len)
494 {
495         return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
496 }
497
498 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op,
499                       off_t offset, off_t count, int type)
500 {
501         return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
502 }
503
504 static int skel_kernel_flock(struct vfs_handle_struct *handle,
505                              struct files_struct *fsp, uint32 share_mode,
506                              uint32 access_mask)
507 {
508         return SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
509 }
510
511 static int skel_linux_setlease(struct vfs_handle_struct *handle,
512                                struct files_struct *fsp, int leasetype)
513 {
514         return SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
515 }
516
517 static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp,
518                          off_t *poffset, off_t *pcount, int *ptype,
519                          pid_t *ppid)
520 {
521         return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
522 }
523
524 static int skel_symlink(vfs_handle_struct *handle, const char *oldpath,
525                         const char *newpath)
526 {
527         return SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
528 }
529
530 static int skel_vfs_readlink(vfs_handle_struct *handle, const char *path,
531                              char *buf, size_t bufsiz)
532 {
533         return SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
534 }
535
536 static int skel_link(vfs_handle_struct *handle, const char *oldpath,
537                      const char *newpath)
538 {
539         return SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
540 }
541
542 static int skel_mknod(vfs_handle_struct *handle, const char *path, mode_t mode,
543                       SMB_DEV_T dev)
544 {
545         return SMB_VFS_NEXT_MKNOD(handle, path, mode, dev);
546 }
547
548 static char *skel_realpath(vfs_handle_struct *handle, const char *path)
549 {
550         return SMB_VFS_NEXT_REALPATH(handle, path);
551 }
552
553 static NTSTATUS skel_notify_watch(struct vfs_handle_struct *handle,
554                                   struct sys_notify_context *ctx,
555                                   const char *path,
556                                   uint32_t *filter,
557                                   uint32_t *subdir_filter,
558                                   void (*callback) (struct sys_notify_context *ctx,
559                                                     void *private_data,
560                                                     struct notify_event *ev),
561                                   void *private_data, void *handle_p)
562 {
563         return SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, path,
564                                          filter, subdir_filter, callback,
565                                          private_data, handle_p);
566 }
567
568 static int skel_chflags(vfs_handle_struct *handle, const char *path,
569                         uint flags)
570 {
571         return SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
572 }
573
574 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
575                                           const SMB_STRUCT_STAT *sbuf)
576 {
577         return SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
578 }
579
580 struct skel_cc_state {
581         struct vfs_handle_struct *handle;
582         off_t copied;
583 };
584 static void skel_copy_chunk_done(struct tevent_req *subreq);
585
586 static struct tevent_req *skel_copy_chunk_send(struct vfs_handle_struct *handle,
587                                                TALLOC_CTX *mem_ctx,
588                                                struct tevent_context *ev,
589                                                struct files_struct *src_fsp,
590                                                off_t src_off,
591                                                struct files_struct *dest_fsp,
592                                                off_t dest_off,
593                                                off_t num)
594 {
595         struct tevent_req *req;
596         struct tevent_req *subreq;
597         struct skel_cc_state *cc_state;
598
599         req = tevent_req_create(mem_ctx, &cc_state, struct skel_cc_state);
600         if (req == NULL) {
601                 return NULL;
602         }
603
604         cc_state->handle = handle;
605         subreq = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, cc_state, ev,
606                                               src_fsp, src_off,
607                                               dest_fsp, dest_off, num);
608         if (tevent_req_nomem(subreq, req)) {
609                 return tevent_req_post(req, ev);
610         }
611
612         tevent_req_set_callback(subreq, skel_copy_chunk_done, req);
613         return req;
614 }
615
616 static void skel_copy_chunk_done(struct tevent_req *subreq)
617 {
618         struct tevent_req *req = tevent_req_callback_data(
619                 subreq, struct tevent_req);
620         struct skel_cc_state *cc_state
621                         = tevent_req_data(req, struct skel_cc_state);
622         NTSTATUS status;
623
624         status = SMB_VFS_NEXT_COPY_CHUNK_RECV(cc_state->handle,
625                                               subreq,
626                                               &cc_state->copied);
627         TALLOC_FREE(subreq);
628         if (tevent_req_nterror(req, status)) {
629                 return;
630         }
631         tevent_req_done(req);
632 }
633
634 static NTSTATUS skel_copy_chunk_recv(struct vfs_handle_struct *handle,
635                                      struct tevent_req *req,
636                                      off_t *copied)
637 {
638         struct skel_cc_state *cc_state
639                         = tevent_req_data(req, struct skel_cc_state);
640         NTSTATUS status;
641
642         *copied = cc_state->copied;
643         if (tevent_req_is_nterror(req, &status)) {
644                 tevent_req_received(req);
645                 return status;
646         }
647
648         tevent_req_received(req);
649         return NT_STATUS_OK;
650 }
651
652 static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
653                                      TALLOC_CTX *mem_ctx,
654                                      struct files_struct *fsp,
655                                      struct smb_filename *smb_fname,
656                                      uint16_t *_compression_fmt)
657 {
658         return SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
659                                             _compression_fmt);
660 }
661
662 static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
663                                      TALLOC_CTX *mem_ctx,
664                                      struct files_struct *fsp,
665                                      uint16_t compression_fmt)
666 {
667         return SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
668                                             compression_fmt);
669 }
670
671 static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
672                                 struct files_struct *fsp,
673                                 const char *fname,
674                                 TALLOC_CTX *mem_ctx,
675                                 unsigned int *num_streams,
676                                 struct stream_struct **streams)
677 {
678         return SMB_VFS_NEXT_STREAMINFO(handle,
679                                        fsp,
680                                        fname, mem_ctx, num_streams, streams);
681 }
682
683 static int skel_get_real_filename(struct vfs_handle_struct *handle,
684                                   const char *path,
685                                   const char *name,
686                                   TALLOC_CTX *mem_ctx, char **found_name)
687 {
688         return SMB_VFS_NEXT_GET_REAL_FILENAME(handle,
689                                               path, name, mem_ctx, found_name);
690 }
691
692 static const char *skel_connectpath(struct vfs_handle_struct *handle,
693                                     const char *filename)
694 {
695         return SMB_VFS_NEXT_CONNECTPATH(handle, filename);
696 }
697
698 static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
699                                       struct byte_range_lock *br_lck,
700                                       struct lock_struct *plock,
701                                       bool blocking_lock)
702 {
703         return SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle,
704                                              br_lck, plock, blocking_lock);
705 }
706
707 static bool skel_brl_unlock_windows(struct vfs_handle_struct *handle,
708                                     struct messaging_context *msg_ctx,
709                                     struct byte_range_lock *br_lck,
710                                     const struct lock_struct *plock)
711 {
712         return SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck, plock);
713 }
714
715 static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
716                                     struct byte_range_lock *br_lck,
717                                     struct lock_struct *plock)
718 {
719         return SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
720 }
721
722 static bool skel_strict_lock(struct vfs_handle_struct *handle,
723                              struct files_struct *fsp,
724                              struct lock_struct *plock)
725 {
726         return SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
727 }
728
729 static void skel_strict_unlock(struct vfs_handle_struct *handle,
730                                struct files_struct *fsp,
731                                struct lock_struct *plock)
732 {
733         SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
734 }
735
736 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
737                                     const char *mapped_name,
738                                     enum vfs_translate_direction direction,
739                                     TALLOC_CTX *mem_ctx, char **pmapped_name)
740 {
741         return SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction,
742                                            mem_ctx, pmapped_name);
743 }
744
745 static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
746                            struct files_struct *fsp,
747                            TALLOC_CTX *ctx,
748                            uint32_t function,
749                            uint16_t req_flags,  /* Needed for UNICODE ... */
750                            const uint8_t *_in_data,
751                            uint32_t in_len,
752                            uint8_t ** _out_data,
753                            uint32_t max_out_len, uint32_t *out_len)
754 {
755         return SMB_VFS_NEXT_FSCTL(handle,
756                                   fsp,
757                                   ctx,
758                                   function,
759                                   req_flags,
760                                   _in_data,
761                                   in_len, _out_data, max_out_len, out_len);
762 }
763
764 static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
765                                   const struct smb_filename *fname,
766                                   TALLOC_CTX *mem_ctx,
767                                   struct readdir_attr_data **pattr_data)
768 {
769         return SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
770 }
771
772 static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
773                                  uint32 security_info,
774                                  TALLOC_CTX *mem_ctx,
775                                  struct security_descriptor **ppdesc)
776 {
777         return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, mem_ctx,
778                                         ppdesc);
779 }
780
781 static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle,
782                                 const char *name, uint32 security_info,
783                                 TALLOC_CTX *mem_ctx,
784                                 struct security_descriptor **ppdesc)
785 {
786         return SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, mem_ctx,
787                                        ppdesc);
788 }
789
790 static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
791                                  uint32 security_info_sent,
792                                  const struct security_descriptor *psd)
793 {
794         return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
795 }
796
797 static int skel_chmod_acl(vfs_handle_struct *handle, const char *name,
798                           mode_t mode)
799 {
800         return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode);
801 }
802
803 static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
804                            mode_t mode)
805 {
806         return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
807 }
808
809 static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle,
810                                        const char *path_p,
811                                        SMB_ACL_TYPE_T type,
812                                        TALLOC_CTX *mem_ctx)
813 {
814         return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type, mem_ctx);
815 }
816
817 static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
818                                      files_struct *fsp, TALLOC_CTX *mem_ctx)
819 {
820         return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
821 }
822
823 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
824                                       const char *path_p, TALLOC_CTX *mem_ctx,
825                                       char **blob_description, DATA_BLOB *blob)
826 {
827         return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p, mem_ctx,
828                                                   blob_description, blob);
829 }
830
831 static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
832                                     files_struct *fsp, TALLOC_CTX *mem_ctx,
833                                     char **blob_description, DATA_BLOB *blob)
834 {
835         return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx,
836                                                 blob_description, blob);
837 }
838
839 static int skel_sys_acl_set_file(vfs_handle_struct *handle, const char *name,
840                                  SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
841 {
842         return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype, theacl);
843 }
844
845 static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
846                                SMB_ACL_T theacl)
847 {
848         return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
849 }
850
851 static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
852                                         const char *path)
853 {
854         return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
855 }
856
857 static ssize_t skel_getxattr(vfs_handle_struct *handle, const char *path,
858                              const char *name, void *value, size_t size)
859 {
860         return SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
861 }
862
863 static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
864                               struct files_struct *fsp, const char *name,
865                               void *value, size_t size)
866 {
867         return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
868 }
869
870 static ssize_t skel_listxattr(vfs_handle_struct *handle, const char *path,
871                               char *list, size_t size)
872 {
873         return SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
874 }
875
876 static ssize_t skel_flistxattr(vfs_handle_struct *handle,
877                                struct files_struct *fsp, char *list,
878                                size_t size)
879 {
880         return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
881 }
882
883 static int skel_removexattr(vfs_handle_struct *handle, const char *path,
884                             const char *name)
885 {
886         return SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
887 }
888
889 static int skel_fremovexattr(vfs_handle_struct *handle,
890                              struct files_struct *fsp, const char *name)
891 {
892         return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
893 }
894
895 static int skel_setxattr(vfs_handle_struct *handle, const char *path,
896                          const char *name, const void *value, size_t size,
897                          int flags)
898 {
899         return SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size, flags);
900 }
901
902 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
903                           const char *name, const void *value, size_t size,
904                           int flags)
905 {
906         return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
907 }
908
909 static bool skel_aio_force(struct vfs_handle_struct *handle,
910                            struct files_struct *fsp)
911 {
912         return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
913 }
914
915 static bool skel_is_offline(struct vfs_handle_struct *handle,
916                             const struct smb_filename *fname,
917                             SMB_STRUCT_STAT *sbuf)
918 {
919         return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
920 }
921
922 static int skel_set_offline(struct vfs_handle_struct *handle,
923                             const struct smb_filename *fname)
924 {
925         return SMB_VFS_NEXT_SET_OFFLINE(handle, fname);
926 }
927
928 /* VFS operations structure */
929
930 struct vfs_fn_pointers skel_transparent_fns = {
931         /* Disk operations */
932
933         .connect_fn = skel_connect,
934         .disconnect_fn = skel_disconnect,
935         .disk_free_fn = skel_disk_free,
936         .get_quota_fn = skel_get_quota,
937         .set_quota_fn = skel_set_quota,
938         .get_shadow_copy_data_fn = skel_get_shadow_copy_data,
939         .statvfs_fn = skel_statvfs,
940         .fs_capabilities_fn = skel_fs_capabilities,
941         .get_dfs_referrals_fn = skel_get_dfs_referrals,
942
943         /* Directory operations */
944
945         .opendir_fn = skel_opendir,
946         .fdopendir_fn = skel_fdopendir,
947         .readdir_fn = skel_readdir,
948         .seekdir_fn = skel_seekdir,
949         .telldir_fn = skel_telldir,
950         .rewind_dir_fn = skel_rewind_dir,
951         .mkdir_fn = skel_mkdir,
952         .rmdir_fn = skel_rmdir,
953         .closedir_fn = skel_closedir,
954         .init_search_op_fn = skel_init_search_op,
955
956         /* File operations */
957
958         .open_fn = skel_open,
959         .create_file_fn = skel_create_file,
960         .close_fn = skel_close_fn,
961         .read_fn = skel_vfs_read,
962         .pread_fn = skel_pread,
963         .pread_send_fn = skel_pread_send,
964         .pread_recv_fn = skel_pread_recv,
965         .write_fn = skel_write,
966         .pwrite_fn = skel_pwrite,
967         .pwrite_send_fn = skel_pwrite_send,
968         .pwrite_recv_fn = skel_pwrite_recv,
969         .lseek_fn = skel_lseek,
970         .sendfile_fn = skel_sendfile,
971         .recvfile_fn = skel_recvfile,
972         .rename_fn = skel_rename,
973         .fsync_fn = skel_fsync,
974         .fsync_send_fn = skel_fsync_send,
975         .fsync_recv_fn = skel_fsync_recv,
976         .stat_fn = skel_stat,
977         .fstat_fn = skel_fstat,
978         .lstat_fn = skel_lstat,
979         .get_alloc_size_fn = skel_get_alloc_size,
980         .unlink_fn = skel_unlink,
981         .chmod_fn = skel_chmod,
982         .fchmod_fn = skel_fchmod,
983         .chown_fn = skel_chown,
984         .fchown_fn = skel_fchown,
985         .lchown_fn = skel_lchown,
986         .chdir_fn = skel_chdir,
987         .getwd_fn = skel_getwd,
988         .ntimes_fn = skel_ntimes,
989         .ftruncate_fn = skel_ftruncate,
990         .fallocate_fn = skel_fallocate,
991         .lock_fn = skel_lock,
992         .kernel_flock_fn = skel_kernel_flock,
993         .linux_setlease_fn = skel_linux_setlease,
994         .getlock_fn = skel_getlock,
995         .symlink_fn = skel_symlink,
996         .readlink_fn = skel_vfs_readlink,
997         .link_fn = skel_link,
998         .mknod_fn = skel_mknod,
999         .realpath_fn = skel_realpath,
1000         .notify_watch_fn = skel_notify_watch,
1001         .chflags_fn = skel_chflags,
1002         .file_id_create_fn = skel_file_id_create,
1003         .copy_chunk_send_fn = skel_copy_chunk_send,
1004         .copy_chunk_recv_fn = skel_copy_chunk_recv,
1005         .get_compression_fn = skel_get_compression,
1006         .set_compression_fn = skel_set_compression,
1007
1008         .streaminfo_fn = skel_streaminfo,
1009         .get_real_filename_fn = skel_get_real_filename,
1010         .connectpath_fn = skel_connectpath,
1011         .brl_lock_windows_fn = skel_brl_lock_windows,
1012         .brl_unlock_windows_fn = skel_brl_unlock_windows,
1013         .brl_cancel_windows_fn = skel_brl_cancel_windows,
1014         .strict_lock_fn = skel_strict_lock,
1015         .strict_unlock_fn = skel_strict_unlock,
1016         .translate_name_fn = skel_translate_name,
1017         .fsctl_fn = skel_fsctl,
1018         .readdir_attr_fn = skel_readdir_attr,
1019
1020         /* NT ACL operations. */
1021
1022         .fget_nt_acl_fn = skel_fget_nt_acl,
1023         .get_nt_acl_fn = skel_get_nt_acl,
1024         .fset_nt_acl_fn = skel_fset_nt_acl,
1025
1026         /* POSIX ACL operations. */
1027
1028         .chmod_acl_fn = skel_chmod_acl,
1029         .fchmod_acl_fn = skel_fchmod_acl,
1030
1031         .sys_acl_get_file_fn = skel_sys_acl_get_file,
1032         .sys_acl_get_fd_fn = skel_sys_acl_get_fd,
1033         .sys_acl_blob_get_file_fn = skel_sys_acl_blob_get_file,
1034         .sys_acl_blob_get_fd_fn = skel_sys_acl_blob_get_fd,
1035         .sys_acl_set_file_fn = skel_sys_acl_set_file,
1036         .sys_acl_set_fd_fn = skel_sys_acl_set_fd,
1037         .sys_acl_delete_def_file_fn = skel_sys_acl_delete_def_file,
1038
1039         /* EA operations. */
1040         .getxattr_fn = skel_getxattr,
1041         .fgetxattr_fn = skel_fgetxattr,
1042         .listxattr_fn = skel_listxattr,
1043         .flistxattr_fn = skel_flistxattr,
1044         .removexattr_fn = skel_removexattr,
1045         .fremovexattr_fn = skel_fremovexattr,
1046         .setxattr_fn = skel_setxattr,
1047         .fsetxattr_fn = skel_fsetxattr,
1048
1049         /* aio operations */
1050         .aio_force_fn = skel_aio_force,
1051
1052         /* offline operations */
1053         .is_offline_fn = skel_is_offline,
1054         .set_offline_fn = skel_set_offline
1055 };
1056
1057 NTSTATUS vfs_skel_transparent_init(void)
1058 {
1059         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "skel_transparent",
1060                                 &skel_transparent_fns);
1061 }