s3: VFS: Complete the replacement of SMB_VFS_SYMLINK() -> SMB_VFS_SYMLINKAT().
[amitay/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 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_symlinkat(vfs_handle_struct *handle,
460                         const char *link_contents,
461                         struct files_struct *dirfsp,
462                         const struct smb_filename *new_smb_fname)
463 {
464         errno = ENOSYS;
465         return -1;
466 }
467
468 static int skel_vfs_readlinkat(vfs_handle_struct *handle,
469                         files_struct *dirfsp,
470                         const struct smb_filename *smb_fname,
471                         char *buf,
472                         size_t bufsiz)
473 {
474         errno = ENOSYS;
475         return -1;
476 }
477
478 static int skel_linkat(vfs_handle_struct *handle,
479                         files_struct *srcfsp,
480                         const struct smb_filename *old_smb_fname,
481                         files_struct *dstfsp,
482                         const struct smb_filename *new_smb_fname,
483                         int flags)
484 {
485         errno = ENOSYS;
486         return -1;
487 }
488
489 static int skel_mknodat(vfs_handle_struct *handle,
490                         files_struct *dirfsp,
491                         const struct smb_filename *smb_fname,
492                         mode_t mode,
493                         SMB_DEV_T dev)
494 {
495         errno = ENOSYS;
496         return -1;
497 }
498
499 static struct smb_filename *skel_realpath(vfs_handle_struct *handle,
500                         TALLOC_CTX *ctx,
501                         const struct smb_filename *smb_fname)
502 {
503         errno = ENOSYS;
504         return NULL;
505 }
506
507 static int skel_chflags(vfs_handle_struct *handle,
508                         const struct smb_filename *smb_fname,
509                         uint flags)
510 {
511         errno = ENOSYS;
512         return -1;
513 }
514
515 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
516                                           const SMB_STRUCT_STAT *sbuf)
517 {
518         struct file_id id;
519         ZERO_STRUCT(id);
520         errno = ENOSYS;
521         return id;
522 }
523
524 static uint64_t skel_fs_file_id(vfs_handle_struct *handle,
525                                 const SMB_STRUCT_STAT *sbuf)
526 {
527         errno = ENOSYS;
528         return 0;
529 }
530
531 struct skel_offload_read_state {
532         bool dummy;
533 };
534
535 static struct tevent_req *skel_offload_read_send(
536         TALLOC_CTX *mem_ctx,
537         struct tevent_context *ev,
538         struct vfs_handle_struct *handle,
539         struct files_struct *fsp,
540         uint32_t fsctl,
541         uint32_t ttl,
542         off_t offset,
543         size_t to_copy)
544 {
545         struct tevent_req *req = NULL;
546         struct skel_offload_read_state *state = NULL;
547
548         req = tevent_req_create(mem_ctx, &state, struct skel_offload_read_state);
549         if (req == NULL) {
550                 return NULL;
551         }
552
553         tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
554         return tevent_req_post(req, ev);
555 }
556
557 static NTSTATUS skel_offload_read_recv(struct tevent_req *req,
558                                        struct vfs_handle_struct *handle,
559                                        TALLOC_CTX *mem_ctx,
560                                        DATA_BLOB *_token_blob)
561 {
562         NTSTATUS status;
563
564         if (tevent_req_is_nterror(req, &status)) {
565                 tevent_req_received(req);
566                 return status;
567         }
568         tevent_req_received(req);
569
570         return NT_STATUS_OK;
571 }
572
573 struct skel_cc_state {
574         uint64_t unused;
575 };
576 static struct tevent_req *skel_offload_write_send(struct vfs_handle_struct *handle,
577                                                TALLOC_CTX *mem_ctx,
578                                                struct tevent_context *ev,
579                                                uint32_t fsctl,
580                                                DATA_BLOB *token,
581                                                off_t transfer_offset,
582                                                struct files_struct *dest_fsp,
583                                                off_t dest_off,
584                                                off_t num)
585 {
586         struct tevent_req *req;
587         struct skel_cc_state *cc_state;
588
589         req = tevent_req_create(mem_ctx, &cc_state, struct skel_cc_state);
590         if (req == NULL) {
591                 return NULL;
592         }
593
594         tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
595         return tevent_req_post(req, ev);
596 }
597
598 static NTSTATUS skel_offload_write_recv(struct vfs_handle_struct *handle,
599                                      struct tevent_req *req,
600                                      off_t *copied)
601 {
602         NTSTATUS status;
603
604         if (tevent_req_is_nterror(req, &status)) {
605                 tevent_req_received(req);
606                 return status;
607         }
608         tevent_req_received(req);
609
610         return NT_STATUS_OK;
611 }
612
613 static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
614                                      TALLOC_CTX *mem_ctx,
615                                      struct files_struct *fsp,
616                                      struct smb_filename *smb_fname,
617                                      uint16_t *_compression_fmt)
618 {
619         return NT_STATUS_INVALID_DEVICE_REQUEST;
620 }
621
622 static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
623                                      TALLOC_CTX *mem_ctx,
624                                      struct files_struct *fsp,
625                                      uint16_t compression_fmt)
626 {
627         return NT_STATUS_INVALID_DEVICE_REQUEST;
628 }
629
630 static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
631                                 struct files_struct *fsp,
632                                 const struct smb_filename *smb_fname,
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 char *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_get_dos_attributes(struct vfs_handle_struct *handle,
709                                 struct smb_filename *smb_fname,
710                                 uint32_t *dosmode)
711 {
712         return NT_STATUS_NOT_IMPLEMENTED;
713 }
714
715 struct skel_get_dos_attributes_state {
716         struct vfs_aio_state aio_state;
717         uint32_t dosmode;
718 };
719
720 static struct tevent_req *skel_get_dos_attributes_send(
721                         TALLOC_CTX *mem_ctx,
722                         struct tevent_context *ev,
723                         struct vfs_handle_struct *handle,
724                         files_struct *dir_fsp,
725                         struct smb_filename *smb_fname)
726 {
727         struct tevent_req *req = NULL;
728         struct skel_get_dos_attributes_state *state = NULL;
729
730         req = tevent_req_create(mem_ctx, &state,
731                                 struct skel_get_dos_attributes_state);
732         if (req == NULL) {
733                 return NULL;
734         }
735
736         tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
737         return tevent_req_post(req, ev);
738 }
739
740 static NTSTATUS skel_get_dos_attributes_recv(struct tevent_req *req,
741                                              struct vfs_aio_state *aio_state,
742                                              uint32_t *dosmode)
743 {
744         struct skel_get_dos_attributes_state *state =
745                 tevent_req_data(req,
746                 struct skel_get_dos_attributes_state);
747         NTSTATUS status;
748
749         if (tevent_req_is_nterror(req, &status)) {
750                 tevent_req_received(req);
751                 return status;
752         }
753
754         *aio_state = state->aio_state;
755         *dosmode = state->dosmode;
756         tevent_req_received(req);
757         return NT_STATUS_OK;
758 }
759
760 static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
761                                 struct files_struct *fsp,
762                                 uint32_t *dosmode)
763 {
764         return NT_STATUS_NOT_IMPLEMENTED;
765 }
766
767 static NTSTATUS skel_set_dos_attributes(struct vfs_handle_struct *handle,
768                                 const struct smb_filename *smb_fname,
769                                 uint32_t dosmode)
770 {
771         return NT_STATUS_NOT_IMPLEMENTED;
772 }
773
774 static NTSTATUS skel_fset_dos_attributes(struct vfs_handle_struct *handle,
775                                 struct files_struct *fsp,
776                                 uint32_t dosmode)
777 {
778         return NT_STATUS_NOT_IMPLEMENTED;
779 }
780
781 static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
782                                  uint32_t security_info,
783                                  TALLOC_CTX *mem_ctx,
784                                  struct security_descriptor **ppdesc)
785 {
786         return NT_STATUS_NOT_IMPLEMENTED;
787 }
788
789 static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle,
790                                 const struct smb_filename *smb_fname,
791                                 uint32_t security_info,
792                                 TALLOC_CTX *mem_ctx,
793                                 struct security_descriptor **ppdesc)
794 {
795         return NT_STATUS_NOT_IMPLEMENTED;
796 }
797
798 static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
799                                  uint32_t security_info_sent,
800                                  const struct security_descriptor *psd)
801 {
802         return NT_STATUS_NOT_IMPLEMENTED;
803 }
804
805 static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle,
806                                        const struct smb_filename *smb_fname,
807                                        SMB_ACL_TYPE_T type,
808                                        TALLOC_CTX *mem_ctx)
809 {
810         errno = ENOSYS;
811         return (SMB_ACL_T) NULL;
812 }
813
814 static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
815                                      files_struct *fsp, TALLOC_CTX *mem_ctx)
816 {
817         errno = ENOSYS;
818         return (SMB_ACL_T) NULL;
819 }
820
821 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
822                                 const struct smb_filename *smb_fname,
823                                 TALLOC_CTX *mem_ctx,
824                                 char **blob_description,
825                                 DATA_BLOB *blob)
826 {
827         errno = ENOSYS;
828         return -1;
829 }
830
831 static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
832                                     files_struct *fsp, TALLOC_CTX *mem_ctx,
833                                     char **blob_description, DATA_BLOB *blob)
834 {
835         errno = ENOSYS;
836         return -1;
837 }
838
839 static int skel_sys_acl_set_file(vfs_handle_struct *handle,
840                                 const struct smb_filename *smb_fname,
841                                 SMB_ACL_TYPE_T acltype,
842                                 SMB_ACL_T theacl)
843 {
844         errno = ENOSYS;
845         return -1;
846 }
847
848 static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
849                                SMB_ACL_T theacl)
850 {
851         errno = ENOSYS;
852         return -1;
853 }
854
855 static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
856                                         const struct smb_filename *smb_fname)
857 {
858         errno = ENOSYS;
859         return -1;
860 }
861
862 static ssize_t skel_getxattr(vfs_handle_struct *handle,
863                                 const struct smb_filename *smb_fname,
864                                 const char *name,
865                                 void *value,
866                                 size_t size)
867 {
868         errno = ENOSYS;
869         return -1;
870 }
871
872 struct skel_getxattrat_state {
873         struct vfs_aio_state aio_state;
874         ssize_t xattr_size;
875         uint8_t *xattr_value;
876 };
877
878 static struct tevent_req *skel_getxattrat_send(
879                         TALLOC_CTX *mem_ctx,
880                         struct tevent_context *ev,
881                         struct vfs_handle_struct *handle,
882                         files_struct *dir_fsp,
883                         const struct smb_filename *smb_fname,
884                         const char *xattr_name,
885                         size_t alloc_hint)
886 {
887         struct tevent_req *req = NULL;
888         struct skel_getxattrat_state *state = NULL;
889
890         req = tevent_req_create(mem_ctx, &state,
891                                 struct skel_getxattrat_state);
892         if (req == NULL) {
893                 return NULL;
894         }
895
896         tevent_req_error(req, ENOSYS);
897         return tevent_req_post(req, ev);
898 }
899
900 static ssize_t skel_getxattrat_recv(struct tevent_req *req,
901                                     struct vfs_aio_state *aio_state,
902                                     TALLOC_CTX *mem_ctx,
903                                     uint8_t **xattr_value)
904 {
905         struct skel_getxattrat_state *state = tevent_req_data(
906                 req, struct skel_getxattrat_state);
907         ssize_t xattr_size;
908
909         if (tevent_req_is_unix_error(req, &aio_state->error)) {
910                 tevent_req_received(req);
911                 return -1;
912         }
913
914         *aio_state = state->aio_state;
915         xattr_size = state->xattr_size;
916         if (xattr_value != NULL) {
917                 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
918         }
919
920         tevent_req_received(req);
921         return xattr_size;
922 }
923
924 static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
925                               struct files_struct *fsp, const char *name,
926                               void *value, size_t size)
927 {
928         errno = ENOSYS;
929         return -1;
930 }
931
932 static ssize_t skel_listxattr(vfs_handle_struct *handle,
933                                 const struct smb_filename *smb_fname,
934                                 char *list,
935                                 size_t size)
936 {
937         errno = ENOSYS;
938         return -1;
939 }
940
941 static ssize_t skel_flistxattr(vfs_handle_struct *handle,
942                                struct files_struct *fsp, char *list,
943                                size_t size)
944 {
945         errno = ENOSYS;
946         return -1;
947 }
948
949 static int skel_removexattr(vfs_handle_struct *handle,
950                         const struct smb_filename *smb_fname,
951                         const char *name)
952 {
953         errno = ENOSYS;
954         return -1;
955 }
956
957 static int skel_fremovexattr(vfs_handle_struct *handle,
958                              struct files_struct *fsp, const char *name)
959 {
960         errno = ENOSYS;
961         return -1;
962 }
963
964 static int skel_setxattr(vfs_handle_struct *handle,
965                         const struct smb_filename *smb_fname,
966                         const char *name,
967                         const void *value,
968                         size_t size,
969                         int flags)
970 {
971         errno = ENOSYS;
972         return -1;
973 }
974
975 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
976                           const char *name, const void *value, size_t size,
977                           int flags)
978 {
979         errno = ENOSYS;
980         return -1;
981 }
982
983 static bool skel_aio_force(struct vfs_handle_struct *handle,
984                            struct files_struct *fsp)
985 {
986         errno = ENOSYS;
987         return false;
988 }
989
990 static NTSTATUS skel_audit_file(struct vfs_handle_struct *handle,
991                                 struct smb_filename *file,
992                                 struct security_acl *sacl,
993                                 uint32_t access_requested,
994                                 uint32_t access_denied)
995 {
996         return NT_STATUS_NOT_IMPLEMENTED;
997 }
998
999 static NTSTATUS skel_durable_cookie(struct vfs_handle_struct *handle,
1000                                     struct files_struct *fsp,
1001                                     TALLOC_CTX *mem_ctx,
1002                                     DATA_BLOB *cookie)
1003 {
1004         return NT_STATUS_NOT_IMPLEMENTED;
1005 }
1006
1007 static NTSTATUS skel_durable_disconnect(struct vfs_handle_struct *handle,
1008                                         struct files_struct *fsp,
1009                                         const DATA_BLOB old_cookie,
1010                                         TALLOC_CTX *mem_ctx,
1011                                         DATA_BLOB *new_cookie)
1012 {
1013         return NT_STATUS_NOT_IMPLEMENTED;
1014 }
1015
1016 static NTSTATUS skel_durable_reconnect(struct vfs_handle_struct *handle,
1017                                        struct smb_request *smb1req,
1018                                        struct smbXsrv_open *op,
1019                                        const DATA_BLOB old_cookie,
1020                                        TALLOC_CTX *mem_ctx,
1021                                        struct files_struct **fsp,
1022                                        DATA_BLOB *new_cookie)
1023 {
1024         return NT_STATUS_NOT_IMPLEMENTED;
1025 }
1026
1027 /* VFS operations structure */
1028
1029 static struct vfs_fn_pointers skel_opaque_fns = {
1030         /* Disk operations */
1031
1032         .connect_fn = skel_connect,
1033         .disconnect_fn = skel_disconnect,
1034         .disk_free_fn = skel_disk_free,
1035         .get_quota_fn = skel_get_quota,
1036         .set_quota_fn = skel_set_quota,
1037         .get_shadow_copy_data_fn = skel_get_shadow_copy_data,
1038         .statvfs_fn = skel_statvfs,
1039         .fs_capabilities_fn = skel_fs_capabilities,
1040         .get_dfs_referrals_fn = skel_get_dfs_referrals,
1041         .snap_check_path_fn = skel_snap_check_path,
1042         .snap_create_fn = skel_snap_create,
1043         .snap_delete_fn = skel_snap_delete,
1044
1045         /* Directory operations */
1046
1047         .opendir_fn = skel_opendir,
1048         .fdopendir_fn = skel_fdopendir,
1049         .readdir_fn = skel_readdir,
1050         .seekdir_fn = skel_seekdir,
1051         .telldir_fn = skel_telldir,
1052         .rewind_dir_fn = skel_rewind_dir,
1053         .mkdir_fn = skel_mkdir,
1054         .rmdir_fn = skel_rmdir,
1055         .closedir_fn = skel_closedir,
1056
1057         /* File operations */
1058
1059         .open_fn = skel_open,
1060         .create_file_fn = skel_create_file,
1061         .close_fn = skel_close_fn,
1062         .pread_fn = skel_pread,
1063         .pread_send_fn = skel_pread_send,
1064         .pread_recv_fn = skel_pread_recv,
1065         .pwrite_fn = skel_pwrite,
1066         .pwrite_send_fn = skel_pwrite_send,
1067         .pwrite_recv_fn = skel_pwrite_recv,
1068         .lseek_fn = skel_lseek,
1069         .sendfile_fn = skel_sendfile,
1070         .recvfile_fn = skel_recvfile,
1071         .renameat_fn = skel_renameat,
1072         .fsync_send_fn = skel_fsync_send,
1073         .fsync_recv_fn = skel_fsync_recv,
1074         .stat_fn = skel_stat,
1075         .fstat_fn = skel_fstat,
1076         .lstat_fn = skel_lstat,
1077         .get_alloc_size_fn = skel_get_alloc_size,
1078         .unlink_fn = skel_unlink,
1079         .chmod_fn = skel_chmod,
1080         .fchmod_fn = skel_fchmod,
1081         .chown_fn = skel_chown,
1082         .fchown_fn = skel_fchown,
1083         .lchown_fn = skel_lchown,
1084         .chdir_fn = skel_chdir,
1085         .getwd_fn = skel_getwd,
1086         .ntimes_fn = skel_ntimes,
1087         .ftruncate_fn = skel_ftruncate,
1088         .fallocate_fn = skel_fallocate,
1089         .lock_fn = skel_lock,
1090         .kernel_flock_fn = skel_kernel_flock,
1091         .linux_setlease_fn = skel_linux_setlease,
1092         .getlock_fn = skel_getlock,
1093         .symlinkat_fn = skel_symlinkat,
1094         .readlinkat_fn = skel_vfs_readlinkat,
1095         .linkat_fn = skel_linkat,
1096         .mknodat_fn = skel_mknodat,
1097         .realpath_fn = skel_realpath,
1098         .chflags_fn = skel_chflags,
1099         .file_id_create_fn = skel_file_id_create,
1100         .fs_file_id_fn = skel_fs_file_id,
1101         .offload_read_send_fn = skel_offload_read_send,
1102         .offload_read_recv_fn = skel_offload_read_recv,
1103         .offload_write_send_fn = skel_offload_write_send,
1104         .offload_write_recv_fn = skel_offload_write_recv,
1105         .get_compression_fn = skel_get_compression,
1106         .set_compression_fn = skel_set_compression,
1107
1108         .streaminfo_fn = skel_streaminfo,
1109         .get_real_filename_fn = skel_get_real_filename,
1110         .connectpath_fn = skel_connectpath,
1111         .brl_lock_windows_fn = skel_brl_lock_windows,
1112         .brl_unlock_windows_fn = skel_brl_unlock_windows,
1113         .strict_lock_check_fn = skel_strict_lock_check,
1114         .translate_name_fn = skel_translate_name,
1115         .fsctl_fn = skel_fsctl,
1116         .readdir_attr_fn = skel_readdir_attr,
1117         .audit_file_fn = skel_audit_file,
1118
1119         /* DOS attributes. */
1120         .get_dos_attributes_fn = skel_get_dos_attributes,
1121         .get_dos_attributes_send_fn = skel_get_dos_attributes_send,
1122         .get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
1123         .fget_dos_attributes_fn = skel_fget_dos_attributes,
1124         .set_dos_attributes_fn = skel_set_dos_attributes,
1125         .fset_dos_attributes_fn = skel_fset_dos_attributes,
1126
1127         /* NT ACL operations. */
1128
1129         .fget_nt_acl_fn = skel_fget_nt_acl,
1130         .get_nt_acl_fn = skel_get_nt_acl,
1131         .fset_nt_acl_fn = skel_fset_nt_acl,
1132
1133         /* POSIX ACL operations. */
1134
1135         .sys_acl_get_file_fn = skel_sys_acl_get_file,
1136         .sys_acl_get_fd_fn = skel_sys_acl_get_fd,
1137         .sys_acl_blob_get_file_fn = skel_sys_acl_blob_get_file,
1138         .sys_acl_blob_get_fd_fn = skel_sys_acl_blob_get_fd,
1139         .sys_acl_set_file_fn = skel_sys_acl_set_file,
1140         .sys_acl_set_fd_fn = skel_sys_acl_set_fd,
1141         .sys_acl_delete_def_file_fn = skel_sys_acl_delete_def_file,
1142
1143         /* EA operations. */
1144         .getxattr_fn = skel_getxattr,
1145         .getxattrat_send_fn = skel_getxattrat_send,
1146         .getxattrat_recv_fn = skel_getxattrat_recv,
1147         .fgetxattr_fn = skel_fgetxattr,
1148         .listxattr_fn = skel_listxattr,
1149         .flistxattr_fn = skel_flistxattr,
1150         .removexattr_fn = skel_removexattr,
1151         .fremovexattr_fn = skel_fremovexattr,
1152         .setxattr_fn = skel_setxattr,
1153         .fsetxattr_fn = skel_fsetxattr,
1154
1155         /* aio operations */
1156         .aio_force_fn = skel_aio_force,
1157
1158         /* durable handle operations */
1159         .durable_cookie_fn = skel_durable_cookie,
1160         .durable_disconnect_fn = skel_durable_disconnect,
1161         .durable_reconnect_fn = skel_durable_reconnect,
1162 };
1163
1164 static_decl_vfs;
1165 NTSTATUS vfs_skel_opaque_init(TALLOC_CTX *ctx)
1166 {
1167         /*
1168          * smb_vfs_assert_all_fns() makes sure every
1169          * call is implemented.
1170          *
1171          * An opaque module requires this!
1172          */
1173         smb_vfs_assert_all_fns(&skel_opaque_fns, "skel_opaque");
1174         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "skel_opaque",
1175                                 &skel_opaque_fns);
1176 }