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