s3: VFS: Change SMB_VFS_LINK to use const struct smb_filename * instead of const...
[Samba.git] / examples / VFS / skel_transparent.c
blobbcd4a44e51da77bda330d50195ee2e90e959bddd
1 /*
2 * Skeleton VFS module. Implements passthrough operation of all VFS
3 * calls to disk functions.
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
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.
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.
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/>.
24 #include "../source3/include/includes.h"
25 #include "lib/util/tevent_unix.h"
26 #include "lib/util/tevent_ntstatus.h"
28 /* PLEASE,PLEASE READ THE VFS MODULES CHAPTER OF THE
29 SAMBA DEVELOPERS GUIDE!!!!!!
32 /* If you take this file as template for your module
33 * please make sure that you remove all skel_XXX() functions you don't
34 * want to implement!! The passthrough operations are not
35 * neccessary in a real module.
37 * --metze
40 static int skel_connect(vfs_handle_struct *handle, const char *service,
41 const char *user)
43 return SMB_VFS_NEXT_CONNECT(handle, service, user);
46 static void skel_disconnect(vfs_handle_struct *handle)
48 SMB_VFS_NEXT_DISCONNECT(handle);
51 static uint64_t skel_disk_free(vfs_handle_struct *handle,
52 const struct smb_filename *smb_fname,
53 uint64_t *bsize,
54 uint64_t *dfree,
55 uint64_t *dsize)
57 return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
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)
66 return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
69 static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
70 unid_t id, SMB_DISK_QUOTA *dq)
72 return SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, dq);
75 static int skel_get_shadow_copy_data(vfs_handle_struct *handle,
76 files_struct *fsp,
77 struct shadow_copy_data *shadow_copy_data,
78 bool labels)
80 return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data,
81 labels);
84 static int skel_statvfs(struct vfs_handle_struct *handle, const char *path,
85 struct vfs_statvfs_struct *statbuf)
87 return SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
90 static uint32_t skel_fs_capabilities(struct vfs_handle_struct *handle,
91 enum timestamp_set_resolution *p_ts_res)
93 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
96 static NTSTATUS skel_get_dfs_referrals(struct vfs_handle_struct *handle,
97 struct dfs_GetDFSReferral *r)
99 return SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
102 static DIR *skel_opendir(vfs_handle_struct *handle,
103 const struct smb_filename *smb_fname,
104 const char *mask,
105 uint32_t attr)
107 return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
110 static NTSTATUS skel_snap_check_path(struct vfs_handle_struct *handle,
111 TALLOC_CTX *mem_ctx,
112 const char *service_path,
113 char **base_volume)
115 return SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
116 base_volume);
119 static NTSTATUS skel_snap_create(struct vfs_handle_struct *handle,
120 TALLOC_CTX *mem_ctx,
121 const char *base_volume,
122 time_t *tstamp,
123 bool rw,
124 char **base_path,
125 char **snap_path)
127 return SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
128 rw, base_path, snap_path);
131 static NTSTATUS skel_snap_delete(struct vfs_handle_struct *handle,
132 TALLOC_CTX *mem_ctx,
133 char *base_path,
134 char *snap_path)
136 return SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path, snap_path);
139 static DIR *skel_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
140 const char *mask, uint32_t attr)
142 return SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
145 static struct dirent *skel_readdir(vfs_handle_struct *handle,
146 DIR *dirp, SMB_STRUCT_STAT *sbuf)
148 return SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
151 static void skel_seekdir(vfs_handle_struct *handle, DIR *dirp, long offset)
153 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
156 static long skel_telldir(vfs_handle_struct *handle, DIR *dirp)
158 return SMB_VFS_NEXT_TELLDIR(handle, dirp);
161 static void skel_rewind_dir(vfs_handle_struct *handle, DIR *dirp)
163 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
166 static int skel_mkdir(vfs_handle_struct *handle,
167 const struct smb_filename *smb_fname,
168 mode_t mode)
170 return SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
173 static int skel_rmdir(vfs_handle_struct *handle,
174 const struct smb_filename *smb_fname)
176 return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
179 static int skel_closedir(vfs_handle_struct *handle, DIR *dir)
181 return SMB_VFS_NEXT_CLOSEDIR(handle, dir);
184 static void skel_init_search_op(struct vfs_handle_struct *handle, DIR *dirp)
186 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
189 static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
190 files_struct *fsp, int flags, mode_t mode)
192 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
195 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
196 struct smb_request *req,
197 uint16_t root_dir_fid,
198 struct smb_filename *smb_fname,
199 uint32_t access_mask,
200 uint32_t share_access,
201 uint32_t create_disposition,
202 uint32_t create_options,
203 uint32_t file_attributes,
204 uint32_t oplock_request,
205 struct smb2_lease *lease,
206 uint64_t allocation_size,
207 uint32_t private_flags,
208 struct security_descriptor *sd,
209 struct ea_list *ea_list,
210 files_struct ** result, int *pinfo,
211 const struct smb2_create_blobs *in_context_blobs,
212 struct smb2_create_blobs *out_context_blobs)
214 return SMB_VFS_NEXT_CREATE_FILE(handle,
215 req,
216 root_dir_fid,
217 smb_fname,
218 access_mask,
219 share_access,
220 create_disposition,
221 create_options,
222 file_attributes,
223 oplock_request,
224 lease,
225 allocation_size,
226 private_flags,
227 sd, ea_list, result, pinfo,
228 in_context_blobs, out_context_blobs);
231 static int skel_close_fn(vfs_handle_struct *handle, files_struct *fsp)
233 return SMB_VFS_NEXT_CLOSE(handle, fsp);
236 static ssize_t skel_vfs_read(vfs_handle_struct *handle, files_struct *fsp,
237 void *data, size_t n)
239 return SMB_VFS_NEXT_READ(handle, fsp, data, n);
242 static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp,
243 void *data, size_t n, off_t offset)
245 return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
248 struct skel_pread_state {
249 ssize_t ret;
250 struct vfs_aio_state vfs_aio_state;
253 static void skel_pread_done(struct tevent_req *subreq);
255 static struct tevent_req *skel_pread_send(struct vfs_handle_struct *handle,
256 TALLOC_CTX *mem_ctx,
257 struct tevent_context *ev,
258 struct files_struct *fsp,
259 void *data, size_t n, off_t offset)
261 struct tevent_req *req, *subreq;
262 struct skel_pread_state *state;
264 req = tevent_req_create(mem_ctx, &state, struct skel_pread_state);
265 if (req == NULL) {
266 return NULL;
268 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
269 n, offset);
270 if (tevent_req_nomem(subreq, req)) {
271 return tevent_req_post(req, ev);
273 tevent_req_set_callback(subreq, skel_pread_done, req);
274 return req;
277 static void skel_pread_done(struct tevent_req *subreq)
279 struct tevent_req *req =
280 tevent_req_callback_data(subreq, struct tevent_req);
281 struct skel_pread_state *state =
282 tevent_req_data(req, struct skel_pread_state);
284 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
285 TALLOC_FREE(subreq);
286 tevent_req_done(req);
289 static ssize_t skel_pread_recv(struct tevent_req *req,
290 struct vfs_aio_state *vfs_aio_state)
292 struct skel_pread_state *state =
293 tevent_req_data(req, struct skel_pread_state);
295 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
296 return -1;
298 *vfs_aio_state = state->vfs_aio_state;
299 return state->ret;
302 static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp,
303 const void *data, size_t n)
305 return SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
308 static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp,
309 const void *data, size_t n, off_t offset)
311 return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
314 struct skel_pwrite_state {
315 ssize_t ret;
316 struct vfs_aio_state vfs_aio_state;
319 static void skel_pwrite_done(struct tevent_req *subreq);
321 static struct tevent_req *skel_pwrite_send(struct vfs_handle_struct *handle,
322 TALLOC_CTX *mem_ctx,
323 struct tevent_context *ev,
324 struct files_struct *fsp,
325 const void *data,
326 size_t n, off_t offset)
328 struct tevent_req *req, *subreq;
329 struct skel_pwrite_state *state;
331 req = tevent_req_create(mem_ctx, &state, struct skel_pwrite_state);
332 if (req == NULL) {
333 return NULL;
335 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
336 n, offset);
337 if (tevent_req_nomem(subreq, req)) {
338 return tevent_req_post(req, ev);
340 tevent_req_set_callback(subreq, skel_pwrite_done, req);
341 return req;
344 static void skel_pwrite_done(struct tevent_req *subreq)
346 struct tevent_req *req =
347 tevent_req_callback_data(subreq, struct tevent_req);
348 struct skel_pwrite_state *state =
349 tevent_req_data(req, struct skel_pwrite_state);
351 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
352 TALLOC_FREE(subreq);
353 tevent_req_done(req);
356 static ssize_t skel_pwrite_recv(struct tevent_req *req,
357 struct vfs_aio_state *vfs_aio_state)
359 struct skel_pwrite_state *state =
360 tevent_req_data(req, struct skel_pwrite_state);
362 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
363 return -1;
365 *vfs_aio_state = state->vfs_aio_state;
366 return state->ret;
369 static off_t skel_lseek(vfs_handle_struct *handle, files_struct *fsp,
370 off_t offset, int whence)
372 return SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
375 static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd,
376 files_struct *fromfsp, const DATA_BLOB *hdr,
377 off_t offset, size_t n)
379 return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
382 static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd,
383 files_struct *tofsp, off_t offset, size_t n)
385 return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
388 static int skel_rename(vfs_handle_struct *handle,
389 const struct smb_filename *smb_fname_src,
390 const struct smb_filename *smb_fname_dst)
392 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
395 static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
397 return SMB_VFS_NEXT_FSYNC(handle, fsp);
400 struct skel_fsync_state {
401 int ret;
402 struct vfs_aio_state vfs_aio_state;
405 static void skel_fsync_done(struct tevent_req *subreq);
407 static struct tevent_req *skel_fsync_send(struct vfs_handle_struct *handle,
408 TALLOC_CTX *mem_ctx,
409 struct tevent_context *ev,
410 struct files_struct *fsp)
412 struct tevent_req *req, *subreq;
413 struct skel_fsync_state *state;
415 req = tevent_req_create(mem_ctx, &state, struct skel_fsync_state);
416 if (req == NULL) {
417 return NULL;
419 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
420 if (tevent_req_nomem(subreq, req)) {
421 return tevent_req_post(req, ev);
423 tevent_req_set_callback(subreq, skel_fsync_done, req);
424 return req;
427 static void skel_fsync_done(struct tevent_req *subreq)
429 struct tevent_req *req =
430 tevent_req_callback_data(subreq, struct tevent_req);
431 struct skel_fsync_state *state =
432 tevent_req_data(req, struct skel_fsync_state);
434 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
435 TALLOC_FREE(subreq);
436 tevent_req_done(req);
439 static int skel_fsync_recv(struct tevent_req *req,
440 struct vfs_aio_state *vfs_aio_state)
442 struct skel_fsync_state *state =
443 tevent_req_data(req, struct skel_fsync_state);
445 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
446 return -1;
448 *vfs_aio_state = state->vfs_aio_state;
449 return state->ret;
452 static int skel_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
454 return SMB_VFS_NEXT_STAT(handle, smb_fname);
457 static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp,
458 SMB_STRUCT_STAT *sbuf)
460 return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
463 static int skel_lstat(vfs_handle_struct *handle,
464 struct smb_filename *smb_fname)
466 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
469 static uint64_t skel_get_alloc_size(struct vfs_handle_struct *handle,
470 struct files_struct *fsp,
471 const SMB_STRUCT_STAT *sbuf)
473 return SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
476 static int skel_unlink(vfs_handle_struct *handle,
477 const struct smb_filename *smb_fname)
479 return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
482 static int skel_chmod(vfs_handle_struct *handle,
483 const struct smb_filename *smb_fname,
484 mode_t mode)
486 return SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
489 static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp,
490 mode_t mode)
492 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
495 static int skel_chown(vfs_handle_struct *handle,
496 const struct smb_filename *smb_fname,
497 uid_t uid,
498 gid_t gid)
500 return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
503 static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp,
504 uid_t uid, gid_t gid)
506 return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
509 static int skel_lchown(vfs_handle_struct *handle,
510 const struct smb_filename *smb_fname,
511 uid_t uid,
512 gid_t gid)
514 return SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
517 static int skel_chdir(vfs_handle_struct *handle, const char *path)
519 return SMB_VFS_NEXT_CHDIR(handle, path);
522 static char *skel_getwd(vfs_handle_struct *handle)
524 return SMB_VFS_NEXT_GETWD(handle);
527 static int skel_ntimes(vfs_handle_struct *handle,
528 const struct smb_filename *smb_fname,
529 struct smb_file_time *ft)
531 return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
534 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
535 off_t offset)
537 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
540 static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
541 uint32_t mode, off_t offset, off_t len)
543 return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
546 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op,
547 off_t offset, off_t count, int type)
549 return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
552 static int skel_kernel_flock(struct vfs_handle_struct *handle,
553 struct files_struct *fsp, uint32_t share_mode,
554 uint32_t access_mask)
556 return SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
559 static int skel_linux_setlease(struct vfs_handle_struct *handle,
560 struct files_struct *fsp, int leasetype)
562 return SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
565 static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp,
566 off_t *poffset, off_t *pcount, int *ptype,
567 pid_t *ppid)
569 return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
572 static int skel_symlink(vfs_handle_struct *handle, const char *oldpath,
573 const char *newpath)
575 return SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
578 static int skel_vfs_readlink(vfs_handle_struct *handle, const char *path,
579 char *buf, size_t bufsiz)
581 return SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
584 static int skel_link(vfs_handle_struct *handle,
585 const struct smb_filename *old_smb_fname,
586 const struct smb_filename *new_smb_fname)
588 return SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
591 static int skel_mknod(vfs_handle_struct *handle,
592 const struct smb_filename *smb_fname,
593 mode_t mode,
594 SMB_DEV_T dev)
596 return SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
599 static char *skel_realpath(vfs_handle_struct *handle, const char *path)
601 return SMB_VFS_NEXT_REALPATH(handle, path);
604 static int skel_chflags(vfs_handle_struct *handle,
605 const struct smb_filename *smb_fname,
606 uint flags)
608 return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
611 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
612 const SMB_STRUCT_STAT *sbuf)
614 return SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
617 struct skel_cc_state {
618 struct vfs_handle_struct *handle;
619 off_t copied;
621 static void skel_copy_chunk_done(struct tevent_req *subreq);
623 static struct tevent_req *skel_copy_chunk_send(struct vfs_handle_struct *handle,
624 TALLOC_CTX *mem_ctx,
625 struct tevent_context *ev,
626 struct files_struct *src_fsp,
627 off_t src_off,
628 struct files_struct *dest_fsp,
629 off_t dest_off,
630 off_t num,
631 uint32_t flags)
633 struct tevent_req *req;
634 struct tevent_req *subreq;
635 struct skel_cc_state *cc_state;
637 req = tevent_req_create(mem_ctx, &cc_state, struct skel_cc_state);
638 if (req == NULL) {
639 return NULL;
642 cc_state->handle = handle;
643 subreq = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, cc_state, ev,
644 src_fsp, src_off,
645 dest_fsp, dest_off, num, flags);
646 if (tevent_req_nomem(subreq, req)) {
647 return tevent_req_post(req, ev);
650 tevent_req_set_callback(subreq, skel_copy_chunk_done, req);
651 return req;
654 static void skel_copy_chunk_done(struct tevent_req *subreq)
656 struct tevent_req *req = tevent_req_callback_data(
657 subreq, struct tevent_req);
658 struct skel_cc_state *cc_state
659 = tevent_req_data(req, struct skel_cc_state);
660 NTSTATUS status;
662 status = SMB_VFS_NEXT_COPY_CHUNK_RECV(cc_state->handle,
663 subreq,
664 &cc_state->copied);
665 TALLOC_FREE(subreq);
666 if (tevent_req_nterror(req, status)) {
667 return;
669 tevent_req_done(req);
672 static NTSTATUS skel_copy_chunk_recv(struct vfs_handle_struct *handle,
673 struct tevent_req *req,
674 off_t *copied)
676 struct skel_cc_state *cc_state
677 = tevent_req_data(req, struct skel_cc_state);
678 NTSTATUS status;
680 *copied = cc_state->copied;
681 if (tevent_req_is_nterror(req, &status)) {
682 tevent_req_received(req);
683 return status;
686 tevent_req_received(req);
687 return NT_STATUS_OK;
690 static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
691 TALLOC_CTX *mem_ctx,
692 struct files_struct *fsp,
693 struct smb_filename *smb_fname,
694 uint16_t *_compression_fmt)
696 return SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
697 _compression_fmt);
700 static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
701 TALLOC_CTX *mem_ctx,
702 struct files_struct *fsp,
703 uint16_t compression_fmt)
705 return SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
706 compression_fmt);
709 static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
710 struct files_struct *fsp,
711 const struct smb_filename *smb_fname,
712 TALLOC_CTX *mem_ctx,
713 unsigned int *num_streams,
714 struct stream_struct **streams)
716 return SMB_VFS_NEXT_STREAMINFO(handle,
717 fsp,
718 smb_fname,
719 mem_ctx,
720 num_streams,
721 streams);
724 static int skel_get_real_filename(struct vfs_handle_struct *handle,
725 const char *path,
726 const char *name,
727 TALLOC_CTX *mem_ctx, char **found_name)
729 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle,
730 path, name, mem_ctx, found_name);
733 static const char *skel_connectpath(struct vfs_handle_struct *handle,
734 const char *filename)
736 return SMB_VFS_NEXT_CONNECTPATH(handle, filename);
739 static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
740 struct byte_range_lock *br_lck,
741 struct lock_struct *plock,
742 bool blocking_lock)
744 return SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle,
745 br_lck, plock, blocking_lock);
748 static bool skel_brl_unlock_windows(struct vfs_handle_struct *handle,
749 struct messaging_context *msg_ctx,
750 struct byte_range_lock *br_lck,
751 const struct lock_struct *plock)
753 return SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck, plock);
756 static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
757 struct byte_range_lock *br_lck,
758 struct lock_struct *plock)
760 return SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
763 static bool skel_strict_lock(struct vfs_handle_struct *handle,
764 struct files_struct *fsp,
765 struct lock_struct *plock)
767 return SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
770 static void skel_strict_unlock(struct vfs_handle_struct *handle,
771 struct files_struct *fsp,
772 struct lock_struct *plock)
774 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
777 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
778 const char *mapped_name,
779 enum vfs_translate_direction direction,
780 TALLOC_CTX *mem_ctx, char **pmapped_name)
782 return SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction,
783 mem_ctx, pmapped_name);
786 static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
787 struct files_struct *fsp,
788 TALLOC_CTX *ctx,
789 uint32_t function,
790 uint16_t req_flags, /* Needed for UNICODE ... */
791 const uint8_t *_in_data,
792 uint32_t in_len,
793 uint8_t ** _out_data,
794 uint32_t max_out_len, uint32_t *out_len)
796 return SMB_VFS_NEXT_FSCTL(handle,
797 fsp,
798 ctx,
799 function,
800 req_flags,
801 _in_data,
802 in_len, _out_data, max_out_len, out_len);
805 static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
806 const struct smb_filename *fname,
807 TALLOC_CTX *mem_ctx,
808 struct readdir_attr_data **pattr_data)
810 return SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
813 static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
814 struct smb_filename *smb_fname,
815 uint32_t *dosmode)
817 return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
818 smb_fname,
819 dosmode);
822 static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
823 struct files_struct *fsp,
824 uint32_t *dosmode)
826 return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
827 fsp,
828 dosmode);
831 static NTSTATUS skel_set_dos_attributes(struct vfs_handle_struct *handle,
832 const struct smb_filename *smb_fname,
833 uint32_t dosmode)
835 return SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
836 smb_fname,
837 dosmode);
840 static NTSTATUS skel_fset_dos_attributes(struct vfs_handle_struct *handle,
841 struct files_struct *fsp,
842 uint32_t dosmode)
844 return SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
845 fsp,
846 dosmode);
849 static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
850 uint32_t security_info,
851 TALLOC_CTX *mem_ctx,
852 struct security_descriptor **ppdesc)
854 return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, mem_ctx,
855 ppdesc);
858 static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle,
859 const struct smb_filename *smb_fname,
860 uint32_t security_info,
861 TALLOC_CTX *mem_ctx,
862 struct security_descriptor **ppdesc)
864 return SMB_VFS_NEXT_GET_NT_ACL(handle,
865 smb_fname,
866 security_info,
867 mem_ctx,
868 ppdesc);
871 static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
872 uint32_t security_info_sent,
873 const struct security_descriptor *psd)
875 return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
878 static int skel_chmod_acl(vfs_handle_struct *handle,
879 const struct smb_filename *smb_fname,
880 mode_t mode)
882 return SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
885 static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
886 mode_t mode)
888 return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
891 static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle,
892 const struct smb_filename *smb_fname,
893 SMB_ACL_TYPE_T type,
894 TALLOC_CTX *mem_ctx)
896 return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname, type, mem_ctx);
899 static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
900 files_struct *fsp, TALLOC_CTX *mem_ctx)
902 return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
905 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
906 const struct smb_filename *smb_fname,
907 TALLOC_CTX *mem_ctx,
908 char **blob_description,
909 DATA_BLOB *blob)
911 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname, mem_ctx,
912 blob_description, blob);
915 static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
916 files_struct *fsp, TALLOC_CTX *mem_ctx,
917 char **blob_description, DATA_BLOB *blob)
919 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx,
920 blob_description, blob);
923 static int skel_sys_acl_set_file(vfs_handle_struct *handle,
924 const struct smb_filename *smb_fname,
925 SMB_ACL_TYPE_T acltype,
926 SMB_ACL_T theacl)
928 return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
929 acltype, theacl);
932 static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
933 SMB_ACL_T theacl)
935 return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
938 static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
939 const struct smb_filename *smb_fname)
941 return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
944 static ssize_t skel_getxattr(vfs_handle_struct *handle,
945 const struct smb_filename *smb_fname,
946 const char *name,
947 void *value,
948 size_t size)
950 return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
953 static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
954 struct files_struct *fsp, const char *name,
955 void *value, size_t size)
957 return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
960 static ssize_t skel_listxattr(vfs_handle_struct *handle,
961 const struct smb_filename *smb_fname,
962 char *list,
963 size_t size)
965 return SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
968 static ssize_t skel_flistxattr(vfs_handle_struct *handle,
969 struct files_struct *fsp, char *list,
970 size_t size)
972 return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
975 static int skel_removexattr(vfs_handle_struct *handle,
976 const struct smb_filename *smb_fname,
977 const char *name)
979 return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
982 static int skel_fremovexattr(vfs_handle_struct *handle,
983 struct files_struct *fsp, const char *name)
985 return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
988 static int skel_setxattr(vfs_handle_struct *handle,
989 const struct smb_filename *smb_fname,
990 const char *name,
991 const void *value,
992 size_t size,
993 int flags)
995 return SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
996 name, value, size, flags);
999 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
1000 const char *name, const void *value, size_t size,
1001 int flags)
1003 return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
1006 static bool skel_aio_force(struct vfs_handle_struct *handle,
1007 struct files_struct *fsp)
1009 return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
1012 /* VFS operations structure */
1014 struct vfs_fn_pointers skel_transparent_fns = {
1015 /* Disk operations */
1017 .connect_fn = skel_connect,
1018 .disconnect_fn = skel_disconnect,
1019 .disk_free_fn = skel_disk_free,
1020 .get_quota_fn = skel_get_quota,
1021 .set_quota_fn = skel_set_quota,
1022 .get_shadow_copy_data_fn = skel_get_shadow_copy_data,
1023 .statvfs_fn = skel_statvfs,
1024 .fs_capabilities_fn = skel_fs_capabilities,
1025 .get_dfs_referrals_fn = skel_get_dfs_referrals,
1026 .snap_check_path_fn = skel_snap_check_path,
1027 .snap_create_fn = skel_snap_create,
1028 .snap_delete_fn = skel_snap_delete,
1030 /* Directory operations */
1032 .opendir_fn = skel_opendir,
1033 .fdopendir_fn = skel_fdopendir,
1034 .readdir_fn = skel_readdir,
1035 .seekdir_fn = skel_seekdir,
1036 .telldir_fn = skel_telldir,
1037 .rewind_dir_fn = skel_rewind_dir,
1038 .mkdir_fn = skel_mkdir,
1039 .rmdir_fn = skel_rmdir,
1040 .closedir_fn = skel_closedir,
1041 .init_search_op_fn = skel_init_search_op,
1043 /* File operations */
1045 .open_fn = skel_open,
1046 .create_file_fn = skel_create_file,
1047 .close_fn = skel_close_fn,
1048 .read_fn = skel_vfs_read,
1049 .pread_fn = skel_pread,
1050 .pread_send_fn = skel_pread_send,
1051 .pread_recv_fn = skel_pread_recv,
1052 .write_fn = skel_write,
1053 .pwrite_fn = skel_pwrite,
1054 .pwrite_send_fn = skel_pwrite_send,
1055 .pwrite_recv_fn = skel_pwrite_recv,
1056 .lseek_fn = skel_lseek,
1057 .sendfile_fn = skel_sendfile,
1058 .recvfile_fn = skel_recvfile,
1059 .rename_fn = skel_rename,
1060 .fsync_fn = skel_fsync,
1061 .fsync_send_fn = skel_fsync_send,
1062 .fsync_recv_fn = skel_fsync_recv,
1063 .stat_fn = skel_stat,
1064 .fstat_fn = skel_fstat,
1065 .lstat_fn = skel_lstat,
1066 .get_alloc_size_fn = skel_get_alloc_size,
1067 .unlink_fn = skel_unlink,
1068 .chmod_fn = skel_chmod,
1069 .fchmod_fn = skel_fchmod,
1070 .chown_fn = skel_chown,
1071 .fchown_fn = skel_fchown,
1072 .lchown_fn = skel_lchown,
1073 .chdir_fn = skel_chdir,
1074 .getwd_fn = skel_getwd,
1075 .ntimes_fn = skel_ntimes,
1076 .ftruncate_fn = skel_ftruncate,
1077 .fallocate_fn = skel_fallocate,
1078 .lock_fn = skel_lock,
1079 .kernel_flock_fn = skel_kernel_flock,
1080 .linux_setlease_fn = skel_linux_setlease,
1081 .getlock_fn = skel_getlock,
1082 .symlink_fn = skel_symlink,
1083 .readlink_fn = skel_vfs_readlink,
1084 .link_fn = skel_link,
1085 .mknod_fn = skel_mknod,
1086 .realpath_fn = skel_realpath,
1087 .chflags_fn = skel_chflags,
1088 .file_id_create_fn = skel_file_id_create,
1089 .copy_chunk_send_fn = skel_copy_chunk_send,
1090 .copy_chunk_recv_fn = skel_copy_chunk_recv,
1091 .get_compression_fn = skel_get_compression,
1092 .set_compression_fn = skel_set_compression,
1094 .streaminfo_fn = skel_streaminfo,
1095 .get_real_filename_fn = skel_get_real_filename,
1096 .connectpath_fn = skel_connectpath,
1097 .brl_lock_windows_fn = skel_brl_lock_windows,
1098 .brl_unlock_windows_fn = skel_brl_unlock_windows,
1099 .brl_cancel_windows_fn = skel_brl_cancel_windows,
1100 .strict_lock_fn = skel_strict_lock,
1101 .strict_unlock_fn = skel_strict_unlock,
1102 .translate_name_fn = skel_translate_name,
1103 .fsctl_fn = skel_fsctl,
1104 .readdir_attr_fn = skel_readdir_attr,
1106 /* DOS attributes. */
1107 .get_dos_attributes_fn = skel_get_dos_attributes,
1108 .fget_dos_attributes_fn = skel_fget_dos_attributes,
1109 .set_dos_attributes_fn = skel_set_dos_attributes,
1110 .fset_dos_attributes_fn = skel_fset_dos_attributes,
1112 /* NT ACL operations. */
1114 .fget_nt_acl_fn = skel_fget_nt_acl,
1115 .get_nt_acl_fn = skel_get_nt_acl,
1116 .fset_nt_acl_fn = skel_fset_nt_acl,
1118 /* POSIX ACL operations. */
1120 .chmod_acl_fn = skel_chmod_acl,
1121 .fchmod_acl_fn = skel_fchmod_acl,
1123 .sys_acl_get_file_fn = skel_sys_acl_get_file,
1124 .sys_acl_get_fd_fn = skel_sys_acl_get_fd,
1125 .sys_acl_blob_get_file_fn = skel_sys_acl_blob_get_file,
1126 .sys_acl_blob_get_fd_fn = skel_sys_acl_blob_get_fd,
1127 .sys_acl_set_file_fn = skel_sys_acl_set_file,
1128 .sys_acl_set_fd_fn = skel_sys_acl_set_fd,
1129 .sys_acl_delete_def_file_fn = skel_sys_acl_delete_def_file,
1131 /* EA operations. */
1132 .getxattr_fn = skel_getxattr,
1133 .fgetxattr_fn = skel_fgetxattr,
1134 .listxattr_fn = skel_listxattr,
1135 .flistxattr_fn = skel_flistxattr,
1136 .removexattr_fn = skel_removexattr,
1137 .fremovexattr_fn = skel_fremovexattr,
1138 .setxattr_fn = skel_setxattr,
1139 .fsetxattr_fn = skel_fsetxattr,
1141 /* aio operations */
1142 .aio_force_fn = skel_aio_force,
1145 static_decl_vfs;
1146 NTSTATUS vfs_skel_transparent_init(TALLOC_CTX *ctx)
1148 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "skel_transparent",
1149 &skel_transparent_fns);