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