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 * necessary 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 NTSTATUS
skel_create_dfs_pathat(struct vfs_handle_struct
*handle
,
104 struct files_struct
*dirfsp
,
105 const struct smb_filename
*smb_fname
,
106 const struct referral
*reflist
,
107 size_t referral_count
)
109 return SMB_VFS_NEXT_CREATE_DFS_PATHAT(handle
,
116 static NTSTATUS
skel_read_dfs_pathat(struct vfs_handle_struct
*handle
,
118 struct files_struct
*dirfsp
,
119 struct smb_filename
*smb_fname
,
120 struct referral
**ppreflist
,
121 size_t *preferral_count
)
123 return SMB_VFS_NEXT_READ_DFS_PATHAT(handle
,
131 static NTSTATUS
skel_snap_check_path(struct vfs_handle_struct
*handle
,
133 const char *service_path
,
136 return SMB_VFS_NEXT_SNAP_CHECK_PATH(handle
, mem_ctx
, service_path
,
140 static NTSTATUS
skel_snap_create(struct vfs_handle_struct
*handle
,
142 const char *base_volume
,
148 return SMB_VFS_NEXT_SNAP_CREATE(handle
, mem_ctx
, base_volume
, tstamp
,
149 rw
, base_path
, snap_path
);
152 static NTSTATUS
skel_snap_delete(struct vfs_handle_struct
*handle
,
157 return SMB_VFS_NEXT_SNAP_DELETE(handle
, mem_ctx
, base_path
, snap_path
);
160 static DIR *skel_fdopendir(vfs_handle_struct
*handle
, files_struct
*fsp
,
161 const char *mask
, uint32_t attr
)
163 return SMB_VFS_NEXT_FDOPENDIR(handle
, fsp
, mask
, attr
);
166 static struct dirent
*skel_readdir(vfs_handle_struct
*handle
,
167 DIR *dirp
, SMB_STRUCT_STAT
*sbuf
)
169 return SMB_VFS_NEXT_READDIR(handle
, dirp
, sbuf
);
172 static void skel_seekdir(vfs_handle_struct
*handle
, DIR *dirp
, long offset
)
174 SMB_VFS_NEXT_SEEKDIR(handle
, dirp
, offset
);
177 static long skel_telldir(vfs_handle_struct
*handle
, DIR *dirp
)
179 return SMB_VFS_NEXT_TELLDIR(handle
, dirp
);
182 static void skel_rewind_dir(vfs_handle_struct
*handle
, DIR *dirp
)
184 SMB_VFS_NEXT_REWINDDIR(handle
, dirp
);
187 static int skel_mkdirat(vfs_handle_struct
*handle
,
188 struct files_struct
*dirfsp
,
189 const struct smb_filename
*smb_fname
,
192 return SMB_VFS_NEXT_MKDIRAT(handle
,
198 static int skel_closedir(vfs_handle_struct
*handle
, DIR *dir
)
200 return SMB_VFS_NEXT_CLOSEDIR(handle
, dir
);
203 static int skel_openat(struct vfs_handle_struct
*handle
,
204 const struct files_struct
*dirfsp
,
205 const struct smb_filename
*smb_fname
,
206 struct files_struct
*fsp
,
210 return SMB_VFS_NEXT_OPENAT(handle
, dirfsp
, smb_fname
, fsp
, flags
, mode
);
213 static NTSTATUS
skel_create_file(struct vfs_handle_struct
*handle
,
214 struct smb_request
*req
,
215 struct smb_filename
*smb_fname
,
216 uint32_t access_mask
,
217 uint32_t share_access
,
218 uint32_t create_disposition
,
219 uint32_t create_options
,
220 uint32_t file_attributes
,
221 uint32_t oplock_request
,
222 const struct smb2_lease
*lease
,
223 uint64_t allocation_size
,
224 uint32_t private_flags
,
225 struct security_descriptor
*sd
,
226 struct ea_list
*ea_list
,
227 files_struct
** result
, int *pinfo
,
228 const struct smb2_create_blobs
*in_context_blobs
,
229 struct smb2_create_blobs
*out_context_blobs
)
231 return SMB_VFS_NEXT_CREATE_FILE(handle
,
243 sd
, ea_list
, result
, pinfo
,
244 in_context_blobs
, out_context_blobs
);
247 static int skel_close_fn(vfs_handle_struct
*handle
, files_struct
*fsp
)
249 return SMB_VFS_NEXT_CLOSE(handle
, fsp
);
252 static ssize_t
skel_pread(vfs_handle_struct
*handle
, files_struct
*fsp
,
253 void *data
, size_t n
, off_t offset
)
255 return SMB_VFS_NEXT_PREAD(handle
, fsp
, data
, n
, offset
);
258 struct skel_pread_state
{
260 struct vfs_aio_state vfs_aio_state
;
263 static void skel_pread_done(struct tevent_req
*subreq
);
265 static struct tevent_req
*skel_pread_send(struct vfs_handle_struct
*handle
,
267 struct tevent_context
*ev
,
268 struct files_struct
*fsp
,
269 void *data
, size_t n
, off_t offset
)
271 struct tevent_req
*req
, *subreq
;
272 struct skel_pread_state
*state
;
274 req
= tevent_req_create(mem_ctx
, &state
, struct skel_pread_state
);
278 subreq
= SMB_VFS_NEXT_PREAD_SEND(state
, ev
, handle
, fsp
, data
,
280 if (tevent_req_nomem(subreq
, req
)) {
281 return tevent_req_post(req
, ev
);
283 tevent_req_set_callback(subreq
, skel_pread_done
, req
);
287 static void skel_pread_done(struct tevent_req
*subreq
)
289 struct tevent_req
*req
=
290 tevent_req_callback_data(subreq
, struct tevent_req
);
291 struct skel_pread_state
*state
=
292 tevent_req_data(req
, struct skel_pread_state
);
294 state
->ret
= SMB_VFS_PREAD_RECV(subreq
, &state
->vfs_aio_state
);
296 tevent_req_done(req
);
299 static ssize_t
skel_pread_recv(struct tevent_req
*req
,
300 struct vfs_aio_state
*vfs_aio_state
)
302 struct skel_pread_state
*state
=
303 tevent_req_data(req
, struct skel_pread_state
);
305 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
308 *vfs_aio_state
= state
->vfs_aio_state
;
312 static ssize_t
skel_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
,
313 const void *data
, size_t n
, off_t offset
)
315 return SMB_VFS_NEXT_PWRITE(handle
, fsp
, data
, n
, offset
);
318 struct skel_pwrite_state
{
320 struct vfs_aio_state vfs_aio_state
;
323 static void skel_pwrite_done(struct tevent_req
*subreq
);
325 static struct tevent_req
*skel_pwrite_send(struct vfs_handle_struct
*handle
,
327 struct tevent_context
*ev
,
328 struct files_struct
*fsp
,
330 size_t n
, off_t offset
)
332 struct tevent_req
*req
, *subreq
;
333 struct skel_pwrite_state
*state
;
335 req
= tevent_req_create(mem_ctx
, &state
, struct skel_pwrite_state
);
339 subreq
= SMB_VFS_NEXT_PWRITE_SEND(state
, ev
, handle
, fsp
, data
,
341 if (tevent_req_nomem(subreq
, req
)) {
342 return tevent_req_post(req
, ev
);
344 tevent_req_set_callback(subreq
, skel_pwrite_done
, req
);
348 static void skel_pwrite_done(struct tevent_req
*subreq
)
350 struct tevent_req
*req
=
351 tevent_req_callback_data(subreq
, struct tevent_req
);
352 struct skel_pwrite_state
*state
=
353 tevent_req_data(req
, struct skel_pwrite_state
);
355 state
->ret
= SMB_VFS_PWRITE_RECV(subreq
, &state
->vfs_aio_state
);
357 tevent_req_done(req
);
360 static ssize_t
skel_pwrite_recv(struct tevent_req
*req
,
361 struct vfs_aio_state
*vfs_aio_state
)
363 struct skel_pwrite_state
*state
=
364 tevent_req_data(req
, struct skel_pwrite_state
);
366 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
369 *vfs_aio_state
= state
->vfs_aio_state
;
373 static off_t
skel_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
,
374 off_t offset
, int whence
)
376 return SMB_VFS_NEXT_LSEEK(handle
, fsp
, offset
, whence
);
379 static ssize_t
skel_sendfile(vfs_handle_struct
*handle
, int tofd
,
380 files_struct
*fromfsp
, const DATA_BLOB
*hdr
,
381 off_t offset
, size_t n
)
383 return SMB_VFS_NEXT_SENDFILE(handle
, tofd
, fromfsp
, hdr
, offset
, n
);
386 static ssize_t
skel_recvfile(vfs_handle_struct
*handle
, int fromfd
,
387 files_struct
*tofsp
, off_t offset
, size_t n
)
389 return SMB_VFS_NEXT_RECVFILE(handle
, fromfd
, tofsp
, offset
, n
);
392 static int skel_renameat(vfs_handle_struct
*handle
,
393 files_struct
*srcfsp
,
394 const struct smb_filename
*smb_fname_src
,
395 files_struct
*dstfsp
,
396 const struct smb_filename
*smb_fname_dst
)
398 return SMB_VFS_NEXT_RENAMEAT(handle
,
405 struct skel_fsync_state
{
407 struct vfs_aio_state vfs_aio_state
;
410 static void skel_fsync_done(struct tevent_req
*subreq
);
412 static struct tevent_req
*skel_fsync_send(struct vfs_handle_struct
*handle
,
414 struct tevent_context
*ev
,
415 struct files_struct
*fsp
)
417 struct tevent_req
*req
, *subreq
;
418 struct skel_fsync_state
*state
;
420 req
= tevent_req_create(mem_ctx
, &state
, struct skel_fsync_state
);
424 subreq
= SMB_VFS_NEXT_FSYNC_SEND(state
, ev
, handle
, fsp
);
425 if (tevent_req_nomem(subreq
, req
)) {
426 return tevent_req_post(req
, ev
);
428 tevent_req_set_callback(subreq
, skel_fsync_done
, req
);
432 static void skel_fsync_done(struct tevent_req
*subreq
)
434 struct tevent_req
*req
=
435 tevent_req_callback_data(subreq
, struct tevent_req
);
436 struct skel_fsync_state
*state
=
437 tevent_req_data(req
, struct skel_fsync_state
);
439 state
->ret
= SMB_VFS_FSYNC_RECV(subreq
, &state
->vfs_aio_state
);
441 tevent_req_done(req
);
444 static int skel_fsync_recv(struct tevent_req
*req
,
445 struct vfs_aio_state
*vfs_aio_state
)
447 struct skel_fsync_state
*state
=
448 tevent_req_data(req
, struct skel_fsync_state
);
450 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
453 *vfs_aio_state
= state
->vfs_aio_state
;
457 static int skel_stat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
459 return SMB_VFS_NEXT_STAT(handle
, smb_fname
);
462 static int skel_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
,
463 SMB_STRUCT_STAT
*sbuf
)
465 return SMB_VFS_NEXT_FSTAT(handle
, fsp
, sbuf
);
468 static int skel_lstat(vfs_handle_struct
*handle
,
469 struct smb_filename
*smb_fname
)
471 return SMB_VFS_NEXT_LSTAT(handle
, smb_fname
);
474 static uint64_t skel_get_alloc_size(struct vfs_handle_struct
*handle
,
475 struct files_struct
*fsp
,
476 const SMB_STRUCT_STAT
*sbuf
)
478 return SMB_VFS_NEXT_GET_ALLOC_SIZE(handle
, fsp
, sbuf
);
481 static int skel_unlinkat(vfs_handle_struct
*handle
,
482 struct files_struct
*dirfsp
,
483 const struct smb_filename
*smb_fname
,
486 return SMB_VFS_NEXT_UNLINKAT(handle
,
492 static int skel_chmod(vfs_handle_struct
*handle
,
493 const struct smb_filename
*smb_fname
,
496 return SMB_VFS_NEXT_CHMOD(handle
, smb_fname
, mode
);
499 static int skel_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
,
502 return SMB_VFS_NEXT_FCHMOD(handle
, fsp
, mode
);
505 static int skel_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
,
506 uid_t uid
, gid_t gid
)
508 return SMB_VFS_NEXT_FCHOWN(handle
, fsp
, uid
, gid
);
511 static int skel_lchown(vfs_handle_struct
*handle
,
512 const struct smb_filename
*smb_fname
,
516 return SMB_VFS_NEXT_LCHOWN(handle
, smb_fname
, uid
, gid
);
519 static int skel_chdir(vfs_handle_struct
*handle
,
520 const struct smb_filename
*smb_fname
)
522 return SMB_VFS_NEXT_CHDIR(handle
, smb_fname
);
525 static struct smb_filename
*skel_getwd(vfs_handle_struct
*handle
,
528 return SMB_VFS_NEXT_GETWD(handle
, ctx
);
531 static int skel_ntimes(vfs_handle_struct
*handle
,
532 const struct smb_filename
*smb_fname
,
533 struct smb_file_time
*ft
)
535 return SMB_VFS_NEXT_NTIMES(handle
, smb_fname
, ft
);
538 static int skel_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
,
541 return SMB_VFS_NEXT_FTRUNCATE(handle
, fsp
, offset
);
544 static int skel_fallocate(vfs_handle_struct
*handle
, files_struct
*fsp
,
545 uint32_t mode
, off_t offset
, off_t len
)
547 return SMB_VFS_NEXT_FALLOCATE(handle
, fsp
, mode
, offset
, len
);
550 static bool skel_lock(vfs_handle_struct
*handle
, files_struct
*fsp
, int op
,
551 off_t offset
, off_t count
, int type
)
553 return SMB_VFS_NEXT_LOCK(handle
, fsp
, op
, offset
, count
, type
);
556 static int skel_kernel_flock(struct vfs_handle_struct
*handle
,
557 struct files_struct
*fsp
, uint32_t share_mode
,
558 uint32_t access_mask
)
560 return SMB_VFS_NEXT_KERNEL_FLOCK(handle
, fsp
, share_mode
, access_mask
);
563 static int skel_fcntl(struct vfs_handle_struct
*handle
,
564 struct files_struct
*fsp
, int cmd
, va_list cmd_arg
)
570 va_copy(dup_cmd_arg
, cmd_arg
);
571 arg
= va_arg(dup_cmd_arg
, void *);
572 result
= SMB_VFS_NEXT_FCNTL(handle
, fsp
, cmd
, arg
);
578 static int skel_linux_setlease(struct vfs_handle_struct
*handle
,
579 struct files_struct
*fsp
, int leasetype
)
581 return SMB_VFS_NEXT_LINUX_SETLEASE(handle
, fsp
, leasetype
);
584 static bool skel_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
,
585 off_t
*poffset
, off_t
*pcount
, int *ptype
,
588 return SMB_VFS_NEXT_GETLOCK(handle
, fsp
, poffset
, pcount
, ptype
, ppid
);
591 static int skel_symlinkat(vfs_handle_struct
*handle
,
592 const struct smb_filename
*link_contents
,
593 struct files_struct
*dirfsp
,
594 const struct smb_filename
*new_smb_fname
)
596 return SMB_VFS_NEXT_SYMLINKAT(handle
,
602 static int skel_vfs_readlinkat(vfs_handle_struct
*handle
,
603 files_struct
*dirfsp
,
604 const struct smb_filename
*smb_fname
,
608 return SMB_VFS_NEXT_READLINKAT(handle
,
615 static int skel_linkat(vfs_handle_struct
*handle
,
616 files_struct
*srcfsp
,
617 const struct smb_filename
*old_smb_fname
,
618 files_struct
*dstfsp
,
619 const struct smb_filename
*new_smb_fname
,
622 return SMB_VFS_NEXT_LINKAT(handle
,
630 static int skel_mknodat(vfs_handle_struct
*handle
,
631 files_struct
*dirfsp
,
632 const struct smb_filename
*smb_fname
,
636 return SMB_VFS_NEXT_MKNODAT(handle
,
643 static struct smb_filename
*skel_realpath(vfs_handle_struct
*handle
,
645 const struct smb_filename
*smb_fname
)
647 return SMB_VFS_NEXT_REALPATH(handle
, ctx
, smb_fname
);
650 static int skel_chflags(vfs_handle_struct
*handle
,
651 const struct smb_filename
*smb_fname
,
654 return SMB_VFS_NEXT_CHFLAGS(handle
, smb_fname
, flags
);
657 static struct file_id
skel_file_id_create(vfs_handle_struct
*handle
,
658 const SMB_STRUCT_STAT
*sbuf
)
660 return SMB_VFS_NEXT_FILE_ID_CREATE(handle
, sbuf
);
663 static uint64_t skel_fs_file_id(vfs_handle_struct
*handle
,
664 const SMB_STRUCT_STAT
*sbuf
)
666 return SMB_VFS_NEXT_FS_FILE_ID(handle
, sbuf
);
669 struct skel_offload_read_state
{
670 struct vfs_handle_struct
*handle
;
674 static void skel_offload_read_done(struct tevent_req
*subreq
);
676 static struct tevent_req
*skel_offload_read_send(
678 struct tevent_context
*ev
,
679 struct vfs_handle_struct
*handle
,
680 struct files_struct
*fsp
,
686 struct tevent_req
*req
= NULL
;
687 struct skel_offload_read_state
*state
= NULL
;
688 struct tevent_req
*subreq
= NULL
;
690 req
= tevent_req_create(mem_ctx
, &state
, struct skel_offload_read_state
);
694 *state
= (struct skel_offload_read_state
) {
698 subreq
= SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx
, ev
, handle
, fsp
,
699 fsctl
, ttl
, offset
, to_copy
);
700 if (tevent_req_nomem(subreq
, req
)) {
701 return tevent_req_post(req
, ev
);
703 tevent_req_set_callback(subreq
, skel_offload_read_done
, req
);
707 static void skel_offload_read_done(struct tevent_req
*subreq
)
709 struct tevent_req
*req
= tevent_req_callback_data(
710 subreq
, struct tevent_req
);
711 struct skel_offload_read_state
*state
= tevent_req_data(
712 req
, struct skel_offload_read_state
);
715 status
= SMB_VFS_NEXT_OFFLOAD_READ_RECV(subreq
,
720 if (tevent_req_nterror(req
, status
)) {
724 tevent_req_done(req
);
728 static NTSTATUS
skel_offload_read_recv(struct tevent_req
*req
,
729 struct vfs_handle_struct
*handle
,
733 struct skel_offload_read_state
*state
= tevent_req_data(
734 req
, struct skel_offload_read_state
);
738 if (tevent_req_is_nterror(req
, &status
)) {
739 tevent_req_received(req
);
743 token
= data_blob_talloc(mem_ctx
,
745 state
->token
.length
);
747 tevent_req_received(req
);
749 if (token
.data
== NULL
) {
750 return NT_STATUS_NO_MEMORY
;
757 struct skel_offload_write_state
{
758 struct vfs_handle_struct
*handle
;
761 static void skel_offload_write_done(struct tevent_req
*subreq
);
763 static struct tevent_req
*skel_offload_write_send(struct vfs_handle_struct
*handle
,
765 struct tevent_context
*ev
,
768 off_t transfer_offset
,
769 struct files_struct
*dest_fsp
,
773 struct tevent_req
*req
;
774 struct tevent_req
*subreq
;
775 struct skel_offload_write_state
*state
;
777 req
= tevent_req_create(mem_ctx
, &state
, struct skel_offload_write_state
);
782 state
->handle
= handle
;
783 subreq
= SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle
, state
, ev
,
784 fsctl
, token
, transfer_offset
,
785 dest_fsp
, dest_off
, num
);
786 if (tevent_req_nomem(subreq
, req
)) {
787 return tevent_req_post(req
, ev
);
790 tevent_req_set_callback(subreq
, skel_offload_write_done
, req
);
794 static void skel_offload_write_done(struct tevent_req
*subreq
)
796 struct tevent_req
*req
= tevent_req_callback_data(
797 subreq
, struct tevent_req
);
798 struct skel_offload_write_state
*state
799 = tevent_req_data(req
, struct skel_offload_write_state
);
802 status
= SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(state
->handle
,
806 if (tevent_req_nterror(req
, status
)) {
809 tevent_req_done(req
);
812 static NTSTATUS
skel_offload_write_recv(struct vfs_handle_struct
*handle
,
813 struct tevent_req
*req
,
816 struct skel_offload_write_state
*state
817 = tevent_req_data(req
, struct skel_offload_write_state
);
820 *copied
= state
->copied
;
821 if (tevent_req_is_nterror(req
, &status
)) {
822 tevent_req_received(req
);
826 tevent_req_received(req
);
830 static NTSTATUS
skel_get_compression(struct vfs_handle_struct
*handle
,
832 struct files_struct
*fsp
,
833 struct smb_filename
*smb_fname
,
834 uint16_t *_compression_fmt
)
836 return SMB_VFS_NEXT_GET_COMPRESSION(handle
, mem_ctx
, fsp
, smb_fname
,
840 static NTSTATUS
skel_set_compression(struct vfs_handle_struct
*handle
,
842 struct files_struct
*fsp
,
843 uint16_t compression_fmt
)
845 return SMB_VFS_NEXT_SET_COMPRESSION(handle
, mem_ctx
, fsp
,
849 static NTSTATUS
skel_streaminfo(struct vfs_handle_struct
*handle
,
850 struct files_struct
*fsp
,
851 const struct smb_filename
*smb_fname
,
853 unsigned int *num_streams
,
854 struct stream_struct
**streams
)
856 return SMB_VFS_NEXT_STREAMINFO(handle
,
864 static int skel_get_real_filename(struct vfs_handle_struct
*handle
,
865 const struct smb_filename
*path
,
867 TALLOC_CTX
*mem_ctx
, char **found_name
)
869 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle
,
870 path
, name
, mem_ctx
, found_name
);
873 static const char *skel_connectpath(struct vfs_handle_struct
*handle
,
874 const struct smb_filename
*smb_fname
)
876 return SMB_VFS_NEXT_CONNECTPATH(handle
, smb_fname
);
879 static NTSTATUS
skel_brl_lock_windows(struct vfs_handle_struct
*handle
,
880 struct byte_range_lock
*br_lck
,
881 struct lock_struct
*plock
)
883 return SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle
, br_lck
, plock
);
886 static bool skel_brl_unlock_windows(struct vfs_handle_struct
*handle
,
887 struct byte_range_lock
*br_lck
,
888 const struct lock_struct
*plock
)
890 return SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle
, br_lck
, plock
);
893 static bool skel_strict_lock_check(struct vfs_handle_struct
*handle
,
894 struct files_struct
*fsp
,
895 struct lock_struct
*plock
)
897 return SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle
, fsp
, plock
);
900 static NTSTATUS
skel_translate_name(struct vfs_handle_struct
*handle
,
901 const char *mapped_name
,
902 enum vfs_translate_direction direction
,
903 TALLOC_CTX
*mem_ctx
, char **pmapped_name
)
905 return SMB_VFS_NEXT_TRANSLATE_NAME(handle
, mapped_name
, direction
,
906 mem_ctx
, pmapped_name
);
909 static NTSTATUS
skel_fsctl(struct vfs_handle_struct
*handle
,
910 struct files_struct
*fsp
,
913 uint16_t req_flags
, /* Needed for UNICODE ... */
914 const uint8_t *_in_data
,
916 uint8_t ** _out_data
,
917 uint32_t max_out_len
, uint32_t *out_len
)
919 return SMB_VFS_NEXT_FSCTL(handle
,
925 in_len
, _out_data
, max_out_len
, out_len
);
928 static NTSTATUS
skel_readdir_attr(struct vfs_handle_struct
*handle
,
929 const struct smb_filename
*fname
,
931 struct readdir_attr_data
**pattr_data
)
933 return SMB_VFS_NEXT_READDIR_ATTR(handle
, fname
, mem_ctx
, pattr_data
);
936 static NTSTATUS
skel_get_dos_attributes(struct vfs_handle_struct
*handle
,
937 struct smb_filename
*smb_fname
,
940 return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle
,
945 struct skel_get_dos_attributes_state
{
946 struct vfs_aio_state aio_state
;
950 static void skel_get_dos_attributes_done(struct tevent_req
*subreq
);
952 static struct tevent_req
*skel_get_dos_attributes_send(
954 struct tevent_context
*ev
,
955 struct vfs_handle_struct
*handle
,
956 files_struct
*dir_fsp
,
957 struct smb_filename
*smb_fname
)
959 struct tevent_req
*req
= NULL
;
960 struct skel_get_dos_attributes_state
*state
= NULL
;
961 struct tevent_req
*subreq
= NULL
;
963 req
= tevent_req_create(mem_ctx
, &state
,
964 struct skel_get_dos_attributes_state
);
969 subreq
= SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx
,
974 if (tevent_req_nomem(subreq
, req
)) {
975 return tevent_req_post(req
, ev
);
977 tevent_req_set_callback(subreq
, skel_get_dos_attributes_done
, req
);
982 static void skel_get_dos_attributes_done(struct tevent_req
*subreq
)
984 struct tevent_req
*req
=
985 tevent_req_callback_data(subreq
,
987 struct skel_get_dos_attributes_state
*state
=
989 struct skel_get_dos_attributes_state
);
992 status
= SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq
,
996 if (tevent_req_nterror(req
, status
)) {
1000 tevent_req_done(req
);
1004 static NTSTATUS
skel_get_dos_attributes_recv(struct tevent_req
*req
,
1005 struct vfs_aio_state
*aio_state
,
1008 struct skel_get_dos_attributes_state
*state
=
1009 tevent_req_data(req
,
1010 struct skel_get_dos_attributes_state
);
1013 if (tevent_req_is_nterror(req
, &status
)) {
1014 tevent_req_received(req
);
1018 *aio_state
= state
->aio_state
;
1019 *dosmode
= state
->dosmode
;
1020 tevent_req_received(req
);
1021 return NT_STATUS_OK
;
1024 static NTSTATUS
skel_fget_dos_attributes(struct vfs_handle_struct
*handle
,
1025 struct files_struct
*fsp
,
1028 return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle
,
1033 static NTSTATUS
skel_set_dos_attributes(struct vfs_handle_struct
*handle
,
1034 const struct smb_filename
*smb_fname
,
1037 return SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle
,
1042 static NTSTATUS
skel_fset_dos_attributes(struct vfs_handle_struct
*handle
,
1043 struct files_struct
*fsp
,
1046 return SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle
,
1051 static NTSTATUS
skel_fget_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1052 uint32_t security_info
,
1053 TALLOC_CTX
*mem_ctx
,
1054 struct security_descriptor
**ppdesc
)
1056 return SMB_VFS_NEXT_FGET_NT_ACL(handle
, fsp
, security_info
, mem_ctx
,
1060 static NTSTATUS
skel_get_nt_acl_at(vfs_handle_struct
*handle
,
1061 struct files_struct
*dirfsp
,
1062 const struct smb_filename
*smb_fname
,
1063 uint32_t security_info
,
1064 TALLOC_CTX
*mem_ctx
,
1065 struct security_descriptor
**ppdesc
)
1067 return SMB_VFS_NEXT_GET_NT_ACL_AT(handle
,
1075 static NTSTATUS
skel_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1076 uint32_t security_info_sent
,
1077 const struct security_descriptor
*psd
)
1079 return SMB_VFS_NEXT_FSET_NT_ACL(handle
, fsp
, security_info_sent
, psd
);
1082 static SMB_ACL_T
skel_sys_acl_get_file(vfs_handle_struct
*handle
,
1083 const struct smb_filename
*smb_fname
,
1084 SMB_ACL_TYPE_T type
,
1085 TALLOC_CTX
*mem_ctx
)
1087 return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle
, smb_fname
, type
, mem_ctx
);
1090 static SMB_ACL_T
skel_sys_acl_get_fd(vfs_handle_struct
*handle
,
1091 files_struct
*fsp
, TALLOC_CTX
*mem_ctx
)
1093 return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle
, fsp
, mem_ctx
);
1096 static int skel_sys_acl_blob_get_file(vfs_handle_struct
*handle
,
1097 const struct smb_filename
*smb_fname
,
1098 TALLOC_CTX
*mem_ctx
,
1099 char **blob_description
,
1102 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle
, smb_fname
, mem_ctx
,
1103 blob_description
, blob
);
1106 static int skel_sys_acl_blob_get_fd(vfs_handle_struct
*handle
,
1107 files_struct
*fsp
, TALLOC_CTX
*mem_ctx
,
1108 char **blob_description
, DATA_BLOB
*blob
)
1110 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle
, fsp
, mem_ctx
,
1111 blob_description
, blob
);
1114 static int skel_sys_acl_set_file(vfs_handle_struct
*handle
,
1115 const struct smb_filename
*smb_fname
,
1116 SMB_ACL_TYPE_T acltype
,
1119 return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle
, smb_fname
,
1123 static int skel_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
,
1126 return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle
, fsp
, theacl
);
1129 static int skel_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
1130 const struct smb_filename
*smb_fname
)
1132 return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle
, smb_fname
);
1135 static ssize_t
skel_getxattr(vfs_handle_struct
*handle
,
1136 const struct smb_filename
*smb_fname
,
1141 return SMB_VFS_NEXT_GETXATTR(handle
, smb_fname
, name
, value
, size
);
1144 struct skel_getxattrat_state
{
1145 struct vfs_aio_state aio_state
;
1147 uint8_t *xattr_value
;
1150 static void skel_getxattrat_done(struct tevent_req
*subreq
);
1152 static struct tevent_req
*skel_getxattrat_send(
1153 TALLOC_CTX
*mem_ctx
,
1154 struct tevent_context
*ev
,
1155 struct vfs_handle_struct
*handle
,
1156 files_struct
*dir_fsp
,
1157 const struct smb_filename
*smb_fname
,
1158 const char *xattr_name
,
1161 struct tevent_req
*req
= NULL
;
1162 struct skel_getxattrat_state
*state
= NULL
;
1163 struct tevent_req
*subreq
= NULL
;
1165 req
= tevent_req_create(mem_ctx
, &state
,
1166 struct skel_getxattrat_state
);
1171 subreq
= SMB_VFS_NEXT_GETXATTRAT_SEND(state
,
1178 if (tevent_req_nomem(subreq
, req
)) {
1179 return tevent_req_post(req
, ev
);
1181 tevent_req_set_callback(subreq
, skel_getxattrat_done
, req
);
1186 static void skel_getxattrat_done(struct tevent_req
*subreq
)
1188 struct tevent_req
*req
= tevent_req_callback_data(
1189 subreq
, struct tevent_req
);
1190 struct skel_getxattrat_state
*state
= tevent_req_data(
1191 req
, struct skel_getxattrat_state
);
1193 state
->xattr_size
= SMB_VFS_NEXT_GETXATTRAT_RECV(subreq
,
1196 &state
->xattr_value
);
1197 TALLOC_FREE(subreq
);
1198 if (state
->xattr_size
== -1) {
1199 tevent_req_error(req
, state
->aio_state
.error
);
1203 tevent_req_done(req
);
1206 static ssize_t
skel_getxattrat_recv(struct tevent_req
*req
,
1207 struct vfs_aio_state
*aio_state
,
1208 TALLOC_CTX
*mem_ctx
,
1209 uint8_t **xattr_value
)
1211 struct skel_getxattrat_state
*state
= tevent_req_data(
1212 req
, struct skel_getxattrat_state
);
1215 if (tevent_req_is_unix_error(req
, &aio_state
->error
)) {
1216 tevent_req_received(req
);
1220 *aio_state
= state
->aio_state
;
1221 xattr_size
= state
->xattr_size
;
1222 if (xattr_value
!= NULL
) {
1223 *xattr_value
= talloc_move(mem_ctx
, &state
->xattr_value
);
1226 tevent_req_received(req
);
1230 static ssize_t
skel_fgetxattr(vfs_handle_struct
*handle
,
1231 struct files_struct
*fsp
, const char *name
,
1232 void *value
, size_t size
)
1234 return SMB_VFS_NEXT_FGETXATTR(handle
, fsp
, name
, value
, size
);
1237 static ssize_t
skel_listxattr(vfs_handle_struct
*handle
,
1238 const struct smb_filename
*smb_fname
,
1242 return SMB_VFS_NEXT_LISTXATTR(handle
, smb_fname
, list
, size
);
1245 static ssize_t
skel_flistxattr(vfs_handle_struct
*handle
,
1246 struct files_struct
*fsp
, char *list
,
1249 return SMB_VFS_NEXT_FLISTXATTR(handle
, fsp
, list
, size
);
1252 static int skel_removexattr(vfs_handle_struct
*handle
,
1253 const struct smb_filename
*smb_fname
,
1256 return SMB_VFS_NEXT_REMOVEXATTR(handle
, smb_fname
, name
);
1259 static int skel_fremovexattr(vfs_handle_struct
*handle
,
1260 struct files_struct
*fsp
, const char *name
)
1262 return SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, name
);
1265 static int skel_setxattr(vfs_handle_struct
*handle
,
1266 const struct smb_filename
*smb_fname
,
1272 return SMB_VFS_NEXT_SETXATTR(handle
, smb_fname
,
1273 name
, value
, size
, flags
);
1276 static int skel_fsetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
,
1277 const char *name
, const void *value
, size_t size
,
1280 return SMB_VFS_NEXT_FSETXATTR(handle
, fsp
, name
, value
, size
, flags
);
1283 static bool skel_aio_force(struct vfs_handle_struct
*handle
,
1284 struct files_struct
*fsp
)
1286 return SMB_VFS_NEXT_AIO_FORCE(handle
, fsp
);
1289 static NTSTATUS
skel_audit_file(struct vfs_handle_struct
*handle
,
1290 struct smb_filename
*file
,
1291 struct security_acl
*sacl
,
1292 uint32_t access_requested
,
1293 uint32_t access_denied
)
1295 return SMB_VFS_NEXT_AUDIT_FILE(handle
,
1302 static NTSTATUS
skel_durable_cookie(struct vfs_handle_struct
*handle
,
1303 struct files_struct
*fsp
,
1304 TALLOC_CTX
*mem_ctx
,
1307 return SMB_VFS_NEXT_DURABLE_COOKIE(handle
,
1313 static NTSTATUS
skel_durable_disconnect(struct vfs_handle_struct
*handle
,
1314 struct files_struct
*fsp
,
1315 const DATA_BLOB old_cookie
,
1316 TALLOC_CTX
*mem_ctx
,
1317 DATA_BLOB
*new_cookie
)
1319 return SMB_VFS_NEXT_DURABLE_DISCONNECT(handle
,
1326 static NTSTATUS
skel_durable_reconnect(struct vfs_handle_struct
*handle
,
1327 struct smb_request
*smb1req
,
1328 struct smbXsrv_open
*op
,
1329 const DATA_BLOB old_cookie
,
1330 TALLOC_CTX
*mem_ctx
,
1331 struct files_struct
**fsp
,
1332 DATA_BLOB
*new_cookie
)
1334 return SMB_VFS_NEXT_DURABLE_RECONNECT(handle
,
1343 /* VFS operations structure */
1345 static struct vfs_fn_pointers skel_transparent_fns
= {
1346 /* Disk operations */
1348 .connect_fn
= skel_connect
,
1349 .disconnect_fn
= skel_disconnect
,
1350 .disk_free_fn
= skel_disk_free
,
1351 .get_quota_fn
= skel_get_quota
,
1352 .set_quota_fn
= skel_set_quota
,
1353 .get_shadow_copy_data_fn
= skel_get_shadow_copy_data
,
1354 .statvfs_fn
= skel_statvfs
,
1355 .fs_capabilities_fn
= skel_fs_capabilities
,
1356 .get_dfs_referrals_fn
= skel_get_dfs_referrals
,
1357 .create_dfs_pathat_fn
= skel_create_dfs_pathat
,
1358 .read_dfs_pathat_fn
= skel_read_dfs_pathat
,
1359 .snap_check_path_fn
= skel_snap_check_path
,
1360 .snap_create_fn
= skel_snap_create
,
1361 .snap_delete_fn
= skel_snap_delete
,
1363 /* Directory operations */
1365 .fdopendir_fn
= skel_fdopendir
,
1366 .readdir_fn
= skel_readdir
,
1367 .seekdir_fn
= skel_seekdir
,
1368 .telldir_fn
= skel_telldir
,
1369 .rewind_dir_fn
= skel_rewind_dir
,
1370 .mkdirat_fn
= skel_mkdirat
,
1371 .closedir_fn
= skel_closedir
,
1373 /* File operations */
1375 .openat_fn
= skel_openat
,
1376 .create_file_fn
= skel_create_file
,
1377 .close_fn
= skel_close_fn
,
1378 .pread_fn
= skel_pread
,
1379 .pread_send_fn
= skel_pread_send
,
1380 .pread_recv_fn
= skel_pread_recv
,
1381 .pwrite_fn
= skel_pwrite
,
1382 .pwrite_send_fn
= skel_pwrite_send
,
1383 .pwrite_recv_fn
= skel_pwrite_recv
,
1384 .lseek_fn
= skel_lseek
,
1385 .sendfile_fn
= skel_sendfile
,
1386 .recvfile_fn
= skel_recvfile
,
1387 .renameat_fn
= skel_renameat
,
1388 .fsync_send_fn
= skel_fsync_send
,
1389 .fsync_recv_fn
= skel_fsync_recv
,
1390 .stat_fn
= skel_stat
,
1391 .fstat_fn
= skel_fstat
,
1392 .lstat_fn
= skel_lstat
,
1393 .get_alloc_size_fn
= skel_get_alloc_size
,
1394 .unlinkat_fn
= skel_unlinkat
,
1395 .chmod_fn
= skel_chmod
,
1396 .fchmod_fn
= skel_fchmod
,
1397 .fchown_fn
= skel_fchown
,
1398 .lchown_fn
= skel_lchown
,
1399 .chdir_fn
= skel_chdir
,
1400 .getwd_fn
= skel_getwd
,
1401 .ntimes_fn
= skel_ntimes
,
1402 .ftruncate_fn
= skel_ftruncate
,
1403 .fallocate_fn
= skel_fallocate
,
1404 .lock_fn
= skel_lock
,
1405 .kernel_flock_fn
= skel_kernel_flock
,
1406 .fcntl_fn
= skel_fcntl
,
1407 .linux_setlease_fn
= skel_linux_setlease
,
1408 .getlock_fn
= skel_getlock
,
1409 .symlinkat_fn
= skel_symlinkat
,
1410 .readlinkat_fn
= skel_vfs_readlinkat
,
1411 .linkat_fn
= skel_linkat
,
1412 .mknodat_fn
= skel_mknodat
,
1413 .realpath_fn
= skel_realpath
,
1414 .chflags_fn
= skel_chflags
,
1415 .file_id_create_fn
= skel_file_id_create
,
1416 .fs_file_id_fn
= skel_fs_file_id
,
1417 .offload_read_send_fn
= skel_offload_read_send
,
1418 .offload_read_recv_fn
= skel_offload_read_recv
,
1419 .offload_write_send_fn
= skel_offload_write_send
,
1420 .offload_write_recv_fn
= skel_offload_write_recv
,
1421 .get_compression_fn
= skel_get_compression
,
1422 .set_compression_fn
= skel_set_compression
,
1424 .streaminfo_fn
= skel_streaminfo
,
1425 .get_real_filename_fn
= skel_get_real_filename
,
1426 .connectpath_fn
= skel_connectpath
,
1427 .brl_lock_windows_fn
= skel_brl_lock_windows
,
1428 .brl_unlock_windows_fn
= skel_brl_unlock_windows
,
1429 .strict_lock_check_fn
= skel_strict_lock_check
,
1430 .translate_name_fn
= skel_translate_name
,
1431 .fsctl_fn
= skel_fsctl
,
1432 .readdir_attr_fn
= skel_readdir_attr
,
1433 .audit_file_fn
= skel_audit_file
,
1435 /* DOS attributes. */
1436 .get_dos_attributes_fn
= skel_get_dos_attributes
,
1437 .get_dos_attributes_send_fn
= skel_get_dos_attributes_send
,
1438 .get_dos_attributes_recv_fn
= skel_get_dos_attributes_recv
,
1439 .fget_dos_attributes_fn
= skel_fget_dos_attributes
,
1440 .set_dos_attributes_fn
= skel_set_dos_attributes
,
1441 .fset_dos_attributes_fn
= skel_fset_dos_attributes
,
1443 /* NT ACL operations. */
1445 .fget_nt_acl_fn
= skel_fget_nt_acl
,
1446 .get_nt_acl_at_fn
= skel_get_nt_acl_at
,
1447 .fset_nt_acl_fn
= skel_fset_nt_acl
,
1449 /* POSIX ACL operations. */
1451 .sys_acl_get_file_fn
= skel_sys_acl_get_file
,
1452 .sys_acl_get_fd_fn
= skel_sys_acl_get_fd
,
1453 .sys_acl_blob_get_file_fn
= skel_sys_acl_blob_get_file
,
1454 .sys_acl_blob_get_fd_fn
= skel_sys_acl_blob_get_fd
,
1455 .sys_acl_set_file_fn
= skel_sys_acl_set_file
,
1456 .sys_acl_set_fd_fn
= skel_sys_acl_set_fd
,
1457 .sys_acl_delete_def_file_fn
= skel_sys_acl_delete_def_file
,
1459 /* EA operations. */
1460 .getxattr_fn
= skel_getxattr
,
1461 .getxattrat_send_fn
= skel_getxattrat_send
,
1462 .getxattrat_recv_fn
= skel_getxattrat_recv
,
1463 .fgetxattr_fn
= skel_fgetxattr
,
1464 .listxattr_fn
= skel_listxattr
,
1465 .flistxattr_fn
= skel_flistxattr
,
1466 .removexattr_fn
= skel_removexattr
,
1467 .fremovexattr_fn
= skel_fremovexattr
,
1468 .setxattr_fn
= skel_setxattr
,
1469 .fsetxattr_fn
= skel_fsetxattr
,
1471 /* aio operations */
1472 .aio_force_fn
= skel_aio_force
,
1474 /* durable handle operations */
1475 .durable_cookie_fn
= skel_durable_cookie
,
1476 .durable_disconnect_fn
= skel_durable_disconnect
,
1477 .durable_reconnect_fn
= skel_durable_reconnect
,
1481 NTSTATUS
vfs_skel_transparent_init(TALLOC_CTX
*ctx
)
1484 * smb_vfs_assert_all_fns() is only needed in
1485 * order to have a complete example.
1487 * A transparent vfs module typically don't
1488 * need to implement every calls.
1490 smb_vfs_assert_all_fns(&skel_transparent_fns
, "skel_transparent");
1491 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "skel_transparent",
1492 &skel_transparent_fns
);