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