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 const 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_renameat(vfs_handle_struct *handle,
373 files_struct *srcfsp,
374 const struct smb_filename *smb_fname_src,
375 files_struct *dstfsp,
376 const struct smb_filename *smb_fname_dst)
378 return SMB_VFS_NEXT_RENAMEAT(handle,
385 struct skel_fsync_state {
387 struct vfs_aio_state vfs_aio_state;
390 static void skel_fsync_done(struct tevent_req *subreq);
392 static struct tevent_req *skel_fsync_send(struct vfs_handle_struct *handle,
394 struct tevent_context *ev,
395 struct files_struct *fsp)
397 struct tevent_req *req, *subreq;
398 struct skel_fsync_state *state;
400 req = tevent_req_create(mem_ctx, &state, struct skel_fsync_state);
404 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
405 if (tevent_req_nomem(subreq, req)) {
406 return tevent_req_post(req, ev);
408 tevent_req_set_callback(subreq, skel_fsync_done, req);
412 static void skel_fsync_done(struct tevent_req *subreq)
414 struct tevent_req *req =
415 tevent_req_callback_data(subreq, struct tevent_req);
416 struct skel_fsync_state *state =
417 tevent_req_data(req, struct skel_fsync_state);
419 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
421 tevent_req_done(req);
424 static int skel_fsync_recv(struct tevent_req *req,
425 struct vfs_aio_state *vfs_aio_state)
427 struct skel_fsync_state *state =
428 tevent_req_data(req, struct skel_fsync_state);
430 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
433 *vfs_aio_state = state->vfs_aio_state;
437 static int skel_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
439 return SMB_VFS_NEXT_STAT(handle, smb_fname);
442 static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp,
443 SMB_STRUCT_STAT *sbuf)
445 return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
448 static int skel_lstat(vfs_handle_struct *handle,
449 struct smb_filename *smb_fname)
451 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
454 static uint64_t skel_get_alloc_size(struct vfs_handle_struct *handle,
455 struct files_struct *fsp,
456 const SMB_STRUCT_STAT *sbuf)
458 return SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
461 static int skel_unlink(vfs_handle_struct *handle,
462 const struct smb_filename *smb_fname)
464 return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
467 static int skel_chmod(vfs_handle_struct *handle,
468 const struct smb_filename *smb_fname,
471 return SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
474 static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp,
477 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
480 static int skel_chown(vfs_handle_struct *handle,
481 const struct smb_filename *smb_fname,
485 return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
488 static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp,
489 uid_t uid, gid_t gid)
491 return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
494 static int skel_lchown(vfs_handle_struct *handle,
495 const struct smb_filename *smb_fname,
499 return SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
502 static int skel_chdir(vfs_handle_struct *handle,
503 const struct smb_filename *smb_fname)
505 return SMB_VFS_NEXT_CHDIR(handle, smb_fname);
508 static struct smb_filename *skel_getwd(vfs_handle_struct *handle,
511 return SMB_VFS_NEXT_GETWD(handle, ctx);
514 static int skel_ntimes(vfs_handle_struct *handle,
515 const struct smb_filename *smb_fname,
516 struct smb_file_time *ft)
518 return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
521 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
524 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
527 static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
528 uint32_t mode, off_t offset, off_t len)
530 return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
533 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op,
534 off_t offset, off_t count, int type)
536 return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
539 static int skel_kernel_flock(struct vfs_handle_struct *handle,
540 struct files_struct *fsp, uint32_t share_mode,
541 uint32_t access_mask)
543 return SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
546 static int skel_linux_setlease(struct vfs_handle_struct *handle,
547 struct files_struct *fsp, int leasetype)
549 return SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
552 static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp,
553 off_t *poffset, off_t *pcount, int *ptype,
556 return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
559 static int skel_symlink(vfs_handle_struct *handle,
560 const char *link_contents,
561 const struct smb_filename *new_smb_fname)
563 return SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
566 static int skel_vfs_readlinkat(vfs_handle_struct *handle,
567 files_struct *dirfsp,
568 const struct smb_filename *smb_fname,
572 return SMB_VFS_NEXT_READLINKAT(handle,
579 static int skel_linkat(vfs_handle_struct *handle,
580 files_struct *srcfsp,
581 const struct smb_filename *old_smb_fname,
582 files_struct *dstfsp,
583 const struct smb_filename *new_smb_fname,
586 return SMB_VFS_NEXT_LINKAT(handle,
594 static int skel_mknodat(vfs_handle_struct *handle,
595 files_struct *dirfsp,
596 const struct smb_filename *smb_fname,
600 return SMB_VFS_NEXT_MKNODAT(handle,
607 static struct smb_filename *skel_realpath(vfs_handle_struct *handle,
609 const struct smb_filename *smb_fname)
611 return SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
614 static int skel_chflags(vfs_handle_struct *handle,
615 const struct smb_filename *smb_fname,
618 return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
621 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
622 const SMB_STRUCT_STAT *sbuf)
624 return SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
627 static uint64_t skel_fs_file_id(vfs_handle_struct *handle,
628 const SMB_STRUCT_STAT *sbuf)
630 return SMB_VFS_NEXT_FS_FILE_ID(handle, sbuf);
633 struct skel_offload_read_state {
634 struct vfs_handle_struct *handle;
638 static void skel_offload_read_done(struct tevent_req *subreq);
640 static struct tevent_req *skel_offload_read_send(
642 struct tevent_context *ev,
643 struct vfs_handle_struct *handle,
644 struct files_struct *fsp,
650 struct tevent_req *req = NULL;
651 struct skel_offload_read_state *state = NULL;
652 struct tevent_req *subreq = NULL;
654 req = tevent_req_create(mem_ctx, &state, struct skel_offload_read_state);
658 *state = (struct skel_offload_read_state) {
662 subreq = SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx, ev, handle, fsp,
663 fsctl, ttl, offset, to_copy);
664 if (tevent_req_nomem(subreq, req)) {
665 return tevent_req_post(req, ev);
667 tevent_req_set_callback(subreq, skel_offload_read_done, req);
671 static void skel_offload_read_done(struct tevent_req *subreq)
673 struct tevent_req *req = tevent_req_callback_data(
674 subreq, struct tevent_req);
675 struct skel_offload_read_state *state = tevent_req_data(
676 req, struct skel_offload_read_state);
679 status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(subreq,
684 if (tevent_req_nterror(req, status)) {
688 tevent_req_done(req);
692 static NTSTATUS skel_offload_read_recv(struct tevent_req *req,
693 struct vfs_handle_struct *handle,
697 struct skel_offload_read_state *state = tevent_req_data(
698 req, struct skel_offload_read_state);
702 if (tevent_req_is_nterror(req, &status)) {
703 tevent_req_received(req);
707 token = data_blob_talloc(mem_ctx,
709 state->token.length);
711 tevent_req_received(req);
713 if (token.data == NULL) {
714 return NT_STATUS_NO_MEMORY;
721 struct skel_offload_write_state {
722 struct vfs_handle_struct *handle;
725 static void skel_offload_write_done(struct tevent_req *subreq);
727 static struct tevent_req *skel_offload_write_send(struct vfs_handle_struct *handle,
729 struct tevent_context *ev,
732 off_t transfer_offset,
733 struct files_struct *dest_fsp,
737 struct tevent_req *req;
738 struct tevent_req *subreq;
739 struct skel_offload_write_state *state;
741 req = tevent_req_create(mem_ctx, &state, struct skel_offload_write_state);
746 state->handle = handle;
747 subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle, state, ev,
748 fsctl, token, transfer_offset,
749 dest_fsp, dest_off, num);
750 if (tevent_req_nomem(subreq, req)) {
751 return tevent_req_post(req, ev);
754 tevent_req_set_callback(subreq, skel_offload_write_done, req);
758 static void skel_offload_write_done(struct tevent_req *subreq)
760 struct tevent_req *req = tevent_req_callback_data(
761 subreq, struct tevent_req);
762 struct skel_offload_write_state *state
763 = tevent_req_data(req, struct skel_offload_write_state);
766 status = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(state->handle,
770 if (tevent_req_nterror(req, status)) {
773 tevent_req_done(req);
776 static NTSTATUS skel_offload_write_recv(struct vfs_handle_struct *handle,
777 struct tevent_req *req,
780 struct skel_offload_write_state *state
781 = tevent_req_data(req, struct skel_offload_write_state);
784 *copied = state->copied;
785 if (tevent_req_is_nterror(req, &status)) {
786 tevent_req_received(req);
790 tevent_req_received(req);
794 static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
796 struct files_struct *fsp,
797 struct smb_filename *smb_fname,
798 uint16_t *_compression_fmt)
800 return SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
804 static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
806 struct files_struct *fsp,
807 uint16_t compression_fmt)
809 return SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
813 static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
814 struct files_struct *fsp,
815 const struct smb_filename *smb_fname,
817 unsigned int *num_streams,
818 struct stream_struct **streams)
820 return SMB_VFS_NEXT_STREAMINFO(handle,
828 static int skel_get_real_filename(struct vfs_handle_struct *handle,
831 TALLOC_CTX *mem_ctx, char **found_name)
833 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle,
834 path, name, mem_ctx, found_name);
837 static const char *skel_connectpath(struct vfs_handle_struct *handle,
838 const struct smb_filename *smb_fname)
840 return SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
843 static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
844 struct byte_range_lock *br_lck,
845 struct lock_struct *plock)
847 return SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock);
850 static bool skel_brl_unlock_windows(struct vfs_handle_struct *handle,
851 struct byte_range_lock *br_lck,
852 const struct lock_struct *plock)
854 return SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, br_lck, plock);
857 static bool skel_strict_lock_check(struct vfs_handle_struct *handle,
858 struct files_struct *fsp,
859 struct lock_struct *plock)
861 return SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
864 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
865 const char *mapped_name,
866 enum vfs_translate_direction direction,
867 TALLOC_CTX *mem_ctx, char **pmapped_name)
869 return SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction,
870 mem_ctx, pmapped_name);
873 static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
874 struct files_struct *fsp,
877 uint16_t req_flags, /* Needed for UNICODE ... */
878 const uint8_t *_in_data,
880 uint8_t ** _out_data,
881 uint32_t max_out_len, uint32_t *out_len)
883 return SMB_VFS_NEXT_FSCTL(handle,
889 in_len, _out_data, max_out_len, out_len);
892 static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
893 const struct smb_filename *fname,
895 struct readdir_attr_data **pattr_data)
897 return SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
900 static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
901 struct smb_filename *smb_fname,
904 return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
909 struct skel_get_dos_attributes_state {
910 struct vfs_aio_state aio_state;
914 static void skel_get_dos_attributes_done(struct tevent_req *subreq);
916 static struct tevent_req *skel_get_dos_attributes_send(
918 struct tevent_context *ev,
919 struct vfs_handle_struct *handle,
920 files_struct *dir_fsp,
921 struct smb_filename *smb_fname)
923 struct tevent_req *req = NULL;
924 struct skel_get_dos_attributes_state *state = NULL;
925 struct tevent_req *subreq = NULL;
927 req = tevent_req_create(mem_ctx, &state,
928 struct skel_get_dos_attributes_state);
933 subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
938 if (tevent_req_nomem(subreq, req)) {
939 return tevent_req_post(req, ev);
941 tevent_req_set_callback(subreq, skel_get_dos_attributes_done, req);
946 static void skel_get_dos_attributes_done(struct tevent_req *subreq)
948 struct tevent_req *req =
949 tevent_req_callback_data(subreq,
951 struct skel_get_dos_attributes_state *state =
953 struct skel_get_dos_attributes_state);
956 status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
960 if (tevent_req_nterror(req, status)) {
964 tevent_req_done(req);
968 static NTSTATUS skel_get_dos_attributes_recv(struct tevent_req *req,
969 struct vfs_aio_state *aio_state,
972 struct skel_get_dos_attributes_state *state =
974 struct skel_get_dos_attributes_state);
977 if (tevent_req_is_nterror(req, &status)) {
978 tevent_req_received(req);
982 *aio_state = state->aio_state;
983 *dosmode = state->dosmode;
984 tevent_req_received(req);
988 static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
989 struct files_struct *fsp,
992 return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
997 static NTSTATUS skel_set_dos_attributes(struct vfs_handle_struct *handle,
998 const struct smb_filename *smb_fname,
1001 return SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
1006 static NTSTATUS skel_fset_dos_attributes(struct vfs_handle_struct *handle,
1007 struct files_struct *fsp,
1010 return SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
1015 static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1016 uint32_t security_info,
1017 TALLOC_CTX *mem_ctx,
1018 struct security_descriptor **ppdesc)
1020 return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, mem_ctx,
1024 static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle,
1025 const struct smb_filename *smb_fname,
1026 uint32_t security_info,
1027 TALLOC_CTX *mem_ctx,
1028 struct security_descriptor **ppdesc)
1030 return SMB_VFS_NEXT_GET_NT_ACL(handle,
1037 static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1038 uint32_t security_info_sent,
1039 const struct security_descriptor *psd)
1041 return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1044 static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle,
1045 const struct smb_filename *smb_fname,
1046 SMB_ACL_TYPE_T type,
1047 TALLOC_CTX *mem_ctx)
1049 return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname, type, mem_ctx);
1052 static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
1053 files_struct *fsp, TALLOC_CTX *mem_ctx)
1055 return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
1058 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
1059 const struct smb_filename *smb_fname,
1060 TALLOC_CTX *mem_ctx,
1061 char **blob_description,
1064 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname, mem_ctx,
1065 blob_description, blob);
1068 static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
1069 files_struct *fsp, TALLOC_CTX *mem_ctx,
1070 char **blob_description, DATA_BLOB *blob)
1072 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx,
1073 blob_description, blob);
1076 static int skel_sys_acl_set_file(vfs_handle_struct *handle,
1077 const struct smb_filename *smb_fname,
1078 SMB_ACL_TYPE_T acltype,
1081 return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
1085 static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1088 return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1091 static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
1092 const struct smb_filename *smb_fname)
1094 return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
1097 static ssize_t skel_getxattr(vfs_handle_struct *handle,
1098 const struct smb_filename *smb_fname,
1103 return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
1106 struct skel_getxattrat_state {
1107 struct vfs_aio_state aio_state;
1109 uint8_t *xattr_value;
1112 static void skel_getxattrat_done(struct tevent_req *subreq);
1114 static struct tevent_req *skel_getxattrat_send(
1115 TALLOC_CTX *mem_ctx,
1116 struct tevent_context *ev,
1117 struct vfs_handle_struct *handle,
1118 files_struct *dir_fsp,
1119 const struct smb_filename *smb_fname,
1120 const char *xattr_name,
1123 struct tevent_req *req = NULL;
1124 struct skel_getxattrat_state *state = NULL;
1125 struct tevent_req *subreq = NULL;
1127 req = tevent_req_create(mem_ctx, &state,
1128 struct skel_getxattrat_state);
1133 subreq = SMB_VFS_NEXT_GETXATTRAT_SEND(state,
1140 if (tevent_req_nomem(subreq, req)) {
1141 return tevent_req_post(req, ev);
1143 tevent_req_set_callback(subreq, skel_getxattrat_done, req);
1148 static void skel_getxattrat_done(struct tevent_req *subreq)
1150 struct tevent_req *req = tevent_req_callback_data(
1151 subreq, struct tevent_req);
1152 struct skel_getxattrat_state *state = tevent_req_data(
1153 req, struct skel_getxattrat_state);
1155 state->xattr_size = SMB_VFS_NEXT_GETXATTRAT_RECV(subreq,
1158 &state->xattr_value);
1159 TALLOC_FREE(subreq);
1160 if (state->xattr_size == -1) {
1161 tevent_req_error(req, state->aio_state.error);
1165 tevent_req_done(req);
1168 static ssize_t skel_getxattrat_recv(struct tevent_req *req,
1169 struct vfs_aio_state *aio_state,
1170 TALLOC_CTX *mem_ctx,
1171 uint8_t **xattr_value)
1173 struct skel_getxattrat_state *state = tevent_req_data(
1174 req, struct skel_getxattrat_state);
1177 if (tevent_req_is_unix_error(req, &aio_state->error)) {
1178 tevent_req_received(req);
1182 *aio_state = state->aio_state;
1183 xattr_size = state->xattr_size;
1184 if (xattr_value != NULL) {
1185 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
1188 tevent_req_received(req);
1192 static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
1193 struct files_struct *fsp, const char *name,
1194 void *value, size_t size)
1196 return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1199 static ssize_t skel_listxattr(vfs_handle_struct *handle,
1200 const struct smb_filename *smb_fname,
1204 return SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
1207 static ssize_t skel_flistxattr(vfs_handle_struct *handle,
1208 struct files_struct *fsp, char *list,
1211 return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1214 static int skel_removexattr(vfs_handle_struct *handle,
1215 const struct smb_filename *smb_fname,
1218 return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
1221 static int skel_fremovexattr(vfs_handle_struct *handle,
1222 struct files_struct *fsp, const char *name)
1224 return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
1227 static int skel_setxattr(vfs_handle_struct *handle,
1228 const struct smb_filename *smb_fname,
1234 return SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
1235 name, value, size, flags);
1238 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
1239 const char *name, const void *value, size_t size,
1242 return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
1245 static bool skel_aio_force(struct vfs_handle_struct *handle,
1246 struct files_struct *fsp)
1248 return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
1251 static NTSTATUS skel_audit_file(struct vfs_handle_struct *handle,
1252 struct smb_filename *file,
1253 struct security_acl *sacl,
1254 uint32_t access_requested,
1255 uint32_t access_denied)
1257 return SMB_VFS_NEXT_AUDIT_FILE(handle,
1264 static NTSTATUS skel_durable_cookie(struct vfs_handle_struct *handle,
1265 struct files_struct *fsp,
1266 TALLOC_CTX *mem_ctx,
1269 return SMB_VFS_NEXT_DURABLE_COOKIE(handle,
1275 static NTSTATUS skel_durable_disconnect(struct vfs_handle_struct *handle,
1276 struct files_struct *fsp,
1277 const DATA_BLOB old_cookie,
1278 TALLOC_CTX *mem_ctx,
1279 DATA_BLOB *new_cookie)
1281 return SMB_VFS_NEXT_DURABLE_DISCONNECT(handle,
1288 static NTSTATUS skel_durable_reconnect(struct vfs_handle_struct *handle,
1289 struct smb_request *smb1req,
1290 struct smbXsrv_open *op,
1291 const DATA_BLOB old_cookie,
1292 TALLOC_CTX *mem_ctx,
1293 struct files_struct **fsp,
1294 DATA_BLOB *new_cookie)
1296 return SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
1305 /* VFS operations structure */
1307 static struct vfs_fn_pointers skel_transparent_fns = {
1308 /* Disk operations */
1310 .connect_fn = skel_connect,
1311 .disconnect_fn = skel_disconnect,
1312 .disk_free_fn = skel_disk_free,
1313 .get_quota_fn = skel_get_quota,
1314 .set_quota_fn = skel_set_quota,
1315 .get_shadow_copy_data_fn = skel_get_shadow_copy_data,
1316 .statvfs_fn = skel_statvfs,
1317 .fs_capabilities_fn = skel_fs_capabilities,
1318 .get_dfs_referrals_fn = skel_get_dfs_referrals,
1319 .snap_check_path_fn = skel_snap_check_path,
1320 .snap_create_fn = skel_snap_create,
1321 .snap_delete_fn = skel_snap_delete,
1323 /* Directory operations */
1325 .opendir_fn = skel_opendir,
1326 .fdopendir_fn = skel_fdopendir,
1327 .readdir_fn = skel_readdir,
1328 .seekdir_fn = skel_seekdir,
1329 .telldir_fn = skel_telldir,
1330 .rewind_dir_fn = skel_rewind_dir,
1331 .mkdir_fn = skel_mkdir,
1332 .rmdir_fn = skel_rmdir,
1333 .closedir_fn = skel_closedir,
1335 /* File operations */
1337 .open_fn = skel_open,
1338 .create_file_fn = skel_create_file,
1339 .close_fn = skel_close_fn,
1340 .pread_fn = skel_pread,
1341 .pread_send_fn = skel_pread_send,
1342 .pread_recv_fn = skel_pread_recv,
1343 .pwrite_fn = skel_pwrite,
1344 .pwrite_send_fn = skel_pwrite_send,
1345 .pwrite_recv_fn = skel_pwrite_recv,
1346 .lseek_fn = skel_lseek,
1347 .sendfile_fn = skel_sendfile,
1348 .recvfile_fn = skel_recvfile,
1349 .renameat_fn = skel_renameat,
1350 .fsync_send_fn = skel_fsync_send,
1351 .fsync_recv_fn = skel_fsync_recv,
1352 .stat_fn = skel_stat,
1353 .fstat_fn = skel_fstat,
1354 .lstat_fn = skel_lstat,
1355 .get_alloc_size_fn = skel_get_alloc_size,
1356 .unlink_fn = skel_unlink,
1357 .chmod_fn = skel_chmod,
1358 .fchmod_fn = skel_fchmod,
1359 .chown_fn = skel_chown,
1360 .fchown_fn = skel_fchown,
1361 .lchown_fn = skel_lchown,
1362 .chdir_fn = skel_chdir,
1363 .getwd_fn = skel_getwd,
1364 .ntimes_fn = skel_ntimes,
1365 .ftruncate_fn = skel_ftruncate,
1366 .fallocate_fn = skel_fallocate,
1367 .lock_fn = skel_lock,
1368 .kernel_flock_fn = skel_kernel_flock,
1369 .linux_setlease_fn = skel_linux_setlease,
1370 .getlock_fn = skel_getlock,
1371 .symlink_fn = skel_symlink,
1372 .readlinkat_fn = skel_vfs_readlinkat,
1373 .linkat_fn = skel_linkat,
1374 .mknodat_fn = skel_mknodat,
1375 .realpath_fn = skel_realpath,
1376 .chflags_fn = skel_chflags,
1377 .file_id_create_fn = skel_file_id_create,
1378 .fs_file_id_fn = skel_fs_file_id,
1379 .offload_read_send_fn = skel_offload_read_send,
1380 .offload_read_recv_fn = skel_offload_read_recv,
1381 .offload_write_send_fn = skel_offload_write_send,
1382 .offload_write_recv_fn = skel_offload_write_recv,
1383 .get_compression_fn = skel_get_compression,
1384 .set_compression_fn = skel_set_compression,
1386 .streaminfo_fn = skel_streaminfo,
1387 .get_real_filename_fn = skel_get_real_filename,
1388 .connectpath_fn = skel_connectpath,
1389 .brl_lock_windows_fn = skel_brl_lock_windows,
1390 .brl_unlock_windows_fn = skel_brl_unlock_windows,
1391 .strict_lock_check_fn = skel_strict_lock_check,
1392 .translate_name_fn = skel_translate_name,
1393 .fsctl_fn = skel_fsctl,
1394 .readdir_attr_fn = skel_readdir_attr,
1395 .audit_file_fn = skel_audit_file,
1397 /* DOS attributes. */
1398 .get_dos_attributes_fn = skel_get_dos_attributes,
1399 .get_dos_attributes_send_fn = skel_get_dos_attributes_send,
1400 .get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
1401 .fget_dos_attributes_fn = skel_fget_dos_attributes,
1402 .set_dos_attributes_fn = skel_set_dos_attributes,
1403 .fset_dos_attributes_fn = skel_fset_dos_attributes,
1405 /* NT ACL operations. */
1407 .fget_nt_acl_fn = skel_fget_nt_acl,
1408 .get_nt_acl_fn = skel_get_nt_acl,
1409 .fset_nt_acl_fn = skel_fset_nt_acl,
1411 /* POSIX ACL operations. */
1413 .sys_acl_get_file_fn = skel_sys_acl_get_file,
1414 .sys_acl_get_fd_fn = skel_sys_acl_get_fd,
1415 .sys_acl_blob_get_file_fn = skel_sys_acl_blob_get_file,
1416 .sys_acl_blob_get_fd_fn = skel_sys_acl_blob_get_fd,
1417 .sys_acl_set_file_fn = skel_sys_acl_set_file,
1418 .sys_acl_set_fd_fn = skel_sys_acl_set_fd,
1419 .sys_acl_delete_def_file_fn = skel_sys_acl_delete_def_file,
1421 /* EA operations. */
1422 .getxattr_fn = skel_getxattr,
1423 .getxattrat_send_fn = skel_getxattrat_send,
1424 .getxattrat_recv_fn = skel_getxattrat_recv,
1425 .fgetxattr_fn = skel_fgetxattr,
1426 .listxattr_fn = skel_listxattr,
1427 .flistxattr_fn = skel_flistxattr,
1428 .removexattr_fn = skel_removexattr,
1429 .fremovexattr_fn = skel_fremovexattr,
1430 .setxattr_fn = skel_setxattr,
1431 .fsetxattr_fn = skel_fsetxattr,
1433 /* aio operations */
1434 .aio_force_fn = skel_aio_force,
1436 /* durable handle operations */
1437 .durable_cookie_fn = skel_durable_cookie,
1438 .durable_disconnect_fn = skel_durable_disconnect,
1439 .durable_reconnect_fn = skel_durable_reconnect,
1443 NTSTATUS vfs_skel_transparent_init(TALLOC_CTX *ctx)
1446 * smb_vfs_assert_all_fns() is only needed in
1447 * order to have a complete example.
1449 * A transparent vfs module typically don't
1450 * need to implement every calls.
1452 smb_vfs_assert_all_fns(&skel_transparent_fns, "skel_transparent");
1453 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "skel_transparent",
1454 &skel_transparent_fns);