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/>.
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
, 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 SMB_STRUCT_DIR
*skel_opendir(vfs_handle_struct
*handle
, const char *fname
, const char *mask
, uint32 attr
)
90 static SMB_STRUCT_DIRENT
*skel_readdir(vfs_handle_struct
*handle
,
92 SMB_STRUCT_STAT
*sbuf
)
97 static void skel_seekdir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
, long offset
)
102 static long skel_telldir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
)
107 static void skel_rewind_dir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
)
112 static int skel_mkdir(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
118 static int skel_rmdir(vfs_handle_struct
*handle
, const char *path
)
124 static int skel_closedir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dir
)
130 static void skel_init_search_op(struct vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
)
135 static int skel_open(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
,
136 files_struct
*fsp
, int flags
, mode_t mode
)
142 static NTSTATUS
skel_create_file(struct vfs_handle_struct
*handle
,
143 struct smb_request
*req
,
144 uint16_t root_dir_fid
,
145 struct smb_filename
*smb_fname
,
146 uint32_t access_mask
,
147 uint32_t share_access
,
148 uint32_t create_disposition
,
149 uint32_t create_options
,
150 uint32_t file_attributes
,
151 uint32_t oplock_request
,
152 uint64_t allocation_size
,
153 uint32_t private_flags
,
154 struct security_descriptor
*sd
,
155 struct ea_list
*ea_list
,
156 files_struct
**result
,
159 return NT_STATUS_NOT_IMPLEMENTED
;
162 static int skel_close_fn(vfs_handle_struct
*handle
, files_struct
*fsp
)
168 static ssize_t
skel_vfs_read(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
, size_t n
)
174 static ssize_t
skel_pread(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
, size_t n
, SMB_OFF_T offset
)
180 static ssize_t
skel_write(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
, size_t n
)
186 static ssize_t
skel_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
, size_t n
, SMB_OFF_T offset
)
192 static SMB_OFF_T
skel_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T offset
, int whence
)
195 return (SMB_OFF_T
)-1;
198 static ssize_t
skel_sendfile(vfs_handle_struct
*handle
, int tofd
, files_struct
*fromfsp
, const DATA_BLOB
*hdr
, SMB_OFF_T offset
, size_t n
)
204 static ssize_t
skel_recvfile(vfs_handle_struct
*handle
, int fromfd
, files_struct
*tofsp
, SMB_OFF_T offset
, size_t n
)
210 static int skel_rename(vfs_handle_struct
*handle
,
211 const struct smb_filename
*smb_fname_src
,
212 const struct smb_filename
*smb_fname_dst
)
218 static int skel_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
)
224 static int skel_stat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
230 static int skel_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
236 static int skel_lstat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
242 static uint64_t skel_get_alloc_size(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const SMB_STRUCT_STAT
*sbuf
)
248 static int skel_unlink(vfs_handle_struct
*handle
,
249 const struct smb_filename
*smb_fname
)
255 static int skel_chmod(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
261 static int skel_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
267 static int skel_chown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
273 static int skel_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
, uid_t uid
, gid_t gid
)
279 static int skel_lchown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
285 static int skel_chdir(vfs_handle_struct
*handle
, const char *path
)
291 static char *skel_getwd(vfs_handle_struct
*handle
, char *buf
)
297 static int skel_ntimes(vfs_handle_struct
*handle
,
298 const struct smb_filename
*smb_fname
,
299 struct smb_file_time
*ft
)
305 static int skel_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T offset
)
311 static int skel_posix_fallocate(vfs_handle_struct
*handle
, files_struct
*fsp
,
312 SMB_OFF_T offset
, SMB_OFF_T len
)
318 static bool skel_lock(vfs_handle_struct
*handle
, files_struct
*fsp
, int op
, SMB_OFF_T offset
, SMB_OFF_T count
, int type
)
324 static int skel_kernel_flock(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, uint32 share_mode
, uint32 access_mask
)
330 static int skel_linux_setlease(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, int leasetype
)
336 static bool skel_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T
*poffset
, SMB_OFF_T
*pcount
, int *ptype
, pid_t
*ppid
)
342 static int skel_symlink(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
348 static int skel_vfs_readlink(vfs_handle_struct
*handle
, const char *path
, char *buf
, size_t bufsiz
)
354 static int skel_link(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
360 static int skel_mknod(vfs_handle_struct
*handle
, const char *path
, mode_t mode
, SMB_DEV_T dev
)
366 static char *skel_realpath(vfs_handle_struct
*handle
, const char *path
)
372 static NTSTATUS
skel_notify_watch(struct vfs_handle_struct
*handle
,
373 struct sys_notify_context
*ctx
, struct notify_entry
*e
,
374 void (*callback
)(struct sys_notify_context
*ctx
, void *private_data
, struct notify_event
*ev
),
375 void *private_data
, void *handle_p
)
377 return NT_STATUS_NOT_IMPLEMENTED
;
380 static int skel_chflags(vfs_handle_struct
*handle
, const char *path
, uint flags
)
386 static struct file_id
skel_file_id_create(vfs_handle_struct
*handle
,
387 const SMB_STRUCT_STAT
*sbuf
)
395 static NTSTATUS
skel_streaminfo(struct vfs_handle_struct
*handle
,
396 struct files_struct
*fsp
,
399 unsigned int *num_streams
,
400 struct stream_struct
**streams
)
402 return NT_STATUS_NOT_IMPLEMENTED
;
405 static int skel_get_real_filename(struct vfs_handle_struct
*handle
,
415 static const char *skel_connectpath(struct vfs_handle_struct
*handle
,
416 const char *filename
)
422 static NTSTATUS
skel_brl_lock_windows(struct vfs_handle_struct
*handle
,
423 struct byte_range_lock
*br_lck
,
424 struct lock_struct
*plock
,
426 struct blocking_lock_record
*blr
)
428 return NT_STATUS_NOT_IMPLEMENTED
;
431 static bool skel_brl_unlock_windows(struct vfs_handle_struct
*handle
,
432 struct messaging_context
*msg_ctx
,
433 struct byte_range_lock
*br_lck
,
434 const struct lock_struct
*plock
)
440 static bool skel_brl_cancel_windows(struct vfs_handle_struct
*handle
,
441 struct byte_range_lock
*br_lck
,
442 struct lock_struct
*plock
,
443 struct blocking_lock_record
*blr
)
449 static bool skel_strict_lock(struct vfs_handle_struct
*handle
,
450 struct files_struct
*fsp
,
451 struct lock_struct
*plock
)
457 static void skel_strict_unlock(struct vfs_handle_struct
*handle
,
458 struct files_struct
*fsp
,
459 struct lock_struct
*plock
)
464 static NTSTATUS
skel_translate_name(struct vfs_handle_struct
*handle
,
465 const char *mapped_name
,
466 enum vfs_translate_direction direction
,
470 return NT_STATUS_NOT_IMPLEMENTED
;
473 static NTSTATUS
skel_fget_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
474 uint32 security_info
, SEC_DESC
**ppdesc
)
476 return NT_STATUS_NOT_IMPLEMENTED
;
479 static NTSTATUS
skel_get_nt_acl(vfs_handle_struct
*handle
,
480 const char *name
, uint32 security_info
, SEC_DESC
**ppdesc
)
482 return NT_STATUS_NOT_IMPLEMENTED
;
485 static NTSTATUS
skel_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
486 uint32 security_info_sent
, const SEC_DESC
*psd
)
488 return NT_STATUS_NOT_IMPLEMENTED
;
491 static int skel_chmod_acl(vfs_handle_struct
*handle
, const char *name
, mode_t mode
)
497 static int skel_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
503 static int skel_sys_acl_get_entry(vfs_handle_struct
*handle
, SMB_ACL_T theacl
, int entry_id
, SMB_ACL_ENTRY_T
*entry_p
)
509 static int skel_sys_acl_get_tag_type(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry_d
, SMB_ACL_TAG_T
*tag_type_p
)
515 static int skel_sys_acl_get_permset(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry_d
, SMB_ACL_PERMSET_T
*permset_p
)
521 static void *skel_sys_acl_get_qualifier(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry_d
)
527 static SMB_ACL_T
skel_sys_acl_get_file(vfs_handle_struct
*handle
, const char *path_p
, SMB_ACL_TYPE_T type
)
530 return (SMB_ACL_T
)NULL
;
533 static SMB_ACL_T
skel_sys_acl_get_fd(vfs_handle_struct
*handle
, files_struct
*fsp
)
536 return (SMB_ACL_T
)NULL
;
539 static int skel_sys_acl_clear_perms(vfs_handle_struct
*handle
, SMB_ACL_PERMSET_T permset
)
545 static int skel_sys_acl_add_perm(vfs_handle_struct
*handle
, SMB_ACL_PERMSET_T permset
, SMB_ACL_PERM_T perm
)
551 static char *skel_sys_acl_to_text(vfs_handle_struct
*handle
, SMB_ACL_T theacl
, ssize_t
*plen
)
557 static SMB_ACL_T
skel_sys_acl_init(vfs_handle_struct
*handle
, int count
)
560 return (SMB_ACL_T
)NULL
;
563 static int skel_sys_acl_create_entry(vfs_handle_struct
*handle
, SMB_ACL_T
*pacl
, SMB_ACL_ENTRY_T
*pentry
)
569 static int skel_sys_acl_set_tag_type(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry
, SMB_ACL_TAG_T tagtype
)
575 static int skel_sys_acl_set_qualifier(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry
, void *qual
)
581 static int skel_sys_acl_set_permset(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry
, SMB_ACL_PERMSET_T permset
)
587 static int skel_sys_acl_valid(vfs_handle_struct
*handle
, SMB_ACL_T theacl
)
593 static int skel_sys_acl_set_file(vfs_handle_struct
*handle
, const char *name
, SMB_ACL_TYPE_T acltype
, SMB_ACL_T theacl
)
599 static int skel_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_ACL_T theacl
)
605 static int skel_sys_acl_delete_def_file(vfs_handle_struct
*handle
, const char *path
)
611 static int skel_sys_acl_get_perm(vfs_handle_struct
*handle
, SMB_ACL_PERMSET_T permset
, SMB_ACL_PERM_T perm
)
617 static int skel_sys_acl_free_text(vfs_handle_struct
*handle
, char *text
)
623 static int skel_sys_acl_free_acl(vfs_handle_struct
*handle
, SMB_ACL_T posix_acl
)
629 static int skel_sys_acl_free_qualifier(vfs_handle_struct
*handle
, void *qualifier
, SMB_ACL_TAG_T tagtype
)
635 static ssize_t
skel_getxattr(vfs_handle_struct
*handle
, const char *path
, const char *name
, void *value
, size_t size
)
641 static ssize_t
skel_lgetxattr(vfs_handle_struct
*handle
, const char *path
, const char *name
, void *value
, size_t
648 static ssize_t
skel_fgetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, void *value
, size_t size
)
654 static ssize_t
skel_listxattr(vfs_handle_struct
*handle
, const char *path
, char *list
, size_t size
)
660 static ssize_t
skel_llistxattr(vfs_handle_struct
*handle
, const char *path
, char *list
, size_t size
)
666 static ssize_t
skel_flistxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, char *list
, size_t size
)
672 static int skel_removexattr(vfs_handle_struct
*handle
, const char *path
, const char *name
)
678 static int skel_lremovexattr(vfs_handle_struct
*handle
, const char *path
, const char *name
)
684 static int skel_fremovexattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
)
688 return SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, name
);
691 static int skel_setxattr(vfs_handle_struct
*handle
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
697 static int skel_lsetxattr(vfs_handle_struct
*handle
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
703 static int skel_fsetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, const void *value
, size_t size
, int flags
)
709 static int skel_aio_read(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
715 static int skel_aio_write(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
721 static ssize_t
skel_aio_return_fn(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
727 static int skel_aio_cancel(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
733 static int skel_aio_error_fn(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
739 static int skel_aio_fsync(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, int op
, SMB_STRUCT_AIOCB
*aiocb
)
745 static int skel_aio_suspend(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const SMB_STRUCT_AIOCB
* const aiocb
[], int n
, const struct timespec
*ts
)
751 static bool skel_aio_force(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
)
757 static bool skel_is_offline(struct vfs_handle_struct
*handle
, const char *path
, SMB_STRUCT_STAT
*sbuf
)
763 static int skel_set_offline(struct vfs_handle_struct
*handle
, const char *path
)
769 /* VFS operations structure */
771 struct vfs_fn_pointers skel_transparent_fns
= {
772 /* Disk operations */
774 .connect_fn
= skel_connect
,
775 .disconnect
= skel_disconnect
,
776 .disk_free
= skel_disk_free
,
777 .get_quota
= skel_get_quota
,
778 .set_quota
= skel_set_quota
,
779 .get_shadow_copy_data
= skel_get_shadow_copy_data
,
780 .statvfs
= skel_statvfs
,
781 .fs_capabilities
= skel_fs_capabilities
,
783 /* Directory operations */
785 .opendir
= skel_opendir
,
786 .readdir
= skel_readdir
,
787 .seekdir
= skel_seekdir
,
788 .telldir
= skel_telldir
,
789 .rewind_dir
= skel_rewind_dir
,
792 .closedir
= skel_closedir
,
793 .init_search_op
= skel_init_search_op
,
795 /* File operations */
798 .create_file
= skel_create_file
,
799 .close_fn
= skel_close_fn
,
800 .vfs_read
= skel_vfs_read
,
803 .pwrite
= skel_pwrite
,
805 .sendfile
= skel_sendfile
,
806 .recvfile
= skel_recvfile
,
807 .rename
= skel_rename
,
812 .get_alloc_size
= skel_get_alloc_size
,
813 .unlink
= skel_unlink
,
815 .fchmod
= skel_fchmod
,
817 .fchown
= skel_fchown
,
818 .lchown
= skel_lchown
,
821 .ntimes
= skel_ntimes
,
822 .ftruncate
= skel_ftruncate
,
823 .posix_fallocate
= skel_posix_fallocate
,
825 .kernel_flock
= skel_kernel_flock
,
826 .linux_setlease
= skel_linux_setlease
,
827 .getlock
= skel_getlock
,
828 .symlink
= skel_symlink
,
829 .vfs_readlink
= skel_vfs_readlink
,
832 .realpath
= skel_realpath
,
833 .notify_watch
= skel_notify_watch
,
834 .chflags
= skel_chflags
,
835 .file_id_create
= skel_file_id_create
,
837 .streaminfo
= skel_streaminfo
,
838 .get_real_filename
= skel_get_real_filename
,
839 .connectpath
= skel_connectpath
,
840 .brl_lock_windows
= skel_brl_lock_windows
,
841 .brl_unlock_windows
= skel_brl_unlock_windows
,
842 .brl_cancel_windows
= skel_brl_cancel_windows
,
843 .strict_lock
= skel_strict_lock
,
844 .strict_unlock
= skel_strict_unlock
,
845 .translate_name
= skel_translate_name
,
847 /* NT ACL operations. */
849 .fget_nt_acl
= skel_fget_nt_acl
,
850 .get_nt_acl
= skel_get_nt_acl
,
851 .fset_nt_acl
= skel_fset_nt_acl
,
853 /* POSIX ACL operations. */
855 .chmod_acl
= skel_chmod_acl
,
856 .fchmod_acl
= skel_fchmod_acl
,
858 .sys_acl_get_entry
= skel_sys_acl_get_entry
,
859 .sys_acl_get_tag_type
= skel_sys_acl_get_tag_type
,
860 .sys_acl_get_permset
= skel_sys_acl_get_permset
,
861 .sys_acl_get_qualifier
= skel_sys_acl_get_qualifier
,
862 .sys_acl_get_file
= skel_sys_acl_get_file
,
863 .sys_acl_get_fd
= skel_sys_acl_get_fd
,
864 .sys_acl_clear_perms
= skel_sys_acl_clear_perms
,
865 .sys_acl_add_perm
= skel_sys_acl_add_perm
,
866 .sys_acl_to_text
= skel_sys_acl_to_text
,
867 .sys_acl_init
= skel_sys_acl_init
,
868 .sys_acl_create_entry
= skel_sys_acl_create_entry
,
869 .sys_acl_set_tag_type
= skel_sys_acl_set_tag_type
,
870 .sys_acl_set_qualifier
= skel_sys_acl_set_qualifier
,
871 .sys_acl_set_permset
= skel_sys_acl_set_permset
,
872 .sys_acl_valid
= skel_sys_acl_valid
,
873 .sys_acl_set_file
= skel_sys_acl_set_file
,
874 .sys_acl_set_fd
= skel_sys_acl_set_fd
,
875 .sys_acl_delete_def_file
= skel_sys_acl_delete_def_file
,
876 .sys_acl_get_perm
= skel_sys_acl_get_perm
,
877 .sys_acl_free_text
= skel_sys_acl_free_text
,
878 .sys_acl_free_acl
= skel_sys_acl_free_acl
,
879 .sys_acl_free_qualifier
= skel_sys_acl_free_qualifier
,
882 .getxattr
= skel_getxattr
,
883 .lgetxattr
= skel_lgetxattr
,
884 .fgetxattr
= skel_fgetxattr
,
885 .listxattr
= skel_listxattr
,
886 .llistxattr
= skel_llistxattr
,
887 .flistxattr
= skel_flistxattr
,
888 .removexattr
= skel_removexattr
,
889 .lremovexattr
= skel_lremovexattr
,
890 .fremovexattr
= skel_fremovexattr
,
891 .setxattr
= skel_setxattr
,
892 .lsetxattr
= skel_lsetxattr
,
893 .fsetxattr
= skel_fsetxattr
,
896 .aio_read
= skel_aio_read
,
897 .aio_write
= skel_aio_write
,
898 .aio_return_fn
= skel_aio_return_fn
,
899 .aio_cancel
= skel_aio_cancel
,
900 .aio_error_fn
= skel_aio_error_fn
,
901 .aio_fsync
= skel_aio_fsync
,
902 .aio_suspend
= skel_aio_suspend
,
903 .aio_force
= skel_aio_force
,
905 /* offline operations */
906 .is_offline
= skel_is_offline
,
907 .set_offline
= skel_set_offline
910 NTSTATUS
vfs_skel_transparent_init(void)
912 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "skel_transparent", &skel_transparent_fns
);