2 Unix SMB/CIFS implementation.
3 Wrap disk only vfs functions to sidestep dodgy compilers.
4 Copyright (C) Tim Potter 1998
5 Copyright (C) Jeremy Allison 2007
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #define DBGC_CLASS DBGC_VFS
26 /* Check for NULL pointer parameters in vfswrap_* functions */
28 /* We don't want to have NULL function pointers lying around. Someone
29 is sure to try and execute them. These stubs are used to prevent
32 static int vfswrap_connect(vfs_handle_struct
*handle
, const char *service
, const char *user
)
34 return 0; /* Return >= 0 for success */
37 static void vfswrap_disconnect(vfs_handle_struct
*handle
)
43 static uint64_t vfswrap_disk_free(vfs_handle_struct
*handle
, const char *path
, bool small_query
, uint64_t *bsize
,
44 uint64_t *dfree
, uint64_t *dsize
)
48 result
= sys_disk_free(handle
->conn
, path
, small_query
, bsize
, dfree
, dsize
);
52 static int vfswrap_get_quota(struct vfs_handle_struct
*handle
, enum SMB_QUOTA_TYPE qtype
, unid_t id
, SMB_DISK_QUOTA
*qt
)
54 #ifdef HAVE_SYS_QUOTAS
57 START_PROFILE(syscall_get_quota
);
58 result
= sys_get_quota(handle
->conn
->connectpath
, qtype
, id
, qt
);
59 END_PROFILE(syscall_get_quota
);
67 static int vfswrap_set_quota(struct vfs_handle_struct
*handle
, enum SMB_QUOTA_TYPE qtype
, unid_t id
, SMB_DISK_QUOTA
*qt
)
69 #ifdef HAVE_SYS_QUOTAS
72 START_PROFILE(syscall_set_quota
);
73 result
= sys_set_quota(handle
->conn
->connectpath
, qtype
, id
, qt
);
74 END_PROFILE(syscall_set_quota
);
82 static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SHADOW_COPY_DATA
*shadow_copy_data
, bool labels
)
85 return -1; /* Not implemented. */
88 static int vfswrap_statvfs(struct vfs_handle_struct
*handle
, const char *path
, vfs_statvfs_struct
*statbuf
)
90 return sys_statvfs(path
, statbuf
);
93 static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct
*handle
,
94 enum timestamp_set_resolution
*p_ts_res
)
96 connection_struct
*conn
= handle
->conn
;
97 uint32_t caps
= FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
98 struct smb_filename
*smb_fname_cpath
= NULL
;
102 #if defined(DARWINOS)
103 struct vfs_statvfs_struct statbuf
;
104 ZERO_STRUCT(statbuf
);
105 sys_statvfs(conn
->connectpath
, &statbuf
);
106 caps
= statbuf
.FsCapabilities
;
109 *p_ts_res
= TIMESTAMP_SET_SECONDS
;
111 /* Work out what timestamp resolution we can
112 * use when setting a timestamp. */
114 status
= create_synthetic_smb_fname(talloc_tos(),
119 if (!NT_STATUS_IS_OK(status
)) {
123 ret
= SMB_VFS_STAT(conn
, smb_fname_cpath
);
125 TALLOC_FREE(smb_fname_cpath
);
129 if (smb_fname_cpath
->st
.st_ex_mtime
.tv_nsec
||
130 smb_fname_cpath
->st
.st_ex_atime
.tv_nsec
||
131 smb_fname_cpath
->st
.st_ex_ctime
.tv_nsec
) {
132 /* If any of the normal UNIX directory timestamps
133 * have a non-zero tv_nsec component assume
134 * we might be able to set sub-second timestamps.
135 * See what filetime set primitives we have.
137 #if defined(HAVE_UTIMES)
138 /* utimes allows msec timestamps to be set. */
139 *p_ts_res
= TIMESTAMP_SET_MSEC
;
140 #elif defined(HAVE_UTIME)
141 /* utime only allows sec timestamps to be set. */
142 *p_ts_res
= TIMESTAMP_SET_SECONDS
;
145 /* TODO. Add a configure test for the Linux
146 * nsec timestamp set system call, and use it
149 DEBUG(10,("vfswrap_fs_capabilities: timestamp "
151 "available on share %s, directory %s\n",
152 *p_ts_res
== TIMESTAMP_SET_MSEC
? "msec" : "sec",
153 lp_servicename(conn
->cnum
),
154 conn
->connectpath
));
156 TALLOC_FREE(smb_fname_cpath
);
160 /* Directory operations */
162 static SMB_STRUCT_DIR
*vfswrap_opendir(vfs_handle_struct
*handle
, const char *fname
, const char *mask
, uint32 attr
)
164 SMB_STRUCT_DIR
*result
;
166 START_PROFILE(syscall_opendir
);
167 result
= sys_opendir(fname
);
168 END_PROFILE(syscall_opendir
);
172 static SMB_STRUCT_DIRENT
*vfswrap_readdir(vfs_handle_struct
*handle
,
173 SMB_STRUCT_DIR
*dirp
,
174 SMB_STRUCT_STAT
*sbuf
)
176 SMB_STRUCT_DIRENT
*result
;
178 START_PROFILE(syscall_readdir
);
179 result
= sys_readdir(dirp
);
180 /* Default Posix readdir() does not give us stat info.
181 * Set to invalid to indicate we didn't return this info. */
183 SET_STAT_INVALID(*sbuf
);
184 END_PROFILE(syscall_readdir
);
188 static void vfswrap_seekdir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
, long offset
)
190 START_PROFILE(syscall_seekdir
);
191 sys_seekdir(dirp
, offset
);
192 END_PROFILE(syscall_seekdir
);
195 static long vfswrap_telldir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
)
198 START_PROFILE(syscall_telldir
);
199 result
= sys_telldir(dirp
);
200 END_PROFILE(syscall_telldir
);
204 static void vfswrap_rewinddir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
)
206 START_PROFILE(syscall_rewinddir
);
208 END_PROFILE(syscall_rewinddir
);
211 static int vfswrap_mkdir(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
214 bool has_dacl
= False
;
217 START_PROFILE(syscall_mkdir
);
219 if (lp_inherit_acls(SNUM(handle
->conn
))
220 && parent_dirname(talloc_tos(), path
, &parent
, NULL
)
221 && (has_dacl
= directory_has_default_acl(handle
->conn
, parent
)))
226 result
= mkdir(path
, mode
);
228 if (result
== 0 && !has_dacl
) {
230 * We need to do this as the default behavior of POSIX ACLs
231 * is to set the mask to be the requested group permission
232 * bits, not the group permission bits to be the requested
233 * group permission bits. This is not what we want, as it will
234 * mess up any inherited ACL bits that were set. JRA.
236 int saved_errno
= errno
; /* We may get ENOSYS */
237 if ((SMB_VFS_CHMOD_ACL(handle
->conn
, path
, mode
) == -1) && (errno
== ENOSYS
))
241 END_PROFILE(syscall_mkdir
);
245 static int vfswrap_rmdir(vfs_handle_struct
*handle
, const char *path
)
249 START_PROFILE(syscall_rmdir
);
250 result
= rmdir(path
);
251 END_PROFILE(syscall_rmdir
);
255 static int vfswrap_closedir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
)
259 START_PROFILE(syscall_closedir
);
260 result
= sys_closedir(dirp
);
261 END_PROFILE(syscall_closedir
);
265 static void vfswrap_init_search_op(vfs_handle_struct
*handle
,
266 SMB_STRUCT_DIR
*dirp
)
268 /* Default behavior is a NOOP */
271 /* File operations */
273 static int vfswrap_open(vfs_handle_struct
*handle
,
274 struct smb_filename
*smb_fname
,
275 files_struct
*fsp
, int flags
, mode_t mode
)
279 START_PROFILE(syscall_open
);
281 if (smb_fname
->stream_name
) {
286 result
= sys_open(smb_fname
->base_name
, flags
, mode
);
288 END_PROFILE(syscall_open
);
292 static NTSTATUS
vfswrap_create_file(vfs_handle_struct
*handle
,
293 struct smb_request
*req
,
294 uint16_t root_dir_fid
,
295 struct smb_filename
*smb_fname
,
296 uint32_t access_mask
,
297 uint32_t share_access
,
298 uint32_t create_disposition
,
299 uint32_t create_options
,
300 uint32_t file_attributes
,
301 uint32_t oplock_request
,
302 uint64_t allocation_size
,
303 struct security_descriptor
*sd
,
304 struct ea_list
*ea_list
,
305 files_struct
**result
,
308 return create_file_default(handle
->conn
, req
, root_dir_fid
, smb_fname
,
309 access_mask
, share_access
,
310 create_disposition
, create_options
,
311 file_attributes
, oplock_request
,
312 allocation_size
, sd
, ea_list
, result
,
316 static int vfswrap_close(vfs_handle_struct
*handle
, files_struct
*fsp
)
320 START_PROFILE(syscall_close
);
321 result
= fd_close_posix(fsp
);
322 END_PROFILE(syscall_close
);
326 static ssize_t
vfswrap_read(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
, size_t n
)
330 START_PROFILE_BYTES(syscall_read
, n
);
331 result
= sys_read(fsp
->fh
->fd
, data
, n
);
332 END_PROFILE(syscall_read
);
336 static ssize_t
vfswrap_pread(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
,
337 size_t n
, SMB_OFF_T offset
)
341 #if defined(HAVE_PREAD) || defined(HAVE_PREAD64)
342 START_PROFILE_BYTES(syscall_pread
, n
);
343 result
= sys_pread(fsp
->fh
->fd
, data
, n
, offset
);
344 END_PROFILE(syscall_pread
);
346 if (result
== -1 && errno
== ESPIPE
) {
347 /* Maintain the fiction that pipes can be seeked (sought?) on. */
348 result
= SMB_VFS_READ(fsp
, data
, n
);
352 #else /* HAVE_PREAD */
356 curr
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
357 if (curr
== -1 && errno
== ESPIPE
) {
358 /* Maintain the fiction that pipes can be seeked (sought?) on. */
359 result
= SMB_VFS_READ(fsp
, data
, n
);
364 if (SMB_VFS_LSEEK(fsp
, offset
, SEEK_SET
) == -1) {
369 result
= SMB_VFS_READ(fsp
, data
, n
);
372 SMB_VFS_LSEEK(fsp
, curr
, SEEK_SET
);
375 #endif /* HAVE_PREAD */
380 static ssize_t
vfswrap_write(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
, size_t n
)
384 START_PROFILE_BYTES(syscall_write
, n
);
385 result
= sys_write(fsp
->fh
->fd
, data
, n
);
386 END_PROFILE(syscall_write
);
390 static ssize_t
vfswrap_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
,
391 size_t n
, SMB_OFF_T offset
)
395 #if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)
396 START_PROFILE_BYTES(syscall_pwrite
, n
);
397 result
= sys_pwrite(fsp
->fh
->fd
, data
, n
, offset
);
398 END_PROFILE(syscall_pwrite
);
400 if (result
== -1 && errno
== ESPIPE
) {
401 /* Maintain the fiction that pipes can be sought on. */
402 result
= SMB_VFS_WRITE(fsp
, data
, n
);
405 #else /* HAVE_PWRITE */
409 curr
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
414 if (SMB_VFS_LSEEK(fsp
, offset
, SEEK_SET
) == -1) {
418 result
= SMB_VFS_WRITE(fsp
, data
, n
);
421 SMB_VFS_LSEEK(fsp
, curr
, SEEK_SET
);
424 #endif /* HAVE_PWRITE */
429 static SMB_OFF_T
vfswrap_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T offset
, int whence
)
431 SMB_OFF_T result
= 0;
433 START_PROFILE(syscall_lseek
);
435 /* Cope with 'stat' file opens. */
436 if (fsp
->fh
->fd
!= -1)
437 result
= sys_lseek(fsp
->fh
->fd
, offset
, whence
);
440 * We want to maintain the fiction that we can seek
441 * on a fifo for file system purposes. This allows
442 * people to set up UNIX fifo's that feed data to Windows
446 if((result
== -1) && (errno
== ESPIPE
)) {
451 END_PROFILE(syscall_lseek
);
455 static ssize_t
vfswrap_sendfile(vfs_handle_struct
*handle
, int tofd
, files_struct
*fromfsp
, const DATA_BLOB
*hdr
,
456 SMB_OFF_T offset
, size_t n
)
460 START_PROFILE_BYTES(syscall_sendfile
, n
);
461 result
= sys_sendfile(tofd
, fromfsp
->fh
->fd
, hdr
, offset
, n
);
462 END_PROFILE(syscall_sendfile
);
466 static ssize_t
vfswrap_recvfile(vfs_handle_struct
*handle
,
474 START_PROFILE_BYTES(syscall_recvfile
, n
);
475 result
= sys_recvfile(fromfd
, tofsp
->fh
->fd
, offset
, n
);
476 END_PROFILE(syscall_recvfile
);
480 /*********************************************************
481 For rename across filesystems Patch from Warren Birnbaum
482 <warrenb@hpcvscdp.cv.hp.com>
483 **********************************************************/
485 static int copy_reg(const char *source
, const char *dest
)
487 SMB_STRUCT_STAT source_stats
;
492 if (sys_lstat (source
, &source_stats
) == -1)
495 if (!S_ISREG (source_stats
.st_ex_mode
))
498 if((ifd
= sys_open (source
, O_RDONLY
, 0)) < 0)
501 if (unlink (dest
) && errno
!= ENOENT
)
505 if((ofd
= sys_open (dest
, O_WRONLY
| O_CREAT
| O_TRUNC
| O_NOFOLLOW
, 0600)) < 0 )
507 if((ofd
= sys_open (dest
, O_WRONLY
| O_CREAT
| O_TRUNC
, 0600)) < 0 )
511 if (transfer_file(ifd
, ofd
, (size_t)-1) == -1)
515 * Try to preserve ownership. For non-root it might fail, but that's ok.
516 * But root probably wants to know, e.g. if NFS disallows it.
520 if ((fchown(ofd
, source_stats
.st_ex_uid
, source_stats
.st_ex_gid
) == -1) && (errno
!= EPERM
))
522 if ((chown(dest
, source_stats
.st_ex_uid
, source_stats
.st_ex_gid
) == -1) && (errno
!= EPERM
))
527 * fchown turns off set[ug]id bits for non-root,
528 * so do the chmod last.
531 #if defined(HAVE_FCHMOD)
532 if (fchmod (ofd
, source_stats
.st_ex_mode
& 07777))
534 if (chmod (dest
, source_stats
.st_ex_mode
& 07777))
538 if (close (ifd
) == -1)
541 if (close (ofd
) == -1)
544 /* Try to copy the old file's modtime and access time. */
548 tv
.actime
= convert_timespec_to_time_t(source_stats
.st_ex_atime
);
549 tv
.modtime
= convert_timespec_to_time_t(source_stats
.st_ex_mtime
);
553 if (unlink (source
) == -1)
569 static int vfswrap_rename(vfs_handle_struct
*handle
,
570 const struct smb_filename
*smb_fname_src
,
571 const struct smb_filename
*smb_fname_dst
)
575 START_PROFILE(syscall_rename
);
577 if (smb_fname_src
->stream_name
|| smb_fname_dst
->stream_name
) {
582 result
= rename(smb_fname_src
->base_name
, smb_fname_dst
->base_name
);
583 if ((result
== -1) && (errno
== EXDEV
)) {
584 /* Rename across filesystems needed. */
585 result
= copy_reg(smb_fname_src
->base_name
,
586 smb_fname_dst
->base_name
);
590 END_PROFILE(syscall_rename
);
594 static int vfswrap_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
)
599 START_PROFILE(syscall_fsync
);
600 result
= fsync(fsp
->fh
->fd
);
601 END_PROFILE(syscall_fsync
);
608 static int vfswrap_stat(vfs_handle_struct
*handle
,
609 struct smb_filename
*smb_fname
)
613 START_PROFILE(syscall_stat
);
615 if (smb_fname
->stream_name
) {
620 result
= sys_stat(smb_fname
->base_name
, &smb_fname
->st
);
622 END_PROFILE(syscall_stat
);
626 static int vfswrap_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
630 START_PROFILE(syscall_fstat
);
631 result
= sys_fstat(fsp
->fh
->fd
, sbuf
);
632 END_PROFILE(syscall_fstat
);
636 static int vfswrap_lstat(vfs_handle_struct
*handle
,
637 struct smb_filename
*smb_fname
)
641 START_PROFILE(syscall_lstat
);
643 if (smb_fname
->stream_name
) {
648 result
= sys_lstat(smb_fname
->base_name
, &smb_fname
->st
);
650 END_PROFILE(syscall_lstat
);
654 static NTSTATUS
vfswrap_translate_name(vfs_handle_struct
*handle
,
656 enum vfs_translate_direction direction
)
658 /* Default behavior is a NOOP */
660 if (*mapped_name
!= NULL
)
663 return NT_STATUS_INVALID_PARAMETER
;
665 /********************************************************************
666 Given a stat buffer return the allocated size on disk, taking into
667 account sparse files.
668 ********************************************************************/
669 static uint64_t vfswrap_get_alloc_size(vfs_handle_struct
*handle
,
670 struct files_struct
*fsp
,
671 const SMB_STRUCT_STAT
*sbuf
)
675 START_PROFILE(syscall_get_alloc_size
);
677 if(S_ISDIR(sbuf
->st_ex_mode
)) {
682 #if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
683 result
= (uint64_t)STAT_ST_BLOCKSIZE
* (uint64_t)sbuf
->st_ex_blocks
;
685 result
= get_file_size_stat(sbuf
);
688 if (fsp
&& fsp
->initial_allocation_size
)
689 result
= MAX(result
,fsp
->initial_allocation_size
);
691 result
= smb_roundup(handle
->conn
, result
);
694 END_PROFILE(syscall_get_alloc_size
);
698 static int vfswrap_unlink(vfs_handle_struct
*handle
,
699 const struct smb_filename
*smb_fname
)
703 START_PROFILE(syscall_unlink
);
705 if (smb_fname
->stream_name
) {
709 result
= unlink(smb_fname
->base_name
);
712 END_PROFILE(syscall_unlink
);
716 static int vfswrap_chmod(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
720 START_PROFILE(syscall_chmod
);
723 * We need to do this due to the fact that the default POSIX ACL
724 * chmod modifies the ACL *mask* for the group owner, not the
725 * group owner bits directly. JRA.
730 int saved_errno
= errno
; /* We might get ENOSYS */
731 if ((result
= SMB_VFS_CHMOD_ACL(handle
->conn
, path
, mode
)) == 0) {
732 END_PROFILE(syscall_chmod
);
735 /* Error - return the old errno. */
739 result
= chmod(path
, mode
);
740 END_PROFILE(syscall_chmod
);
744 static int vfswrap_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
748 START_PROFILE(syscall_fchmod
);
751 * We need to do this due to the fact that the default POSIX ACL
752 * chmod modifies the ACL *mask* for the group owner, not the
753 * group owner bits directly. JRA.
757 int saved_errno
= errno
; /* We might get ENOSYS */
758 if ((result
= SMB_VFS_FCHMOD_ACL(fsp
, mode
)) == 0) {
759 END_PROFILE(syscall_fchmod
);
762 /* Error - return the old errno. */
766 #if defined(HAVE_FCHMOD)
767 result
= fchmod(fsp
->fh
->fd
, mode
);
773 END_PROFILE(syscall_fchmod
);
777 static int vfswrap_chown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
781 START_PROFILE(syscall_chown
);
782 result
= chown(path
, uid
, gid
);
783 END_PROFILE(syscall_chown
);
787 static int vfswrap_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
, uid_t uid
, gid_t gid
)
792 START_PROFILE(syscall_fchown
);
793 result
= fchown(fsp
->fh
->fd
, uid
, gid
);
794 END_PROFILE(syscall_fchown
);
802 static int vfswrap_lchown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
806 START_PROFILE(syscall_lchown
);
807 result
= lchown(path
, uid
, gid
);
808 END_PROFILE(syscall_lchown
);
812 static int vfswrap_chdir(vfs_handle_struct
*handle
, const char *path
)
816 START_PROFILE(syscall_chdir
);
817 result
= chdir(path
);
818 END_PROFILE(syscall_chdir
);
822 static char *vfswrap_getwd(vfs_handle_struct
*handle
, char *path
)
826 START_PROFILE(syscall_getwd
);
827 result
= sys_getwd(path
);
828 END_PROFILE(syscall_getwd
);
832 /*********************************************************************
833 nsec timestamp resolution call. Convert down to whatever the underlying
835 **********************************************************************/
837 static int vfswrap_ntimes(vfs_handle_struct
*handle
,
838 const struct smb_filename
*smb_fname
,
839 struct smb_file_time
*ft
)
843 START_PROFILE(syscall_ntimes
);
845 if (smb_fname
->stream_name
) {
850 if (null_timespec(ft
->atime
)) {
851 ft
->atime
= smb_fname
->st
.st_ex_atime
;
854 if (null_timespec(ft
->mtime
)) {
855 ft
->mtime
= smb_fname
->st
.st_ex_mtime
;
858 if (!null_timespec(ft
->create_time
) &&
859 lp_store_create_time(SNUM(handle
->conn
))) {
860 set_create_timespec_ea(handle
->conn
,
866 if ((timespec_compare(&ft
->atime
,
867 &smb_fname
->st
.st_ex_atime
) == 0) &&
868 (timespec_compare(&ft
->mtime
,
869 &smb_fname
->st
.st_ex_mtime
) == 0)) {
873 #if defined(HAVE_UTIMES)
875 struct timeval tv
[2];
876 tv
[0] = convert_timespec_to_timeval(ft
->atime
);
877 tv
[1] = convert_timespec_to_timeval(ft
->mtime
);
878 result
= utimes(smb_fname
->base_name
, tv
);
880 result
= utimes(smb_fname
->base_name
, NULL
);
882 #elif defined(HAVE_UTIME)
884 struct utimbuf times
;
885 times
.actime
= convert_timespec_to_time_t(ft
->atime
);
886 times
.modtime
= convert_timespec_to_time_t(ft
->mtime
);
887 result
= utime(smb_fname
->base_name
, ×
);
889 result
= utime(smb_fname
->base_name
, NULL
);
897 END_PROFILE(syscall_ntimes
);
901 /*********************************************************************
902 A version of ftruncate that will write the space on disk if strict
904 **********************************************************************/
906 static int strict_allocate_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T len
)
909 SMB_OFF_T currpos
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
910 unsigned char zero_space
[4096];
911 SMB_OFF_T space_to_write
;
916 if (SMB_VFS_FSTAT(fsp
, &st
) == -1)
919 space_to_write
= len
- st
.st_ex_size
;
922 if (S_ISFIFO(st
.st_ex_mode
))
926 if (st
.st_ex_size
== len
)
929 /* Shrink - just ftruncate. */
930 if (st
.st_ex_size
> len
)
931 return sys_ftruncate(fsp
->fh
->fd
, len
);
933 /* available disk space is enough or not? */
934 if (lp_strict_allocate(SNUM(fsp
->conn
))){
935 uint64_t space_avail
;
936 uint64_t bsize
,dfree
,dsize
;
938 space_avail
= get_dfree_info(fsp
->conn
,
939 fsp
->fsp_name
->base_name
, false,
940 &bsize
, &dfree
, &dsize
);
941 /* space_avail is 1k blocks */
942 if (space_avail
== (uint64_t)-1 ||
943 ((uint64_t)space_to_write
/1024 > space_avail
) ) {
949 /* Write out the real space on disk. */
950 if (SMB_VFS_LSEEK(fsp
, st
.st_ex_size
, SEEK_SET
) != st
.st_ex_size
)
953 space_to_write
= len
- st
.st_ex_size
;
955 memset(zero_space
, '\0', sizeof(zero_space
));
956 while ( space_to_write
> 0) {
958 SMB_OFF_T current_len_to_write
= MIN(sizeof(zero_space
),space_to_write
);
960 retlen
= SMB_VFS_WRITE(fsp
,(char *)zero_space
,current_len_to_write
);
964 space_to_write
-= retlen
;
967 /* Seek to where we were */
968 if (SMB_VFS_LSEEK(fsp
, currpos
, SEEK_SET
) != currpos
)
974 static int vfswrap_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T len
)
981 START_PROFILE(syscall_ftruncate
);
983 if (lp_strict_allocate(SNUM(fsp
->conn
))) {
984 result
= strict_allocate_ftruncate(handle
, fsp
, len
);
985 END_PROFILE(syscall_ftruncate
);
989 /* we used to just check HAVE_FTRUNCATE_EXTEND and only use
990 sys_ftruncate if the system supports it. Then I discovered that
991 you can have some filesystems that support ftruncate
992 expansion and some that don't! On Linux fat can't do
993 ftruncate extend but ext2 can. */
995 result
= sys_ftruncate(fsp
->fh
->fd
, len
);
999 /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
1000 extend a file with ftruncate. Provide alternate implementation
1002 currpos
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
1003 if (currpos
== -1) {
1007 /* Do an fstat to see if the file is longer than the requested
1008 size in which case the ftruncate above should have
1009 succeeded or shorter, in which case seek to len - 1 and
1010 write 1 byte of zero */
1011 if (SMB_VFS_FSTAT(fsp
, &st
) == -1) {
1016 if (S_ISFIFO(st
.st_ex_mode
)) {
1022 if (st
.st_ex_size
== len
) {
1027 if (st
.st_ex_size
> len
) {
1028 /* the sys_ftruncate should have worked */
1032 if (SMB_VFS_LSEEK(fsp
, len
-1, SEEK_SET
) != len
-1)
1035 if (SMB_VFS_WRITE(fsp
, &c
, 1)!=1)
1038 /* Seek to where we were */
1039 if (SMB_VFS_LSEEK(fsp
, currpos
, SEEK_SET
) != currpos
)
1045 END_PROFILE(syscall_ftruncate
);
1049 static bool vfswrap_lock(vfs_handle_struct
*handle
, files_struct
*fsp
, int op
, SMB_OFF_T offset
, SMB_OFF_T count
, int type
)
1053 START_PROFILE(syscall_fcntl_lock
);
1054 result
= fcntl_lock(fsp
->fh
->fd
, op
, offset
, count
, type
);
1055 END_PROFILE(syscall_fcntl_lock
);
1059 static int vfswrap_kernel_flock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1060 uint32 share_mode
, uint32 access_mask
)
1062 START_PROFILE(syscall_kernel_flock
);
1063 kernel_flock(fsp
->fh
->fd
, share_mode
, access_mask
);
1064 END_PROFILE(syscall_kernel_flock
);
1068 static bool vfswrap_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T
*poffset
, SMB_OFF_T
*pcount
, int *ptype
, pid_t
*ppid
)
1072 START_PROFILE(syscall_fcntl_getlock
);
1073 result
= fcntl_getlock(fsp
->fh
->fd
, poffset
, pcount
, ptype
, ppid
);
1074 END_PROFILE(syscall_fcntl_getlock
);
1078 static int vfswrap_linux_setlease(vfs_handle_struct
*handle
, files_struct
*fsp
,
1083 START_PROFILE(syscall_linux_setlease
);
1085 #ifdef HAVE_KERNEL_OPLOCKS_LINUX
1086 /* first set the signal handler */
1087 if(linux_set_lease_sighandler(fsp
->fh
->fd
) == -1) {
1091 result
= linux_setlease(fsp
->fh
->fd
, leasetype
);
1095 END_PROFILE(syscall_linux_setlease
);
1099 static int vfswrap_symlink(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
1103 START_PROFILE(syscall_symlink
);
1104 result
= symlink(oldpath
, newpath
);
1105 END_PROFILE(syscall_symlink
);
1109 static int vfswrap_readlink(vfs_handle_struct
*handle
, const char *path
, char *buf
, size_t bufsiz
)
1113 START_PROFILE(syscall_readlink
);
1114 result
= readlink(path
, buf
, bufsiz
);
1115 END_PROFILE(syscall_readlink
);
1119 static int vfswrap_link(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
1123 START_PROFILE(syscall_link
);
1124 result
= link(oldpath
, newpath
);
1125 END_PROFILE(syscall_link
);
1129 static int vfswrap_mknod(vfs_handle_struct
*handle
, const char *pathname
, mode_t mode
, SMB_DEV_T dev
)
1133 START_PROFILE(syscall_mknod
);
1134 result
= sys_mknod(pathname
, mode
, dev
);
1135 END_PROFILE(syscall_mknod
);
1139 static char *vfswrap_realpath(vfs_handle_struct
*handle
, const char *path
, char *resolved_path
)
1143 START_PROFILE(syscall_realpath
);
1144 result
= realpath(path
, resolved_path
);
1145 END_PROFILE(syscall_realpath
);
1149 static NTSTATUS
vfswrap_notify_watch(vfs_handle_struct
*vfs_handle
,
1150 struct sys_notify_context
*ctx
,
1151 struct notify_entry
*e
,
1152 void (*callback
)(struct sys_notify_context
*ctx
,
1154 struct notify_event
*ev
),
1155 void *private_data
, void *handle
)
1158 * So far inotify is the only supported default notify mechanism. If
1159 * another platform like the the BSD's or a proprietary Unix comes
1160 * along and wants another default, we can play the same trick we
1161 * played with Posix ACLs.
1163 * Until that is the case, hard-code inotify here.
1166 if (lp_kernel_change_notify(ctx
->conn
->params
)) {
1167 return inotify_watch(ctx
, e
, callback
, private_data
, handle
);
1171 * Do nothing, leave everything to notify_internal.c
1173 return NT_STATUS_OK
;
1176 static int vfswrap_chflags(vfs_handle_struct
*handle
, const char *path
,
1180 return chflags(path
, flags
);
1187 static struct file_id
vfswrap_file_id_create(struct vfs_handle_struct
*handle
,
1188 const SMB_STRUCT_STAT
*sbuf
)
1192 /* the ZERO_STRUCT ensures padding doesn't break using the key as a
1196 key
.devid
= sbuf
->st_ex_dev
;
1197 key
.inode
= sbuf
->st_ex_ino
;
1198 /* key.extid is unused by default. */
1203 static NTSTATUS
vfswrap_streaminfo(vfs_handle_struct
*handle
,
1204 struct files_struct
*fsp
,
1206 TALLOC_CTX
*mem_ctx
,
1207 unsigned int *pnum_streams
,
1208 struct stream_struct
**pstreams
)
1210 SMB_STRUCT_STAT sbuf
;
1211 unsigned int num_streams
= 0;
1212 struct stream_struct
*streams
= NULL
;
1215 if ((fsp
!= NULL
) && (fsp
->is_directory
)) {
1217 * No default streams on directories
1222 if ((fsp
!= NULL
) && (fsp
->fh
->fd
!= -1)) {
1223 ret
= SMB_VFS_FSTAT(fsp
, &sbuf
);
1226 struct smb_filename
*smb_fname
= NULL
;
1229 status
= create_synthetic_smb_fname(talloc_tos(), fname
, NULL
,
1231 if (!NT_STATUS_IS_OK(status
)) {
1234 if (lp_posix_pathnames()) {
1235 ret
= SMB_VFS_LSTAT(handle
->conn
, smb_fname
);
1237 ret
= SMB_VFS_STAT(handle
->conn
, smb_fname
);
1239 sbuf
= smb_fname
->st
;
1240 TALLOC_FREE(smb_fname
);
1244 return map_nt_error_from_unix(errno
);
1247 if (S_ISDIR(sbuf
.st_ex_mode
)) {
1251 streams
= talloc(mem_ctx
, struct stream_struct
);
1253 if (streams
== NULL
) {
1254 return NT_STATUS_NO_MEMORY
;
1257 streams
->size
= sbuf
.st_ex_size
;
1258 streams
->alloc_size
= SMB_VFS_GET_ALLOC_SIZE(handle
->conn
, fsp
, &sbuf
);
1260 streams
->name
= talloc_strdup(streams
, "::$DATA");
1261 if (streams
->name
== NULL
) {
1262 TALLOC_FREE(streams
);
1263 return NT_STATUS_NO_MEMORY
;
1268 *pnum_streams
= num_streams
;
1269 *pstreams
= streams
;
1270 return NT_STATUS_OK
;
1273 static int vfswrap_get_real_filename(struct vfs_handle_struct
*handle
,
1276 TALLOC_CTX
*mem_ctx
,
1280 * Don't fall back to get_real_filename so callers can differentiate
1281 * between a full directory scan and an actual case-insensitive stat.
1287 static const char *vfswrap_connectpath(struct vfs_handle_struct
*handle
,
1290 return handle
->conn
->connectpath
;
1293 static NTSTATUS
vfswrap_brl_lock_windows(struct vfs_handle_struct
*handle
,
1294 struct byte_range_lock
*br_lck
,
1295 struct lock_struct
*plock
,
1297 struct blocking_lock_record
*blr
)
1299 SMB_ASSERT(plock
->lock_flav
== WINDOWS_LOCK
);
1301 /* Note: blr is not used in the default implementation. */
1302 return brl_lock_windows_default(br_lck
, plock
, blocking_lock
);
1305 static bool vfswrap_brl_unlock_windows(struct vfs_handle_struct
*handle
,
1306 struct messaging_context
*msg_ctx
,
1307 struct byte_range_lock
*br_lck
,
1308 const struct lock_struct
*plock
)
1310 SMB_ASSERT(plock
->lock_flav
== WINDOWS_LOCK
);
1312 return brl_unlock_windows_default(msg_ctx
, br_lck
, plock
);
1315 static bool vfswrap_brl_cancel_windows(struct vfs_handle_struct
*handle
,
1316 struct byte_range_lock
*br_lck
,
1317 struct lock_struct
*plock
,
1318 struct blocking_lock_record
*blr
)
1320 SMB_ASSERT(plock
->lock_flav
== WINDOWS_LOCK
);
1322 /* Note: blr is not used in the default implementation. */
1323 return brl_lock_cancel_default(br_lck
, plock
);
1326 static bool vfswrap_strict_lock(struct vfs_handle_struct
*handle
,
1328 struct lock_struct
*plock
)
1330 SMB_ASSERT(plock
->lock_type
== READ_LOCK
||
1331 plock
->lock_type
== WRITE_LOCK
);
1333 return strict_lock_default(fsp
, plock
);
1336 static void vfswrap_strict_unlock(struct vfs_handle_struct
*handle
,
1338 struct lock_struct
*plock
)
1340 SMB_ASSERT(plock
->lock_type
== READ_LOCK
||
1341 plock
->lock_type
== WRITE_LOCK
);
1343 strict_unlock_default(fsp
, plock
);
1346 /* NT ACL operations. */
1348 static NTSTATUS
vfswrap_fget_nt_acl(vfs_handle_struct
*handle
,
1350 uint32 security_info
, SEC_DESC
**ppdesc
)
1354 START_PROFILE(fget_nt_acl
);
1355 result
= posix_fget_nt_acl(fsp
, security_info
, ppdesc
);
1356 END_PROFILE(fget_nt_acl
);
1360 static NTSTATUS
vfswrap_get_nt_acl(vfs_handle_struct
*handle
,
1362 uint32 security_info
, SEC_DESC
**ppdesc
)
1366 START_PROFILE(get_nt_acl
);
1367 result
= posix_get_nt_acl(handle
->conn
, name
, security_info
, ppdesc
);
1368 END_PROFILE(get_nt_acl
);
1372 static NTSTATUS
vfswrap_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
, uint32 security_info_sent
, const SEC_DESC
*psd
)
1376 START_PROFILE(fset_nt_acl
);
1377 result
= set_nt_acl(fsp
, security_info_sent
, psd
);
1378 END_PROFILE(fset_nt_acl
);
1382 static int vfswrap_chmod_acl(vfs_handle_struct
*handle
, const char *name
, mode_t mode
)
1390 START_PROFILE(chmod_acl
);
1391 result
= chmod_acl(handle
->conn
, name
, mode
);
1392 END_PROFILE(chmod_acl
);
1397 static int vfswrap_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
1405 START_PROFILE(fchmod_acl
);
1406 result
= fchmod_acl(fsp
, mode
);
1407 END_PROFILE(fchmod_acl
);
1412 static int vfswrap_sys_acl_get_entry(vfs_handle_struct
*handle
, SMB_ACL_T theacl
, int entry_id
, SMB_ACL_ENTRY_T
*entry_p
)
1414 return sys_acl_get_entry(theacl
, entry_id
, entry_p
);
1417 static int vfswrap_sys_acl_get_tag_type(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry_d
, SMB_ACL_TAG_T
*tag_type_p
)
1419 return sys_acl_get_tag_type(entry_d
, tag_type_p
);
1422 static int vfswrap_sys_acl_get_permset(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry_d
, SMB_ACL_PERMSET_T
*permset_p
)
1424 return sys_acl_get_permset(entry_d
, permset_p
);
1427 static void * vfswrap_sys_acl_get_qualifier(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry_d
)
1429 return sys_acl_get_qualifier(entry_d
);
1432 static SMB_ACL_T
vfswrap_sys_acl_get_file(vfs_handle_struct
*handle
, const char *path_p
, SMB_ACL_TYPE_T type
)
1434 return sys_acl_get_file(handle
, path_p
, type
);
1437 static SMB_ACL_T
vfswrap_sys_acl_get_fd(vfs_handle_struct
*handle
, files_struct
*fsp
)
1439 return sys_acl_get_fd(handle
, fsp
);
1442 static int vfswrap_sys_acl_clear_perms(vfs_handle_struct
*handle
, SMB_ACL_PERMSET_T permset
)
1444 return sys_acl_clear_perms(permset
);
1447 static int vfswrap_sys_acl_add_perm(vfs_handle_struct
*handle
, SMB_ACL_PERMSET_T permset
, SMB_ACL_PERM_T perm
)
1449 return sys_acl_add_perm(permset
, perm
);
1452 static char * vfswrap_sys_acl_to_text(vfs_handle_struct
*handle
, SMB_ACL_T theacl
, ssize_t
*plen
)
1454 return sys_acl_to_text(theacl
, plen
);
1457 static SMB_ACL_T
vfswrap_sys_acl_init(vfs_handle_struct
*handle
, int count
)
1459 return sys_acl_init(count
);
1462 static int vfswrap_sys_acl_create_entry(vfs_handle_struct
*handle
, SMB_ACL_T
*pacl
, SMB_ACL_ENTRY_T
*pentry
)
1464 return sys_acl_create_entry(pacl
, pentry
);
1467 static int vfswrap_sys_acl_set_tag_type(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry
, SMB_ACL_TAG_T tagtype
)
1469 return sys_acl_set_tag_type(entry
, tagtype
);
1472 static int vfswrap_sys_acl_set_qualifier(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry
, void *qual
)
1474 return sys_acl_set_qualifier(entry
, qual
);
1477 static int vfswrap_sys_acl_set_permset(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry
, SMB_ACL_PERMSET_T permset
)
1479 return sys_acl_set_permset(entry
, permset
);
1482 static int vfswrap_sys_acl_valid(vfs_handle_struct
*handle
, SMB_ACL_T theacl
)
1484 return sys_acl_valid(theacl
);
1487 static int vfswrap_sys_acl_set_file(vfs_handle_struct
*handle
, const char *name
, SMB_ACL_TYPE_T acltype
, SMB_ACL_T theacl
)
1489 return sys_acl_set_file(handle
, name
, acltype
, theacl
);
1492 static int vfswrap_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_ACL_T theacl
)
1494 return sys_acl_set_fd(handle
, fsp
, theacl
);
1497 static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct
*handle
, const char *path
)
1499 return sys_acl_delete_def_file(handle
, path
);
1502 static int vfswrap_sys_acl_get_perm(vfs_handle_struct
*handle
, SMB_ACL_PERMSET_T permset
, SMB_ACL_PERM_T perm
)
1504 return sys_acl_get_perm(permset
, perm
);
1507 static int vfswrap_sys_acl_free_text(vfs_handle_struct
*handle
, char *text
)
1509 return sys_acl_free_text(text
);
1512 static int vfswrap_sys_acl_free_acl(vfs_handle_struct
*handle
, SMB_ACL_T posix_acl
)
1514 return sys_acl_free_acl(posix_acl
);
1517 static int vfswrap_sys_acl_free_qualifier(vfs_handle_struct
*handle
, void *qualifier
, SMB_ACL_TAG_T tagtype
)
1519 return sys_acl_free_qualifier(qualifier
, tagtype
);
1522 /****************************************************************
1523 Extended attribute operations.
1524 *****************************************************************/
1526 static ssize_t
vfswrap_getxattr(struct vfs_handle_struct
*handle
,const char *path
, const char *name
, void *value
, size_t size
)
1528 return sys_getxattr(path
, name
, value
, size
);
1531 static ssize_t
vfswrap_lgetxattr(struct vfs_handle_struct
*handle
,const char *path
, const char *name
, void *value
, size_t size
)
1533 return sys_lgetxattr(path
, name
, value
, size
);
1536 static ssize_t
vfswrap_fgetxattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, void *value
, size_t size
)
1538 return sys_fgetxattr(fsp
->fh
->fd
, name
, value
, size
);
1541 static ssize_t
vfswrap_listxattr(struct vfs_handle_struct
*handle
, const char *path
, char *list
, size_t size
)
1543 return sys_listxattr(path
, list
, size
);
1546 ssize_t
vfswrap_llistxattr(struct vfs_handle_struct
*handle
, const char *path
, char *list
, size_t size
)
1548 return sys_llistxattr(path
, list
, size
);
1551 ssize_t
vfswrap_flistxattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, char *list
, size_t size
)
1553 return sys_flistxattr(fsp
->fh
->fd
, list
, size
);
1556 static int vfswrap_removexattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
)
1558 return sys_removexattr(path
, name
);
1561 static int vfswrap_lremovexattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
)
1563 return sys_lremovexattr(path
, name
);
1566 static int vfswrap_fremovexattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
)
1568 return sys_fremovexattr(fsp
->fh
->fd
, name
);
1571 static int vfswrap_setxattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
1573 return sys_setxattr(path
, name
, value
, size
, flags
);
1576 static int vfswrap_lsetxattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
1578 return sys_lsetxattr(path
, name
, value
, size
, flags
);
1581 static int vfswrap_fsetxattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, const void *value
, size_t size
, int flags
)
1583 return sys_fsetxattr(fsp
->fh
->fd
, name
, value
, size
, flags
);
1586 static int vfswrap_aio_read(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1590 * aio_read must be done as root, because in the glibc aio
1591 * implementation the helper thread needs to be able to send a signal
1592 * to the main thread, even when it has done a seteuid() to a
1596 ret
= sys_aio_read(aiocb
);
1601 static int vfswrap_aio_write(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1605 * aio_write must be done as root, because in the glibc aio
1606 * implementation the helper thread needs to be able to send a signal
1607 * to the main thread, even when it has done a seteuid() to a
1611 ret
= sys_aio_write(aiocb
);
1616 static ssize_t
vfswrap_aio_return(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1618 return sys_aio_return(aiocb
);
1621 static int vfswrap_aio_cancel(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1623 return sys_aio_cancel(fsp
->fh
->fd
, aiocb
);
1626 static int vfswrap_aio_error(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1628 return sys_aio_error(aiocb
);
1631 static int vfswrap_aio_fsync(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, int op
, SMB_STRUCT_AIOCB
*aiocb
)
1633 return sys_aio_fsync(op
, aiocb
);
1636 static int vfswrap_aio_suspend(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const SMB_STRUCT_AIOCB
* const aiocb
[], int n
, const struct timespec
*timeout
)
1638 return sys_aio_suspend(aiocb
, n
, timeout
);
1641 static bool vfswrap_aio_force(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
)
1646 static bool vfswrap_is_offline(struct vfs_handle_struct
*handle
, const char *path
, SMB_STRUCT_STAT
*sbuf
)
1648 if (ISDOT(path
) || ISDOTDOT(path
)) {
1652 if (!lp_dmapi_support(SNUM(handle
->conn
)) || !dmapi_have_session()) {
1653 #if defined(ENOTSUP)
1659 return (dmapi_file_flags(path
) & FILE_ATTRIBUTE_OFFLINE
) != 0;
1662 static int vfswrap_set_offline(struct vfs_handle_struct
*handle
, const char *path
)
1664 /* We don't know how to set offline bit by default, needs to be overriden in the vfs modules */
1665 #if defined(ENOTSUP)
1671 static struct vfs_fn_pointers vfs_default_fns
= {
1672 /* Disk operations */
1674 .connect_fn
= vfswrap_connect
,
1675 .disconnect
= vfswrap_disconnect
,
1676 .disk_free
= vfswrap_disk_free
,
1677 .get_quota
= vfswrap_get_quota
,
1678 .set_quota
= vfswrap_set_quota
,
1679 .get_shadow_copy_data
= vfswrap_get_shadow_copy_data
,
1680 .statvfs
= vfswrap_statvfs
,
1681 .fs_capabilities
= vfswrap_fs_capabilities
,
1683 /* Directory operations */
1685 .opendir
= vfswrap_opendir
,
1686 .readdir
= vfswrap_readdir
,
1687 .seekdir
= vfswrap_seekdir
,
1688 .telldir
= vfswrap_telldir
,
1689 .rewind_dir
= vfswrap_rewinddir
,
1690 .mkdir
= vfswrap_mkdir
,
1691 .rmdir
= vfswrap_rmdir
,
1692 .closedir
= vfswrap_closedir
,
1693 .init_search_op
= vfswrap_init_search_op
,
1695 /* File operations */
1697 .open
= vfswrap_open
,
1698 .create_file
= vfswrap_create_file
,
1699 .close_fn
= vfswrap_close
,
1700 .vfs_read
= vfswrap_read
,
1701 .pread
= vfswrap_pread
,
1702 .write
= vfswrap_write
,
1703 .pwrite
= vfswrap_pwrite
,
1704 .lseek
= vfswrap_lseek
,
1705 .sendfile
= vfswrap_sendfile
,
1706 .recvfile
= vfswrap_recvfile
,
1707 .rename
= vfswrap_rename
,
1708 .fsync
= vfswrap_fsync
,
1709 .stat
= vfswrap_stat
,
1710 .fstat
= vfswrap_fstat
,
1711 .lstat
= vfswrap_lstat
,
1712 .get_alloc_size
= vfswrap_get_alloc_size
,
1713 .unlink
= vfswrap_unlink
,
1714 .chmod
= vfswrap_chmod
,
1715 .fchmod
= vfswrap_fchmod
,
1716 .chown
= vfswrap_chown
,
1717 .fchown
= vfswrap_fchown
,
1718 .lchown
= vfswrap_lchown
,
1719 .chdir
= vfswrap_chdir
,
1720 .getwd
= vfswrap_getwd
,
1721 .ntimes
= vfswrap_ntimes
,
1722 .ftruncate
= vfswrap_ftruncate
,
1723 .lock
= vfswrap_lock
,
1724 .kernel_flock
= vfswrap_kernel_flock
,
1725 .linux_setlease
= vfswrap_linux_setlease
,
1726 .getlock
= vfswrap_getlock
,
1727 .symlink
= vfswrap_symlink
,
1728 .vfs_readlink
= vfswrap_readlink
,
1729 .link
= vfswrap_link
,
1730 .mknod
= vfswrap_mknod
,
1731 .realpath
= vfswrap_realpath
,
1732 .notify_watch
= vfswrap_notify_watch
,
1733 .chflags
= vfswrap_chflags
,
1734 .file_id_create
= vfswrap_file_id_create
,
1735 .streaminfo
= vfswrap_streaminfo
,
1736 .get_real_filename
= vfswrap_get_real_filename
,
1737 .connectpath
= vfswrap_connectpath
,
1738 .brl_lock_windows
= vfswrap_brl_lock_windows
,
1739 .brl_unlock_windows
= vfswrap_brl_unlock_windows
,
1740 .brl_cancel_windows
= vfswrap_brl_cancel_windows
,
1741 .strict_lock
= vfswrap_strict_lock
,
1742 .strict_unlock
= vfswrap_strict_unlock
,
1743 .translate_name
= vfswrap_translate_name
,
1745 /* NT ACL operations. */
1747 .fget_nt_acl
= vfswrap_fget_nt_acl
,
1748 .get_nt_acl
= vfswrap_get_nt_acl
,
1749 .fset_nt_acl
= vfswrap_fset_nt_acl
,
1751 /* POSIX ACL operations. */
1753 .chmod_acl
= vfswrap_chmod_acl
,
1754 .fchmod_acl
= vfswrap_fchmod_acl
,
1756 .sys_acl_get_entry
= vfswrap_sys_acl_get_entry
,
1757 .sys_acl_get_tag_type
= vfswrap_sys_acl_get_tag_type
,
1758 .sys_acl_get_permset
= vfswrap_sys_acl_get_permset
,
1759 .sys_acl_get_qualifier
= vfswrap_sys_acl_get_qualifier
,
1760 .sys_acl_get_file
= vfswrap_sys_acl_get_file
,
1761 .sys_acl_get_fd
= vfswrap_sys_acl_get_fd
,
1762 .sys_acl_clear_perms
= vfswrap_sys_acl_clear_perms
,
1763 .sys_acl_add_perm
= vfswrap_sys_acl_add_perm
,
1764 .sys_acl_to_text
= vfswrap_sys_acl_to_text
,
1765 .sys_acl_init
= vfswrap_sys_acl_init
,
1766 .sys_acl_create_entry
= vfswrap_sys_acl_create_entry
,
1767 .sys_acl_set_tag_type
= vfswrap_sys_acl_set_tag_type
,
1768 .sys_acl_set_qualifier
= vfswrap_sys_acl_set_qualifier
,
1769 .sys_acl_set_permset
= vfswrap_sys_acl_set_permset
,
1770 .sys_acl_valid
= vfswrap_sys_acl_valid
,
1771 .sys_acl_set_file
= vfswrap_sys_acl_set_file
,
1772 .sys_acl_set_fd
= vfswrap_sys_acl_set_fd
,
1773 .sys_acl_delete_def_file
= vfswrap_sys_acl_delete_def_file
,
1774 .sys_acl_get_perm
= vfswrap_sys_acl_get_perm
,
1775 .sys_acl_free_text
= vfswrap_sys_acl_free_text
,
1776 .sys_acl_free_acl
= vfswrap_sys_acl_free_acl
,
1777 .sys_acl_free_qualifier
= vfswrap_sys_acl_free_qualifier
,
1779 /* EA operations. */
1780 .getxattr
= vfswrap_getxattr
,
1781 .lgetxattr
= vfswrap_lgetxattr
,
1782 .fgetxattr
= vfswrap_fgetxattr
,
1783 .listxattr
= vfswrap_listxattr
,
1784 .llistxattr
= vfswrap_llistxattr
,
1785 .flistxattr
= vfswrap_flistxattr
,
1786 .removexattr
= vfswrap_removexattr
,
1787 .lremovexattr
= vfswrap_lremovexattr
,
1788 .fremovexattr
= vfswrap_fremovexattr
,
1789 .setxattr
= vfswrap_setxattr
,
1790 .lsetxattr
= vfswrap_lsetxattr
,
1791 .fsetxattr
= vfswrap_fsetxattr
,
1793 /* aio operations */
1794 .aio_read
= vfswrap_aio_read
,
1795 .aio_write
= vfswrap_aio_write
,
1796 .aio_return_fn
= vfswrap_aio_return
,
1797 .aio_cancel
= vfswrap_aio_cancel
,
1798 .aio_error_fn
= vfswrap_aio_error
,
1799 .aio_fsync
= vfswrap_aio_fsync
,
1800 .aio_suspend
= vfswrap_aio_suspend
,
1801 .aio_force
= vfswrap_aio_force
,
1803 /* offline operations */
1804 .is_offline
= vfswrap_is_offline
,
1805 .set_offline
= vfswrap_set_offline
1808 NTSTATUS
vfs_default_init(void);
1809 NTSTATUS
vfs_default_init(void)
1811 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
1812 DEFAULT_VFS_MODULE_NAME
, &vfs_default_fns
);