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/>.
25 #include "../source3/include/includes.h"
27 /* PLEASE,PLEASE READ THE VFS MODULES CHAPTER OF THE
28 SAMBA DEVELOPERS GUIDE!!!!!!
31 /* If you take this file as template for your module
32 * you must re-implement every function.
35 static int skel_connect(vfs_handle_struct
*handle
, const char *service
, const char *user
)
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
, unid_t id
, SMB_DISK_QUOTA
*dq
)
62 static int skel_set_quota(vfs_handle_struct
*handle
, enum SMB_QUOTA_TYPE qtype
, unid_t id
, SMB_DISK_QUOTA
*dq
)
68 static int skel_get_shadow_copy_data(vfs_handle_struct
*handle
, files_struct
*fsp
, struct shadow_copy_data
*shadow_copy_data
, bool labels
)
74 static int skel_statvfs(struct vfs_handle_struct
*handle
, const char *path
, struct vfs_statvfs_struct
*statbuf
)
80 static uint32_t skel_fs_capabilities(struct vfs_handle_struct
*handle
, enum timestamp_set_resolution
*p_ts_res
)
85 static NTSTATUS
skel_get_dfs_referrals(struct vfs_handle_struct
*handle
,
86 struct dfs_GetDFSReferral
*r
)
88 return NT_STATUS_NOT_IMPLEMENTED
;
91 static DIR *skel_opendir(vfs_handle_struct
*handle
, const char *fname
, const char *mask
, uint32 attr
)
96 static DIR *skel_fdopendir(vfs_handle_struct
*handle
, files_struct
*fsp
, const char *mask
, uint32 attr
)
101 static struct dirent
*skel_readdir(vfs_handle_struct
*handle
,
103 SMB_STRUCT_STAT
*sbuf
)
108 static void skel_seekdir(vfs_handle_struct
*handle
, DIR *dirp
, long offset
)
113 static long skel_telldir(vfs_handle_struct
*handle
, DIR *dirp
)
118 static void skel_rewind_dir(vfs_handle_struct
*handle
, DIR *dirp
)
123 static int skel_mkdir(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
129 static int skel_rmdir(vfs_handle_struct
*handle
, const char *path
)
135 static int skel_closedir(vfs_handle_struct
*handle
, DIR *dir
)
141 static void skel_init_search_op(struct vfs_handle_struct
*handle
, DIR *dirp
)
146 static int skel_open(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
,
147 files_struct
*fsp
, int flags
, mode_t mode
)
153 static NTSTATUS
skel_create_file(struct vfs_handle_struct
*handle
,
154 struct smb_request
*req
,
155 uint16_t root_dir_fid
,
156 struct smb_filename
*smb_fname
,
157 uint32_t access_mask
,
158 uint32_t share_access
,
159 uint32_t create_disposition
,
160 uint32_t create_options
,
161 uint32_t file_attributes
,
162 uint32_t oplock_request
,
163 uint64_t allocation_size
,
164 uint32_t private_flags
,
165 struct security_descriptor
*sd
,
166 struct ea_list
*ea_list
,
167 files_struct
**result
,
170 return NT_STATUS_NOT_IMPLEMENTED
;
173 static int skel_close_fn(vfs_handle_struct
*handle
, files_struct
*fsp
)
179 static ssize_t
skel_vfs_read(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
, size_t n
)
185 static ssize_t
skel_pread(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
, size_t n
, off_t offset
)
191 static struct tevent_req
*skel_pread_send(struct vfs_handle_struct
*handle
,
193 struct tevent_context
*ev
,
194 struct files_struct
*fsp
,
195 void *data
, size_t n
, off_t offset
)
200 static ssize_t
skel_pread_recv(struct tevent_req
*req
, int *err
)
206 static ssize_t
skel_write(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
, size_t n
)
212 static ssize_t
skel_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
, size_t n
, off_t offset
)
218 static struct tevent_req
*skel_pwrite_send(struct vfs_handle_struct
*handle
,
220 struct tevent_context
*ev
,
221 struct files_struct
*fsp
,
223 size_t n
, off_t offset
)
228 static ssize_t
skel_pwrite_recv(struct tevent_req
*req
, int *err
)
234 static off_t
skel_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
, off_t offset
, int whence
)
240 static ssize_t
skel_sendfile(vfs_handle_struct
*handle
, int tofd
, files_struct
*fromfsp
, const DATA_BLOB
*hdr
, off_t offset
, size_t n
)
246 static ssize_t
skel_recvfile(vfs_handle_struct
*handle
, int fromfd
, files_struct
*tofsp
, off_t offset
, size_t n
)
252 static int skel_rename(vfs_handle_struct
*handle
,
253 const struct smb_filename
*smb_fname_src
,
254 const struct smb_filename
*smb_fname_dst
)
260 static int skel_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
)
266 static struct tevent_req
*skel_fsync_send(struct vfs_handle_struct
*handle
,
268 struct tevent_context
*ev
,
269 struct files_struct
*fsp
)
274 static int skel_fsync_recv(struct tevent_req
*req
, int *err
)
280 static int skel_stat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
286 static int skel_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
292 static int skel_lstat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
298 static uint64_t skel_get_alloc_size(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const SMB_STRUCT_STAT
*sbuf
)
304 static int skel_unlink(vfs_handle_struct
*handle
,
305 const struct smb_filename
*smb_fname
)
311 static int skel_chmod(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
317 static int skel_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
323 static int skel_chown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
329 static int skel_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
, uid_t uid
, gid_t gid
)
335 static int skel_lchown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
341 static int skel_chdir(vfs_handle_struct
*handle
, const char *path
)
347 static char *skel_getwd(vfs_handle_struct
*handle
)
353 static int skel_ntimes(vfs_handle_struct
*handle
,
354 const struct smb_filename
*smb_fname
,
355 struct smb_file_time
*ft
)
361 static int skel_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
, off_t offset
)
367 static int skel_fallocate(vfs_handle_struct
*handle
, files_struct
*fsp
,
368 enum vfs_fallocate_mode mode
,
369 off_t offset
, off_t len
)
375 static bool skel_lock(vfs_handle_struct
*handle
, files_struct
*fsp
, int op
, off_t offset
, off_t count
, int type
)
381 static int skel_kernel_flock(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, uint32 share_mode
, uint32 access_mask
)
387 static int skel_linux_setlease(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, int leasetype
)
393 static bool skel_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
, off_t
*poffset
, off_t
*pcount
, int *ptype
, pid_t
*ppid
)
399 static int skel_symlink(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
405 static int skel_vfs_readlink(vfs_handle_struct
*handle
, const char *path
, char *buf
, size_t bufsiz
)
411 static int skel_link(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
417 static int skel_mknod(vfs_handle_struct
*handle
, const char *path
, mode_t mode
, SMB_DEV_T dev
)
423 static char *skel_realpath(vfs_handle_struct
*handle
, const char *path
)
429 static NTSTATUS
skel_notify_watch(struct vfs_handle_struct
*handle
,
430 struct sys_notify_context
*ctx
,
433 uint32_t *subdir_filter
,
434 void (*callback
)(struct sys_notify_context
*ctx
, void *private_data
, struct notify_event
*ev
),
435 void *private_data
, void *handle_p
)
437 return NT_STATUS_NOT_IMPLEMENTED
;
440 static int skel_chflags(vfs_handle_struct
*handle
, const char *path
, uint flags
)
446 static struct file_id
skel_file_id_create(vfs_handle_struct
*handle
,
447 const SMB_STRUCT_STAT
*sbuf
)
455 static NTSTATUS
skel_streaminfo(struct vfs_handle_struct
*handle
,
456 struct files_struct
*fsp
,
459 unsigned int *num_streams
,
460 struct stream_struct
**streams
)
462 return NT_STATUS_NOT_IMPLEMENTED
;
465 static int skel_get_real_filename(struct vfs_handle_struct
*handle
,
475 static const char *skel_connectpath(struct vfs_handle_struct
*handle
,
476 const char *filename
)
482 static NTSTATUS
skel_brl_lock_windows(struct vfs_handle_struct
*handle
,
483 struct byte_range_lock
*br_lck
,
484 struct lock_struct
*plock
,
486 struct blocking_lock_record
*blr
)
488 return NT_STATUS_NOT_IMPLEMENTED
;
491 static bool skel_brl_unlock_windows(struct vfs_handle_struct
*handle
,
492 struct messaging_context
*msg_ctx
,
493 struct byte_range_lock
*br_lck
,
494 const struct lock_struct
*plock
)
500 static bool skel_brl_cancel_windows(struct vfs_handle_struct
*handle
,
501 struct byte_range_lock
*br_lck
,
502 struct lock_struct
*plock
,
503 struct blocking_lock_record
*blr
)
509 static bool skel_strict_lock(struct vfs_handle_struct
*handle
,
510 struct files_struct
*fsp
,
511 struct lock_struct
*plock
)
517 static void skel_strict_unlock(struct vfs_handle_struct
*handle
,
518 struct files_struct
*fsp
,
519 struct lock_struct
*plock
)
524 static NTSTATUS
skel_translate_name(struct vfs_handle_struct
*handle
,
525 const char *mapped_name
,
526 enum vfs_translate_direction direction
,
530 return NT_STATUS_NOT_IMPLEMENTED
;
533 static NTSTATUS
skel_fsctl(struct vfs_handle_struct
*handle
,
534 struct files_struct
*fsp
,
537 uint16_t req_flags
, /* Needed for UNICODE ... */
538 const uint8_t *_in_data
,
541 uint32_t max_out_len
,
544 return NT_STATUS_NOT_IMPLEMENTED
;
547 static NTSTATUS
skel_fget_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
548 uint32 security_info
,
550 struct security_descriptor
**ppdesc
)
552 return NT_STATUS_NOT_IMPLEMENTED
;
555 static NTSTATUS
skel_get_nt_acl(vfs_handle_struct
*handle
,
556 const char *name
, uint32 security_info
,
558 struct security_descriptor
**ppdesc
)
560 return NT_STATUS_NOT_IMPLEMENTED
;
563 static NTSTATUS
skel_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
564 uint32 security_info_sent
, const struct security_descriptor
*psd
)
566 return NT_STATUS_NOT_IMPLEMENTED
;
569 static int skel_chmod_acl(vfs_handle_struct
*handle
, const char *name
, mode_t mode
)
575 static int skel_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
581 static SMB_ACL_T
skel_sys_acl_get_file(vfs_handle_struct
*handle
,
587 return (SMB_ACL_T
)NULL
;
590 static SMB_ACL_T
skel_sys_acl_get_fd(vfs_handle_struct
*handle
,
595 return (SMB_ACL_T
)NULL
;
598 static int skel_sys_acl_blob_get_file(vfs_handle_struct
*handle
, const char *path_p
, TALLOC_CTX
*mem_ctx
, char **blob_description
, DATA_BLOB
*blob
)
604 static int skel_sys_acl_blob_get_fd(vfs_handle_struct
*handle
, files_struct
*fsp
, TALLOC_CTX
*mem_ctx
, char **blob_description
, DATA_BLOB
*blob
)
610 static int skel_sys_acl_set_file(vfs_handle_struct
*handle
, const char *name
, SMB_ACL_TYPE_T acltype
, SMB_ACL_T theacl
)
616 static int skel_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_ACL_T theacl
)
622 static int skel_sys_acl_delete_def_file(vfs_handle_struct
*handle
, const char *path
)
628 static ssize_t
skel_getxattr(vfs_handle_struct
*handle
, const char *path
, const char *name
, void *value
, size_t size
)
634 static ssize_t
skel_fgetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, void *value
, size_t size
)
640 static ssize_t
skel_listxattr(vfs_handle_struct
*handle
, const char *path
, char *list
, size_t size
)
646 static ssize_t
skel_flistxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, char *list
, size_t size
)
652 static int skel_removexattr(vfs_handle_struct
*handle
, const char *path
, const char *name
)
658 static int skel_fremovexattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
)
662 return SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, name
);
665 static int skel_setxattr(vfs_handle_struct
*handle
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
671 static int skel_fsetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, const void *value
, size_t size
, int flags
)
677 static bool skel_aio_force(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
)
683 static bool skel_is_offline(struct vfs_handle_struct
*handle
, const struct smb_filename
*fname
, SMB_STRUCT_STAT
*sbuf
)
689 static int skel_set_offline(struct vfs_handle_struct
*handle
, const struct smb_filename
*fname
)
695 /* VFS operations structure */
697 struct vfs_fn_pointers skel_opaque_fns
= {
698 /* Disk operations */
700 .connect_fn
= skel_connect
,
701 .disconnect_fn
= skel_disconnect
,
702 .disk_free_fn
= skel_disk_free
,
703 .get_quota_fn
= skel_get_quota
,
704 .set_quota_fn
= skel_set_quota
,
705 .get_shadow_copy_data_fn
= skel_get_shadow_copy_data
,
706 .statvfs_fn
= skel_statvfs
,
707 .fs_capabilities_fn
= skel_fs_capabilities
,
708 .get_dfs_referrals_fn
= skel_get_dfs_referrals
,
710 /* Directory operations */
712 .opendir_fn
= skel_opendir
,
713 .fdopendir_fn
= skel_fdopendir
,
714 .readdir_fn
= skel_readdir
,
715 .seekdir_fn
= skel_seekdir
,
716 .telldir_fn
= skel_telldir
,
717 .rewind_dir_fn
= skel_rewind_dir
,
718 .mkdir_fn
= skel_mkdir
,
719 .rmdir_fn
= skel_rmdir
,
720 .closedir_fn
= skel_closedir
,
721 .init_search_op_fn
= skel_init_search_op
,
723 /* File operations */
725 .open_fn
= skel_open
,
726 .create_file_fn
= skel_create_file
,
727 .close_fn
= skel_close_fn
,
728 .read_fn
= skel_vfs_read
,
729 .pread_fn
= skel_pread
,
730 .pread_send_fn
= skel_pread_send
,
731 .pread_recv_fn
= skel_pread_recv
,
732 .write_fn
= skel_write
,
733 .pwrite_fn
= skel_pwrite
,
734 .pwrite_send_fn
= skel_pwrite_send
,
735 .pwrite_recv_fn
= skel_pwrite_recv
,
736 .lseek_fn
= skel_lseek
,
737 .sendfile_fn
= skel_sendfile
,
738 .recvfile_fn
= skel_recvfile
,
739 .rename_fn
= skel_rename
,
740 .fsync_fn
= skel_fsync
,
741 .fsync_send_fn
= skel_fsync_send
,
742 .fsync_recv_fn
= skel_fsync_recv
,
743 .stat_fn
= skel_stat
,
744 .fstat_fn
= skel_fstat
,
745 .lstat_fn
= skel_lstat
,
746 .get_alloc_size_fn
= skel_get_alloc_size
,
747 .unlink_fn
= skel_unlink
,
748 .chmod_fn
= skel_chmod
,
749 .fchmod_fn
= skel_fchmod
,
750 .chown_fn
= skel_chown
,
751 .fchown_fn
= skel_fchown
,
752 .lchown_fn
= skel_lchown
,
753 .chdir_fn
= skel_chdir
,
754 .getwd_fn
= skel_getwd
,
755 .ntimes_fn
= skel_ntimes
,
756 .ftruncate_fn
= skel_ftruncate
,
757 .fallocate_fn
= skel_fallocate
,
758 .lock_fn
= skel_lock
,
759 .kernel_flock_fn
= skel_kernel_flock
,
760 .linux_setlease_fn
= skel_linux_setlease
,
761 .getlock_fn
= skel_getlock
,
762 .symlink_fn
= skel_symlink
,
763 .readlink_fn
= skel_vfs_readlink
,
764 .link_fn
= skel_link
,
765 .mknod_fn
= skel_mknod
,
766 .realpath_fn
= skel_realpath
,
767 .notify_watch_fn
= skel_notify_watch
,
768 .chflags_fn
= skel_chflags
,
769 .file_id_create_fn
= skel_file_id_create
,
771 .streaminfo_fn
= skel_streaminfo
,
772 .get_real_filename_fn
= skel_get_real_filename
,
773 .connectpath_fn
= skel_connectpath
,
774 .brl_lock_windows_fn
= skel_brl_lock_windows
,
775 .brl_unlock_windows_fn
= skel_brl_unlock_windows
,
776 .brl_cancel_windows_fn
= skel_brl_cancel_windows
,
777 .strict_lock_fn
= skel_strict_lock
,
778 .strict_unlock_fn
= skel_strict_unlock
,
779 .translate_name_fn
= skel_translate_name
,
780 .fsctl_fn
= skel_fsctl
,
782 /* NT ACL operations. */
784 .fget_nt_acl_fn
= skel_fget_nt_acl
,
785 .get_nt_acl_fn
= skel_get_nt_acl
,
786 .fset_nt_acl_fn
= skel_fset_nt_acl
,
788 /* POSIX ACL operations. */
790 .chmod_acl_fn
= skel_chmod_acl
,
791 .fchmod_acl_fn
= skel_fchmod_acl
,
793 .sys_acl_get_file_fn
= skel_sys_acl_get_file
,
794 .sys_acl_get_fd_fn
= skel_sys_acl_get_fd
,
795 .sys_acl_blob_get_file_fn
= skel_sys_acl_blob_get_file
,
796 .sys_acl_blob_get_fd_fn
= skel_sys_acl_blob_get_fd
,
797 .sys_acl_set_file_fn
= skel_sys_acl_set_file
,
798 .sys_acl_set_fd_fn
= skel_sys_acl_set_fd
,
799 .sys_acl_delete_def_file_fn
= skel_sys_acl_delete_def_file
,
803 .getxattr_fn
= skel_getxattr
,
804 .fgetxattr_fn
= skel_fgetxattr
,
805 .listxattr_fn
= skel_listxattr
,
806 .flistxattr_fn
= skel_flistxattr
,
807 .removexattr_fn
= skel_removexattr
,
808 .fremovexattr_fn
= skel_fremovexattr
,
809 .setxattr_fn
= skel_setxattr
,
810 .fsetxattr_fn
= skel_fsetxattr
,
813 .aio_force_fn
= skel_aio_force
,
815 /* offline operations */
816 .is_offline_fn
= skel_is_offline
,
817 .set_offline_fn
= skel_set_offline
820 NTSTATUS
vfs_skel_opaque_init(void)
822 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "skel_opaque", &skel_opaque_fns
);