VFS: Add SMB_VFS_FREADDIR_ATTR()
[samba.git] / examples / VFS / skel_opaque.c
1 /* 
2  * Skeleton VFS module.  Implements dummy versions of all VFS
3  * 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  * you must re-implement every function.
34  */
35
36 static int skel_connect(vfs_handle_struct *handle, const char *service,
37                         const char *user)
38 {
39         errno = ENOSYS;
40         return -1;
41 }
42
43 static void skel_disconnect(vfs_handle_struct *handle)
44 {
45         ;
46 }
47
48 static uint64_t skel_disk_free(vfs_handle_struct *handle,
49                                 const struct smb_filename *smb_fname,
50                                 uint64_t *bsize,
51                                 uint64_t *dfree,
52                                 uint64_t *dsize)
53 {
54         *bsize = 0;
55         *dfree = 0;
56         *dsize = 0;
57         return 0;
58 }
59
60 static int skel_get_quota(vfs_handle_struct *handle,
61                                 const struct smb_filename *smb_fname,
62                                 enum SMB_QUOTA_TYPE qtype,
63                                 unid_t id,
64                                 SMB_DISK_QUOTA *dq)
65 {
66         errno = ENOSYS;
67         return -1;
68 }
69
70 static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
71                           unid_t id, SMB_DISK_QUOTA *dq)
72 {
73         errno = ENOSYS;
74         return -1;
75 }
76
77 static int skel_get_shadow_copy_data(vfs_handle_struct *handle,
78                                      files_struct *fsp,
79                                      struct shadow_copy_data *shadow_copy_data,
80                                      bool labels)
81 {
82         errno = ENOSYS;
83         return -1;
84 }
85
86 static int skel_statvfs(struct vfs_handle_struct *handle,
87                                 const struct smb_filename *smb_fname,
88                                 struct vfs_statvfs_struct *statbuf)
89 {
90         errno = ENOSYS;
91         return -1;
92 }
93
94 static uint32_t skel_fs_capabilities(struct vfs_handle_struct *handle,
95                                      enum timestamp_set_resolution *p_ts_res)
96 {
97         return 0;
98 }
99
100 static NTSTATUS skel_get_dfs_referrals(struct vfs_handle_struct *handle,
101                                        struct dfs_GetDFSReferral *r)
102 {
103         return NT_STATUS_NOT_IMPLEMENTED;
104 }
105
106 static NTSTATUS skel_create_dfs_pathat(struct vfs_handle_struct *handle,
107                                 struct files_struct *dirfsp,
108                                 const struct smb_filename *smb_fname,
109                                 const struct referral *reflist,
110                                 size_t referral_count)
111 {
112         return NT_STATUS_NOT_IMPLEMENTED;
113 }
114
115 static NTSTATUS skel_read_dfs_pathat(struct vfs_handle_struct *handle,
116                                 TALLOC_CTX *mem_ctx,
117                                 struct files_struct *dirfsp,
118                                 struct smb_filename *smb_fname,
119                                 struct referral **ppreflist,
120                                 size_t *preferral_count)
121 {
122         return NT_STATUS_NOT_IMPLEMENTED;
123 }
124
125 static NTSTATUS skel_snap_check_path(struct vfs_handle_struct *handle,
126                                      TALLOC_CTX *mem_ctx,
127                                      const char *service_path,
128                                      char **base_volume)
129 {
130         return NT_STATUS_NOT_SUPPORTED;
131 }
132
133 static NTSTATUS skel_snap_create(struct vfs_handle_struct *handle,
134                                  TALLOC_CTX *mem_ctx,
135                                  const char *base_volume,
136                                  time_t *tstamp,
137                                  bool rw,
138                                  char **base_path,
139                                  char **snap_path)
140 {
141         return NT_STATUS_NOT_SUPPORTED;
142 }
143
144 static NTSTATUS skel_snap_delete(struct vfs_handle_struct *handle,
145                                  TALLOC_CTX *mem_ctx,
146                                  char *base_path,
147                                  char *snap_path)
148 {
149         return NT_STATUS_NOT_SUPPORTED;
150 }
151
152 static DIR *skel_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
153                            const char *mask, uint32_t attr)
154 {
155         return NULL;
156 }
157
158 static struct dirent *skel_readdir(vfs_handle_struct *handle,
159                                    struct files_struct *dirfsp,
160                                    DIR *dirp,
161                                    SMB_STRUCT_STAT *sbuf)
162 {
163         return NULL;
164 }
165
166 static void skel_seekdir(vfs_handle_struct *handle, DIR *dirp, long offset)
167 {
168         ;
169 }
170
171 static long skel_telldir(vfs_handle_struct *handle, DIR *dirp)
172 {
173         return (long)-1;
174 }
175
176 static void skel_rewind_dir(vfs_handle_struct *handle, DIR *dirp)
177 {
178         ;
179 }
180
181 static int skel_mkdirat(vfs_handle_struct *handle,
182                 struct files_struct *dirfsp,
183                 const struct smb_filename *smb_fname,
184                 mode_t mode)
185 {
186         errno = ENOSYS;
187         return -1;
188 }
189
190 static int skel_closedir(vfs_handle_struct *handle, DIR *dir)
191 {
192         errno = ENOSYS;
193         return -1;
194 }
195
196 static int skel_openat(struct vfs_handle_struct *handle,
197                        const struct files_struct *dirfsp,
198                        const struct smb_filename *smb_fname,
199                        struct files_struct *fsp,
200                        int flags,
201                        mode_t mode)
202 {
203         errno = ENOSYS;
204         return -1;
205 }
206
207 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
208                                  struct smb_request *req,
209                                  struct smb_filename *smb_fname,
210                                  uint32_t access_mask,
211                                  uint32_t share_access,
212                                  uint32_t create_disposition,
213                                  uint32_t create_options,
214                                  uint32_t file_attributes,
215                                  uint32_t oplock_request,
216                                  const struct smb2_lease *lease,
217                                  uint64_t allocation_size,
218                                  uint32_t private_flags,
219                                  struct security_descriptor *sd,
220                                  struct ea_list *ea_list,
221                                  files_struct **result, int *pinfo,
222                                  const struct smb2_create_blobs *in_context_blobs,
223                                  struct smb2_create_blobs *out_context_blobs)
224 {
225         return NT_STATUS_NOT_IMPLEMENTED;
226 }
227
228 static int skel_close_fn(vfs_handle_struct *handle, files_struct *fsp)
229 {
230         errno = ENOSYS;
231         return -1;
232 }
233
234 static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp,
235                           void *data, size_t n, off_t offset)
236 {
237         errno = ENOSYS;
238         return -1;
239 }
240
241 static struct tevent_req *skel_pread_send(struct vfs_handle_struct *handle,
242                                           TALLOC_CTX *mem_ctx,
243                                           struct tevent_context *ev,
244                                           struct files_struct *fsp,
245                                           void *data, size_t n, off_t offset)
246 {
247         return NULL;
248 }
249
250 static ssize_t skel_pread_recv(struct tevent_req *req,
251                                struct vfs_aio_state *vfs_aio_state)
252 {
253         vfs_aio_state->error = ENOSYS;
254         return -1;
255 }
256
257 static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp,
258                            const void *data, size_t n, off_t offset)
259 {
260         errno = ENOSYS;
261         return -1;
262 }
263
264 static struct tevent_req *skel_pwrite_send(struct vfs_handle_struct *handle,
265                                            TALLOC_CTX *mem_ctx,
266                                            struct tevent_context *ev,
267                                            struct files_struct *fsp,
268                                            const void *data,
269                                            size_t n, off_t offset)
270 {
271         return NULL;
272 }
273
274 static ssize_t skel_pwrite_recv(struct tevent_req *req,
275                                 struct vfs_aio_state *vfs_aio_state)
276 {
277         vfs_aio_state->error = ENOSYS;
278         return -1;
279 }
280
281 static off_t skel_lseek(vfs_handle_struct *handle, files_struct *fsp,
282                         off_t offset, int whence)
283 {
284         errno = ENOSYS;
285         return (off_t) - 1;
286 }
287
288 static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd,
289                              files_struct *fromfsp, const DATA_BLOB *hdr,
290                              off_t offset, size_t n)
291 {
292         errno = ENOSYS;
293         return -1;
294 }
295
296 static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd,
297                              files_struct *tofsp, off_t offset, size_t n)
298 {
299         errno = ENOSYS;
300         return -1;
301 }
302
303 static int skel_renameat(vfs_handle_struct *handle,
304                        files_struct *srcfsp,
305                        const struct smb_filename *smb_fname_src,
306                        files_struct *dstfsp,
307                        const struct smb_filename *smb_fname_dst)
308 {
309         errno = ENOSYS;
310         return -1;
311 }
312
313 static struct tevent_req *skel_fsync_send(struct vfs_handle_struct *handle,
314                                           TALLOC_CTX *mem_ctx,
315                                           struct tevent_context *ev,
316                                           struct files_struct *fsp)
317 {
318         return NULL;
319 }
320
321 static int skel_fsync_recv(struct tevent_req *req,
322                            struct vfs_aio_state *vfs_aio_state)
323 {
324         vfs_aio_state->error = ENOSYS;
325         return -1;
326 }
327
328 static int skel_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
329 {
330         errno = ENOSYS;
331         return -1;
332 }
333
334 static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp,
335                       SMB_STRUCT_STAT *sbuf)
336 {
337         errno = ENOSYS;
338         return -1;
339 }
340
341 static int skel_lstat(vfs_handle_struct *handle,
342                       struct smb_filename *smb_fname)
343 {
344         errno = ENOSYS;
345         return -1;
346 }
347
348 static uint64_t skel_get_alloc_size(struct vfs_handle_struct *handle,
349                                     struct files_struct *fsp,
350                                     const SMB_STRUCT_STAT *sbuf)
351 {
352         errno = ENOSYS;
353         return -1;
354 }
355
356 static int skel_unlinkat(vfs_handle_struct *handle,
357                         struct files_struct *dirfsp,
358                         const struct smb_filename *smb_fname,
359                         int flags)
360 {
361         errno = ENOSYS;
362         return -1;
363 }
364
365 static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp,
366                        mode_t mode)
367 {
368         errno = ENOSYS;
369         return -1;
370 }
371
372 static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp,
373                        uid_t uid, gid_t gid)
374 {
375         errno = ENOSYS;
376         return -1;
377 }
378
379 static int skel_lchown(vfs_handle_struct *handle,
380                         const struct smb_filename *smb_fname,
381                         uid_t uid,
382                         gid_t gid)
383 {
384         errno = ENOSYS;
385         return -1;
386 }
387
388 static int skel_chdir(vfs_handle_struct *handle,
389                         const struct smb_filename *smb_fname)
390 {
391         errno = ENOSYS;
392         return -1;
393 }
394
395 static struct smb_filename *skel_getwd(vfs_handle_struct *handle,
396                                 TALLOC_CTX *ctx)
397 {
398         errno = ENOSYS;
399         return NULL;
400 }
401
402 static int skel_fntimes(vfs_handle_struct *handle,
403                         files_struct *fsp,
404                         struct smb_file_time *ft)
405 {
406         errno = ENOSYS;
407         return -1;
408 }
409
410 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
411                           off_t offset)
412 {
413         errno = ENOSYS;
414         return -1;
415 }
416
417 static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
418                           uint32_t mode, off_t offset, off_t len)
419 {
420         errno = ENOSYS;
421         return -1;
422 }
423
424 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op,
425                       off_t offset, off_t count, int type)
426 {
427         errno = ENOSYS;
428         return false;
429 }
430
431 static int skel_kernel_flock(struct vfs_handle_struct *handle,
432                              struct files_struct *fsp,
433                              uint32_t share_mode, uint32_t access_mask)
434 {
435         errno = ENOSYS;
436         return -1;
437 }
438
439 static int skel_fcntl(struct vfs_handle_struct *handle,
440                       struct files_struct *fsp, int cmd, va_list cmd_arg)
441 {
442         errno = ENOSYS;
443         return -1;
444 }
445
446 static int skel_linux_setlease(struct vfs_handle_struct *handle,
447                                struct files_struct *fsp, int leasetype)
448 {
449         errno = ENOSYS;
450         return -1;
451 }
452
453 static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp,
454                          off_t *poffset, off_t *pcount, int *ptype,
455                          pid_t *ppid)
456 {
457         errno = ENOSYS;
458         return false;
459 }
460
461 static int skel_symlinkat(vfs_handle_struct *handle,
462                         const struct smb_filename *link_contents,
463                         struct files_struct *dirfsp,
464                         const struct smb_filename *new_smb_fname)
465 {
466         errno = ENOSYS;
467         return -1;
468 }
469
470 static int skel_vfs_readlinkat(vfs_handle_struct *handle,
471                         const struct files_struct *dirfsp,
472                         const struct smb_filename *smb_fname,
473                         char *buf,
474                         size_t bufsiz)
475 {
476         errno = ENOSYS;
477         return -1;
478 }
479
480 static int skel_linkat(vfs_handle_struct *handle,
481                         files_struct *srcfsp,
482                         const struct smb_filename *old_smb_fname,
483                         files_struct *dstfsp,
484                         const struct smb_filename *new_smb_fname,
485                         int flags)
486 {
487         errno = ENOSYS;
488         return -1;
489 }
490
491 static int skel_mknodat(vfs_handle_struct *handle,
492                         files_struct *dirfsp,
493                         const struct smb_filename *smb_fname,
494                         mode_t mode,
495                         SMB_DEV_T dev)
496 {
497         errno = ENOSYS;
498         return -1;
499 }
500
501 static struct smb_filename *skel_realpath(vfs_handle_struct *handle,
502                         TALLOC_CTX *ctx,
503                         const struct smb_filename *smb_fname)
504 {
505         errno = ENOSYS;
506         return NULL;
507 }
508
509 static int skel_chflags(vfs_handle_struct *handle,
510                         const struct smb_filename *smb_fname,
511                         uint flags)
512 {
513         errno = ENOSYS;
514         return -1;
515 }
516
517 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
518                                           const SMB_STRUCT_STAT *sbuf)
519 {
520         struct file_id id;
521         ZERO_STRUCT(id);
522         errno = ENOSYS;
523         return id;
524 }
525
526 static uint64_t skel_fs_file_id(vfs_handle_struct *handle,
527                                 const SMB_STRUCT_STAT *sbuf)
528 {
529         errno = ENOSYS;
530         return 0;
531 }
532
533 struct skel_offload_read_state {
534         bool dummy;
535 };
536
537 static struct tevent_req *skel_offload_read_send(
538         TALLOC_CTX *mem_ctx,
539         struct tevent_context *ev,
540         struct vfs_handle_struct *handle,
541         struct files_struct *fsp,
542         uint32_t fsctl,
543         uint32_t ttl,
544         off_t offset,
545         size_t to_copy)
546 {
547         struct tevent_req *req = NULL;
548         struct skel_offload_read_state *state = NULL;
549
550         req = tevent_req_create(mem_ctx, &state, struct skel_offload_read_state);
551         if (req == NULL) {
552                 return NULL;
553         }
554
555         tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
556         return tevent_req_post(req, ev);
557 }
558
559 static NTSTATUS skel_offload_read_recv(struct tevent_req *req,
560                                        struct vfs_handle_struct *handle,
561                                        TALLOC_CTX *mem_ctx,
562                                        DATA_BLOB *_token_blob)
563 {
564         NTSTATUS status;
565
566         if (tevent_req_is_nterror(req, &status)) {
567                 tevent_req_received(req);
568                 return status;
569         }
570         tevent_req_received(req);
571
572         return NT_STATUS_OK;
573 }
574
575 struct skel_cc_state {
576         uint64_t unused;
577 };
578 static struct tevent_req *skel_offload_write_send(struct vfs_handle_struct *handle,
579                                                TALLOC_CTX *mem_ctx,
580                                                struct tevent_context *ev,
581                                                uint32_t fsctl,
582                                                DATA_BLOB *token,
583                                                off_t transfer_offset,
584                                                struct files_struct *dest_fsp,
585                                                off_t dest_off,
586                                                off_t num)
587 {
588         struct tevent_req *req;
589         struct skel_cc_state *cc_state;
590
591         req = tevent_req_create(mem_ctx, &cc_state, struct skel_cc_state);
592         if (req == NULL) {
593                 return NULL;
594         }
595
596         tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
597         return tevent_req_post(req, ev);
598 }
599
600 static NTSTATUS skel_offload_write_recv(struct vfs_handle_struct *handle,
601                                      struct tevent_req *req,
602                                      off_t *copied)
603 {
604         NTSTATUS status;
605
606         if (tevent_req_is_nterror(req, &status)) {
607                 tevent_req_received(req);
608                 return status;
609         }
610         tevent_req_received(req);
611
612         return NT_STATUS_OK;
613 }
614
615 static NTSTATUS skel_fget_compression(struct vfs_handle_struct *handle,
616                                      TALLOC_CTX *mem_ctx,
617                                      struct files_struct *fsp,
618                                      uint16_t *_compression_fmt)
619 {
620         return NT_STATUS_INVALID_DEVICE_REQUEST;
621 }
622
623 static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
624                                      TALLOC_CTX *mem_ctx,
625                                      struct files_struct *fsp,
626                                      uint16_t compression_fmt)
627 {
628         return NT_STATUS_INVALID_DEVICE_REQUEST;
629 }
630
631 static NTSTATUS skel_fstreaminfo(struct vfs_handle_struct *handle,
632                                  struct files_struct *fsp,
633                                  TALLOC_CTX *mem_ctx,
634                                  unsigned int *num_streams,
635                                  struct stream_struct **streams)
636 {
637         return NT_STATUS_NOT_IMPLEMENTED;
638 }
639
640 static int skel_get_real_filename(struct vfs_handle_struct *handle,
641                                   const struct smb_filename *path,
642                                   const char *name,
643                                   TALLOC_CTX *mem_ctx, char **found_name)
644 {
645         errno = ENOSYS;
646         return -1;
647 }
648
649 static const char *skel_connectpath(struct vfs_handle_struct *handle,
650                                 const struct smb_filename *smb_fname)
651 {
652         errno = ENOSYS;
653         return NULL;
654 }
655
656 static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
657                                       struct byte_range_lock *br_lck,
658                                       struct lock_struct *plock)
659 {
660         return NT_STATUS_NOT_IMPLEMENTED;
661 }
662
663 static bool skel_brl_unlock_windows(struct vfs_handle_struct *handle,
664                                     struct byte_range_lock *br_lck,
665                                     const struct lock_struct *plock)
666 {
667         errno = ENOSYS;
668         return false;
669 }
670
671 static bool skel_strict_lock_check(struct vfs_handle_struct *handle,
672                                    struct files_struct *fsp,
673                                    struct lock_struct *plock)
674 {
675         errno = ENOSYS;
676         return false;
677 }
678
679 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
680                                     const char *mapped_name,
681                                     enum vfs_translate_direction direction,
682                                     TALLOC_CTX *mem_ctx, char **pmapped_name)
683 {
684         return NT_STATUS_NOT_IMPLEMENTED;
685 }
686
687 static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
688                            struct files_struct *fsp,
689                            TALLOC_CTX *ctx,
690                            uint32_t function,
691                            uint16_t req_flags,  /* Needed for UNICODE ... */
692                            const uint8_t *_in_data,
693                            uint32_t in_len,
694                            uint8_t **_out_data,
695                            uint32_t max_out_len, uint32_t *out_len)
696 {
697         return NT_STATUS_NOT_IMPLEMENTED;
698 }
699
700 static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
701                                   const struct smb_filename *fname,
702                                   TALLOC_CTX *mem_ctx,
703                                   struct readdir_attr_data **pattr_data)
704 {
705         return NT_STATUS_NOT_IMPLEMENTED;
706 }
707
708 static NTSTATUS skel_freaddir_attr(struct vfs_handle_struct *handle,
709                                    struct files_struct *fsp,
710                                    TALLOC_CTX *mem_ctx,
711                                    struct readdir_attr_data **pattr_data)
712 {
713         return NT_STATUS_NOT_IMPLEMENTED;
714 }
715
716 struct skel_get_dos_attributes_state {
717         struct vfs_aio_state aio_state;
718         uint32_t dosmode;
719 };
720
721 static struct tevent_req *skel_get_dos_attributes_send(
722                         TALLOC_CTX *mem_ctx,
723                         struct tevent_context *ev,
724                         struct vfs_handle_struct *handle,
725                         files_struct *dir_fsp,
726                         struct smb_filename *smb_fname)
727 {
728         struct tevent_req *req = NULL;
729         struct skel_get_dos_attributes_state *state = NULL;
730
731         req = tevent_req_create(mem_ctx, &state,
732                                 struct skel_get_dos_attributes_state);
733         if (req == NULL) {
734                 return NULL;
735         }
736
737         tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
738         return tevent_req_post(req, ev);
739 }
740
741 static NTSTATUS skel_get_dos_attributes_recv(struct tevent_req *req,
742                                              struct vfs_aio_state *aio_state,
743                                              uint32_t *dosmode)
744 {
745         struct skel_get_dos_attributes_state *state =
746                 tevent_req_data(req,
747                 struct skel_get_dos_attributes_state);
748         NTSTATUS status;
749
750         if (tevent_req_is_nterror(req, &status)) {
751                 tevent_req_received(req);
752                 return status;
753         }
754
755         *aio_state = state->aio_state;
756         *dosmode = state->dosmode;
757         tevent_req_received(req);
758         return NT_STATUS_OK;
759 }
760
761 static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
762                                 struct files_struct *fsp,
763                                 uint32_t *dosmode)
764 {
765         return NT_STATUS_NOT_IMPLEMENTED;
766 }
767
768 static NTSTATUS skel_fset_dos_attributes(struct vfs_handle_struct *handle,
769                                 struct files_struct *fsp,
770                                 uint32_t dosmode)
771 {
772         return NT_STATUS_NOT_IMPLEMENTED;
773 }
774
775 static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
776                                  uint32_t security_info,
777                                  TALLOC_CTX *mem_ctx,
778                                  struct security_descriptor **ppdesc)
779 {
780         return NT_STATUS_NOT_IMPLEMENTED;
781 }
782
783 static NTSTATUS skel_get_nt_acl_at(vfs_handle_struct *handle,
784                                 struct files_struct *dirfsp,
785                                 const struct smb_filename *smb_fname,
786                                 uint32_t security_info,
787                                 TALLOC_CTX *mem_ctx,
788                                 struct security_descriptor **ppdesc)
789 {
790         return NT_STATUS_NOT_IMPLEMENTED;
791 }
792
793 static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
794                                  uint32_t security_info_sent,
795                                  const struct security_descriptor *psd)
796 {
797         return NT_STATUS_NOT_IMPLEMENTED;
798 }
799
800 static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle,
801                                        const struct smb_filename *smb_fname,
802                                        SMB_ACL_TYPE_T type,
803                                        TALLOC_CTX *mem_ctx)
804 {
805         errno = ENOSYS;
806         return (SMB_ACL_T) NULL;
807 }
808
809 static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
810                                      files_struct *fsp, TALLOC_CTX *mem_ctx)
811 {
812         errno = ENOSYS;
813         return (SMB_ACL_T) NULL;
814 }
815
816 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
817                                 const struct smb_filename *smb_fname,
818                                 TALLOC_CTX *mem_ctx,
819                                 char **blob_description,
820                                 DATA_BLOB *blob)
821 {
822         errno = ENOSYS;
823         return -1;
824 }
825
826 static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
827                                     files_struct *fsp, TALLOC_CTX *mem_ctx,
828                                     char **blob_description, DATA_BLOB *blob)
829 {
830         errno = ENOSYS;
831         return -1;
832 }
833
834 static int skel_sys_acl_set_fd(vfs_handle_struct *handle,
835                                struct files_struct *fsp,
836                                SMB_ACL_TYPE_T type,
837                                SMB_ACL_T theacl)
838 {
839         errno = ENOSYS;
840         return -1;
841 }
842
843 static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
844                                         const struct smb_filename *smb_fname)
845 {
846         errno = ENOSYS;
847         return -1;
848 }
849
850 static ssize_t skel_getxattr(vfs_handle_struct *handle,
851                                 const struct smb_filename *smb_fname,
852                                 const char *name,
853                                 void *value,
854                                 size_t size)
855 {
856         errno = ENOSYS;
857         return -1;
858 }
859
860 struct skel_getxattrat_state {
861         struct vfs_aio_state aio_state;
862         ssize_t xattr_size;
863         uint8_t *xattr_value;
864 };
865
866 static struct tevent_req *skel_getxattrat_send(
867                         TALLOC_CTX *mem_ctx,
868                         struct tevent_context *ev,
869                         struct vfs_handle_struct *handle,
870                         files_struct *dir_fsp,
871                         const struct smb_filename *smb_fname,
872                         const char *xattr_name,
873                         size_t alloc_hint)
874 {
875         struct tevent_req *req = NULL;
876         struct skel_getxattrat_state *state = NULL;
877
878         req = tevent_req_create(mem_ctx, &state,
879                                 struct skel_getxattrat_state);
880         if (req == NULL) {
881                 return NULL;
882         }
883
884         tevent_req_error(req, ENOSYS);
885         return tevent_req_post(req, ev);
886 }
887
888 static ssize_t skel_getxattrat_recv(struct tevent_req *req,
889                                     struct vfs_aio_state *aio_state,
890                                     TALLOC_CTX *mem_ctx,
891                                     uint8_t **xattr_value)
892 {
893         struct skel_getxattrat_state *state = tevent_req_data(
894                 req, struct skel_getxattrat_state);
895         ssize_t xattr_size;
896
897         if (tevent_req_is_unix_error(req, &aio_state->error)) {
898                 tevent_req_received(req);
899                 return -1;
900         }
901
902         *aio_state = state->aio_state;
903         xattr_size = state->xattr_size;
904         if (xattr_value != NULL) {
905                 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
906         }
907
908         tevent_req_received(req);
909         return xattr_size;
910 }
911
912 static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
913                               struct files_struct *fsp, const char *name,
914                               void *value, size_t size)
915 {
916         errno = ENOSYS;
917         return -1;
918 }
919
920 static ssize_t skel_flistxattr(vfs_handle_struct *handle,
921                                struct files_struct *fsp, char *list,
922                                size_t size)
923 {
924         errno = ENOSYS;
925         return -1;
926 }
927
928 static int skel_fremovexattr(vfs_handle_struct *handle,
929                              struct files_struct *fsp, const char *name)
930 {
931         errno = ENOSYS;
932         return -1;
933 }
934
935 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
936                           const char *name, const void *value, size_t size,
937                           int flags)
938 {
939         errno = ENOSYS;
940         return -1;
941 }
942
943 static bool skel_aio_force(struct vfs_handle_struct *handle,
944                            struct files_struct *fsp)
945 {
946         errno = ENOSYS;
947         return false;
948 }
949
950 static NTSTATUS skel_audit_file(struct vfs_handle_struct *handle,
951                                 struct smb_filename *file,
952                                 struct security_acl *sacl,
953                                 uint32_t access_requested,
954                                 uint32_t access_denied)
955 {
956         return NT_STATUS_NOT_IMPLEMENTED;
957 }
958
959 static NTSTATUS skel_durable_cookie(struct vfs_handle_struct *handle,
960                                     struct files_struct *fsp,
961                                     TALLOC_CTX *mem_ctx,
962                                     DATA_BLOB *cookie)
963 {
964         return NT_STATUS_NOT_IMPLEMENTED;
965 }
966
967 static NTSTATUS skel_durable_disconnect(struct vfs_handle_struct *handle,
968                                         struct files_struct *fsp,
969                                         const DATA_BLOB old_cookie,
970                                         TALLOC_CTX *mem_ctx,
971                                         DATA_BLOB *new_cookie)
972 {
973         return NT_STATUS_NOT_IMPLEMENTED;
974 }
975
976 static NTSTATUS skel_durable_reconnect(struct vfs_handle_struct *handle,
977                                        struct smb_request *smb1req,
978                                        struct smbXsrv_open *op,
979                                        const DATA_BLOB old_cookie,
980                                        TALLOC_CTX *mem_ctx,
981                                        struct files_struct **fsp,
982                                        DATA_BLOB *new_cookie)
983 {
984         return NT_STATUS_NOT_IMPLEMENTED;
985 }
986
987 /* VFS operations structure */
988
989 static struct vfs_fn_pointers skel_opaque_fns = {
990         /* Disk operations */
991
992         .connect_fn = skel_connect,
993         .disconnect_fn = skel_disconnect,
994         .disk_free_fn = skel_disk_free,
995         .get_quota_fn = skel_get_quota,
996         .set_quota_fn = skel_set_quota,
997         .get_shadow_copy_data_fn = skel_get_shadow_copy_data,
998         .statvfs_fn = skel_statvfs,
999         .fs_capabilities_fn = skel_fs_capabilities,
1000         .get_dfs_referrals_fn = skel_get_dfs_referrals,
1001         .create_dfs_pathat_fn = skel_create_dfs_pathat,
1002         .read_dfs_pathat_fn = skel_read_dfs_pathat,
1003         .snap_check_path_fn = skel_snap_check_path,
1004         .snap_create_fn = skel_snap_create,
1005         .snap_delete_fn = skel_snap_delete,
1006
1007         /* Directory operations */
1008
1009         .fdopendir_fn = skel_fdopendir,
1010         .readdir_fn = skel_readdir,
1011         .seekdir_fn = skel_seekdir,
1012         .telldir_fn = skel_telldir,
1013         .rewind_dir_fn = skel_rewind_dir,
1014         .mkdirat_fn = skel_mkdirat,
1015         .closedir_fn = skel_closedir,
1016
1017         /* File operations */
1018
1019         .openat_fn = skel_openat,
1020         .create_file_fn = skel_create_file,
1021         .close_fn = skel_close_fn,
1022         .pread_fn = skel_pread,
1023         .pread_send_fn = skel_pread_send,
1024         .pread_recv_fn = skel_pread_recv,
1025         .pwrite_fn = skel_pwrite,
1026         .pwrite_send_fn = skel_pwrite_send,
1027         .pwrite_recv_fn = skel_pwrite_recv,
1028         .lseek_fn = skel_lseek,
1029         .sendfile_fn = skel_sendfile,
1030         .recvfile_fn = skel_recvfile,
1031         .renameat_fn = skel_renameat,
1032         .fsync_send_fn = skel_fsync_send,
1033         .fsync_recv_fn = skel_fsync_recv,
1034         .stat_fn = skel_stat,
1035         .fstat_fn = skel_fstat,
1036         .lstat_fn = skel_lstat,
1037         .get_alloc_size_fn = skel_get_alloc_size,
1038         .unlinkat_fn = skel_unlinkat,
1039         .fchmod_fn = skel_fchmod,
1040         .fchown_fn = skel_fchown,
1041         .lchown_fn = skel_lchown,
1042         .chdir_fn = skel_chdir,
1043         .getwd_fn = skel_getwd,
1044         .fntimes_fn = skel_fntimes,
1045         .ftruncate_fn = skel_ftruncate,
1046         .fallocate_fn = skel_fallocate,
1047         .lock_fn = skel_lock,
1048         .kernel_flock_fn = skel_kernel_flock,
1049         .fcntl_fn = skel_fcntl,
1050         .linux_setlease_fn = skel_linux_setlease,
1051         .getlock_fn = skel_getlock,
1052         .symlinkat_fn = skel_symlinkat,
1053         .readlinkat_fn = skel_vfs_readlinkat,
1054         .linkat_fn = skel_linkat,
1055         .mknodat_fn = skel_mknodat,
1056         .realpath_fn = skel_realpath,
1057         .chflags_fn = skel_chflags,
1058         .file_id_create_fn = skel_file_id_create,
1059         .fs_file_id_fn = skel_fs_file_id,
1060         .offload_read_send_fn = skel_offload_read_send,
1061         .offload_read_recv_fn = skel_offload_read_recv,
1062         .offload_write_send_fn = skel_offload_write_send,
1063         .offload_write_recv_fn = skel_offload_write_recv,
1064         .fget_compression_fn = skel_fget_compression,
1065         .set_compression_fn = skel_set_compression,
1066
1067         .fstreaminfo_fn = skel_fstreaminfo,
1068         .get_real_filename_fn = skel_get_real_filename,
1069         .connectpath_fn = skel_connectpath,
1070         .brl_lock_windows_fn = skel_brl_lock_windows,
1071         .brl_unlock_windows_fn = skel_brl_unlock_windows,
1072         .strict_lock_check_fn = skel_strict_lock_check,
1073         .translate_name_fn = skel_translate_name,
1074         .fsctl_fn = skel_fsctl,
1075         .readdir_attr_fn = skel_readdir_attr,
1076         .freaddir_attr_fn = skel_freaddir_attr,
1077         .audit_file_fn = skel_audit_file,
1078
1079         /* DOS attributes. */
1080         .get_dos_attributes_send_fn = skel_get_dos_attributes_send,
1081         .get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
1082         .fget_dos_attributes_fn = skel_fget_dos_attributes,
1083         .fset_dos_attributes_fn = skel_fset_dos_attributes,
1084
1085         /* NT ACL operations. */
1086
1087         .fget_nt_acl_fn = skel_fget_nt_acl,
1088         .get_nt_acl_at_fn = skel_get_nt_acl_at,
1089         .fset_nt_acl_fn = skel_fset_nt_acl,
1090
1091         /* POSIX ACL operations. */
1092
1093         .sys_acl_get_file_fn = skel_sys_acl_get_file,
1094         .sys_acl_get_fd_fn = skel_sys_acl_get_fd,
1095         .sys_acl_blob_get_file_fn = skel_sys_acl_blob_get_file,
1096         .sys_acl_blob_get_fd_fn = skel_sys_acl_blob_get_fd,
1097         .sys_acl_set_fd_fn = skel_sys_acl_set_fd,
1098         .sys_acl_delete_def_file_fn = skel_sys_acl_delete_def_file,
1099
1100         /* EA operations. */
1101         .getxattr_fn = skel_getxattr,
1102         .getxattrat_send_fn = skel_getxattrat_send,
1103         .getxattrat_recv_fn = skel_getxattrat_recv,
1104         .fgetxattr_fn = skel_fgetxattr,
1105         .flistxattr_fn = skel_flistxattr,
1106         .fremovexattr_fn = skel_fremovexattr,
1107         .fsetxattr_fn = skel_fsetxattr,
1108
1109         /* aio operations */
1110         .aio_force_fn = skel_aio_force,
1111
1112         /* durable handle operations */
1113         .durable_cookie_fn = skel_durable_cookie,
1114         .durable_disconnect_fn = skel_durable_disconnect,
1115         .durable_reconnect_fn = skel_durable_reconnect,
1116 };
1117
1118 static_decl_vfs;
1119 NTSTATUS vfs_skel_opaque_init(TALLOC_CTX *ctx)
1120 {
1121         /*
1122          * smb_vfs_assert_all_fns() makes sure every
1123          * call is implemented.
1124          *
1125          * An opaque module requires this!
1126          */
1127         smb_vfs_assert_all_fns(&skel_opaque_fns, "skel_opaque");
1128         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "skel_opaque",
1129                                 &skel_opaque_fns);
1130 }