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.
40 static int skel_connect(vfs_handle_struct *handle, const char *service,
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,
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,
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,
77 struct shadow_copy_data *shadow_copy_data,
80 return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data,
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,
108 return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
111 static NTSTATUS skel_snap_check_path(struct vfs_handle_struct *handle,
113 const char *service_path,
116 return SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
120 static NTSTATUS skel_snap_create(struct vfs_handle_struct *handle,
122 const char *base_volume,
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,
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,
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,
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_pread(vfs_handle_struct *handle, files_struct *fsp,
233 void *data, size_t n, off_t offset)
235 return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
238 struct skel_pread_state {
240 struct vfs_aio_state vfs_aio_state;
243 static void skel_pread_done(struct tevent_req *subreq);
245 static struct tevent_req *skel_pread_send(struct vfs_handle_struct *handle,
247 struct tevent_context *ev,
248 struct files_struct *fsp,
249 void *data, size_t n, off_t offset)
251 struct tevent_req *req, *subreq;
252 struct skel_pread_state *state;
254 req = tevent_req_create(mem_ctx, &state, struct skel_pread_state);
258 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
260 if (tevent_req_nomem(subreq, req)) {
261 return tevent_req_post(req, ev);
263 tevent_req_set_callback(subreq, skel_pread_done, req);
267 static void skel_pread_done(struct tevent_req *subreq)
269 struct tevent_req *req =
270 tevent_req_callback_data(subreq, struct tevent_req);
271 struct skel_pread_state *state =
272 tevent_req_data(req, struct skel_pread_state);
274 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
276 tevent_req_done(req);
279 static ssize_t skel_pread_recv(struct tevent_req *req,
280 struct vfs_aio_state *vfs_aio_state)
282 struct skel_pread_state *state =
283 tevent_req_data(req, struct skel_pread_state);
285 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
288 *vfs_aio_state = state->vfs_aio_state;
292 static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp,
293 const void *data, size_t n, off_t offset)
295 return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
298 struct skel_pwrite_state {
300 struct vfs_aio_state vfs_aio_state;
303 static void skel_pwrite_done(struct tevent_req *subreq);
305 static struct tevent_req *skel_pwrite_send(struct vfs_handle_struct *handle,
307 struct tevent_context *ev,
308 struct files_struct *fsp,
310 size_t n, off_t offset)
312 struct tevent_req *req, *subreq;
313 struct skel_pwrite_state *state;
315 req = tevent_req_create(mem_ctx, &state, struct skel_pwrite_state);
319 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
321 if (tevent_req_nomem(subreq, req)) {
322 return tevent_req_post(req, ev);
324 tevent_req_set_callback(subreq, skel_pwrite_done, req);
328 static void skel_pwrite_done(struct tevent_req *subreq)
330 struct tevent_req *req =
331 tevent_req_callback_data(subreq, struct tevent_req);
332 struct skel_pwrite_state *state =
333 tevent_req_data(req, struct skel_pwrite_state);
335 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
337 tevent_req_done(req);
340 static ssize_t skel_pwrite_recv(struct tevent_req *req,
341 struct vfs_aio_state *vfs_aio_state)
343 struct skel_pwrite_state *state =
344 tevent_req_data(req, struct skel_pwrite_state);
346 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
349 *vfs_aio_state = state->vfs_aio_state;
353 static off_t skel_lseek(vfs_handle_struct *handle, files_struct *fsp,
354 off_t offset, int whence)
356 return SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
359 static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd,
360 files_struct *fromfsp, const DATA_BLOB *hdr,
361 off_t offset, size_t n)
363 return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
366 static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd,
367 files_struct *tofsp, off_t offset, size_t n)
369 return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
372 static int skel_rename(vfs_handle_struct *handle,
373 const struct smb_filename *smb_fname_src,
374 const struct smb_filename *smb_fname_dst)
376 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
379 struct skel_fsync_state {
381 struct vfs_aio_state vfs_aio_state;
384 static void skel_fsync_done(struct tevent_req *subreq);
386 static struct tevent_req *skel_fsync_send(struct vfs_handle_struct *handle,
388 struct tevent_context *ev,
389 struct files_struct *fsp)
391 struct tevent_req *req, *subreq;
392 struct skel_fsync_state *state;
394 req = tevent_req_create(mem_ctx, &state, struct skel_fsync_state);
398 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
399 if (tevent_req_nomem(subreq, req)) {
400 return tevent_req_post(req, ev);
402 tevent_req_set_callback(subreq, skel_fsync_done, req);
406 static void skel_fsync_done(struct tevent_req *subreq)
408 struct tevent_req *req =
409 tevent_req_callback_data(subreq, struct tevent_req);
410 struct skel_fsync_state *state =
411 tevent_req_data(req, struct skel_fsync_state);
413 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
415 tevent_req_done(req);
418 static int skel_fsync_recv(struct tevent_req *req,
419 struct vfs_aio_state *vfs_aio_state)
421 struct skel_fsync_state *state =
422 tevent_req_data(req, struct skel_fsync_state);
424 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
427 *vfs_aio_state = state->vfs_aio_state;
431 static int skel_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
433 return SMB_VFS_NEXT_STAT(handle, smb_fname);
436 static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp,
437 SMB_STRUCT_STAT *sbuf)
439 return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
442 static int skel_lstat(vfs_handle_struct *handle,
443 struct smb_filename *smb_fname)
445 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
448 static uint64_t skel_get_alloc_size(struct vfs_handle_struct *handle,
449 struct files_struct *fsp,
450 const SMB_STRUCT_STAT *sbuf)
452 return SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
455 static int skel_unlink(vfs_handle_struct *handle,
456 const struct smb_filename *smb_fname)
458 return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
461 static int skel_chmod(vfs_handle_struct *handle,
462 const struct smb_filename *smb_fname,
465 return SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
468 static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp,
471 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
474 static int skel_chown(vfs_handle_struct *handle,
475 const struct smb_filename *smb_fname,
479 return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
482 static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp,
483 uid_t uid, gid_t gid)
485 return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
488 static int skel_lchown(vfs_handle_struct *handle,
489 const struct smb_filename *smb_fname,
493 return SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
496 static int skel_chdir(vfs_handle_struct *handle,
497 const struct smb_filename *smb_fname)
499 return SMB_VFS_NEXT_CHDIR(handle, smb_fname);
502 static struct smb_filename *skel_getwd(vfs_handle_struct *handle,
505 return SMB_VFS_NEXT_GETWD(handle, ctx);
508 static int skel_ntimes(vfs_handle_struct *handle,
509 const struct smb_filename *smb_fname,
510 struct smb_file_time *ft)
512 return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
515 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
518 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
521 static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
522 uint32_t mode, off_t offset, off_t len)
524 return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
527 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op,
528 off_t offset, off_t count, int type)
530 return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
533 static int skel_kernel_flock(struct vfs_handle_struct *handle,
534 struct files_struct *fsp, uint32_t share_mode,
535 uint32_t access_mask)
537 return SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
540 static int skel_linux_setlease(struct vfs_handle_struct *handle,
541 struct files_struct *fsp, int leasetype)
543 return SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
546 static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp,
547 off_t *poffset, off_t *pcount, int *ptype,
550 return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
553 static int skel_symlink(vfs_handle_struct *handle,
554 const char *link_contents,
555 const struct smb_filename *new_smb_fname)
557 return SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
560 static int skel_vfs_readlink(vfs_handle_struct *handle,
561 const struct smb_filename *smb_fname,
565 return SMB_VFS_NEXT_READLINK(handle, smb_fname, buf, bufsiz);
568 static int skel_link(vfs_handle_struct *handle,
569 const struct smb_filename *old_smb_fname,
570 const struct smb_filename *new_smb_fname)
572 return SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
575 static int skel_mknod(vfs_handle_struct *handle,
576 const struct smb_filename *smb_fname,
580 return SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
583 static struct smb_filename *skel_realpath(vfs_handle_struct *handle,
585 const struct smb_filename *smb_fname)
587 return SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
590 static int skel_chflags(vfs_handle_struct *handle,
591 const struct smb_filename *smb_fname,
594 return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
597 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
598 const SMB_STRUCT_STAT *sbuf)
600 return SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
603 struct skel_offload_read_state {
604 struct vfs_handle_struct *handle;
608 static void skel_offload_read_done(struct tevent_req *subreq);
610 static struct tevent_req *skel_offload_read_send(
612 struct tevent_context *ev,
613 struct vfs_handle_struct *handle,
614 struct files_struct *fsp,
620 struct tevent_req *req = NULL;
621 struct skel_offload_read_state *state = NULL;
622 struct tevent_req *subreq = NULL;
624 req = tevent_req_create(mem_ctx, &state, struct skel_offload_read_state);
628 *state = (struct skel_offload_read_state) {
632 subreq = SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx, ev, handle, fsp,
633 fsctl, ttl, offset, to_copy);
634 if (tevent_req_nomem(subreq, req)) {
635 return tevent_req_post(req, ev);
637 tevent_req_set_callback(subreq, skel_offload_read_done, req);
641 static void skel_offload_read_done(struct tevent_req *subreq)
643 struct tevent_req *req = tevent_req_callback_data(
644 subreq, struct tevent_req);
645 struct skel_offload_read_state *state = tevent_req_data(
646 req, struct skel_offload_read_state);
649 status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(subreq,
654 if (tevent_req_nterror(req, status)) {
658 tevent_req_done(req);
662 static NTSTATUS skel_offload_read_recv(struct tevent_req *req,
663 struct vfs_handle_struct *handle,
667 struct skel_offload_read_state *state = tevent_req_data(
668 req, struct skel_offload_read_state);
672 if (tevent_req_is_nterror(req, &status)) {
673 tevent_req_received(req);
677 token = data_blob_talloc(mem_ctx,
679 state->token.length);
681 tevent_req_received(req);
683 if (token.data == NULL) {
684 return NT_STATUS_NO_MEMORY;
691 struct skel_offload_write_state {
692 struct vfs_handle_struct *handle;
695 static void skel_offload_write_done(struct tevent_req *subreq);
697 static struct tevent_req *skel_offload_write_send(struct vfs_handle_struct *handle,
699 struct tevent_context *ev,
702 off_t transfer_offset,
703 struct files_struct *dest_fsp,
707 struct tevent_req *req;
708 struct tevent_req *subreq;
709 struct skel_offload_write_state *state;
711 req = tevent_req_create(mem_ctx, &state, struct skel_offload_write_state);
716 state->handle = handle;
717 subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle, state, ev,
718 fsctl, token, transfer_offset,
719 dest_fsp, dest_off, num);
720 if (tevent_req_nomem(subreq, req)) {
721 return tevent_req_post(req, ev);
724 tevent_req_set_callback(subreq, skel_offload_write_done, req);
728 static void skel_offload_write_done(struct tevent_req *subreq)
730 struct tevent_req *req = tevent_req_callback_data(
731 subreq, struct tevent_req);
732 struct skel_offload_write_state *state
733 = tevent_req_data(req, struct skel_offload_write_state);
736 status = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(state->handle,
740 if (tevent_req_nterror(req, status)) {
743 tevent_req_done(req);
746 static NTSTATUS skel_offload_write_recv(struct vfs_handle_struct *handle,
747 struct tevent_req *req,
750 struct skel_offload_write_state *state
751 = tevent_req_data(req, struct skel_offload_write_state);
754 *copied = state->copied;
755 if (tevent_req_is_nterror(req, &status)) {
756 tevent_req_received(req);
760 tevent_req_received(req);
764 static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
766 struct files_struct *fsp,
767 struct smb_filename *smb_fname,
768 uint16_t *_compression_fmt)
770 return SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
774 static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
776 struct files_struct *fsp,
777 uint16_t compression_fmt)
779 return SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
783 static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
784 struct files_struct *fsp,
785 const struct smb_filename *smb_fname,
787 unsigned int *num_streams,
788 struct stream_struct **streams)
790 return SMB_VFS_NEXT_STREAMINFO(handle,
798 static int skel_get_real_filename(struct vfs_handle_struct *handle,
801 TALLOC_CTX *mem_ctx, char **found_name)
803 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle,
804 path, name, mem_ctx, found_name);
807 static const char *skel_connectpath(struct vfs_handle_struct *handle,
808 const struct smb_filename *smb_fname)
810 return SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
813 static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
814 struct byte_range_lock *br_lck,
815 struct lock_struct *plock,
818 return SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle,
819 br_lck, plock, blocking_lock);
822 static bool skel_brl_unlock_windows(struct vfs_handle_struct *handle,
823 struct messaging_context *msg_ctx,
824 struct byte_range_lock *br_lck,
825 const struct lock_struct *plock)
827 return SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck, plock);
830 static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
831 struct byte_range_lock *br_lck,
832 struct lock_struct *plock)
834 return SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
837 static bool skel_strict_lock_check(struct vfs_handle_struct *handle,
838 struct files_struct *fsp,
839 struct lock_struct *plock)
841 return SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
844 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
845 const char *mapped_name,
846 enum vfs_translate_direction direction,
847 TALLOC_CTX *mem_ctx, char **pmapped_name)
849 return SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction,
850 mem_ctx, pmapped_name);
853 static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
854 struct files_struct *fsp,
857 uint16_t req_flags, /* Needed for UNICODE ... */
858 const uint8_t *_in_data,
860 uint8_t ** _out_data,
861 uint32_t max_out_len, uint32_t *out_len)
863 return SMB_VFS_NEXT_FSCTL(handle,
869 in_len, _out_data, max_out_len, out_len);
872 static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
873 const struct smb_filename *fname,
875 struct readdir_attr_data **pattr_data)
877 return SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
880 static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
881 struct smb_filename *smb_fname,
884 return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
889 struct skel_get_dos_attributes_state {
890 struct vfs_aio_state aio_state;
894 static void skel_get_dos_attributes_done(struct tevent_req *subreq);
896 static struct tevent_req *skel_get_dos_attributes_send(
898 const struct smb_vfs_ev_glue *evg,
899 struct vfs_handle_struct *handle,
900 files_struct *dir_fsp,
901 struct smb_filename *smb_fname)
903 struct tevent_context *ev = smb_vfs_ev_glue_ev_ctx(evg);
904 struct tevent_req *req = NULL;
905 struct skel_get_dos_attributes_state *state = NULL;
906 struct tevent_req *subreq = NULL;
908 req = tevent_req_create(mem_ctx, &state,
909 struct skel_get_dos_attributes_state);
914 subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
919 if (tevent_req_nomem(subreq, req)) {
920 return tevent_req_post(req, ev);
922 tevent_req_set_callback(subreq, skel_get_dos_attributes_done, req);
927 static void skel_get_dos_attributes_done(struct tevent_req *subreq)
929 struct tevent_req *req =
930 tevent_req_callback_data(subreq,
932 struct skel_get_dos_attributes_state *state =
934 struct skel_get_dos_attributes_state);
937 status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
941 if (tevent_req_nterror(req, status)) {
945 tevent_req_done(req);
949 static NTSTATUS skel_get_dos_attributes_recv(struct tevent_req *req,
950 struct vfs_aio_state *aio_state,
953 struct skel_get_dos_attributes_state *state =
955 struct skel_get_dos_attributes_state);
958 if (tevent_req_is_nterror(req, &status)) {
959 tevent_req_received(req);
963 *aio_state = state->aio_state;
964 *dosmode = state->dosmode;
965 tevent_req_received(req);
969 static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
970 struct files_struct *fsp,
973 return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
978 static NTSTATUS skel_set_dos_attributes(struct vfs_handle_struct *handle,
979 const struct smb_filename *smb_fname,
982 return SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
987 static NTSTATUS skel_fset_dos_attributes(struct vfs_handle_struct *handle,
988 struct files_struct *fsp,
991 return SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
996 static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
997 uint32_t security_info,
999 struct security_descriptor **ppdesc)
1001 return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, mem_ctx,
1005 static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle,
1006 const struct smb_filename *smb_fname,
1007 uint32_t security_info,
1008 TALLOC_CTX *mem_ctx,
1009 struct security_descriptor **ppdesc)
1011 return SMB_VFS_NEXT_GET_NT_ACL(handle,
1018 static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1019 uint32_t security_info_sent,
1020 const struct security_descriptor *psd)
1022 return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1025 static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle,
1026 const struct smb_filename *smb_fname,
1027 SMB_ACL_TYPE_T type,
1028 TALLOC_CTX *mem_ctx)
1030 return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname, type, mem_ctx);
1033 static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
1034 files_struct *fsp, TALLOC_CTX *mem_ctx)
1036 return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
1039 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
1040 const struct smb_filename *smb_fname,
1041 TALLOC_CTX *mem_ctx,
1042 char **blob_description,
1045 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname, mem_ctx,
1046 blob_description, blob);
1049 static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
1050 files_struct *fsp, TALLOC_CTX *mem_ctx,
1051 char **blob_description, DATA_BLOB *blob)
1053 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx,
1054 blob_description, blob);
1057 static int skel_sys_acl_set_file(vfs_handle_struct *handle,
1058 const struct smb_filename *smb_fname,
1059 SMB_ACL_TYPE_T acltype,
1062 return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
1066 static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1069 return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1072 static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
1073 const struct smb_filename *smb_fname)
1075 return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
1078 static ssize_t skel_getxattr(vfs_handle_struct *handle,
1079 const struct smb_filename *smb_fname,
1084 return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
1087 struct skel_getxattrat_state {
1088 struct vfs_aio_state aio_state;
1090 uint8_t *xattr_value;
1093 static void skel_getxattrat_done(struct tevent_req *subreq);
1095 static struct tevent_req *skel_getxattrat_send(
1096 TALLOC_CTX *mem_ctx,
1097 struct tevent_context *ev,
1098 struct vfs_handle_struct *handle,
1099 files_struct *dir_fsp,
1100 const struct smb_filename *smb_fname,
1101 const char *xattr_name,
1104 struct tevent_req *req = NULL;
1105 struct skel_getxattrat_state *state = NULL;
1106 struct tevent_req *subreq = NULL;
1108 req = tevent_req_create(mem_ctx, &state,
1109 struct skel_getxattrat_state);
1114 subreq = SMB_VFS_NEXT_GETXATTRAT_SEND(state,
1121 if (tevent_req_nomem(subreq, req)) {
1122 return tevent_req_post(req, ev);
1124 tevent_req_set_callback(subreq, skel_getxattrat_done, req);
1129 static void skel_getxattrat_done(struct tevent_req *subreq)
1131 struct tevent_req *req = tevent_req_callback_data(
1132 subreq, struct tevent_req);
1133 struct skel_getxattrat_state *state = tevent_req_data(
1134 req, struct skel_getxattrat_state);
1136 state->xattr_size = SMB_VFS_NEXT_GETXATTRAT_RECV(subreq,
1139 &state->xattr_value);
1140 TALLOC_FREE(subreq);
1141 if (state->xattr_size == -1) {
1142 tevent_req_error(req, state->aio_state.error);
1146 tevent_req_done(req);
1149 static ssize_t skel_getxattrat_recv(struct tevent_req *req,
1150 struct vfs_aio_state *aio_state,
1151 TALLOC_CTX *mem_ctx,
1152 uint8_t **xattr_value)
1154 struct skel_getxattrat_state *state = tevent_req_data(
1155 req, struct skel_getxattrat_state);
1158 if (tevent_req_is_unix_error(req, &aio_state->error)) {
1159 tevent_req_received(req);
1163 *aio_state = state->aio_state;
1164 xattr_size = state->xattr_size;
1165 if (xattr_value != NULL) {
1166 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
1169 tevent_req_received(req);
1173 static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
1174 struct files_struct *fsp, const char *name,
1175 void *value, size_t size)
1177 return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1180 static ssize_t skel_listxattr(vfs_handle_struct *handle,
1181 const struct smb_filename *smb_fname,
1185 return SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
1188 static ssize_t skel_flistxattr(vfs_handle_struct *handle,
1189 struct files_struct *fsp, char *list,
1192 return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1195 static int skel_removexattr(vfs_handle_struct *handle,
1196 const struct smb_filename *smb_fname,
1199 return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
1202 static int skel_fremovexattr(vfs_handle_struct *handle,
1203 struct files_struct *fsp, const char *name)
1205 return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
1208 static int skel_setxattr(vfs_handle_struct *handle,
1209 const struct smb_filename *smb_fname,
1215 return SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
1216 name, value, size, flags);
1219 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
1220 const char *name, const void *value, size_t size,
1223 return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
1226 static bool skel_aio_force(struct vfs_handle_struct *handle,
1227 struct files_struct *fsp)
1229 return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
1232 static NTSTATUS skel_audit_file(struct vfs_handle_struct *handle,
1233 struct smb_filename *file,
1234 struct security_acl *sacl,
1235 uint32_t access_requested,
1236 uint32_t access_denied)
1238 return SMB_VFS_NEXT_AUDIT_FILE(handle,
1245 static NTSTATUS skel_durable_cookie(struct vfs_handle_struct *handle,
1246 struct files_struct *fsp,
1247 TALLOC_CTX *mem_ctx,
1250 return SMB_VFS_NEXT_DURABLE_COOKIE(handle,
1256 static NTSTATUS skel_durable_disconnect(struct vfs_handle_struct *handle,
1257 struct files_struct *fsp,
1258 const DATA_BLOB old_cookie,
1259 TALLOC_CTX *mem_ctx,
1260 DATA_BLOB *new_cookie)
1262 return SMB_VFS_NEXT_DURABLE_DISCONNECT(handle,
1269 static NTSTATUS skel_durable_reconnect(struct vfs_handle_struct *handle,
1270 struct smb_request *smb1req,
1271 struct smbXsrv_open *op,
1272 const DATA_BLOB old_cookie,
1273 TALLOC_CTX *mem_ctx,
1274 struct files_struct **fsp,
1275 DATA_BLOB *new_cookie)
1277 return SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
1286 /* VFS operations structure */
1288 static struct vfs_fn_pointers skel_transparent_fns = {
1289 /* Disk operations */
1291 .connect_fn = skel_connect,
1292 .disconnect_fn = skel_disconnect,
1293 .disk_free_fn = skel_disk_free,
1294 .get_quota_fn = skel_get_quota,
1295 .set_quota_fn = skel_set_quota,
1296 .get_shadow_copy_data_fn = skel_get_shadow_copy_data,
1297 .statvfs_fn = skel_statvfs,
1298 .fs_capabilities_fn = skel_fs_capabilities,
1299 .get_dfs_referrals_fn = skel_get_dfs_referrals,
1300 .snap_check_path_fn = skel_snap_check_path,
1301 .snap_create_fn = skel_snap_create,
1302 .snap_delete_fn = skel_snap_delete,
1304 /* Directory operations */
1306 .opendir_fn = skel_opendir,
1307 .fdopendir_fn = skel_fdopendir,
1308 .readdir_fn = skel_readdir,
1309 .seekdir_fn = skel_seekdir,
1310 .telldir_fn = skel_telldir,
1311 .rewind_dir_fn = skel_rewind_dir,
1312 .mkdir_fn = skel_mkdir,
1313 .rmdir_fn = skel_rmdir,
1314 .closedir_fn = skel_closedir,
1316 /* File operations */
1318 .open_fn = skel_open,
1319 .create_file_fn = skel_create_file,
1320 .close_fn = skel_close_fn,
1321 .pread_fn = skel_pread,
1322 .pread_send_fn = skel_pread_send,
1323 .pread_recv_fn = skel_pread_recv,
1324 .pwrite_fn = skel_pwrite,
1325 .pwrite_send_fn = skel_pwrite_send,
1326 .pwrite_recv_fn = skel_pwrite_recv,
1327 .lseek_fn = skel_lseek,
1328 .sendfile_fn = skel_sendfile,
1329 .recvfile_fn = skel_recvfile,
1330 .rename_fn = skel_rename,
1331 .fsync_send_fn = skel_fsync_send,
1332 .fsync_recv_fn = skel_fsync_recv,
1333 .stat_fn = skel_stat,
1334 .fstat_fn = skel_fstat,
1335 .lstat_fn = skel_lstat,
1336 .get_alloc_size_fn = skel_get_alloc_size,
1337 .unlink_fn = skel_unlink,
1338 .chmod_fn = skel_chmod,
1339 .fchmod_fn = skel_fchmod,
1340 .chown_fn = skel_chown,
1341 .fchown_fn = skel_fchown,
1342 .lchown_fn = skel_lchown,
1343 .chdir_fn = skel_chdir,
1344 .getwd_fn = skel_getwd,
1345 .ntimes_fn = skel_ntimes,
1346 .ftruncate_fn = skel_ftruncate,
1347 .fallocate_fn = skel_fallocate,
1348 .lock_fn = skel_lock,
1349 .kernel_flock_fn = skel_kernel_flock,
1350 .linux_setlease_fn = skel_linux_setlease,
1351 .getlock_fn = skel_getlock,
1352 .symlink_fn = skel_symlink,
1353 .readlink_fn = skel_vfs_readlink,
1354 .link_fn = skel_link,
1355 .mknod_fn = skel_mknod,
1356 .realpath_fn = skel_realpath,
1357 .chflags_fn = skel_chflags,
1358 .file_id_create_fn = skel_file_id_create,
1359 .offload_read_send_fn = skel_offload_read_send,
1360 .offload_read_recv_fn = skel_offload_read_recv,
1361 .offload_write_send_fn = skel_offload_write_send,
1362 .offload_write_recv_fn = skel_offload_write_recv,
1363 .get_compression_fn = skel_get_compression,
1364 .set_compression_fn = skel_set_compression,
1366 .streaminfo_fn = skel_streaminfo,
1367 .get_real_filename_fn = skel_get_real_filename,
1368 .connectpath_fn = skel_connectpath,
1369 .brl_lock_windows_fn = skel_brl_lock_windows,
1370 .brl_unlock_windows_fn = skel_brl_unlock_windows,
1371 .brl_cancel_windows_fn = skel_brl_cancel_windows,
1372 .strict_lock_check_fn = skel_strict_lock_check,
1373 .translate_name_fn = skel_translate_name,
1374 .fsctl_fn = skel_fsctl,
1375 .readdir_attr_fn = skel_readdir_attr,
1376 .audit_file_fn = skel_audit_file,
1378 /* DOS attributes. */
1379 .get_dos_attributes_fn = skel_get_dos_attributes,
1380 .get_dos_attributes_send_fn = skel_get_dos_attributes_send,
1381 .get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
1382 .fget_dos_attributes_fn = skel_fget_dos_attributes,
1383 .set_dos_attributes_fn = skel_set_dos_attributes,
1384 .fset_dos_attributes_fn = skel_fset_dos_attributes,
1386 /* NT ACL operations. */
1388 .fget_nt_acl_fn = skel_fget_nt_acl,
1389 .get_nt_acl_fn = skel_get_nt_acl,
1390 .fset_nt_acl_fn = skel_fset_nt_acl,
1392 /* POSIX ACL operations. */
1394 .sys_acl_get_file_fn = skel_sys_acl_get_file,
1395 .sys_acl_get_fd_fn = skel_sys_acl_get_fd,
1396 .sys_acl_blob_get_file_fn = skel_sys_acl_blob_get_file,
1397 .sys_acl_blob_get_fd_fn = skel_sys_acl_blob_get_fd,
1398 .sys_acl_set_file_fn = skel_sys_acl_set_file,
1399 .sys_acl_set_fd_fn = skel_sys_acl_set_fd,
1400 .sys_acl_delete_def_file_fn = skel_sys_acl_delete_def_file,
1402 /* EA operations. */
1403 .getxattr_fn = skel_getxattr,
1404 .getxattrat_send_fn = skel_getxattrat_send,
1405 .getxattrat_recv_fn = skel_getxattrat_recv,
1406 .fgetxattr_fn = skel_fgetxattr,
1407 .listxattr_fn = skel_listxattr,
1408 .flistxattr_fn = skel_flistxattr,
1409 .removexattr_fn = skel_removexattr,
1410 .fremovexattr_fn = skel_fremovexattr,
1411 .setxattr_fn = skel_setxattr,
1412 .fsetxattr_fn = skel_fsetxattr,
1414 /* aio operations */
1415 .aio_force_fn = skel_aio_force,
1417 /* durable handle operations */
1418 .durable_cookie_fn = skel_durable_cookie,
1419 .durable_disconnect_fn = skel_durable_disconnect,
1420 .durable_reconnect_fn = skel_durable_reconnect,
1424 NTSTATUS vfs_skel_transparent_init(TALLOC_CTX *ctx)
1427 * smb_vfs_assert_all_fns() is only needed in
1428 * order to have a complete example.
1430 * A transparent vfs module typically don't
1431 * need to implement every calls.
1433 smb_vfs_assert_all_fns(&skel_transparent_fns, "skel_transparent");
1434 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "skel_transparent",
1435 &skel_transparent_fns);