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_UTIMENSAT)
138 *p_ts_res
= TIMESTAMP_SET_NT_OR_BETTER
;
139 #elif defined(HAVE_UTIMES)
140 /* utimes allows msec timestamps to be set. */
141 *p_ts_res
= TIMESTAMP_SET_MSEC
;
142 #elif defined(HAVE_UTIME)
143 /* utime only allows sec timestamps to be set. */
144 *p_ts_res
= TIMESTAMP_SET_SECONDS
;
147 DEBUG(10,("vfswrap_fs_capabilities: timestamp "
149 "available on share %s, directory %s\n",
150 *p_ts_res
== TIMESTAMP_SET_MSEC
? "msec" : "sec",
151 lp_servicename(conn
->params
->service
),
152 conn
->connectpath
));
154 TALLOC_FREE(smb_fname_cpath
);
158 /* Directory operations */
160 static SMB_STRUCT_DIR
*vfswrap_opendir(vfs_handle_struct
*handle
, const char *fname
, const char *mask
, uint32 attr
)
162 SMB_STRUCT_DIR
*result
;
164 START_PROFILE(syscall_opendir
);
165 result
= sys_opendir(fname
);
166 END_PROFILE(syscall_opendir
);
170 static SMB_STRUCT_DIRENT
*vfswrap_readdir(vfs_handle_struct
*handle
,
171 SMB_STRUCT_DIR
*dirp
,
172 SMB_STRUCT_STAT
*sbuf
)
174 SMB_STRUCT_DIRENT
*result
;
176 START_PROFILE(syscall_readdir
);
177 result
= sys_readdir(dirp
);
178 /* Default Posix readdir() does not give us stat info.
179 * Set to invalid to indicate we didn't return this info. */
181 SET_STAT_INVALID(*sbuf
);
182 END_PROFILE(syscall_readdir
);
186 static void vfswrap_seekdir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
, long offset
)
188 START_PROFILE(syscall_seekdir
);
189 sys_seekdir(dirp
, offset
);
190 END_PROFILE(syscall_seekdir
);
193 static long vfswrap_telldir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
)
196 START_PROFILE(syscall_telldir
);
197 result
= sys_telldir(dirp
);
198 END_PROFILE(syscall_telldir
);
202 static void vfswrap_rewinddir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
)
204 START_PROFILE(syscall_rewinddir
);
206 END_PROFILE(syscall_rewinddir
);
209 static int vfswrap_mkdir(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
212 bool has_dacl
= False
;
215 START_PROFILE(syscall_mkdir
);
217 if (lp_inherit_acls(SNUM(handle
->conn
))
218 && parent_dirname(talloc_tos(), path
, &parent
, NULL
)
219 && (has_dacl
= directory_has_default_acl(handle
->conn
, parent
)))
224 result
= mkdir(path
, mode
);
226 if (result
== 0 && !has_dacl
) {
228 * We need to do this as the default behavior of POSIX ACLs
229 * is to set the mask to be the requested group permission
230 * bits, not the group permission bits to be the requested
231 * group permission bits. This is not what we want, as it will
232 * mess up any inherited ACL bits that were set. JRA.
234 int saved_errno
= errno
; /* We may get ENOSYS */
235 if ((SMB_VFS_CHMOD_ACL(handle
->conn
, path
, mode
) == -1) && (errno
== ENOSYS
))
239 END_PROFILE(syscall_mkdir
);
243 static int vfswrap_rmdir(vfs_handle_struct
*handle
, const char *path
)
247 START_PROFILE(syscall_rmdir
);
248 result
= rmdir(path
);
249 END_PROFILE(syscall_rmdir
);
253 static int vfswrap_closedir(vfs_handle_struct
*handle
, SMB_STRUCT_DIR
*dirp
)
257 START_PROFILE(syscall_closedir
);
258 result
= sys_closedir(dirp
);
259 END_PROFILE(syscall_closedir
);
263 static void vfswrap_init_search_op(vfs_handle_struct
*handle
,
264 SMB_STRUCT_DIR
*dirp
)
266 /* Default behavior is a NOOP */
269 /* File operations */
271 static int vfswrap_open(vfs_handle_struct
*handle
,
272 struct smb_filename
*smb_fname
,
273 files_struct
*fsp
, int flags
, mode_t mode
)
277 START_PROFILE(syscall_open
);
279 if (smb_fname
->stream_name
) {
284 result
= sys_open(smb_fname
->base_name
, flags
, mode
);
286 END_PROFILE(syscall_open
);
290 static NTSTATUS
vfswrap_create_file(vfs_handle_struct
*handle
,
291 struct smb_request
*req
,
292 uint16_t root_dir_fid
,
293 struct smb_filename
*smb_fname
,
294 uint32_t access_mask
,
295 uint32_t share_access
,
296 uint32_t create_disposition
,
297 uint32_t create_options
,
298 uint32_t file_attributes
,
299 uint32_t oplock_request
,
300 uint64_t allocation_size
,
301 struct security_descriptor
*sd
,
302 struct ea_list
*ea_list
,
303 files_struct
**result
,
306 return create_file_default(handle
->conn
, req
, root_dir_fid
, smb_fname
,
307 access_mask
, share_access
,
308 create_disposition
, create_options
,
309 file_attributes
, oplock_request
,
310 allocation_size
, sd
, ea_list
, result
,
314 static int vfswrap_close(vfs_handle_struct
*handle
, files_struct
*fsp
)
318 START_PROFILE(syscall_close
);
319 result
= fd_close_posix(fsp
);
320 END_PROFILE(syscall_close
);
324 static ssize_t
vfswrap_read(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
, size_t n
)
328 START_PROFILE_BYTES(syscall_read
, n
);
329 result
= sys_read(fsp
->fh
->fd
, data
, n
);
330 END_PROFILE(syscall_read
);
334 static ssize_t
vfswrap_pread(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
,
335 size_t n
, SMB_OFF_T offset
)
339 #if defined(HAVE_PREAD) || defined(HAVE_PREAD64)
340 START_PROFILE_BYTES(syscall_pread
, n
);
341 result
= sys_pread(fsp
->fh
->fd
, data
, n
, offset
);
342 END_PROFILE(syscall_pread
);
344 if (result
== -1 && errno
== ESPIPE
) {
345 /* Maintain the fiction that pipes can be seeked (sought?) on. */
346 result
= SMB_VFS_READ(fsp
, data
, n
);
350 #else /* HAVE_PREAD */
354 curr
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
355 if (curr
== -1 && errno
== ESPIPE
) {
356 /* Maintain the fiction that pipes can be seeked (sought?) on. */
357 result
= SMB_VFS_READ(fsp
, data
, n
);
362 if (SMB_VFS_LSEEK(fsp
, offset
, SEEK_SET
) == -1) {
367 result
= SMB_VFS_READ(fsp
, data
, n
);
370 SMB_VFS_LSEEK(fsp
, curr
, SEEK_SET
);
373 #endif /* HAVE_PREAD */
378 static ssize_t
vfswrap_write(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
, size_t n
)
382 START_PROFILE_BYTES(syscall_write
, n
);
383 result
= sys_write(fsp
->fh
->fd
, data
, n
);
384 END_PROFILE(syscall_write
);
388 static ssize_t
vfswrap_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
,
389 size_t n
, SMB_OFF_T offset
)
393 #if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)
394 START_PROFILE_BYTES(syscall_pwrite
, n
);
395 result
= sys_pwrite(fsp
->fh
->fd
, data
, n
, offset
);
396 END_PROFILE(syscall_pwrite
);
398 if (result
== -1 && errno
== ESPIPE
) {
399 /* Maintain the fiction that pipes can be sought on. */
400 result
= SMB_VFS_WRITE(fsp
, data
, n
);
403 #else /* HAVE_PWRITE */
407 curr
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
412 if (SMB_VFS_LSEEK(fsp
, offset
, SEEK_SET
) == -1) {
416 result
= SMB_VFS_WRITE(fsp
, data
, n
);
419 SMB_VFS_LSEEK(fsp
, curr
, SEEK_SET
);
422 #endif /* HAVE_PWRITE */
427 static SMB_OFF_T
vfswrap_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T offset
, int whence
)
429 SMB_OFF_T result
= 0;
431 START_PROFILE(syscall_lseek
);
433 /* Cope with 'stat' file opens. */
434 if (fsp
->fh
->fd
!= -1)
435 result
= sys_lseek(fsp
->fh
->fd
, offset
, whence
);
438 * We want to maintain the fiction that we can seek
439 * on a fifo for file system purposes. This allows
440 * people to set up UNIX fifo's that feed data to Windows
444 if((result
== -1) && (errno
== ESPIPE
)) {
449 END_PROFILE(syscall_lseek
);
453 static ssize_t
vfswrap_sendfile(vfs_handle_struct
*handle
, int tofd
, files_struct
*fromfsp
, const DATA_BLOB
*hdr
,
454 SMB_OFF_T offset
, size_t n
)
458 START_PROFILE_BYTES(syscall_sendfile
, n
);
459 result
= sys_sendfile(tofd
, fromfsp
->fh
->fd
, hdr
, offset
, n
);
460 END_PROFILE(syscall_sendfile
);
464 static ssize_t
vfswrap_recvfile(vfs_handle_struct
*handle
,
472 START_PROFILE_BYTES(syscall_recvfile
, n
);
473 result
= sys_recvfile(fromfd
, tofsp
->fh
->fd
, offset
, n
);
474 END_PROFILE(syscall_recvfile
);
478 /*********************************************************
479 For rename across filesystems Patch from Warren Birnbaum
480 <warrenb@hpcvscdp.cv.hp.com>
481 **********************************************************/
483 static int copy_reg(const char *source
, const char *dest
)
485 SMB_STRUCT_STAT source_stats
;
490 if (sys_lstat (source
, &source_stats
) == -1)
493 if (!S_ISREG (source_stats
.st_ex_mode
))
496 if((ifd
= sys_open (source
, O_RDONLY
, 0)) < 0)
499 if (unlink (dest
) && errno
!= ENOENT
)
503 if((ofd
= sys_open (dest
, O_WRONLY
| O_CREAT
| O_TRUNC
| O_NOFOLLOW
, 0600)) < 0 )
505 if((ofd
= sys_open (dest
, O_WRONLY
| O_CREAT
| O_TRUNC
, 0600)) < 0 )
509 if (transfer_file(ifd
, ofd
, (size_t)-1) == -1)
513 * Try to preserve ownership. For non-root it might fail, but that's ok.
514 * But root probably wants to know, e.g. if NFS disallows it.
518 if ((fchown(ofd
, source_stats
.st_ex_uid
, source_stats
.st_ex_gid
) == -1) && (errno
!= EPERM
))
520 if ((chown(dest
, source_stats
.st_ex_uid
, source_stats
.st_ex_gid
) == -1) && (errno
!= EPERM
))
525 * fchown turns off set[ug]id bits for non-root,
526 * so do the chmod last.
529 #if defined(HAVE_FCHMOD)
530 if (fchmod (ofd
, source_stats
.st_ex_mode
& 07777))
532 if (chmod (dest
, source_stats
.st_ex_mode
& 07777))
536 if (close (ifd
) == -1)
539 if (close (ofd
) == -1)
542 /* Try to copy the old file's modtime and access time. */
546 tv
.actime
= convert_timespec_to_time_t(source_stats
.st_ex_atime
);
547 tv
.modtime
= convert_timespec_to_time_t(source_stats
.st_ex_mtime
);
551 if (unlink (source
) == -1)
567 static int vfswrap_rename(vfs_handle_struct
*handle
,
568 const struct smb_filename
*smb_fname_src
,
569 const struct smb_filename
*smb_fname_dst
)
573 START_PROFILE(syscall_rename
);
575 if (smb_fname_src
->stream_name
|| smb_fname_dst
->stream_name
) {
580 result
= rename(smb_fname_src
->base_name
, smb_fname_dst
->base_name
);
581 if ((result
== -1) && (errno
== EXDEV
)) {
582 /* Rename across filesystems needed. */
583 result
= copy_reg(smb_fname_src
->base_name
,
584 smb_fname_dst
->base_name
);
588 END_PROFILE(syscall_rename
);
592 static int vfswrap_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
)
597 START_PROFILE(syscall_fsync
);
598 result
= fsync(fsp
->fh
->fd
);
599 END_PROFILE(syscall_fsync
);
606 static int vfswrap_stat(vfs_handle_struct
*handle
,
607 struct smb_filename
*smb_fname
)
611 START_PROFILE(syscall_stat
);
613 if (smb_fname
->stream_name
) {
618 result
= sys_stat(smb_fname
->base_name
, &smb_fname
->st
);
620 END_PROFILE(syscall_stat
);
624 static int vfswrap_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
628 START_PROFILE(syscall_fstat
);
629 result
= sys_fstat(fsp
->fh
->fd
, sbuf
);
630 END_PROFILE(syscall_fstat
);
634 static int vfswrap_lstat(vfs_handle_struct
*handle
,
635 struct smb_filename
*smb_fname
)
639 START_PROFILE(syscall_lstat
);
641 if (smb_fname
->stream_name
) {
646 result
= sys_lstat(smb_fname
->base_name
, &smb_fname
->st
);
648 END_PROFILE(syscall_lstat
);
652 static NTSTATUS
vfswrap_translate_name(struct vfs_handle_struct
*handle
,
654 enum vfs_translate_direction direction
,
658 return NT_STATUS_NONE_MAPPED
;
661 /********************************************************************
662 Given a stat buffer return the allocated size on disk, taking into
663 account sparse files.
664 ********************************************************************/
665 static uint64_t vfswrap_get_alloc_size(vfs_handle_struct
*handle
,
666 struct files_struct
*fsp
,
667 const SMB_STRUCT_STAT
*sbuf
)
671 START_PROFILE(syscall_get_alloc_size
);
673 if(S_ISDIR(sbuf
->st_ex_mode
)) {
678 #if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
679 result
= (uint64_t)STAT_ST_BLOCKSIZE
* (uint64_t)sbuf
->st_ex_blocks
;
681 result
= get_file_size_stat(sbuf
);
684 if (fsp
&& fsp
->initial_allocation_size
)
685 result
= MAX(result
,fsp
->initial_allocation_size
);
687 result
= smb_roundup(handle
->conn
, result
);
690 END_PROFILE(syscall_get_alloc_size
);
694 static int vfswrap_unlink(vfs_handle_struct
*handle
,
695 const struct smb_filename
*smb_fname
)
699 START_PROFILE(syscall_unlink
);
701 if (smb_fname
->stream_name
) {
705 result
= unlink(smb_fname
->base_name
);
708 END_PROFILE(syscall_unlink
);
712 static int vfswrap_chmod(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
716 START_PROFILE(syscall_chmod
);
719 * We need to do this due to the fact that the default POSIX ACL
720 * chmod modifies the ACL *mask* for the group owner, not the
721 * group owner bits directly. JRA.
726 int saved_errno
= errno
; /* We might get ENOSYS */
727 if ((result
= SMB_VFS_CHMOD_ACL(handle
->conn
, path
, mode
)) == 0) {
728 END_PROFILE(syscall_chmod
);
731 /* Error - return the old errno. */
735 result
= chmod(path
, mode
);
736 END_PROFILE(syscall_chmod
);
740 static int vfswrap_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
744 START_PROFILE(syscall_fchmod
);
747 * We need to do this due to the fact that the default POSIX ACL
748 * chmod modifies the ACL *mask* for the group owner, not the
749 * group owner bits directly. JRA.
753 int saved_errno
= errno
; /* We might get ENOSYS */
754 if ((result
= SMB_VFS_FCHMOD_ACL(fsp
, mode
)) == 0) {
755 END_PROFILE(syscall_fchmod
);
758 /* Error - return the old errno. */
762 #if defined(HAVE_FCHMOD)
763 result
= fchmod(fsp
->fh
->fd
, mode
);
769 END_PROFILE(syscall_fchmod
);
773 static int vfswrap_chown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
777 START_PROFILE(syscall_chown
);
778 result
= chown(path
, uid
, gid
);
779 END_PROFILE(syscall_chown
);
783 static int vfswrap_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
, uid_t uid
, gid_t gid
)
788 START_PROFILE(syscall_fchown
);
789 result
= fchown(fsp
->fh
->fd
, uid
, gid
);
790 END_PROFILE(syscall_fchown
);
798 static int vfswrap_lchown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
802 START_PROFILE(syscall_lchown
);
803 result
= lchown(path
, uid
, gid
);
804 END_PROFILE(syscall_lchown
);
808 static int vfswrap_chdir(vfs_handle_struct
*handle
, const char *path
)
812 START_PROFILE(syscall_chdir
);
813 result
= chdir(path
);
814 END_PROFILE(syscall_chdir
);
818 static char *vfswrap_getwd(vfs_handle_struct
*handle
, char *path
)
822 START_PROFILE(syscall_getwd
);
823 result
= sys_getwd(path
);
824 END_PROFILE(syscall_getwd
);
828 /*********************************************************************
829 nsec timestamp resolution call. Convert down to whatever the underlying
831 **********************************************************************/
833 static int vfswrap_ntimes(vfs_handle_struct
*handle
,
834 const struct smb_filename
*smb_fname
,
835 struct smb_file_time
*ft
)
839 START_PROFILE(syscall_ntimes
);
841 if (smb_fname
->stream_name
) {
846 if (null_timespec(ft
->atime
)) {
847 ft
->atime
= smb_fname
->st
.st_ex_atime
;
850 if (null_timespec(ft
->mtime
)) {
851 ft
->mtime
= smb_fname
->st
.st_ex_mtime
;
854 if (!null_timespec(ft
->create_time
)) {
855 set_create_timespec_ea(handle
->conn
,
860 if ((timespec_compare(&ft
->atime
,
861 &smb_fname
->st
.st_ex_atime
) == 0) &&
862 (timespec_compare(&ft
->mtime
,
863 &smb_fname
->st
.st_ex_mtime
) == 0)) {
867 #if defined(HAVE_UTIMENSAT)
869 struct timespec ts
[2];
872 result
= utimensat(AT_FDCWD
, smb_fname
->base_name
, ts
, 0);
874 result
= utimensat(AT_FDCWD
, smb_fname
->base_name
, NULL
, 0);
876 #elif defined(HAVE_UTIMES)
878 struct timeval tv
[2];
879 tv
[0] = convert_timespec_to_timeval(ft
->atime
);
880 tv
[1] = convert_timespec_to_timeval(ft
->mtime
);
881 result
= utimes(smb_fname
->base_name
, tv
);
883 result
= utimes(smb_fname
->base_name
, NULL
);
885 #elif defined(HAVE_UTIME)
887 struct utimbuf times
;
888 times
.actime
= convert_timespec_to_time_t(ft
->atime
);
889 times
.modtime
= convert_timespec_to_time_t(ft
->mtime
);
890 result
= utime(smb_fname
->base_name
, ×
);
892 result
= utime(smb_fname
->base_name
, NULL
);
900 END_PROFILE(syscall_ntimes
);
904 /*********************************************************************
905 A version of ftruncate that will write the space on disk if strict
907 **********************************************************************/
909 static int strict_allocate_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T len
)
912 SMB_OFF_T currpos
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
913 unsigned char zero_space
[4096];
914 SMB_OFF_T space_to_write
;
919 if (SMB_VFS_FSTAT(fsp
, &st
) == -1)
922 space_to_write
= len
- st
.st_ex_size
;
925 if (S_ISFIFO(st
.st_ex_mode
))
929 if (st
.st_ex_size
== len
)
932 /* Shrink - just ftruncate. */
933 if (st
.st_ex_size
> len
)
934 return sys_ftruncate(fsp
->fh
->fd
, len
);
936 /* available disk space is enough or not? */
937 if (lp_strict_allocate(SNUM(fsp
->conn
))){
938 uint64_t space_avail
;
939 uint64_t bsize
,dfree
,dsize
;
941 space_avail
= get_dfree_info(fsp
->conn
,
942 fsp
->fsp_name
->base_name
, false,
943 &bsize
, &dfree
, &dsize
);
944 /* space_avail is 1k blocks */
945 if (space_avail
== (uint64_t)-1 ||
946 ((uint64_t)space_to_write
/1024 > space_avail
) ) {
952 /* Write out the real space on disk. */
953 if (SMB_VFS_LSEEK(fsp
, st
.st_ex_size
, SEEK_SET
) != st
.st_ex_size
)
956 space_to_write
= len
- st
.st_ex_size
;
958 memset(zero_space
, '\0', sizeof(zero_space
));
959 while ( space_to_write
> 0) {
961 SMB_OFF_T current_len_to_write
= MIN(sizeof(zero_space
),space_to_write
);
963 retlen
= SMB_VFS_WRITE(fsp
,(char *)zero_space
,current_len_to_write
);
967 space_to_write
-= retlen
;
970 /* Seek to where we were */
971 if (SMB_VFS_LSEEK(fsp
, currpos
, SEEK_SET
) != currpos
)
977 static int vfswrap_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T len
)
984 START_PROFILE(syscall_ftruncate
);
986 if (lp_strict_allocate(SNUM(fsp
->conn
))) {
987 result
= strict_allocate_ftruncate(handle
, fsp
, len
);
988 END_PROFILE(syscall_ftruncate
);
992 /* we used to just check HAVE_FTRUNCATE_EXTEND and only use
993 sys_ftruncate if the system supports it. Then I discovered that
994 you can have some filesystems that support ftruncate
995 expansion and some that don't! On Linux fat can't do
996 ftruncate extend but ext2 can. */
998 result
= sys_ftruncate(fsp
->fh
->fd
, len
);
1002 /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
1003 extend a file with ftruncate. Provide alternate implementation
1005 currpos
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
1006 if (currpos
== -1) {
1010 /* Do an fstat to see if the file is longer than the requested
1011 size in which case the ftruncate above should have
1012 succeeded or shorter, in which case seek to len - 1 and
1013 write 1 byte of zero */
1014 if (SMB_VFS_FSTAT(fsp
, &st
) == -1) {
1019 if (S_ISFIFO(st
.st_ex_mode
)) {
1025 if (st
.st_ex_size
== len
) {
1030 if (st
.st_ex_size
> len
) {
1031 /* the sys_ftruncate should have worked */
1035 if (SMB_VFS_LSEEK(fsp
, len
-1, SEEK_SET
) != len
-1)
1038 if (SMB_VFS_WRITE(fsp
, &c
, 1)!=1)
1041 /* Seek to where we were */
1042 if (SMB_VFS_LSEEK(fsp
, currpos
, SEEK_SET
) != currpos
)
1048 END_PROFILE(syscall_ftruncate
);
1052 static bool vfswrap_lock(vfs_handle_struct
*handle
, files_struct
*fsp
, int op
, SMB_OFF_T offset
, SMB_OFF_T count
, int type
)
1056 START_PROFILE(syscall_fcntl_lock
);
1057 result
= fcntl_lock(fsp
->fh
->fd
, op
, offset
, count
, type
);
1058 END_PROFILE(syscall_fcntl_lock
);
1062 static int vfswrap_kernel_flock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1063 uint32 share_mode
, uint32 access_mask
)
1065 START_PROFILE(syscall_kernel_flock
);
1066 kernel_flock(fsp
->fh
->fd
, share_mode
, access_mask
);
1067 END_PROFILE(syscall_kernel_flock
);
1071 static bool vfswrap_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_OFF_T
*poffset
, SMB_OFF_T
*pcount
, int *ptype
, pid_t
*ppid
)
1075 START_PROFILE(syscall_fcntl_getlock
);
1076 result
= fcntl_getlock(fsp
->fh
->fd
, poffset
, pcount
, ptype
, ppid
);
1077 END_PROFILE(syscall_fcntl_getlock
);
1081 static int vfswrap_linux_setlease(vfs_handle_struct
*handle
, files_struct
*fsp
,
1086 START_PROFILE(syscall_linux_setlease
);
1088 #ifdef HAVE_KERNEL_OPLOCKS_LINUX
1089 /* first set the signal handler */
1090 if(linux_set_lease_sighandler(fsp
->fh
->fd
) == -1) {
1094 result
= linux_setlease(fsp
->fh
->fd
, leasetype
);
1098 END_PROFILE(syscall_linux_setlease
);
1102 static int vfswrap_symlink(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
1106 START_PROFILE(syscall_symlink
);
1107 result
= symlink(oldpath
, newpath
);
1108 END_PROFILE(syscall_symlink
);
1112 static int vfswrap_readlink(vfs_handle_struct
*handle
, const char *path
, char *buf
, size_t bufsiz
)
1116 START_PROFILE(syscall_readlink
);
1117 result
= readlink(path
, buf
, bufsiz
);
1118 END_PROFILE(syscall_readlink
);
1122 static int vfswrap_link(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
1126 START_PROFILE(syscall_link
);
1127 result
= link(oldpath
, newpath
);
1128 END_PROFILE(syscall_link
);
1132 static int vfswrap_mknod(vfs_handle_struct
*handle
, const char *pathname
, mode_t mode
, SMB_DEV_T dev
)
1136 START_PROFILE(syscall_mknod
);
1137 result
= sys_mknod(pathname
, mode
, dev
);
1138 END_PROFILE(syscall_mknod
);
1142 static char *vfswrap_realpath(vfs_handle_struct
*handle
, const char *path
, char *resolved_path
)
1146 START_PROFILE(syscall_realpath
);
1147 result
= realpath(path
, resolved_path
);
1148 END_PROFILE(syscall_realpath
);
1152 static NTSTATUS
vfswrap_notify_watch(vfs_handle_struct
*vfs_handle
,
1153 struct sys_notify_context
*ctx
,
1154 struct notify_entry
*e
,
1155 void (*callback
)(struct sys_notify_context
*ctx
,
1157 struct notify_event
*ev
),
1158 void *private_data
, void *handle
)
1161 * So far inotify is the only supported default notify mechanism. If
1162 * another platform like the the BSD's or a proprietary Unix comes
1163 * along and wants another default, we can play the same trick we
1164 * played with Posix ACLs.
1166 * Until that is the case, hard-code inotify here.
1169 if (lp_kernel_change_notify(ctx
->conn
->params
)) {
1170 return inotify_watch(ctx
, e
, callback
, private_data
, handle
);
1174 * Do nothing, leave everything to notify_internal.c
1176 return NT_STATUS_OK
;
1179 static int vfswrap_chflags(vfs_handle_struct
*handle
, const char *path
,
1183 return chflags(path
, flags
);
1190 static struct file_id
vfswrap_file_id_create(struct vfs_handle_struct
*handle
,
1191 const SMB_STRUCT_STAT
*sbuf
)
1195 /* the ZERO_STRUCT ensures padding doesn't break using the key as a
1199 key
.devid
= sbuf
->st_ex_dev
;
1200 key
.inode
= sbuf
->st_ex_ino
;
1201 /* key.extid is unused by default. */
1206 static NTSTATUS
vfswrap_streaminfo(vfs_handle_struct
*handle
,
1207 struct files_struct
*fsp
,
1209 TALLOC_CTX
*mem_ctx
,
1210 unsigned int *pnum_streams
,
1211 struct stream_struct
**pstreams
)
1213 SMB_STRUCT_STAT sbuf
;
1214 unsigned int num_streams
= 0;
1215 struct stream_struct
*streams
= NULL
;
1218 if ((fsp
!= NULL
) && (fsp
->is_directory
)) {
1220 * No default streams on directories
1225 if ((fsp
!= NULL
) && (fsp
->fh
->fd
!= -1)) {
1226 ret
= SMB_VFS_FSTAT(fsp
, &sbuf
);
1229 struct smb_filename smb_fname
;
1231 ZERO_STRUCT(smb_fname
);
1232 smb_fname
.base_name
= discard_const_p(char, fname
);
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
;
1243 return map_nt_error_from_unix(errno
);
1246 if (S_ISDIR(sbuf
.st_ex_mode
)) {
1250 streams
= talloc(mem_ctx
, struct stream_struct
);
1252 if (streams
== NULL
) {
1253 return NT_STATUS_NO_MEMORY
;
1256 streams
->size
= sbuf
.st_ex_size
;
1257 streams
->alloc_size
= SMB_VFS_GET_ALLOC_SIZE(handle
->conn
, fsp
, &sbuf
);
1259 streams
->name
= talloc_strdup(streams
, "::$DATA");
1260 if (streams
->name
== NULL
) {
1261 TALLOC_FREE(streams
);
1262 return NT_STATUS_NO_MEMORY
;
1267 *pnum_streams
= num_streams
;
1268 *pstreams
= streams
;
1269 return NT_STATUS_OK
;
1272 static int vfswrap_get_real_filename(struct vfs_handle_struct
*handle
,
1275 TALLOC_CTX
*mem_ctx
,
1279 * Don't fall back to get_real_filename so callers can differentiate
1280 * between a full directory scan and an actual case-insensitive stat.
1286 static const char *vfswrap_connectpath(struct vfs_handle_struct
*handle
,
1289 return handle
->conn
->connectpath
;
1292 static NTSTATUS
vfswrap_brl_lock_windows(struct vfs_handle_struct
*handle
,
1293 struct byte_range_lock
*br_lck
,
1294 struct lock_struct
*plock
,
1296 struct blocking_lock_record
*blr
)
1298 SMB_ASSERT(plock
->lock_flav
== WINDOWS_LOCK
);
1300 /* Note: blr is not used in the default implementation. */
1301 return brl_lock_windows_default(br_lck
, plock
, blocking_lock
);
1304 static bool vfswrap_brl_unlock_windows(struct vfs_handle_struct
*handle
,
1305 struct messaging_context
*msg_ctx
,
1306 struct byte_range_lock
*br_lck
,
1307 const struct lock_struct
*plock
)
1309 SMB_ASSERT(plock
->lock_flav
== WINDOWS_LOCK
);
1311 return brl_unlock_windows_default(msg_ctx
, br_lck
, plock
);
1314 static bool vfswrap_brl_cancel_windows(struct vfs_handle_struct
*handle
,
1315 struct byte_range_lock
*br_lck
,
1316 struct lock_struct
*plock
,
1317 struct blocking_lock_record
*blr
)
1319 SMB_ASSERT(plock
->lock_flav
== WINDOWS_LOCK
);
1321 /* Note: blr is not used in the default implementation. */
1322 return brl_lock_cancel_default(br_lck
, plock
);
1325 static bool vfswrap_strict_lock(struct vfs_handle_struct
*handle
,
1327 struct lock_struct
*plock
)
1329 SMB_ASSERT(plock
->lock_type
== READ_LOCK
||
1330 plock
->lock_type
== WRITE_LOCK
);
1332 return strict_lock_default(fsp
, plock
);
1335 static void vfswrap_strict_unlock(struct vfs_handle_struct
*handle
,
1337 struct lock_struct
*plock
)
1339 SMB_ASSERT(plock
->lock_type
== READ_LOCK
||
1340 plock
->lock_type
== WRITE_LOCK
);
1342 strict_unlock_default(fsp
, plock
);
1345 /* NT ACL operations. */
1347 static NTSTATUS
vfswrap_fget_nt_acl(vfs_handle_struct
*handle
,
1349 uint32 security_info
, SEC_DESC
**ppdesc
)
1353 START_PROFILE(fget_nt_acl
);
1354 result
= posix_fget_nt_acl(fsp
, security_info
, ppdesc
);
1355 END_PROFILE(fget_nt_acl
);
1359 static NTSTATUS
vfswrap_get_nt_acl(vfs_handle_struct
*handle
,
1361 uint32 security_info
, SEC_DESC
**ppdesc
)
1365 START_PROFILE(get_nt_acl
);
1366 result
= posix_get_nt_acl(handle
->conn
, name
, security_info
, ppdesc
);
1367 END_PROFILE(get_nt_acl
);
1371 static NTSTATUS
vfswrap_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
, uint32 security_info_sent
, const SEC_DESC
*psd
)
1375 START_PROFILE(fset_nt_acl
);
1376 result
= set_nt_acl(fsp
, security_info_sent
, psd
);
1377 END_PROFILE(fset_nt_acl
);
1381 static int vfswrap_chmod_acl(vfs_handle_struct
*handle
, const char *name
, mode_t mode
)
1389 START_PROFILE(chmod_acl
);
1390 result
= chmod_acl(handle
->conn
, name
, mode
);
1391 END_PROFILE(chmod_acl
);
1396 static int vfswrap_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
1404 START_PROFILE(fchmod_acl
);
1405 result
= fchmod_acl(fsp
, mode
);
1406 END_PROFILE(fchmod_acl
);
1411 static int vfswrap_sys_acl_get_entry(vfs_handle_struct
*handle
, SMB_ACL_T theacl
, int entry_id
, SMB_ACL_ENTRY_T
*entry_p
)
1413 return sys_acl_get_entry(theacl
, entry_id
, entry_p
);
1416 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
)
1418 return sys_acl_get_tag_type(entry_d
, tag_type_p
);
1421 static int vfswrap_sys_acl_get_permset(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry_d
, SMB_ACL_PERMSET_T
*permset_p
)
1423 return sys_acl_get_permset(entry_d
, permset_p
);
1426 static void * vfswrap_sys_acl_get_qualifier(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry_d
)
1428 return sys_acl_get_qualifier(entry_d
);
1431 static SMB_ACL_T
vfswrap_sys_acl_get_file(vfs_handle_struct
*handle
, const char *path_p
, SMB_ACL_TYPE_T type
)
1433 return sys_acl_get_file(handle
, path_p
, type
);
1436 static SMB_ACL_T
vfswrap_sys_acl_get_fd(vfs_handle_struct
*handle
, files_struct
*fsp
)
1438 return sys_acl_get_fd(handle
, fsp
);
1441 static int vfswrap_sys_acl_clear_perms(vfs_handle_struct
*handle
, SMB_ACL_PERMSET_T permset
)
1443 return sys_acl_clear_perms(permset
);
1446 static int vfswrap_sys_acl_add_perm(vfs_handle_struct
*handle
, SMB_ACL_PERMSET_T permset
, SMB_ACL_PERM_T perm
)
1448 return sys_acl_add_perm(permset
, perm
);
1451 static char * vfswrap_sys_acl_to_text(vfs_handle_struct
*handle
, SMB_ACL_T theacl
, ssize_t
*plen
)
1453 return sys_acl_to_text(theacl
, plen
);
1456 static SMB_ACL_T
vfswrap_sys_acl_init(vfs_handle_struct
*handle
, int count
)
1458 return sys_acl_init(count
);
1461 static int vfswrap_sys_acl_create_entry(vfs_handle_struct
*handle
, SMB_ACL_T
*pacl
, SMB_ACL_ENTRY_T
*pentry
)
1463 return sys_acl_create_entry(pacl
, pentry
);
1466 static int vfswrap_sys_acl_set_tag_type(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry
, SMB_ACL_TAG_T tagtype
)
1468 return sys_acl_set_tag_type(entry
, tagtype
);
1471 static int vfswrap_sys_acl_set_qualifier(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry
, void *qual
)
1473 return sys_acl_set_qualifier(entry
, qual
);
1476 static int vfswrap_sys_acl_set_permset(vfs_handle_struct
*handle
, SMB_ACL_ENTRY_T entry
, SMB_ACL_PERMSET_T permset
)
1478 return sys_acl_set_permset(entry
, permset
);
1481 static int vfswrap_sys_acl_valid(vfs_handle_struct
*handle
, SMB_ACL_T theacl
)
1483 return sys_acl_valid(theacl
);
1486 static int vfswrap_sys_acl_set_file(vfs_handle_struct
*handle
, const char *name
, SMB_ACL_TYPE_T acltype
, SMB_ACL_T theacl
)
1488 return sys_acl_set_file(handle
, name
, acltype
, theacl
);
1491 static int vfswrap_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_ACL_T theacl
)
1493 return sys_acl_set_fd(handle
, fsp
, theacl
);
1496 static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct
*handle
, const char *path
)
1498 return sys_acl_delete_def_file(handle
, path
);
1501 static int vfswrap_sys_acl_get_perm(vfs_handle_struct
*handle
, SMB_ACL_PERMSET_T permset
, SMB_ACL_PERM_T perm
)
1503 return sys_acl_get_perm(permset
, perm
);
1506 static int vfswrap_sys_acl_free_text(vfs_handle_struct
*handle
, char *text
)
1508 return sys_acl_free_text(text
);
1511 static int vfswrap_sys_acl_free_acl(vfs_handle_struct
*handle
, SMB_ACL_T posix_acl
)
1513 return sys_acl_free_acl(posix_acl
);
1516 static int vfswrap_sys_acl_free_qualifier(vfs_handle_struct
*handle
, void *qualifier
, SMB_ACL_TAG_T tagtype
)
1518 return sys_acl_free_qualifier(qualifier
, tagtype
);
1521 /****************************************************************
1522 Extended attribute operations.
1523 *****************************************************************/
1525 static ssize_t
vfswrap_getxattr(struct vfs_handle_struct
*handle
,const char *path
, const char *name
, void *value
, size_t size
)
1527 return sys_getxattr(path
, name
, value
, size
);
1530 static ssize_t
vfswrap_lgetxattr(struct vfs_handle_struct
*handle
,const char *path
, const char *name
, void *value
, size_t size
)
1532 return sys_lgetxattr(path
, name
, value
, size
);
1535 static ssize_t
vfswrap_fgetxattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, void *value
, size_t size
)
1537 return sys_fgetxattr(fsp
->fh
->fd
, name
, value
, size
);
1540 static ssize_t
vfswrap_listxattr(struct vfs_handle_struct
*handle
, const char *path
, char *list
, size_t size
)
1542 return sys_listxattr(path
, list
, size
);
1545 ssize_t
vfswrap_llistxattr(struct vfs_handle_struct
*handle
, const char *path
, char *list
, size_t size
)
1547 return sys_llistxattr(path
, list
, size
);
1550 ssize_t
vfswrap_flistxattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, char *list
, size_t size
)
1552 return sys_flistxattr(fsp
->fh
->fd
, list
, size
);
1555 static int vfswrap_removexattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
)
1557 return sys_removexattr(path
, name
);
1560 static int vfswrap_lremovexattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
)
1562 return sys_lremovexattr(path
, name
);
1565 static int vfswrap_fremovexattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
)
1567 return sys_fremovexattr(fsp
->fh
->fd
, name
);
1570 static int vfswrap_setxattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
1572 return sys_setxattr(path
, name
, value
, size
, flags
);
1575 static int vfswrap_lsetxattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
1577 return sys_lsetxattr(path
, name
, value
, size
, flags
);
1580 static int vfswrap_fsetxattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, const void *value
, size_t size
, int flags
)
1582 return sys_fsetxattr(fsp
->fh
->fd
, name
, value
, size
, flags
);
1585 static int vfswrap_aio_read(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1589 * aio_read must be done as root, because in the glibc aio
1590 * implementation the helper thread needs to be able to send a signal
1591 * to the main thread, even when it has done a seteuid() to a
1595 ret
= sys_aio_read(aiocb
);
1600 static int vfswrap_aio_write(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1604 * aio_write must be done as root, because in the glibc aio
1605 * implementation the helper thread needs to be able to send a signal
1606 * to the main thread, even when it has done a seteuid() to a
1610 ret
= sys_aio_write(aiocb
);
1615 static ssize_t
vfswrap_aio_return(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1617 return sys_aio_return(aiocb
);
1620 static int vfswrap_aio_cancel(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1622 return sys_aio_cancel(fsp
->fh
->fd
, aiocb
);
1625 static int vfswrap_aio_error(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1627 return sys_aio_error(aiocb
);
1630 static int vfswrap_aio_fsync(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, int op
, SMB_STRUCT_AIOCB
*aiocb
)
1632 return sys_aio_fsync(op
, aiocb
);
1635 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
)
1637 return sys_aio_suspend(aiocb
, n
, timeout
);
1640 static bool vfswrap_aio_force(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
)
1645 static bool vfswrap_is_offline(struct vfs_handle_struct
*handle
, const char *path
, SMB_STRUCT_STAT
*sbuf
)
1647 if (ISDOT(path
) || ISDOTDOT(path
)) {
1651 if (!lp_dmapi_support(SNUM(handle
->conn
)) || !dmapi_have_session()) {
1652 #if defined(ENOTSUP)
1658 return (dmapi_file_flags(path
) & FILE_ATTRIBUTE_OFFLINE
) != 0;
1661 static int vfswrap_set_offline(struct vfs_handle_struct
*handle
, const char *path
)
1663 /* We don't know how to set offline bit by default, needs to be overriden in the vfs modules */
1664 #if defined(ENOTSUP)
1670 static struct vfs_fn_pointers vfs_default_fns
= {
1671 /* Disk operations */
1673 .connect_fn
= vfswrap_connect
,
1674 .disconnect
= vfswrap_disconnect
,
1675 .disk_free
= vfswrap_disk_free
,
1676 .get_quota
= vfswrap_get_quota
,
1677 .set_quota
= vfswrap_set_quota
,
1678 .get_shadow_copy_data
= vfswrap_get_shadow_copy_data
,
1679 .statvfs
= vfswrap_statvfs
,
1680 .fs_capabilities
= vfswrap_fs_capabilities
,
1682 /* Directory operations */
1684 .opendir
= vfswrap_opendir
,
1685 .readdir
= vfswrap_readdir
,
1686 .seekdir
= vfswrap_seekdir
,
1687 .telldir
= vfswrap_telldir
,
1688 .rewind_dir
= vfswrap_rewinddir
,
1689 .mkdir
= vfswrap_mkdir
,
1690 .rmdir
= vfswrap_rmdir
,
1691 .closedir
= vfswrap_closedir
,
1692 .init_search_op
= vfswrap_init_search_op
,
1694 /* File operations */
1696 .open
= vfswrap_open
,
1697 .create_file
= vfswrap_create_file
,
1698 .close_fn
= vfswrap_close
,
1699 .vfs_read
= vfswrap_read
,
1700 .pread
= vfswrap_pread
,
1701 .write
= vfswrap_write
,
1702 .pwrite
= vfswrap_pwrite
,
1703 .lseek
= vfswrap_lseek
,
1704 .sendfile
= vfswrap_sendfile
,
1705 .recvfile
= vfswrap_recvfile
,
1706 .rename
= vfswrap_rename
,
1707 .fsync
= vfswrap_fsync
,
1708 .stat
= vfswrap_stat
,
1709 .fstat
= vfswrap_fstat
,
1710 .lstat
= vfswrap_lstat
,
1711 .get_alloc_size
= vfswrap_get_alloc_size
,
1712 .unlink
= vfswrap_unlink
,
1713 .chmod
= vfswrap_chmod
,
1714 .fchmod
= vfswrap_fchmod
,
1715 .chown
= vfswrap_chown
,
1716 .fchown
= vfswrap_fchown
,
1717 .lchown
= vfswrap_lchown
,
1718 .chdir
= vfswrap_chdir
,
1719 .getwd
= vfswrap_getwd
,
1720 .ntimes
= vfswrap_ntimes
,
1721 .ftruncate
= vfswrap_ftruncate
,
1722 .lock
= vfswrap_lock
,
1723 .kernel_flock
= vfswrap_kernel_flock
,
1724 .linux_setlease
= vfswrap_linux_setlease
,
1725 .getlock
= vfswrap_getlock
,
1726 .symlink
= vfswrap_symlink
,
1727 .vfs_readlink
= vfswrap_readlink
,
1728 .link
= vfswrap_link
,
1729 .mknod
= vfswrap_mknod
,
1730 .realpath
= vfswrap_realpath
,
1731 .notify_watch
= vfswrap_notify_watch
,
1732 .chflags
= vfswrap_chflags
,
1733 .file_id_create
= vfswrap_file_id_create
,
1734 .streaminfo
= vfswrap_streaminfo
,
1735 .get_real_filename
= vfswrap_get_real_filename
,
1736 .connectpath
= vfswrap_connectpath
,
1737 .brl_lock_windows
= vfswrap_brl_lock_windows
,
1738 .brl_unlock_windows
= vfswrap_brl_unlock_windows
,
1739 .brl_cancel_windows
= vfswrap_brl_cancel_windows
,
1740 .strict_lock
= vfswrap_strict_lock
,
1741 .strict_unlock
= vfswrap_strict_unlock
,
1742 .translate_name
= vfswrap_translate_name
,
1744 /* NT ACL operations. */
1746 .fget_nt_acl
= vfswrap_fget_nt_acl
,
1747 .get_nt_acl
= vfswrap_get_nt_acl
,
1748 .fset_nt_acl
= vfswrap_fset_nt_acl
,
1750 /* POSIX ACL operations. */
1752 .chmod_acl
= vfswrap_chmod_acl
,
1753 .fchmod_acl
= vfswrap_fchmod_acl
,
1755 .sys_acl_get_entry
= vfswrap_sys_acl_get_entry
,
1756 .sys_acl_get_tag_type
= vfswrap_sys_acl_get_tag_type
,
1757 .sys_acl_get_permset
= vfswrap_sys_acl_get_permset
,
1758 .sys_acl_get_qualifier
= vfswrap_sys_acl_get_qualifier
,
1759 .sys_acl_get_file
= vfswrap_sys_acl_get_file
,
1760 .sys_acl_get_fd
= vfswrap_sys_acl_get_fd
,
1761 .sys_acl_clear_perms
= vfswrap_sys_acl_clear_perms
,
1762 .sys_acl_add_perm
= vfswrap_sys_acl_add_perm
,
1763 .sys_acl_to_text
= vfswrap_sys_acl_to_text
,
1764 .sys_acl_init
= vfswrap_sys_acl_init
,
1765 .sys_acl_create_entry
= vfswrap_sys_acl_create_entry
,
1766 .sys_acl_set_tag_type
= vfswrap_sys_acl_set_tag_type
,
1767 .sys_acl_set_qualifier
= vfswrap_sys_acl_set_qualifier
,
1768 .sys_acl_set_permset
= vfswrap_sys_acl_set_permset
,
1769 .sys_acl_valid
= vfswrap_sys_acl_valid
,
1770 .sys_acl_set_file
= vfswrap_sys_acl_set_file
,
1771 .sys_acl_set_fd
= vfswrap_sys_acl_set_fd
,
1772 .sys_acl_delete_def_file
= vfswrap_sys_acl_delete_def_file
,
1773 .sys_acl_get_perm
= vfswrap_sys_acl_get_perm
,
1774 .sys_acl_free_text
= vfswrap_sys_acl_free_text
,
1775 .sys_acl_free_acl
= vfswrap_sys_acl_free_acl
,
1776 .sys_acl_free_qualifier
= vfswrap_sys_acl_free_qualifier
,
1778 /* EA operations. */
1779 .getxattr
= vfswrap_getxattr
,
1780 .lgetxattr
= vfswrap_lgetxattr
,
1781 .fgetxattr
= vfswrap_fgetxattr
,
1782 .listxattr
= vfswrap_listxattr
,
1783 .llistxattr
= vfswrap_llistxattr
,
1784 .flistxattr
= vfswrap_flistxattr
,
1785 .removexattr
= vfswrap_removexattr
,
1786 .lremovexattr
= vfswrap_lremovexattr
,
1787 .fremovexattr
= vfswrap_fremovexattr
,
1788 .setxattr
= vfswrap_setxattr
,
1789 .lsetxattr
= vfswrap_lsetxattr
,
1790 .fsetxattr
= vfswrap_fsetxattr
,
1792 /* aio operations */
1793 .aio_read
= vfswrap_aio_read
,
1794 .aio_write
= vfswrap_aio_write
,
1795 .aio_return_fn
= vfswrap_aio_return
,
1796 .aio_cancel
= vfswrap_aio_cancel
,
1797 .aio_error_fn
= vfswrap_aio_error
,
1798 .aio_fsync
= vfswrap_aio_fsync
,
1799 .aio_suspend
= vfswrap_aio_suspend
,
1800 .aio_force
= vfswrap_aio_force
,
1802 /* offline operations */
1803 .is_offline
= vfswrap_is_offline
,
1804 .set_offline
= vfswrap_set_offline
1807 NTSTATUS
vfs_default_init(void);
1808 NTSTATUS
vfs_default_init(void)
1810 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
1811 DEFAULT_VFS_MODULE_NAME
, &vfs_default_fns
);