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