s3:avahi: Fix size types
[Samba.git] / examples / VFS / skel_transparent.c
blob59d16340025a71c85f4ee3e96394888c421b5889
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,
85 const struct smb_filename *smb_fname,
86 struct vfs_statvfs_struct *statbuf)
88 return SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf);
91 static uint32_t skel_fs_capabilities(struct vfs_handle_struct *handle,
92 enum timestamp_set_resolution *p_ts_res)
94 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
97 static NTSTATUS skel_get_dfs_referrals(struct vfs_handle_struct *handle,
98 struct dfs_GetDFSReferral *r)
100 return SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
103 static DIR *skel_opendir(vfs_handle_struct *handle,
104 const struct smb_filename *smb_fname,
105 const char *mask,
106 uint32_t attr)
108 return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
111 static NTSTATUS skel_snap_check_path(struct vfs_handle_struct *handle,
112 TALLOC_CTX *mem_ctx,
113 const char *service_path,
114 char **base_volume)
116 return SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
117 base_volume);
120 static NTSTATUS skel_snap_create(struct vfs_handle_struct *handle,
121 TALLOC_CTX *mem_ctx,
122 const char *base_volume,
123 time_t *tstamp,
124 bool rw,
125 char **base_path,
126 char **snap_path)
128 return SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
129 rw, base_path, snap_path);
132 static NTSTATUS skel_snap_delete(struct vfs_handle_struct *handle,
133 TALLOC_CTX *mem_ctx,
134 char *base_path,
135 char *snap_path)
137 return SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path, snap_path);
140 static DIR *skel_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
141 const char *mask, uint32_t attr)
143 return SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
146 static struct dirent *skel_readdir(vfs_handle_struct *handle,
147 DIR *dirp, SMB_STRUCT_STAT *sbuf)
149 return SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
152 static void skel_seekdir(vfs_handle_struct *handle, DIR *dirp, long offset)
154 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
157 static long skel_telldir(vfs_handle_struct *handle, DIR *dirp)
159 return SMB_VFS_NEXT_TELLDIR(handle, dirp);
162 static void skel_rewind_dir(vfs_handle_struct *handle, DIR *dirp)
164 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
167 static int skel_mkdir(vfs_handle_struct *handle,
168 const struct smb_filename *smb_fname,
169 mode_t mode)
171 return SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
174 static int skel_rmdir(vfs_handle_struct *handle,
175 const struct smb_filename *smb_fname)
177 return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
180 static int skel_closedir(vfs_handle_struct *handle, DIR *dir)
182 return SMB_VFS_NEXT_CLOSEDIR(handle, dir);
185 static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
186 files_struct *fsp, int flags, mode_t mode)
188 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
191 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
192 struct smb_request *req,
193 uint16_t root_dir_fid,
194 struct smb_filename *smb_fname,
195 uint32_t access_mask,
196 uint32_t share_access,
197 uint32_t create_disposition,
198 uint32_t create_options,
199 uint32_t file_attributes,
200 uint32_t oplock_request,
201 struct smb2_lease *lease,
202 uint64_t allocation_size,
203 uint32_t private_flags,
204 struct security_descriptor *sd,
205 struct ea_list *ea_list,
206 files_struct ** result, int *pinfo,
207 const struct smb2_create_blobs *in_context_blobs,
208 struct smb2_create_blobs *out_context_blobs)
210 return SMB_VFS_NEXT_CREATE_FILE(handle,
211 req,
212 root_dir_fid,
213 smb_fname,
214 access_mask,
215 share_access,
216 create_disposition,
217 create_options,
218 file_attributes,
219 oplock_request,
220 lease,
221 allocation_size,
222 private_flags,
223 sd, ea_list, result, pinfo,
224 in_context_blobs, out_context_blobs);
227 static int skel_close_fn(vfs_handle_struct *handle, files_struct *fsp)
229 return SMB_VFS_NEXT_CLOSE(handle, fsp);
232 static ssize_t skel_vfs_read(vfs_handle_struct *handle, files_struct *fsp,
233 void *data, size_t n)
235 return SMB_VFS_NEXT_READ(handle, fsp, data, n);
238 static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp,
239 void *data, size_t n, off_t offset)
241 return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
244 struct skel_pread_state {
245 ssize_t ret;
246 struct vfs_aio_state vfs_aio_state;
249 static void skel_pread_done(struct tevent_req *subreq);
251 static struct tevent_req *skel_pread_send(struct vfs_handle_struct *handle,
252 TALLOC_CTX *mem_ctx,
253 struct tevent_context *ev,
254 struct files_struct *fsp,
255 void *data, size_t n, off_t offset)
257 struct tevent_req *req, *subreq;
258 struct skel_pread_state *state;
260 req = tevent_req_create(mem_ctx, &state, struct skel_pread_state);
261 if (req == NULL) {
262 return NULL;
264 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
265 n, offset);
266 if (tevent_req_nomem(subreq, req)) {
267 return tevent_req_post(req, ev);
269 tevent_req_set_callback(subreq, skel_pread_done, req);
270 return req;
273 static void skel_pread_done(struct tevent_req *subreq)
275 struct tevent_req *req =
276 tevent_req_callback_data(subreq, struct tevent_req);
277 struct skel_pread_state *state =
278 tevent_req_data(req, struct skel_pread_state);
280 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
281 TALLOC_FREE(subreq);
282 tevent_req_done(req);
285 static ssize_t skel_pread_recv(struct tevent_req *req,
286 struct vfs_aio_state *vfs_aio_state)
288 struct skel_pread_state *state =
289 tevent_req_data(req, struct skel_pread_state);
291 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
292 return -1;
294 *vfs_aio_state = state->vfs_aio_state;
295 return state->ret;
298 static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp,
299 const void *data, size_t n)
301 return SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
304 static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp,
305 const void *data, size_t n, off_t offset)
307 return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
310 struct skel_pwrite_state {
311 ssize_t ret;
312 struct vfs_aio_state vfs_aio_state;
315 static void skel_pwrite_done(struct tevent_req *subreq);
317 static struct tevent_req *skel_pwrite_send(struct vfs_handle_struct *handle,
318 TALLOC_CTX *mem_ctx,
319 struct tevent_context *ev,
320 struct files_struct *fsp,
321 const void *data,
322 size_t n, off_t offset)
324 struct tevent_req *req, *subreq;
325 struct skel_pwrite_state *state;
327 req = tevent_req_create(mem_ctx, &state, struct skel_pwrite_state);
328 if (req == NULL) {
329 return NULL;
331 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
332 n, offset);
333 if (tevent_req_nomem(subreq, req)) {
334 return tevent_req_post(req, ev);
336 tevent_req_set_callback(subreq, skel_pwrite_done, req);
337 return req;
340 static void skel_pwrite_done(struct tevent_req *subreq)
342 struct tevent_req *req =
343 tevent_req_callback_data(subreq, struct tevent_req);
344 struct skel_pwrite_state *state =
345 tevent_req_data(req, struct skel_pwrite_state);
347 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
348 TALLOC_FREE(subreq);
349 tevent_req_done(req);
352 static ssize_t skel_pwrite_recv(struct tevent_req *req,
353 struct vfs_aio_state *vfs_aio_state)
355 struct skel_pwrite_state *state =
356 tevent_req_data(req, struct skel_pwrite_state);
358 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
359 return -1;
361 *vfs_aio_state = state->vfs_aio_state;
362 return state->ret;
365 static off_t skel_lseek(vfs_handle_struct *handle, files_struct *fsp,
366 off_t offset, int whence)
368 return SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
371 static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd,
372 files_struct *fromfsp, const DATA_BLOB *hdr,
373 off_t offset, size_t n)
375 return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
378 static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd,
379 files_struct *tofsp, off_t offset, size_t n)
381 return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
384 static int skel_rename(vfs_handle_struct *handle,
385 const struct smb_filename *smb_fname_src,
386 const struct smb_filename *smb_fname_dst)
388 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
391 static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
393 return SMB_VFS_NEXT_FSYNC(handle, fsp);
396 struct skel_fsync_state {
397 int ret;
398 struct vfs_aio_state vfs_aio_state;
401 static void skel_fsync_done(struct tevent_req *subreq);
403 static struct tevent_req *skel_fsync_send(struct vfs_handle_struct *handle,
404 TALLOC_CTX *mem_ctx,
405 struct tevent_context *ev,
406 struct files_struct *fsp)
408 struct tevent_req *req, *subreq;
409 struct skel_fsync_state *state;
411 req = tevent_req_create(mem_ctx, &state, struct skel_fsync_state);
412 if (req == NULL) {
413 return NULL;
415 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
416 if (tevent_req_nomem(subreq, req)) {
417 return tevent_req_post(req, ev);
419 tevent_req_set_callback(subreq, skel_fsync_done, req);
420 return req;
423 static void skel_fsync_done(struct tevent_req *subreq)
425 struct tevent_req *req =
426 tevent_req_callback_data(subreq, struct tevent_req);
427 struct skel_fsync_state *state =
428 tevent_req_data(req, struct skel_fsync_state);
430 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
431 TALLOC_FREE(subreq);
432 tevent_req_done(req);
435 static int skel_fsync_recv(struct tevent_req *req,
436 struct vfs_aio_state *vfs_aio_state)
438 struct skel_fsync_state *state =
439 tevent_req_data(req, struct skel_fsync_state);
441 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
442 return -1;
444 *vfs_aio_state = state->vfs_aio_state;
445 return state->ret;
448 static int skel_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
450 return SMB_VFS_NEXT_STAT(handle, smb_fname);
453 static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp,
454 SMB_STRUCT_STAT *sbuf)
456 return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
459 static int skel_lstat(vfs_handle_struct *handle,
460 struct smb_filename *smb_fname)
462 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
465 static uint64_t skel_get_alloc_size(struct vfs_handle_struct *handle,
466 struct files_struct *fsp,
467 const SMB_STRUCT_STAT *sbuf)
469 return SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
472 static int skel_unlink(vfs_handle_struct *handle,
473 const struct smb_filename *smb_fname)
475 return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
478 static int skel_chmod(vfs_handle_struct *handle,
479 const struct smb_filename *smb_fname,
480 mode_t mode)
482 return SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
485 static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp,
486 mode_t mode)
488 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
491 static int skel_chown(vfs_handle_struct *handle,
492 const struct smb_filename *smb_fname,
493 uid_t uid,
494 gid_t gid)
496 return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
499 static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp,
500 uid_t uid, gid_t gid)
502 return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
505 static int skel_lchown(vfs_handle_struct *handle,
506 const struct smb_filename *smb_fname,
507 uid_t uid,
508 gid_t gid)
510 return SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
513 static int skel_chdir(vfs_handle_struct *handle,
514 const struct smb_filename *smb_fname)
516 return SMB_VFS_NEXT_CHDIR(handle, smb_fname);
519 static struct smb_filename *skel_getwd(vfs_handle_struct *handle,
520 TALLOC_CTX *ctx)
522 return SMB_VFS_NEXT_GETWD(handle, ctx);
525 static int skel_ntimes(vfs_handle_struct *handle,
526 const struct smb_filename *smb_fname,
527 struct smb_file_time *ft)
529 return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
532 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
533 off_t offset)
535 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
538 static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
539 uint32_t mode, off_t offset, off_t len)
541 return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
544 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op,
545 off_t offset, off_t count, int type)
547 return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
550 static int skel_kernel_flock(struct vfs_handle_struct *handle,
551 struct files_struct *fsp, uint32_t share_mode,
552 uint32_t access_mask)
554 return SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
557 static int skel_linux_setlease(struct vfs_handle_struct *handle,
558 struct files_struct *fsp, int leasetype)
560 return SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
563 static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp,
564 off_t *poffset, off_t *pcount, int *ptype,
565 pid_t *ppid)
567 return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
570 static int skel_symlink(vfs_handle_struct *handle,
571 const char *link_contents,
572 const struct smb_filename *new_smb_fname)
574 return SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
577 static int skel_vfs_readlink(vfs_handle_struct *handle,
578 const struct smb_filename *smb_fname,
579 char *buf,
580 size_t bufsiz)
582 return SMB_VFS_NEXT_READLINK(handle, smb_fname, buf, bufsiz);
585 static int skel_link(vfs_handle_struct *handle,
586 const struct smb_filename *old_smb_fname,
587 const struct smb_filename *new_smb_fname)
589 return SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
592 static int skel_mknod(vfs_handle_struct *handle,
593 const struct smb_filename *smb_fname,
594 mode_t mode,
595 SMB_DEV_T dev)
597 return SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
600 static struct smb_filename *skel_realpath(vfs_handle_struct *handle,
601 TALLOC_CTX *ctx,
602 const struct smb_filename *smb_fname)
604 return SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
607 static int skel_chflags(vfs_handle_struct *handle,
608 const struct smb_filename *smb_fname,
609 uint flags)
611 return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
614 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
615 const SMB_STRUCT_STAT *sbuf)
617 return SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
620 struct skel_offload_read_state {
621 struct vfs_handle_struct *handle;
622 DATA_BLOB token;
625 static void skel_offload_read_done(struct tevent_req *subreq);
627 static struct tevent_req *skel_offload_read_send(
628 TALLOC_CTX *mem_ctx,
629 struct tevent_context *ev,
630 struct vfs_handle_struct *handle,
631 struct files_struct *fsp,
632 uint32_t fsctl,
633 uint32_t ttl,
634 off_t offset,
635 size_t to_copy)
637 struct tevent_req *req = NULL;
638 struct skel_offload_read_state *state = NULL;
639 struct tevent_req *subreq = NULL;
641 req = tevent_req_create(mem_ctx, &state, struct skel_offload_read_state);
642 if (req == NULL) {
643 return NULL;
645 *state = (struct skel_offload_read_state) {
646 .handle = handle,
649 subreq = SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx, ev, handle, fsp,
650 fsctl, ttl, offset, to_copy);
651 if (tevent_req_nomem(subreq, req)) {
652 return tevent_req_post(req, ev);
654 tevent_req_set_callback(subreq, skel_offload_read_done, req);
655 return req;
658 static void skel_offload_read_done(struct tevent_req *subreq)
660 struct tevent_req *req = tevent_req_callback_data(
661 subreq, struct tevent_req);
662 struct skel_offload_read_state *state = tevent_req_data(
663 req, struct skel_offload_read_state);
664 NTSTATUS status;
666 status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(subreq,
667 state->handle,
668 state,
669 &state->token);
670 TALLOC_FREE(subreq);
671 if (tevent_req_nterror(req, status)) {
672 return;
675 tevent_req_done(req);
676 return;
679 static NTSTATUS skel_offload_read_recv(struct tevent_req *req,
680 struct vfs_handle_struct *handle,
681 TALLOC_CTX *mem_ctx,
682 DATA_BLOB *_token)
684 struct skel_offload_read_state *state = tevent_req_data(
685 req, struct skel_offload_read_state);
686 DATA_BLOB token;
687 NTSTATUS status;
689 if (tevent_req_is_nterror(req, &status)) {
690 tevent_req_received(req);
691 return status;
694 token = data_blob_talloc(mem_ctx,
695 state->token.data,
696 state->token.length);
698 tevent_req_received(req);
700 if (token.data == NULL) {
701 return NT_STATUS_NO_MEMORY;
704 *_token = token;
705 return NT_STATUS_OK;
708 struct skel_offload_write_state {
709 struct vfs_handle_struct *handle;
710 off_t copied;
712 static void skel_offload_write_done(struct tevent_req *subreq);
714 static struct tevent_req *skel_offload_write_send(struct vfs_handle_struct *handle,
715 TALLOC_CTX *mem_ctx,
716 struct tevent_context *ev,
717 uint32_t fsctl,
718 DATA_BLOB *token,
719 off_t transfer_offset,
720 struct files_struct *dest_fsp,
721 off_t dest_off,
722 off_t num)
724 struct tevent_req *req;
725 struct tevent_req *subreq;
726 struct skel_offload_write_state *state;
728 req = tevent_req_create(mem_ctx, &state, struct skel_offload_write_state);
729 if (req == NULL) {
730 return NULL;
733 state->handle = handle;
734 subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle, state, ev,
735 fsctl, token, transfer_offset,
736 dest_fsp, dest_off, num);
737 if (tevent_req_nomem(subreq, req)) {
738 return tevent_req_post(req, ev);
741 tevent_req_set_callback(subreq, skel_offload_write_done, req);
742 return req;
745 static void skel_offload_write_done(struct tevent_req *subreq)
747 struct tevent_req *req = tevent_req_callback_data(
748 subreq, struct tevent_req);
749 struct skel_offload_write_state *state
750 = tevent_req_data(req, struct skel_offload_write_state);
751 NTSTATUS status;
753 status = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(state->handle,
754 subreq,
755 &state->copied);
756 TALLOC_FREE(subreq);
757 if (tevent_req_nterror(req, status)) {
758 return;
760 tevent_req_done(req);
763 static NTSTATUS skel_offload_write_recv(struct vfs_handle_struct *handle,
764 struct tevent_req *req,
765 off_t *copied)
767 struct skel_offload_write_state *state
768 = tevent_req_data(req, struct skel_offload_write_state);
769 NTSTATUS status;
771 *copied = state->copied;
772 if (tevent_req_is_nterror(req, &status)) {
773 tevent_req_received(req);
774 return status;
777 tevent_req_received(req);
778 return NT_STATUS_OK;
781 static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
782 TALLOC_CTX *mem_ctx,
783 struct files_struct *fsp,
784 struct smb_filename *smb_fname,
785 uint16_t *_compression_fmt)
787 return SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
788 _compression_fmt);
791 static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
792 TALLOC_CTX *mem_ctx,
793 struct files_struct *fsp,
794 uint16_t compression_fmt)
796 return SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
797 compression_fmt);
800 static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
801 struct files_struct *fsp,
802 const struct smb_filename *smb_fname,
803 TALLOC_CTX *mem_ctx,
804 unsigned int *num_streams,
805 struct stream_struct **streams)
807 return SMB_VFS_NEXT_STREAMINFO(handle,
808 fsp,
809 smb_fname,
810 mem_ctx,
811 num_streams,
812 streams);
815 static int skel_get_real_filename(struct vfs_handle_struct *handle,
816 const char *path,
817 const char *name,
818 TALLOC_CTX *mem_ctx, char **found_name)
820 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle,
821 path, name, mem_ctx, found_name);
824 static const char *skel_connectpath(struct vfs_handle_struct *handle,
825 const struct smb_filename *smb_fname)
827 return SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
830 static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
831 struct byte_range_lock *br_lck,
832 struct lock_struct *plock,
833 bool blocking_lock)
835 return SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle,
836 br_lck, plock, blocking_lock);
839 static bool skel_brl_unlock_windows(struct vfs_handle_struct *handle,
840 struct messaging_context *msg_ctx,
841 struct byte_range_lock *br_lck,
842 const struct lock_struct *plock)
844 return SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck, plock);
847 static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
848 struct byte_range_lock *br_lck,
849 struct lock_struct *plock)
851 return SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
854 static bool skel_strict_lock_check(struct vfs_handle_struct *handle,
855 struct files_struct *fsp,
856 struct lock_struct *plock)
858 return SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
861 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
862 const char *mapped_name,
863 enum vfs_translate_direction direction,
864 TALLOC_CTX *mem_ctx, char **pmapped_name)
866 return SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction,
867 mem_ctx, pmapped_name);
870 static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
871 struct files_struct *fsp,
872 TALLOC_CTX *ctx,
873 uint32_t function,
874 uint16_t req_flags, /* Needed for UNICODE ... */
875 const uint8_t *_in_data,
876 uint32_t in_len,
877 uint8_t ** _out_data,
878 uint32_t max_out_len, uint32_t *out_len)
880 return SMB_VFS_NEXT_FSCTL(handle,
881 fsp,
882 ctx,
883 function,
884 req_flags,
885 _in_data,
886 in_len, _out_data, max_out_len, out_len);
889 static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
890 const struct smb_filename *fname,
891 TALLOC_CTX *mem_ctx,
892 struct readdir_attr_data **pattr_data)
894 return SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
897 static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
898 struct smb_filename *smb_fname,
899 uint32_t *dosmode)
901 return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
902 smb_fname,
903 dosmode);
906 static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
907 struct files_struct *fsp,
908 uint32_t *dosmode)
910 return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
911 fsp,
912 dosmode);
915 static NTSTATUS skel_set_dos_attributes(struct vfs_handle_struct *handle,
916 const struct smb_filename *smb_fname,
917 uint32_t dosmode)
919 return SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
920 smb_fname,
921 dosmode);
924 static NTSTATUS skel_fset_dos_attributes(struct vfs_handle_struct *handle,
925 struct files_struct *fsp,
926 uint32_t dosmode)
928 return SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
929 fsp,
930 dosmode);
933 static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
934 uint32_t security_info,
935 TALLOC_CTX *mem_ctx,
936 struct security_descriptor **ppdesc)
938 return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, mem_ctx,
939 ppdesc);
942 static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle,
943 const struct smb_filename *smb_fname,
944 uint32_t security_info,
945 TALLOC_CTX *mem_ctx,
946 struct security_descriptor **ppdesc)
948 return SMB_VFS_NEXT_GET_NT_ACL(handle,
949 smb_fname,
950 security_info,
951 mem_ctx,
952 ppdesc);
955 static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
956 uint32_t security_info_sent,
957 const struct security_descriptor *psd)
959 return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
962 static int skel_chmod_acl(vfs_handle_struct *handle,
963 const struct smb_filename *smb_fname,
964 mode_t mode)
966 return SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
969 static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
970 mode_t mode)
972 return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
975 static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle,
976 const struct smb_filename *smb_fname,
977 SMB_ACL_TYPE_T type,
978 TALLOC_CTX *mem_ctx)
980 return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname, type, mem_ctx);
983 static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
984 files_struct *fsp, TALLOC_CTX *mem_ctx)
986 return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
989 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
990 const struct smb_filename *smb_fname,
991 TALLOC_CTX *mem_ctx,
992 char **blob_description,
993 DATA_BLOB *blob)
995 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname, mem_ctx,
996 blob_description, blob);
999 static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
1000 files_struct *fsp, TALLOC_CTX *mem_ctx,
1001 char **blob_description, DATA_BLOB *blob)
1003 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx,
1004 blob_description, blob);
1007 static int skel_sys_acl_set_file(vfs_handle_struct *handle,
1008 const struct smb_filename *smb_fname,
1009 SMB_ACL_TYPE_T acltype,
1010 SMB_ACL_T theacl)
1012 return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
1013 acltype, theacl);
1016 static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1017 SMB_ACL_T theacl)
1019 return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1022 static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
1023 const struct smb_filename *smb_fname)
1025 return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
1028 static ssize_t skel_getxattr(vfs_handle_struct *handle,
1029 const struct smb_filename *smb_fname,
1030 const char *name,
1031 void *value,
1032 size_t size)
1034 return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
1037 static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
1038 struct files_struct *fsp, const char *name,
1039 void *value, size_t size)
1041 return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1044 static ssize_t skel_listxattr(vfs_handle_struct *handle,
1045 const struct smb_filename *smb_fname,
1046 char *list,
1047 size_t size)
1049 return SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
1052 static ssize_t skel_flistxattr(vfs_handle_struct *handle,
1053 struct files_struct *fsp, char *list,
1054 size_t size)
1056 return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1059 static int skel_removexattr(vfs_handle_struct *handle,
1060 const struct smb_filename *smb_fname,
1061 const char *name)
1063 return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
1066 static int skel_fremovexattr(vfs_handle_struct *handle,
1067 struct files_struct *fsp, const char *name)
1069 return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
1072 static int skel_setxattr(vfs_handle_struct *handle,
1073 const struct smb_filename *smb_fname,
1074 const char *name,
1075 const void *value,
1076 size_t size,
1077 int flags)
1079 return SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
1080 name, value, size, flags);
1083 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
1084 const char *name, const void *value, size_t size,
1085 int flags)
1087 return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
1090 static bool skel_aio_force(struct vfs_handle_struct *handle,
1091 struct files_struct *fsp)
1093 return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
1096 /* VFS operations structure */
1098 struct vfs_fn_pointers skel_transparent_fns = {
1099 /* Disk operations */
1101 .connect_fn = skel_connect,
1102 .disconnect_fn = skel_disconnect,
1103 .disk_free_fn = skel_disk_free,
1104 .get_quota_fn = skel_get_quota,
1105 .set_quota_fn = skel_set_quota,
1106 .get_shadow_copy_data_fn = skel_get_shadow_copy_data,
1107 .statvfs_fn = skel_statvfs,
1108 .fs_capabilities_fn = skel_fs_capabilities,
1109 .get_dfs_referrals_fn = skel_get_dfs_referrals,
1110 .snap_check_path_fn = skel_snap_check_path,
1111 .snap_create_fn = skel_snap_create,
1112 .snap_delete_fn = skel_snap_delete,
1114 /* Directory operations */
1116 .opendir_fn = skel_opendir,
1117 .fdopendir_fn = skel_fdopendir,
1118 .readdir_fn = skel_readdir,
1119 .seekdir_fn = skel_seekdir,
1120 .telldir_fn = skel_telldir,
1121 .rewind_dir_fn = skel_rewind_dir,
1122 .mkdir_fn = skel_mkdir,
1123 .rmdir_fn = skel_rmdir,
1124 .closedir_fn = skel_closedir,
1126 /* File operations */
1128 .open_fn = skel_open,
1129 .create_file_fn = skel_create_file,
1130 .close_fn = skel_close_fn,
1131 .read_fn = skel_vfs_read,
1132 .pread_fn = skel_pread,
1133 .pread_send_fn = skel_pread_send,
1134 .pread_recv_fn = skel_pread_recv,
1135 .write_fn = skel_write,
1136 .pwrite_fn = skel_pwrite,
1137 .pwrite_send_fn = skel_pwrite_send,
1138 .pwrite_recv_fn = skel_pwrite_recv,
1139 .lseek_fn = skel_lseek,
1140 .sendfile_fn = skel_sendfile,
1141 .recvfile_fn = skel_recvfile,
1142 .rename_fn = skel_rename,
1143 .fsync_fn = skel_fsync,
1144 .fsync_send_fn = skel_fsync_send,
1145 .fsync_recv_fn = skel_fsync_recv,
1146 .stat_fn = skel_stat,
1147 .fstat_fn = skel_fstat,
1148 .lstat_fn = skel_lstat,
1149 .get_alloc_size_fn = skel_get_alloc_size,
1150 .unlink_fn = skel_unlink,
1151 .chmod_fn = skel_chmod,
1152 .fchmod_fn = skel_fchmod,
1153 .chown_fn = skel_chown,
1154 .fchown_fn = skel_fchown,
1155 .lchown_fn = skel_lchown,
1156 .chdir_fn = skel_chdir,
1157 .getwd_fn = skel_getwd,
1158 .ntimes_fn = skel_ntimes,
1159 .ftruncate_fn = skel_ftruncate,
1160 .fallocate_fn = skel_fallocate,
1161 .lock_fn = skel_lock,
1162 .kernel_flock_fn = skel_kernel_flock,
1163 .linux_setlease_fn = skel_linux_setlease,
1164 .getlock_fn = skel_getlock,
1165 .symlink_fn = skel_symlink,
1166 .readlink_fn = skel_vfs_readlink,
1167 .link_fn = skel_link,
1168 .mknod_fn = skel_mknod,
1169 .realpath_fn = skel_realpath,
1170 .chflags_fn = skel_chflags,
1171 .file_id_create_fn = skel_file_id_create,
1172 .offload_read_send_fn = skel_offload_read_send,
1173 .offload_read_recv_fn = skel_offload_read_recv,
1174 .offload_write_send_fn = skel_offload_write_send,
1175 .offload_write_recv_fn = skel_offload_write_recv,
1176 .get_compression_fn = skel_get_compression,
1177 .set_compression_fn = skel_set_compression,
1179 .streaminfo_fn = skel_streaminfo,
1180 .get_real_filename_fn = skel_get_real_filename,
1181 .connectpath_fn = skel_connectpath,
1182 .brl_lock_windows_fn = skel_brl_lock_windows,
1183 .brl_unlock_windows_fn = skel_brl_unlock_windows,
1184 .brl_cancel_windows_fn = skel_brl_cancel_windows,
1185 .strict_lock_check_fn = skel_strict_lock_check,
1186 .translate_name_fn = skel_translate_name,
1187 .fsctl_fn = skel_fsctl,
1188 .readdir_attr_fn = skel_readdir_attr,
1190 /* DOS attributes. */
1191 .get_dos_attributes_fn = skel_get_dos_attributes,
1192 .fget_dos_attributes_fn = skel_fget_dos_attributes,
1193 .set_dos_attributes_fn = skel_set_dos_attributes,
1194 .fset_dos_attributes_fn = skel_fset_dos_attributes,
1196 /* NT ACL operations. */
1198 .fget_nt_acl_fn = skel_fget_nt_acl,
1199 .get_nt_acl_fn = skel_get_nt_acl,
1200 .fset_nt_acl_fn = skel_fset_nt_acl,
1202 /* POSIX ACL operations. */
1204 .chmod_acl_fn = skel_chmod_acl,
1205 .fchmod_acl_fn = skel_fchmod_acl,
1207 .sys_acl_get_file_fn = skel_sys_acl_get_file,
1208 .sys_acl_get_fd_fn = skel_sys_acl_get_fd,
1209 .sys_acl_blob_get_file_fn = skel_sys_acl_blob_get_file,
1210 .sys_acl_blob_get_fd_fn = skel_sys_acl_blob_get_fd,
1211 .sys_acl_set_file_fn = skel_sys_acl_set_file,
1212 .sys_acl_set_fd_fn = skel_sys_acl_set_fd,
1213 .sys_acl_delete_def_file_fn = skel_sys_acl_delete_def_file,
1215 /* EA operations. */
1216 .getxattr_fn = skel_getxattr,
1217 .fgetxattr_fn = skel_fgetxattr,
1218 .listxattr_fn = skel_listxattr,
1219 .flistxattr_fn = skel_flistxattr,
1220 .removexattr_fn = skel_removexattr,
1221 .fremovexattr_fn = skel_fremovexattr,
1222 .setxattr_fn = skel_setxattr,
1223 .fsetxattr_fn = skel_fsetxattr,
1225 /* aio operations */
1226 .aio_force_fn = skel_aio_force,
1229 static_decl_vfs;
1230 NTSTATUS vfs_skel_transparent_init(TALLOC_CTX *ctx)
1232 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "skel_transparent",
1233 &skel_transparent_fns);