2 * Skeleton VFS module. Implements dummy versions of all VFS
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"
26 /* PLEASE,PLEASE READ THE VFS MODULES CHAPTER OF THE
27 SAMBA DEVELOPERS GUIDE!!!!!!
30 /* If you take this file as template for your module
31 * you must re-implement every function.
34 static int skel_connect(vfs_handle_struct
*handle
, const char *service
,
41 static void skel_disconnect(vfs_handle_struct
*handle
)
46 static uint64_t skel_disk_free(vfs_handle_struct
*handle
, const char *path
,
47 bool small_query
, uint64_t *bsize
,
48 uint64_t *dfree
, uint64_t *dsize
)
56 static int skel_get_quota(vfs_handle_struct
*handle
, enum SMB_QUOTA_TYPE qtype
,
57 unid_t id
, SMB_DISK_QUOTA
*dq
)
63 static int skel_set_quota(vfs_handle_struct
*handle
, enum SMB_QUOTA_TYPE qtype
,
64 unid_t id
, SMB_DISK_QUOTA
*dq
)
70 static int skel_get_shadow_copy_data(vfs_handle_struct
*handle
,
72 struct shadow_copy_data
*shadow_copy_data
,
79 static int skel_statvfs(struct vfs_handle_struct
*handle
,
80 const char *path
, struct vfs_statvfs_struct
*statbuf
)
86 static uint32_t skel_fs_capabilities(struct vfs_handle_struct
*handle
,
87 enum timestamp_set_resolution
*p_ts_res
)
92 static NTSTATUS
skel_get_dfs_referrals(struct vfs_handle_struct
*handle
,
93 struct dfs_GetDFSReferral
*r
)
95 return NT_STATUS_NOT_IMPLEMENTED
;
98 static DIR *skel_opendir(vfs_handle_struct
*handle
, const char *fname
,
99 const char *mask
, uint32 attr
)
104 static DIR *skel_fdopendir(vfs_handle_struct
*handle
, files_struct
*fsp
,
105 const char *mask
, uint32 attr
)
110 static struct dirent
*skel_readdir(vfs_handle_struct
*handle
,
111 DIR *dirp
, SMB_STRUCT_STAT
*sbuf
)
116 static void skel_seekdir(vfs_handle_struct
*handle
, DIR *dirp
, long offset
)
121 static long skel_telldir(vfs_handle_struct
*handle
, DIR *dirp
)
126 static void skel_rewind_dir(vfs_handle_struct
*handle
, DIR *dirp
)
131 static int skel_mkdir(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
137 static int skel_rmdir(vfs_handle_struct
*handle
, const char *path
)
143 static int skel_closedir(vfs_handle_struct
*handle
, DIR *dir
)
149 static void skel_init_search_op(struct vfs_handle_struct
*handle
, DIR *dirp
)
154 static int skel_open(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
,
155 files_struct
*fsp
, int flags
, mode_t mode
)
161 static NTSTATUS
skel_create_file(struct vfs_handle_struct
*handle
,
162 struct smb_request
*req
,
163 uint16_t root_dir_fid
,
164 struct smb_filename
*smb_fname
,
165 uint32_t access_mask
,
166 uint32_t share_access
,
167 uint32_t create_disposition
,
168 uint32_t create_options
,
169 uint32_t file_attributes
,
170 uint32_t oplock_request
,
171 uint64_t allocation_size
,
172 uint32_t private_flags
,
173 struct security_descriptor
*sd
,
174 struct ea_list
*ea_list
,
175 files_struct
**result
, int *pinfo
)
177 return NT_STATUS_NOT_IMPLEMENTED
;
180 static int skel_close_fn(vfs_handle_struct
*handle
, files_struct
*fsp
)
186 static ssize_t
skel_vfs_read(vfs_handle_struct
*handle
, files_struct
*fsp
,
187 void *data
, size_t n
)
193 static ssize_t
skel_pread(vfs_handle_struct
*handle
, files_struct
*fsp
,
194 void *data
, size_t n
, off_t offset
)
200 static struct tevent_req
*skel_pread_send(struct vfs_handle_struct
*handle
,
202 struct tevent_context
*ev
,
203 struct files_struct
*fsp
,
204 void *data
, size_t n
, off_t offset
)
209 static ssize_t
skel_pread_recv(struct tevent_req
*req
, int *err
)
215 static ssize_t
skel_write(vfs_handle_struct
*handle
, files_struct
*fsp
,
216 const void *data
, size_t n
)
222 static ssize_t
skel_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
,
223 const void *data
, size_t n
, off_t offset
)
229 static struct tevent_req
*skel_pwrite_send(struct vfs_handle_struct
*handle
,
231 struct tevent_context
*ev
,
232 struct files_struct
*fsp
,
234 size_t n
, off_t offset
)
239 static ssize_t
skel_pwrite_recv(struct tevent_req
*req
, int *err
)
245 static off_t
skel_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
,
246 off_t offset
, int whence
)
252 static ssize_t
skel_sendfile(vfs_handle_struct
*handle
, int tofd
,
253 files_struct
*fromfsp
, const DATA_BLOB
*hdr
,
254 off_t offset
, size_t n
)
260 static ssize_t
skel_recvfile(vfs_handle_struct
*handle
, int fromfd
,
261 files_struct
*tofsp
, off_t offset
, size_t n
)
267 static int skel_rename(vfs_handle_struct
*handle
,
268 const struct smb_filename
*smb_fname_src
,
269 const struct smb_filename
*smb_fname_dst
)
275 static int skel_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
)
281 static struct tevent_req
*skel_fsync_send(struct vfs_handle_struct
*handle
,
283 struct tevent_context
*ev
,
284 struct files_struct
*fsp
)
289 static int skel_fsync_recv(struct tevent_req
*req
, int *err
)
295 static int skel_stat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
301 static int skel_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
,
302 SMB_STRUCT_STAT
*sbuf
)
308 static int skel_lstat(vfs_handle_struct
*handle
,
309 struct smb_filename
*smb_fname
)
315 static uint64_t skel_get_alloc_size(struct vfs_handle_struct
*handle
,
316 struct files_struct
*fsp
,
317 const SMB_STRUCT_STAT
*sbuf
)
323 static int skel_unlink(vfs_handle_struct
*handle
,
324 const struct smb_filename
*smb_fname
)
330 static int skel_chmod(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
336 static int skel_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
,
343 static int skel_chown(vfs_handle_struct
*handle
, const char *path
,
344 uid_t uid
, gid_t gid
)
350 static int skel_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
,
351 uid_t uid
, gid_t gid
)
357 static int skel_lchown(vfs_handle_struct
*handle
, const char *path
,
358 uid_t uid
, gid_t gid
)
364 static int skel_chdir(vfs_handle_struct
*handle
, const char *path
)
370 static char *skel_getwd(vfs_handle_struct
*handle
)
376 static int skel_ntimes(vfs_handle_struct
*handle
,
377 const struct smb_filename
*smb_fname
,
378 struct smb_file_time
*ft
)
384 static int skel_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
,
391 static int skel_fallocate(vfs_handle_struct
*handle
, files_struct
*fsp
,
392 enum vfs_fallocate_mode mode
, off_t offset
, off_t len
)
398 static bool skel_lock(vfs_handle_struct
*handle
, files_struct
*fsp
, int op
,
399 off_t offset
, off_t count
, int type
)
405 static int skel_kernel_flock(struct vfs_handle_struct
*handle
,
406 struct files_struct
*fsp
,
407 uint32 share_mode
, uint32 access_mask
)
413 static int skel_linux_setlease(struct vfs_handle_struct
*handle
,
414 struct files_struct
*fsp
, int leasetype
)
420 static bool skel_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
,
421 off_t
*poffset
, off_t
*pcount
, int *ptype
,
428 static int skel_symlink(vfs_handle_struct
*handle
, const char *oldpath
,
435 static int skel_vfs_readlink(vfs_handle_struct
*handle
, const char *path
,
436 char *buf
, size_t bufsiz
)
442 static int skel_link(vfs_handle_struct
*handle
, const char *oldpath
,
449 static int skel_mknod(vfs_handle_struct
*handle
, const char *path
, mode_t mode
,
456 static char *skel_realpath(vfs_handle_struct
*handle
, const char *path
)
462 static NTSTATUS
skel_notify_watch(struct vfs_handle_struct
*handle
,
463 struct sys_notify_context
*ctx
,
466 uint32_t *subdir_filter
,
467 void (*callback
) (struct sys_notify_context
*
468 ctx
, void *private_data
,
469 struct notify_event
*ev
),
470 void *private_data
, void *handle_p
)
472 return NT_STATUS_NOT_IMPLEMENTED
;
475 static int skel_chflags(vfs_handle_struct
*handle
, const char *path
,
482 static struct file_id
skel_file_id_create(vfs_handle_struct
*handle
,
483 const SMB_STRUCT_STAT
*sbuf
)
491 static NTSTATUS
skel_streaminfo(struct vfs_handle_struct
*handle
,
492 struct files_struct
*fsp
,
495 unsigned int *num_streams
,
496 struct stream_struct
**streams
)
498 return NT_STATUS_NOT_IMPLEMENTED
;
501 static int skel_get_real_filename(struct vfs_handle_struct
*handle
,
504 TALLOC_CTX
*mem_ctx
, char **found_name
)
510 static const char *skel_connectpath(struct vfs_handle_struct
*handle
,
511 const char *filename
)
517 static NTSTATUS
skel_brl_lock_windows(struct vfs_handle_struct
*handle
,
518 struct byte_range_lock
*br_lck
,
519 struct lock_struct
*plock
,
521 struct blocking_lock_record
*blr
)
523 return NT_STATUS_NOT_IMPLEMENTED
;
526 static bool skel_brl_unlock_windows(struct vfs_handle_struct
*handle
,
527 struct messaging_context
*msg_ctx
,
528 struct byte_range_lock
*br_lck
,
529 const struct lock_struct
*plock
)
535 static bool skel_brl_cancel_windows(struct vfs_handle_struct
*handle
,
536 struct byte_range_lock
*br_lck
,
537 struct lock_struct
*plock
,
538 struct blocking_lock_record
*blr
)
544 static bool skel_strict_lock(struct vfs_handle_struct
*handle
,
545 struct files_struct
*fsp
,
546 struct lock_struct
*plock
)
552 static void skel_strict_unlock(struct vfs_handle_struct
*handle
,
553 struct files_struct
*fsp
,
554 struct lock_struct
*plock
)
559 static NTSTATUS
skel_translate_name(struct vfs_handle_struct
*handle
,
560 const char *mapped_name
,
561 enum vfs_translate_direction direction
,
562 TALLOC_CTX
*mem_ctx
, char **pmapped_name
)
564 return NT_STATUS_NOT_IMPLEMENTED
;
567 static NTSTATUS
skel_fsctl(struct vfs_handle_struct
*handle
,
568 struct files_struct
*fsp
,
571 uint16_t req_flags
, /* Needed for UNICODE ... */
572 const uint8_t *_in_data
,
575 uint32_t max_out_len
, uint32_t *out_len
)
577 return NT_STATUS_NOT_IMPLEMENTED
;
580 static NTSTATUS
skel_fget_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
581 uint32 security_info
,
583 struct security_descriptor
**ppdesc
)
585 return NT_STATUS_NOT_IMPLEMENTED
;
588 static NTSTATUS
skel_get_nt_acl(vfs_handle_struct
*handle
,
589 const char *name
, uint32 security_info
,
591 struct security_descriptor
**ppdesc
)
593 return NT_STATUS_NOT_IMPLEMENTED
;
596 static NTSTATUS
skel_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
597 uint32 security_info_sent
,
598 const struct security_descriptor
*psd
)
600 return NT_STATUS_NOT_IMPLEMENTED
;
603 static int skel_chmod_acl(vfs_handle_struct
*handle
, const char *name
,
610 static int skel_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
617 static SMB_ACL_T
skel_sys_acl_get_file(vfs_handle_struct
*handle
,
623 return (SMB_ACL_T
) NULL
;
626 static SMB_ACL_T
skel_sys_acl_get_fd(vfs_handle_struct
*handle
,
627 files_struct
*fsp
, TALLOC_CTX
*mem_ctx
)
630 return (SMB_ACL_T
) NULL
;
633 static int skel_sys_acl_blob_get_file(vfs_handle_struct
*handle
,
634 const char *path_p
, TALLOC_CTX
*mem_ctx
,
635 char **blob_description
, DATA_BLOB
*blob
)
641 static int skel_sys_acl_blob_get_fd(vfs_handle_struct
*handle
,
642 files_struct
*fsp
, TALLOC_CTX
*mem_ctx
,
643 char **blob_description
, DATA_BLOB
*blob
)
649 static int skel_sys_acl_set_file(vfs_handle_struct
*handle
, const char *name
,
650 SMB_ACL_TYPE_T acltype
, SMB_ACL_T theacl
)
656 static int skel_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
,
663 static int skel_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
670 static ssize_t
skel_getxattr(vfs_handle_struct
*handle
, const char *path
,
671 const char *name
, void *value
, size_t size
)
677 static ssize_t
skel_fgetxattr(vfs_handle_struct
*handle
,
678 struct files_struct
*fsp
, const char *name
,
679 void *value
, size_t size
)
685 static ssize_t
skel_listxattr(vfs_handle_struct
*handle
, const char *path
,
686 char *list
, size_t size
)
692 static ssize_t
skel_flistxattr(vfs_handle_struct
*handle
,
693 struct files_struct
*fsp
, char *list
,
700 static int skel_removexattr(vfs_handle_struct
*handle
, const char *path
,
707 static int skel_fremovexattr(vfs_handle_struct
*handle
,
708 struct files_struct
*fsp
, const char *name
)
712 return SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, name
);
715 static int skel_setxattr(vfs_handle_struct
*handle
, const char *path
,
716 const char *name
, const void *value
, size_t size
,
723 static int skel_fsetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
,
724 const char *name
, const void *value
, size_t size
,
731 static bool skel_aio_force(struct vfs_handle_struct
*handle
,
732 struct files_struct
*fsp
)
738 static bool skel_is_offline(struct vfs_handle_struct
*handle
,
739 const struct smb_filename
*fname
,
740 SMB_STRUCT_STAT
*sbuf
)
746 static int skel_set_offline(struct vfs_handle_struct
*handle
,
747 const struct smb_filename
*fname
)
753 /* VFS operations structure */
755 struct vfs_fn_pointers skel_opaque_fns
= {
756 /* Disk operations */
758 .connect_fn
= skel_connect
,
759 .disconnect_fn
= skel_disconnect
,
760 .disk_free_fn
= skel_disk_free
,
761 .get_quota_fn
= skel_get_quota
,
762 .set_quota_fn
= skel_set_quota
,
763 .get_shadow_copy_data_fn
= skel_get_shadow_copy_data
,
764 .statvfs_fn
= skel_statvfs
,
765 .fs_capabilities_fn
= skel_fs_capabilities
,
766 .get_dfs_referrals_fn
= skel_get_dfs_referrals
,
768 /* Directory operations */
770 .opendir_fn
= skel_opendir
,
771 .fdopendir_fn
= skel_fdopendir
,
772 .readdir_fn
= skel_readdir
,
773 .seekdir_fn
= skel_seekdir
,
774 .telldir_fn
= skel_telldir
,
775 .rewind_dir_fn
= skel_rewind_dir
,
776 .mkdir_fn
= skel_mkdir
,
777 .rmdir_fn
= skel_rmdir
,
778 .closedir_fn
= skel_closedir
,
779 .init_search_op_fn
= skel_init_search_op
,
781 /* File operations */
783 .open_fn
= skel_open
,
784 .create_file_fn
= skel_create_file
,
785 .close_fn
= skel_close_fn
,
786 .read_fn
= skel_vfs_read
,
787 .pread_fn
= skel_pread
,
788 .pread_send_fn
= skel_pread_send
,
789 .pread_recv_fn
= skel_pread_recv
,
790 .write_fn
= skel_write
,
791 .pwrite_fn
= skel_pwrite
,
792 .pwrite_send_fn
= skel_pwrite_send
,
793 .pwrite_recv_fn
= skel_pwrite_recv
,
794 .lseek_fn
= skel_lseek
,
795 .sendfile_fn
= skel_sendfile
,
796 .recvfile_fn
= skel_recvfile
,
797 .rename_fn
= skel_rename
,
798 .fsync_fn
= skel_fsync
,
799 .fsync_send_fn
= skel_fsync_send
,
800 .fsync_recv_fn
= skel_fsync_recv
,
801 .stat_fn
= skel_stat
,
802 .fstat_fn
= skel_fstat
,
803 .lstat_fn
= skel_lstat
,
804 .get_alloc_size_fn
= skel_get_alloc_size
,
805 .unlink_fn
= skel_unlink
,
806 .chmod_fn
= skel_chmod
,
807 .fchmod_fn
= skel_fchmod
,
808 .chown_fn
= skel_chown
,
809 .fchown_fn
= skel_fchown
,
810 .lchown_fn
= skel_lchown
,
811 .chdir_fn
= skel_chdir
,
812 .getwd_fn
= skel_getwd
,
813 .ntimes_fn
= skel_ntimes
,
814 .ftruncate_fn
= skel_ftruncate
,
815 .fallocate_fn
= skel_fallocate
,
816 .lock_fn
= skel_lock
,
817 .kernel_flock_fn
= skel_kernel_flock
,
818 .linux_setlease_fn
= skel_linux_setlease
,
819 .getlock_fn
= skel_getlock
,
820 .symlink_fn
= skel_symlink
,
821 .readlink_fn
= skel_vfs_readlink
,
822 .link_fn
= skel_link
,
823 .mknod_fn
= skel_mknod
,
824 .realpath_fn
= skel_realpath
,
825 .notify_watch_fn
= skel_notify_watch
,
826 .chflags_fn
= skel_chflags
,
827 .file_id_create_fn
= skel_file_id_create
,
829 .streaminfo_fn
= skel_streaminfo
,
830 .get_real_filename_fn
= skel_get_real_filename
,
831 .connectpath_fn
= skel_connectpath
,
832 .brl_lock_windows_fn
= skel_brl_lock_windows
,
833 .brl_unlock_windows_fn
= skel_brl_unlock_windows
,
834 .brl_cancel_windows_fn
= skel_brl_cancel_windows
,
835 .strict_lock_fn
= skel_strict_lock
,
836 .strict_unlock_fn
= skel_strict_unlock
,
837 .translate_name_fn
= skel_translate_name
,
838 .fsctl_fn
= skel_fsctl
,
840 /* NT ACL operations. */
842 .fget_nt_acl_fn
= skel_fget_nt_acl
,
843 .get_nt_acl_fn
= skel_get_nt_acl
,
844 .fset_nt_acl_fn
= skel_fset_nt_acl
,
846 /* POSIX ACL operations. */
848 .chmod_acl_fn
= skel_chmod_acl
,
849 .fchmod_acl_fn
= skel_fchmod_acl
,
851 .sys_acl_get_file_fn
= skel_sys_acl_get_file
,
852 .sys_acl_get_fd_fn
= skel_sys_acl_get_fd
,
853 .sys_acl_blob_get_file_fn
= skel_sys_acl_blob_get_file
,
854 .sys_acl_blob_get_fd_fn
= skel_sys_acl_blob_get_fd
,
855 .sys_acl_set_file_fn
= skel_sys_acl_set_file
,
856 .sys_acl_set_fd_fn
= skel_sys_acl_set_fd
,
857 .sys_acl_delete_def_file_fn
= skel_sys_acl_delete_def_file
,
860 .getxattr_fn
= skel_getxattr
,
861 .fgetxattr_fn
= skel_fgetxattr
,
862 .listxattr_fn
= skel_listxattr
,
863 .flistxattr_fn
= skel_flistxattr
,
864 .removexattr_fn
= skel_removexattr
,
865 .fremovexattr_fn
= skel_fremovexattr
,
866 .setxattr_fn
= skel_setxattr
,
867 .fsetxattr_fn
= skel_fsetxattr
,
870 .aio_force_fn
= skel_aio_force
,
872 /* offline operations */
873 .is_offline_fn
= skel_is_offline
,
874 .set_offline_fn
= skel_set_offline
877 NTSTATUS
vfs_skel_opaque_init(void)
879 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "skel_opaque",