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/>.
22 #include "system/time.h"
23 #include "system/filesys.h"
24 #include "smbd/smbd.h"
25 #include "smbd/globals.h"
27 #include "smbprofile.h"
28 #include "../libcli/security/security.h"
29 #include "passdb/lookup_sid.h"
30 #include "source3/include/msdfs.h"
31 #include "librpc/gen_ndr/ndr_dfsblobs.h"
32 #include "lib/util/tevent_unix.h"
33 #include "lib/asys/asys.h"
36 #define DBGC_CLASS DBGC_VFS
38 /* Check for NULL pointer parameters in vfswrap_* functions */
40 /* We don't want to have NULL function pointers lying around. Someone
41 is sure to try and execute them. These stubs are used to prevent
44 static int vfswrap_connect(vfs_handle_struct
*handle
, const char *service
, const char *user
)
46 return 0; /* Return >= 0 for success */
49 static void vfswrap_disconnect(vfs_handle_struct
*handle
)
55 static uint64_t vfswrap_disk_free(vfs_handle_struct
*handle
, const char *path
, bool small_query
, uint64_t *bsize
,
56 uint64_t *dfree
, uint64_t *dsize
)
60 result
= sys_disk_free(handle
->conn
, path
, small_query
, bsize
, dfree
, dsize
);
64 static int vfswrap_get_quota(struct vfs_handle_struct
*handle
, enum SMB_QUOTA_TYPE qtype
, unid_t id
, SMB_DISK_QUOTA
*qt
)
66 #ifdef HAVE_SYS_QUOTAS
69 START_PROFILE(syscall_get_quota
);
70 result
= sys_get_quota(handle
->conn
->connectpath
, qtype
, id
, qt
);
71 END_PROFILE(syscall_get_quota
);
79 static int vfswrap_set_quota(struct vfs_handle_struct
*handle
, enum SMB_QUOTA_TYPE qtype
, unid_t id
, SMB_DISK_QUOTA
*qt
)
81 #ifdef HAVE_SYS_QUOTAS
84 START_PROFILE(syscall_set_quota
);
85 result
= sys_set_quota(handle
->conn
->connectpath
, qtype
, id
, qt
);
86 END_PROFILE(syscall_set_quota
);
94 static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct
*handle
,
95 struct files_struct
*fsp
,
96 struct shadow_copy_data
*shadow_copy_data
,
100 return -1; /* Not implemented. */
103 static int vfswrap_statvfs(struct vfs_handle_struct
*handle
, const char *path
, vfs_statvfs_struct
*statbuf
)
105 return sys_statvfs(path
, statbuf
);
108 static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct
*handle
,
109 enum timestamp_set_resolution
*p_ts_res
)
111 connection_struct
*conn
= handle
->conn
;
112 uint32_t caps
= FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
113 struct smb_filename
*smb_fname_cpath
= NULL
;
114 struct vfs_statvfs_struct statbuf
;
118 ZERO_STRUCT(statbuf
);
119 ret
= sys_statvfs(conn
->connectpath
, &statbuf
);
121 caps
= statbuf
.FsCapabilities
;
124 *p_ts_res
= TIMESTAMP_SET_SECONDS
;
126 /* Work out what timestamp resolution we can
127 * use when setting a timestamp. */
129 status
= create_synthetic_smb_fname(talloc_tos(),
134 if (!NT_STATUS_IS_OK(status
)) {
138 ret
= SMB_VFS_STAT(conn
, smb_fname_cpath
);
140 TALLOC_FREE(smb_fname_cpath
);
144 if (smb_fname_cpath
->st
.st_ex_mtime
.tv_nsec
||
145 smb_fname_cpath
->st
.st_ex_atime
.tv_nsec
||
146 smb_fname_cpath
->st
.st_ex_ctime
.tv_nsec
) {
147 /* If any of the normal UNIX directory timestamps
148 * have a non-zero tv_nsec component assume
149 * we might be able to set sub-second timestamps.
150 * See what filetime set primitives we have.
152 #if defined(HAVE_UTIMENSAT)
153 *p_ts_res
= TIMESTAMP_SET_NT_OR_BETTER
;
154 #elif defined(HAVE_UTIMES)
155 /* utimes allows msec timestamps to be set. */
156 *p_ts_res
= TIMESTAMP_SET_MSEC
;
157 #elif defined(HAVE_UTIME)
158 /* utime only allows sec timestamps to be set. */
159 *p_ts_res
= TIMESTAMP_SET_SECONDS
;
162 DEBUG(10,("vfswrap_fs_capabilities: timestamp "
164 "available on share %s, directory %s\n",
165 *p_ts_res
== TIMESTAMP_SET_MSEC
? "msec" : "sec",
166 lp_servicename(talloc_tos(), conn
->params
->service
),
167 conn
->connectpath
));
169 TALLOC_FREE(smb_fname_cpath
);
173 static NTSTATUS
vfswrap_get_dfs_referrals(struct vfs_handle_struct
*handle
,
174 struct dfs_GetDFSReferral
*r
)
176 struct junction_map
*junction
= NULL
;
178 bool self_referral
= false;
179 char *pathnamep
= NULL
;
180 char *local_dfs_path
= NULL
;
183 uint16_t max_referral_level
= r
->in
.req
.max_referral_level
;
186 NDR_PRINT_IN_DEBUG(dfs_GetDFSReferral
, r
);
189 /* get the junction entry */
190 if (r
->in
.req
.servername
== NULL
) {
191 return NT_STATUS_NOT_FOUND
;
195 * Trim pathname sent by client so it begins with only one backslash.
196 * Two backslashes confuse some dfs clients
199 local_dfs_path
= talloc_strdup(r
, r
->in
.req
.servername
);
200 if (local_dfs_path
== NULL
) {
201 return NT_STATUS_NO_MEMORY
;
203 pathnamep
= local_dfs_path
;
204 while (IS_DIRECTORY_SEP(pathnamep
[0]) &&
205 IS_DIRECTORY_SEP(pathnamep
[1])) {
209 junction
= talloc_zero(r
, struct junction_map
);
210 if (junction
== NULL
) {
211 return NT_STATUS_NO_MEMORY
;
214 /* The following call can change cwd. */
215 status
= get_referred_path(r
, pathnamep
,
216 !handle
->conn
->sconn
->using_smb2
,
217 junction
, &consumedcnt
, &self_referral
);
218 if (!NT_STATUS_IS_OK(status
)) {
219 vfs_ChDir(handle
->conn
, handle
->conn
->connectpath
);
222 vfs_ChDir(handle
->conn
, handle
->conn
->connectpath
);
224 if (!self_referral
) {
225 pathnamep
[consumedcnt
] = '\0';
228 dbgtext("setup_dfs_referral: Path %s to "
229 "alternate path(s):",
231 for (i
=0; i
< junction
->referral_count
; i
++) {
233 junction
->referral_list
[i
].alternate_path
);
239 if (r
->in
.req
.max_referral_level
<= 2) {
240 max_referral_level
= 2;
242 if (r
->in
.req
.max_referral_level
>= 3) {
243 max_referral_level
= 3;
246 r
->out
.resp
= talloc_zero(r
, struct dfs_referral_resp
);
247 if (r
->out
.resp
== NULL
) {
248 return NT_STATUS_NO_MEMORY
;
251 r
->out
.resp
->path_consumed
= strlen_m(pathnamep
) * 2;
252 r
->out
.resp
->nb_referrals
= junction
->referral_count
;
254 r
->out
.resp
->header_flags
= DFS_HEADER_FLAG_STORAGE_SVR
;
256 r
->out
.resp
->header_flags
|= DFS_HEADER_FLAG_REFERAL_SVR
;
259 r
->out
.resp
->referral_entries
= talloc_zero_array(r
,
260 struct dfs_referral_type
,
261 r
->out
.resp
->nb_referrals
);
262 if (r
->out
.resp
->referral_entries
== NULL
) {
263 return NT_STATUS_NO_MEMORY
;
266 switch (max_referral_level
) {
268 for(i
=0; i
< junction
->referral_count
; i
++) {
269 struct referral
*ref
= &junction
->referral_list
[i
];
270 TALLOC_CTX
*mem_ctx
= r
->out
.resp
->referral_entries
;
271 struct dfs_referral_type
*t
=
272 &r
->out
.resp
->referral_entries
[i
];
273 struct dfs_referral_v2
*v2
= &t
->referral
.v2
;
276 v2
->size
= VERSION2_REFERRAL_SIZE
;
278 v2
->server_type
= DFS_SERVER_ROOT
;
280 v2
->server_type
= DFS_SERVER_NON_ROOT
;
283 v2
->proximity
= ref
->proximity
;
285 v2
->DFS_path
= talloc_strdup(mem_ctx
, pathnamep
);
286 if (v2
->DFS_path
== NULL
) {
287 return NT_STATUS_NO_MEMORY
;
289 v2
->DFS_alt_path
= talloc_strdup(mem_ctx
, pathnamep
);
290 if (v2
->DFS_alt_path
== NULL
) {
291 return NT_STATUS_NO_MEMORY
;
293 v2
->netw_address
= talloc_strdup(mem_ctx
,
294 ref
->alternate_path
);
295 if (v2
->netw_address
== NULL
) {
296 return NT_STATUS_NO_MEMORY
;
302 for(i
=0; i
< junction
->referral_count
; i
++) {
303 struct referral
*ref
= &junction
->referral_list
[i
];
304 TALLOC_CTX
*mem_ctx
= r
->out
.resp
->referral_entries
;
305 struct dfs_referral_type
*t
=
306 &r
->out
.resp
->referral_entries
[i
];
307 struct dfs_referral_v3
*v3
= &t
->referral
.v3
;
308 struct dfs_normal_referral
*r1
= &v3
->referrals
.r1
;
311 v3
->size
= VERSION3_REFERRAL_SIZE
;
313 v3
->server_type
= DFS_SERVER_ROOT
;
315 v3
->server_type
= DFS_SERVER_NON_ROOT
;
319 r1
->DFS_path
= talloc_strdup(mem_ctx
, pathnamep
);
320 if (r1
->DFS_path
== NULL
) {
321 return NT_STATUS_NO_MEMORY
;
323 r1
->DFS_alt_path
= talloc_strdup(mem_ctx
, pathnamep
);
324 if (r1
->DFS_alt_path
== NULL
) {
325 return NT_STATUS_NO_MEMORY
;
327 r1
->netw_address
= talloc_strdup(mem_ctx
,
328 ref
->alternate_path
);
329 if (r1
->netw_address
== NULL
) {
330 return NT_STATUS_NO_MEMORY
;
335 DEBUG(0,("setup_dfs_referral: Invalid dfs referral "
337 max_referral_level
));
338 return NT_STATUS_INVALID_LEVEL
;
342 NDR_PRINT_OUT_DEBUG(dfs_GetDFSReferral
, r
);
348 /* Directory operations */
350 static DIR *vfswrap_opendir(vfs_handle_struct
*handle
, const char *fname
, const char *mask
, uint32 attr
)
354 START_PROFILE(syscall_opendir
);
355 result
= opendir(fname
);
356 END_PROFILE(syscall_opendir
);
360 static DIR *vfswrap_fdopendir(vfs_handle_struct
*handle
,
367 START_PROFILE(syscall_fdopendir
);
368 result
= sys_fdopendir(fsp
->fh
->fd
);
369 END_PROFILE(syscall_fdopendir
);
374 static struct dirent
*vfswrap_readdir(vfs_handle_struct
*handle
,
376 SMB_STRUCT_STAT
*sbuf
)
378 struct dirent
*result
;
380 START_PROFILE(syscall_readdir
);
381 result
= readdir(dirp
);
382 /* Default Posix readdir() does not give us stat info.
383 * Set to invalid to indicate we didn't return this info. */
385 SET_STAT_INVALID(*sbuf
);
386 END_PROFILE(syscall_readdir
);
390 static void vfswrap_seekdir(vfs_handle_struct
*handle
, DIR *dirp
, long offset
)
392 START_PROFILE(syscall_seekdir
);
393 seekdir(dirp
, offset
);
394 END_PROFILE(syscall_seekdir
);
397 static long vfswrap_telldir(vfs_handle_struct
*handle
, DIR *dirp
)
400 START_PROFILE(syscall_telldir
);
401 result
= telldir(dirp
);
402 END_PROFILE(syscall_telldir
);
406 static void vfswrap_rewinddir(vfs_handle_struct
*handle
, DIR *dirp
)
408 START_PROFILE(syscall_rewinddir
);
410 END_PROFILE(syscall_rewinddir
);
413 static int vfswrap_mkdir(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
416 bool has_dacl
= False
;
419 START_PROFILE(syscall_mkdir
);
421 if (lp_inherit_acls(SNUM(handle
->conn
))
422 && parent_dirname(talloc_tos(), path
, &parent
, NULL
)
423 && (has_dacl
= directory_has_default_acl(handle
->conn
, parent
)))
424 mode
= (0777 & lp_dir_mask(SNUM(handle
->conn
)));
428 result
= mkdir(path
, mode
);
430 if (result
== 0 && !has_dacl
) {
432 * We need to do this as the default behavior of POSIX ACLs
433 * is to set the mask to be the requested group permission
434 * bits, not the group permission bits to be the requested
435 * group permission bits. This is not what we want, as it will
436 * mess up any inherited ACL bits that were set. JRA.
438 int saved_errno
= errno
; /* We may get ENOSYS */
439 if ((SMB_VFS_CHMOD_ACL(handle
->conn
, path
, mode
) == -1) && (errno
== ENOSYS
))
443 END_PROFILE(syscall_mkdir
);
447 static int vfswrap_rmdir(vfs_handle_struct
*handle
, const char *path
)
451 START_PROFILE(syscall_rmdir
);
452 result
= rmdir(path
);
453 END_PROFILE(syscall_rmdir
);
457 static int vfswrap_closedir(vfs_handle_struct
*handle
, DIR *dirp
)
461 START_PROFILE(syscall_closedir
);
462 result
= closedir(dirp
);
463 END_PROFILE(syscall_closedir
);
467 static void vfswrap_init_search_op(vfs_handle_struct
*handle
,
470 /* Default behavior is a NOOP */
473 /* File operations */
475 static int vfswrap_open(vfs_handle_struct
*handle
,
476 struct smb_filename
*smb_fname
,
477 files_struct
*fsp
, int flags
, mode_t mode
)
481 START_PROFILE(syscall_open
);
483 if (smb_fname
->stream_name
) {
488 result
= open(smb_fname
->base_name
, flags
, mode
);
490 END_PROFILE(syscall_open
);
494 static NTSTATUS
vfswrap_create_file(vfs_handle_struct
*handle
,
495 struct smb_request
*req
,
496 uint16_t root_dir_fid
,
497 struct smb_filename
*smb_fname
,
498 uint32_t access_mask
,
499 uint32_t share_access
,
500 uint32_t create_disposition
,
501 uint32_t create_options
,
502 uint32_t file_attributes
,
503 uint32_t oplock_request
,
504 uint64_t allocation_size
,
505 uint32_t private_flags
,
506 struct security_descriptor
*sd
,
507 struct ea_list
*ea_list
,
508 files_struct
**result
,
511 return create_file_default(handle
->conn
, req
, root_dir_fid
, smb_fname
,
512 access_mask
, share_access
,
513 create_disposition
, create_options
,
514 file_attributes
, oplock_request
,
515 allocation_size
, private_flags
,
520 static int vfswrap_close(vfs_handle_struct
*handle
, files_struct
*fsp
)
524 START_PROFILE(syscall_close
);
525 result
= fd_close_posix(fsp
);
526 END_PROFILE(syscall_close
);
530 static ssize_t
vfswrap_read(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
, size_t n
)
534 START_PROFILE_BYTES(syscall_read
, n
);
535 result
= sys_read(fsp
->fh
->fd
, data
, n
);
536 END_PROFILE(syscall_read
);
540 static ssize_t
vfswrap_pread(vfs_handle_struct
*handle
, files_struct
*fsp
, void *data
,
541 size_t n
, off_t offset
)
545 #if defined(HAVE_PREAD) || defined(HAVE_PREAD64)
546 START_PROFILE_BYTES(syscall_pread
, n
);
547 result
= sys_pread(fsp
->fh
->fd
, data
, n
, offset
);
548 END_PROFILE(syscall_pread
);
550 if (result
== -1 && errno
== ESPIPE
) {
551 /* Maintain the fiction that pipes can be seeked (sought?) on. */
552 result
= SMB_VFS_READ(fsp
, data
, n
);
556 #else /* HAVE_PREAD */
560 curr
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
561 if (curr
== -1 && errno
== ESPIPE
) {
562 /* Maintain the fiction that pipes can be seeked (sought?) on. */
563 result
= SMB_VFS_READ(fsp
, data
, n
);
568 if (SMB_VFS_LSEEK(fsp
, offset
, SEEK_SET
) == -1) {
573 result
= SMB_VFS_READ(fsp
, data
, n
);
576 SMB_VFS_LSEEK(fsp
, curr
, SEEK_SET
);
579 #endif /* HAVE_PREAD */
584 static ssize_t
vfswrap_write(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
, size_t n
)
588 START_PROFILE_BYTES(syscall_write
, n
);
589 result
= sys_write(fsp
->fh
->fd
, data
, n
);
590 END_PROFILE(syscall_write
);
594 static ssize_t
vfswrap_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
, const void *data
,
595 size_t n
, off_t offset
)
599 #if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)
600 START_PROFILE_BYTES(syscall_pwrite
, n
);
601 result
= sys_pwrite(fsp
->fh
->fd
, data
, n
, offset
);
602 END_PROFILE(syscall_pwrite
);
604 if (result
== -1 && errno
== ESPIPE
) {
605 /* Maintain the fiction that pipes can be sought on. */
606 result
= SMB_VFS_WRITE(fsp
, data
, n
);
609 #else /* HAVE_PWRITE */
613 curr
= SMB_VFS_LSEEK(fsp
, 0, SEEK_CUR
);
618 if (SMB_VFS_LSEEK(fsp
, offset
, SEEK_SET
) == -1) {
622 result
= SMB_VFS_WRITE(fsp
, data
, n
);
625 SMB_VFS_LSEEK(fsp
, curr
, SEEK_SET
);
628 #endif /* HAVE_PWRITE */
633 static void vfswrap_asys_finished(struct tevent_context
*ev
,
634 struct tevent_fd
*fde
,
635 uint16_t flags
, void *p
);
637 static bool vfswrap_init_asys_ctx(struct smbXsrv_connection
*conn
)
641 if (conn
->asys_ctx
!= NULL
) {
644 ret
= asys_context_init(&conn
->asys_ctx
, aio_pending_size
);
646 DEBUG(1, ("asys_context_init failed: %s\n", strerror(ret
)));
649 conn
->asys_fde
= tevent_add_fd(conn
->ev_ctx
, conn
,
650 asys_signalfd(conn
->asys_ctx
),
652 vfswrap_asys_finished
,
654 if (conn
->asys_fde
== NULL
) {
655 DEBUG(1, ("tevent_add_fd failed\n"));
656 asys_context_destroy(conn
->asys_ctx
);
657 conn
->asys_ctx
= NULL
;
663 struct vfswrap_asys_state
{
664 struct asys_context
*asys_ctx
;
665 struct tevent_req
*req
;
670 static int vfswrap_asys_state_destructor(struct vfswrap_asys_state
*s
)
672 asys_cancel(s
->asys_ctx
, s
->req
);
676 static struct tevent_req
*vfswrap_pread_send(struct vfs_handle_struct
*handle
,
678 struct tevent_context
*ev
,
679 struct files_struct
*fsp
,
681 size_t n
, off_t offset
)
683 struct tevent_req
*req
;
684 struct vfswrap_asys_state
*state
;
687 req
= tevent_req_create(mem_ctx
, &state
, struct vfswrap_asys_state
);
691 if (!vfswrap_init_asys_ctx(handle
->conn
->sconn
->conn
)) {
693 return tevent_req_post(req
, ev
);
695 state
->asys_ctx
= handle
->conn
->sconn
->conn
->asys_ctx
;
698 ret
= asys_pread(state
->asys_ctx
, fsp
->fh
->fd
, data
, n
, offset
, req
);
700 tevent_req_error(req
, ret
);
701 return tevent_req_post(req
, ev
);
703 talloc_set_destructor(state
, vfswrap_asys_state_destructor
);
708 static struct tevent_req
*vfswrap_pwrite_send(struct vfs_handle_struct
*handle
,
710 struct tevent_context
*ev
,
711 struct files_struct
*fsp
,
713 size_t n
, off_t offset
)
715 struct tevent_req
*req
;
716 struct vfswrap_asys_state
*state
;
719 req
= tevent_req_create(mem_ctx
, &state
, struct vfswrap_asys_state
);
723 if (!vfswrap_init_asys_ctx(handle
->conn
->sconn
->conn
)) {
725 return tevent_req_post(req
, ev
);
727 state
->asys_ctx
= handle
->conn
->sconn
->conn
->asys_ctx
;
730 ret
= asys_pwrite(state
->asys_ctx
, fsp
->fh
->fd
, data
, n
, offset
, req
);
732 tevent_req_error(req
, ret
);
733 return tevent_req_post(req
, ev
);
735 talloc_set_destructor(state
, vfswrap_asys_state_destructor
);
740 static struct tevent_req
*vfswrap_fsync_send(struct vfs_handle_struct
*handle
,
742 struct tevent_context
*ev
,
743 struct files_struct
*fsp
)
745 struct tevent_req
*req
;
746 struct vfswrap_asys_state
*state
;
749 req
= tevent_req_create(mem_ctx
, &state
, struct vfswrap_asys_state
);
753 if (!vfswrap_init_asys_ctx(handle
->conn
->sconn
->conn
)) {
755 return tevent_req_post(req
, ev
);
757 state
->asys_ctx
= handle
->conn
->sconn
->conn
->asys_ctx
;
760 ret
= asys_fsync(state
->asys_ctx
, fsp
->fh
->fd
, req
);
762 tevent_req_error(req
, ret
);
763 return tevent_req_post(req
, ev
);
765 talloc_set_destructor(state
, vfswrap_asys_state_destructor
);
770 static void vfswrap_asys_finished(struct tevent_context
*ev
,
771 struct tevent_fd
*fde
,
772 uint16_t flags
, void *p
)
774 struct asys_context
*asys_ctx
= (struct asys_context
*)p
;
775 struct tevent_req
*req
;
776 struct vfswrap_asys_state
*state
;
782 if ((flags
& TEVENT_FD_READ
) == 0) {
786 res
= asys_result(asys_ctx
, &ret
, &err
, &private_data
);
787 if (res
== ECANCELED
) {
792 DEBUG(1, ("asys_result returned %s\n", strerror(res
)));
796 req
= talloc_get_type_abort(private_data
, struct tevent_req
);
797 state
= tevent_req_data(req
, struct vfswrap_asys_state
);
799 talloc_set_destructor(state
, NULL
);
803 tevent_req_done(req
);
806 static ssize_t
vfswrap_asys_ssize_t_recv(struct tevent_req
*req
, int *err
)
808 struct vfswrap_asys_state
*state
= tevent_req_data(
809 req
, struct vfswrap_asys_state
);
811 if (tevent_req_is_unix_error(req
, err
)) {
818 static int vfswrap_asys_int_recv(struct tevent_req
*req
, int *err
)
820 struct vfswrap_asys_state
*state
= tevent_req_data(
821 req
, struct vfswrap_asys_state
);
823 if (tevent_req_is_unix_error(req
, err
)) {
830 static off_t
vfswrap_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
, off_t offset
, int whence
)
834 START_PROFILE(syscall_lseek
);
836 /* Cope with 'stat' file opens. */
837 if (fsp
->fh
->fd
!= -1)
838 result
= lseek(fsp
->fh
->fd
, offset
, whence
);
841 * We want to maintain the fiction that we can seek
842 * on a fifo for file system purposes. This allows
843 * people to set up UNIX fifo's that feed data to Windows
847 if((result
== -1) && (errno
== ESPIPE
)) {
852 END_PROFILE(syscall_lseek
);
856 static ssize_t
vfswrap_sendfile(vfs_handle_struct
*handle
, int tofd
, files_struct
*fromfsp
, const DATA_BLOB
*hdr
,
857 off_t offset
, size_t n
)
861 START_PROFILE_BYTES(syscall_sendfile
, n
);
862 result
= sys_sendfile(tofd
, fromfsp
->fh
->fd
, hdr
, offset
, n
);
863 END_PROFILE(syscall_sendfile
);
867 static ssize_t
vfswrap_recvfile(vfs_handle_struct
*handle
,
875 START_PROFILE_BYTES(syscall_recvfile
, n
);
876 result
= sys_recvfile(fromfd
, tofsp
->fh
->fd
, offset
, n
);
877 END_PROFILE(syscall_recvfile
);
881 static int vfswrap_rename(vfs_handle_struct
*handle
,
882 const struct smb_filename
*smb_fname_src
,
883 const struct smb_filename
*smb_fname_dst
)
887 START_PROFILE(syscall_rename
);
889 if (smb_fname_src
->stream_name
|| smb_fname_dst
->stream_name
) {
894 result
= rename(smb_fname_src
->base_name
, smb_fname_dst
->base_name
);
897 END_PROFILE(syscall_rename
);
901 static int vfswrap_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
)
906 START_PROFILE(syscall_fsync
);
907 result
= fsync(fsp
->fh
->fd
);
908 END_PROFILE(syscall_fsync
);
915 static int vfswrap_stat(vfs_handle_struct
*handle
,
916 struct smb_filename
*smb_fname
)
920 START_PROFILE(syscall_stat
);
922 if (smb_fname
->stream_name
) {
927 result
= sys_stat(smb_fname
->base_name
, &smb_fname
->st
,
928 lp_fake_dir_create_times(SNUM(handle
->conn
)));
930 END_PROFILE(syscall_stat
);
934 static int vfswrap_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
938 START_PROFILE(syscall_fstat
);
939 result
= sys_fstat(fsp
->fh
->fd
,
940 sbuf
, lp_fake_dir_create_times(SNUM(handle
->conn
)));
941 END_PROFILE(syscall_fstat
);
945 static int vfswrap_lstat(vfs_handle_struct
*handle
,
946 struct smb_filename
*smb_fname
)
950 START_PROFILE(syscall_lstat
);
952 if (smb_fname
->stream_name
) {
957 result
= sys_lstat(smb_fname
->base_name
, &smb_fname
->st
,
958 lp_fake_dir_create_times(SNUM(handle
->conn
)));
960 END_PROFILE(syscall_lstat
);
964 static NTSTATUS
vfswrap_translate_name(struct vfs_handle_struct
*handle
,
966 enum vfs_translate_direction direction
,
970 return NT_STATUS_NONE_MAPPED
;
974 * Implement the default fsctl operation.
976 static bool vfswrap_logged_ioctl_message
= false;
978 static NTSTATUS
vfswrap_fsctl(struct vfs_handle_struct
*handle
,
979 struct files_struct
*fsp
,
982 uint16_t req_flags
, /* Needed for UNICODE ... */
983 const uint8_t *_in_data
,
986 uint32_t max_out_len
,
989 const char *in_data
= (const char *)_in_data
;
990 char **out_data
= (char **)_out_data
;
993 case FSCTL_SET_SPARSE
:
995 bool set_sparse
= true;
998 if (in_len
>= 1 && in_data
[0] == 0) {
1002 status
= file_set_sparse(handle
->conn
, fsp
, set_sparse
);
1004 DEBUG(NT_STATUS_IS_OK(status
) ? 10 : 9,
1005 ("FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\n",
1006 smb_fname_str_dbg(fsp
->fsp_name
), set_sparse
,
1007 nt_errstr(status
)));
1012 case FSCTL_CREATE_OR_GET_OBJECT_ID
:
1014 unsigned char objid
[16];
1015 char *return_data
= NULL
;
1017 /* This should return the object-id on this file.
1018 * I think I'll make this be the inode+dev. JRA.
1021 DEBUG(10,("FSCTL_CREATE_OR_GET_OBJECT_ID: called on %s\n",
1022 fsp_fnum_dbg(fsp
)));
1024 *out_len
= (max_out_len
>= 64) ? 64 : max_out_len
;
1025 /* Hmmm, will this cause problems if less data asked for? */
1026 return_data
= talloc_array(ctx
, char, 64);
1027 if (return_data
== NULL
) {
1028 return NT_STATUS_NO_MEMORY
;
1031 /* For backwards compatibility only store the dev/inode. */
1032 push_file_id_16(return_data
, &fsp
->file_id
);
1033 memcpy(return_data
+16,create_volume_objectid(fsp
->conn
,objid
),16);
1034 push_file_id_16(return_data
+32, &fsp
->file_id
);
1035 *out_data
= return_data
;
1036 return NT_STATUS_OK
;
1039 case FSCTL_GET_REPARSE_POINT
:
1041 /* Fail it with STATUS_NOT_A_REPARSE_POINT */
1042 DEBUG(10, ("FSCTL_GET_REPARSE_POINT: called on %s. "
1043 "Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp
)));
1044 return NT_STATUS_NOT_A_REPARSE_POINT
;
1047 case FSCTL_SET_REPARSE_POINT
:
1049 /* Fail it with STATUS_NOT_A_REPARSE_POINT */
1050 DEBUG(10, ("FSCTL_SET_REPARSE_POINT: called on %s. "
1051 "Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp
)));
1052 return NT_STATUS_NOT_A_REPARSE_POINT
;
1055 case FSCTL_GET_SHADOW_COPY_DATA
:
1058 * This is called to retrieve the number of Shadow Copies (a.k.a. snapshots)
1059 * and return their volume names. If max_data_count is 16, then it is just
1060 * asking for the number of volumes and length of the combined names.
1062 * pdata is the data allocated by our caller, but that uses
1063 * total_data_count (which is 0 in our case) rather than max_data_count.
1064 * Allocate the correct amount and return the pointer to let
1065 * it be deallocated when we return.
1067 struct shadow_copy_data
*shadow_data
= NULL
;
1068 bool labels
= False
;
1069 uint32 labels_data_count
= 0;
1071 char *cur_pdata
= NULL
;
1073 if (max_out_len
< 16) {
1074 DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) < 16 is invalid!\n",
1076 return NT_STATUS_INVALID_PARAMETER
;
1079 if (max_out_len
> 16) {
1083 shadow_data
= talloc_zero(ctx
, struct shadow_copy_data
);
1084 if (shadow_data
== NULL
) {
1085 DEBUG(0,("TALLOC_ZERO() failed!\n"));
1086 return NT_STATUS_NO_MEMORY
;
1090 * Call the VFS routine to actually do the work.
1092 if (SMB_VFS_GET_SHADOW_COPY_DATA(fsp
, shadow_data
, labels
)!=0) {
1093 TALLOC_FREE(shadow_data
);
1094 if (errno
== ENOSYS
) {
1095 DEBUG(5,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\n",
1096 fsp
->conn
->connectpath
));
1097 return NT_STATUS_NOT_SUPPORTED
;
1099 DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, failed.\n",
1100 fsp
->conn
->connectpath
));
1101 return NT_STATUS_UNSUCCESSFUL
;
1105 labels_data_count
= (shadow_data
->num_volumes
* 2 *
1106 sizeof(SHADOW_COPY_LABEL
)) + 2;
1111 *out_len
= 12 + labels_data_count
+ 4;
1114 if (max_out_len
< *out_len
) {
1115 DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) too small (%u) bytes needed!\n",
1116 max_out_len
, *out_len
));
1117 TALLOC_FREE(shadow_data
);
1118 return NT_STATUS_BUFFER_TOO_SMALL
;
1121 cur_pdata
= talloc_array(ctx
, char, *out_len
);
1122 if (cur_pdata
== NULL
) {
1123 TALLOC_FREE(shadow_data
);
1124 return NT_STATUS_NO_MEMORY
;
1127 *out_data
= cur_pdata
;
1129 /* num_volumes 4 bytes */
1130 SIVAL(cur_pdata
, 0, shadow_data
->num_volumes
);
1133 /* num_labels 4 bytes */
1134 SIVAL(cur_pdata
, 4, shadow_data
->num_volumes
);
1137 /* needed_data_count 4 bytes */
1138 SIVAL(cur_pdata
, 8, labels_data_count
+ 4);
1142 DEBUG(10,("FSCTL_GET_SHADOW_COPY_DATA: %u volumes for path[%s].\n",
1143 shadow_data
->num_volumes
, fsp_str_dbg(fsp
)));
1144 if (labels
&& shadow_data
->labels
) {
1145 for (i
=0; i
<shadow_data
->num_volumes
; i
++) {
1146 srvstr_push(cur_pdata
, req_flags
,
1147 cur_pdata
, shadow_data
->labels
[i
],
1148 2 * sizeof(SHADOW_COPY_LABEL
),
1149 STR_UNICODE
|STR_TERMINATE
);
1150 cur_pdata
+= 2 * sizeof(SHADOW_COPY_LABEL
);
1151 DEBUGADD(10,("Label[%u]: '%s'\n",i
,shadow_data
->labels
[i
]));
1155 TALLOC_FREE(shadow_data
);
1157 return NT_STATUS_OK
;
1160 case FSCTL_FIND_FILES_BY_SID
:
1162 /* pretend this succeeded -
1164 * we have to send back a list with all files owned by this SID
1166 * but I have to check that --metze
1172 DEBUG(10, ("FSCTL_FIND_FILES_BY_SID: called on %s\n",
1173 fsp_fnum_dbg(fsp
)));
1176 /* NT_STATUS_BUFFER_TOO_SMALL maybe? */
1177 return NT_STATUS_INVALID_PARAMETER
;
1180 sid_len
= MIN(in_len
- 4,SID_MAX_SIZE
);
1182 /* unknown 4 bytes: this is not the length of the sid :-( */
1183 /*unknown = IVAL(pdata,0);*/
1185 if (!sid_parse(in_data
+ 4, sid_len
, &sid
)) {
1186 return NT_STATUS_INVALID_PARAMETER
;
1188 DEBUGADD(10, ("for SID: %s\n", sid_string_dbg(&sid
)));
1190 if (!sid_to_uid(&sid
, &uid
)) {
1191 DEBUG(0,("sid_to_uid: failed, sid[%s] sid_len[%lu]\n",
1192 sid_string_dbg(&sid
),
1193 (unsigned long)sid_len
));
1197 /* we can take a look at the find source :-)
1199 * find ./ -uid $uid -name '*' is what we need here
1202 * and send 4bytes len and then NULL terminated unicode strings
1205 * but I don't know how to deal with the paged results
1206 * (maybe we can hang the result anywhere in the fsp struct)
1208 * but I don't know how to deal with the paged results
1209 * (maybe we can hang the result anywhere in the fsp struct)
1211 * we don't send all files at once
1212 * and at the next we should *not* start from the beginning,
1213 * so we have to cache the result
1218 /* this works for now... */
1219 return NT_STATUS_OK
;
1222 case FSCTL_QUERY_ALLOCATED_RANGES
:
1224 /* FIXME: This is just a dummy reply, telling that all of the
1225 * file is allocated. MKS cp needs that.
1226 * Adding the real allocated ranges via FIEMAP on Linux
1227 * and SEEK_DATA/SEEK_HOLE on Solaris is needed to make
1228 * this FSCTL correct for sparse files.
1231 uint64_t offset
, length
;
1232 char *out_data_tmp
= NULL
;
1235 DEBUG(0,("FSCTL_QUERY_ALLOCATED_RANGES: data_count(%u) != 16 is invalid!\n",
1237 return NT_STATUS_INVALID_PARAMETER
;
1240 if (max_out_len
< 16) {
1241 DEBUG(0,("FSCTL_QUERY_ALLOCATED_RANGES: max_out_len (%u) < 16 is invalid!\n",
1243 return NT_STATUS_INVALID_PARAMETER
;
1246 offset
= BVAL(in_data
,0);
1247 length
= BVAL(in_data
,8);
1249 if (offset
+ length
< offset
) {
1250 /* No 64-bit integer wrap. */
1251 return NT_STATUS_INVALID_PARAMETER
;
1254 /* Shouldn't this be SMB_VFS_STAT ... ? */
1255 status
= vfs_stat_fsp(fsp
);
1256 if (!NT_STATUS_IS_OK(status
)) {
1261 out_data_tmp
= talloc_array(ctx
, char, *out_len
);
1262 if (out_data_tmp
== NULL
) {
1263 DEBUG(10, ("unable to allocate memory for response\n"));
1264 return NT_STATUS_NO_MEMORY
;
1267 if (offset
> fsp
->fsp_name
->st
.st_ex_size
||
1268 fsp
->fsp_name
->st
.st_ex_size
== 0 ||
1270 memset(out_data_tmp
, 0, *out_len
);
1272 uint64_t end
= offset
+ length
;
1273 end
= MIN(end
, fsp
->fsp_name
->st
.st_ex_size
);
1274 SBVAL(out_data_tmp
, 0, 0);
1275 SBVAL(out_data_tmp
, 8, end
);
1278 *out_data
= out_data_tmp
;
1280 return NT_STATUS_OK
;
1283 case FSCTL_IS_VOLUME_DIRTY
:
1285 DEBUG(10,("FSCTL_IS_VOLUME_DIRTY: called on %s "
1286 "(but remotely not supported)\n", fsp_fnum_dbg(fsp
)));
1288 * http://msdn.microsoft.com/en-us/library/cc232128%28PROT.10%29.aspx
1289 * says we have to respond with NT_STATUS_INVALID_PARAMETER
1291 return NT_STATUS_INVALID_PARAMETER
;
1296 * Only print once ... unfortunately there could be lots of
1297 * different FSCTLs that are called.
1299 if (!vfswrap_logged_ioctl_message
) {
1300 vfswrap_logged_ioctl_message
= true;
1301 DEBUG(2, ("%s (0x%x): Currently not implemented.\n",
1302 __func__
, function
));
1306 return NT_STATUS_NOT_SUPPORTED
;
1309 /********************************************************************
1310 Given a stat buffer return the allocated size on disk, taking into
1311 account sparse files.
1312 ********************************************************************/
1313 static uint64_t vfswrap_get_alloc_size(vfs_handle_struct
*handle
,
1314 struct files_struct
*fsp
,
1315 const SMB_STRUCT_STAT
*sbuf
)
1319 START_PROFILE(syscall_get_alloc_size
);
1321 if(S_ISDIR(sbuf
->st_ex_mode
)) {
1326 #if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
1327 /* The type of st_blocksize is blkcnt_t which *MUST* be
1328 signed (according to POSIX) and can be less than 64-bits.
1329 Ensure when we're converting to 64 bits wide we don't
1331 #if defined(SIZEOF_BLKCNT_T_8)
1332 result
= (uint64_t)STAT_ST_BLOCKSIZE
* (uint64_t)sbuf
->st_ex_blocks
;
1333 #elif defined(SIZEOF_BLKCNT_T_4)
1335 uint64_t bs
= ((uint64_t)sbuf
->st_ex_blocks
) & 0xFFFFFFFFLL
;
1336 result
= (uint64_t)STAT_ST_BLOCKSIZE
* bs
;
1339 #error SIZEOF_BLKCNT_T_NOT_A_SUPPORTED_VALUE
1342 result
= get_file_size_stat(sbuf
);
1345 if (fsp
&& fsp
->initial_allocation_size
)
1346 result
= MAX(result
,fsp
->initial_allocation_size
);
1348 result
= smb_roundup(handle
->conn
, result
);
1351 END_PROFILE(syscall_get_alloc_size
);
1355 static int vfswrap_unlink(vfs_handle_struct
*handle
,
1356 const struct smb_filename
*smb_fname
)
1360 START_PROFILE(syscall_unlink
);
1362 if (smb_fname
->stream_name
) {
1366 result
= unlink(smb_fname
->base_name
);
1369 END_PROFILE(syscall_unlink
);
1373 static int vfswrap_chmod(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
1377 START_PROFILE(syscall_chmod
);
1380 * We need to do this due to the fact that the default POSIX ACL
1381 * chmod modifies the ACL *mask* for the group owner, not the
1382 * group owner bits directly. JRA.
1387 int saved_errno
= errno
; /* We might get ENOSYS */
1388 if ((result
= SMB_VFS_CHMOD_ACL(handle
->conn
, path
, mode
)) == 0) {
1389 END_PROFILE(syscall_chmod
);
1392 /* Error - return the old errno. */
1393 errno
= saved_errno
;
1396 result
= chmod(path
, mode
);
1397 END_PROFILE(syscall_chmod
);
1401 static int vfswrap_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
1405 START_PROFILE(syscall_fchmod
);
1408 * We need to do this due to the fact that the default POSIX ACL
1409 * chmod modifies the ACL *mask* for the group owner, not the
1410 * group owner bits directly. JRA.
1414 int saved_errno
= errno
; /* We might get ENOSYS */
1415 if ((result
= SMB_VFS_FCHMOD_ACL(fsp
, mode
)) == 0) {
1416 END_PROFILE(syscall_fchmod
);
1419 /* Error - return the old errno. */
1420 errno
= saved_errno
;
1423 #if defined(HAVE_FCHMOD)
1424 result
= fchmod(fsp
->fh
->fd
, mode
);
1430 END_PROFILE(syscall_fchmod
);
1434 static int vfswrap_chown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
1438 START_PROFILE(syscall_chown
);
1439 result
= chown(path
, uid
, gid
);
1440 END_PROFILE(syscall_chown
);
1444 static int vfswrap_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
, uid_t uid
, gid_t gid
)
1449 START_PROFILE(syscall_fchown
);
1450 result
= fchown(fsp
->fh
->fd
, uid
, gid
);
1451 END_PROFILE(syscall_fchown
);
1459 static int vfswrap_lchown(vfs_handle_struct
*handle
, const char *path
, uid_t uid
, gid_t gid
)
1463 START_PROFILE(syscall_lchown
);
1464 result
= lchown(path
, uid
, gid
);
1465 END_PROFILE(syscall_lchown
);
1469 static int vfswrap_chdir(vfs_handle_struct
*handle
, const char *path
)
1473 START_PROFILE(syscall_chdir
);
1474 result
= chdir(path
);
1475 END_PROFILE(syscall_chdir
);
1479 static char *vfswrap_getwd(vfs_handle_struct
*handle
)
1483 START_PROFILE(syscall_getwd
);
1484 result
= sys_getwd();
1485 END_PROFILE(syscall_getwd
);
1489 /*********************************************************************
1490 nsec timestamp resolution call. Convert down to whatever the underlying
1491 system will support.
1492 **********************************************************************/
1494 static int vfswrap_ntimes(vfs_handle_struct
*handle
,
1495 const struct smb_filename
*smb_fname
,
1496 struct smb_file_time
*ft
)
1500 START_PROFILE(syscall_ntimes
);
1502 if (smb_fname
->stream_name
) {
1508 if (null_timespec(ft
->atime
)) {
1509 ft
->atime
= smb_fname
->st
.st_ex_atime
;
1512 if (null_timespec(ft
->mtime
)) {
1513 ft
->mtime
= smb_fname
->st
.st_ex_mtime
;
1516 if (!null_timespec(ft
->create_time
)) {
1517 set_create_timespec_ea(handle
->conn
,
1522 if ((timespec_compare(&ft
->atime
,
1523 &smb_fname
->st
.st_ex_atime
) == 0) &&
1524 (timespec_compare(&ft
->mtime
,
1525 &smb_fname
->st
.st_ex_mtime
) == 0)) {
1530 #if defined(HAVE_UTIMENSAT)
1532 struct timespec ts
[2];
1535 result
= utimensat(AT_FDCWD
, smb_fname
->base_name
, ts
, 0);
1537 result
= utimensat(AT_FDCWD
, smb_fname
->base_name
, NULL
, 0);
1539 if (!((result
== -1) && (errno
== ENOSYS
))) {
1543 #if defined(HAVE_UTIMES)
1545 struct timeval tv
[2];
1546 tv
[0] = convert_timespec_to_timeval(ft
->atime
);
1547 tv
[1] = convert_timespec_to_timeval(ft
->mtime
);
1548 result
= utimes(smb_fname
->base_name
, tv
);
1550 result
= utimes(smb_fname
->base_name
, NULL
);
1552 if (!((result
== -1) && (errno
== ENOSYS
))) {
1556 #if defined(HAVE_UTIME)
1558 struct utimbuf times
;
1559 times
.actime
= convert_timespec_to_time_t(ft
->atime
);
1560 times
.modtime
= convert_timespec_to_time_t(ft
->mtime
);
1561 result
= utime(smb_fname
->base_name
, ×
);
1563 result
= utime(smb_fname
->base_name
, NULL
);
1565 if (!((result
== -1) && (errno
== ENOSYS
))) {
1573 END_PROFILE(syscall_ntimes
);
1577 /*********************************************************************
1578 A version of ftruncate that will write the space on disk if strict
1580 **********************************************************************/
1582 static int strict_allocate_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
, off_t len
)
1584 off_t space_to_write
;
1585 uint64_t space_avail
;
1586 uint64_t bsize
,dfree
,dsize
;
1589 SMB_STRUCT_STAT
*pst
;
1591 status
= vfs_stat_fsp(fsp
);
1592 if (!NT_STATUS_IS_OK(status
)) {
1595 pst
= &fsp
->fsp_name
->st
;
1598 if (S_ISFIFO(pst
->st_ex_mode
))
1602 if (pst
->st_ex_size
== len
)
1605 /* Shrink - just ftruncate. */
1606 if (pst
->st_ex_size
> len
)
1607 return ftruncate(fsp
->fh
->fd
, len
);
1609 space_to_write
= len
- pst
->st_ex_size
;
1611 /* for allocation try fallocate first. This can fail on some
1612 platforms e.g. when the filesystem doesn't support it and no
1613 emulation is being done by the libc (like on AIX with JFS1). In that
1614 case we do our own emulation. fallocate implementations can
1615 return ENOTSUP or EINVAL in cases like that. */
1616 ret
= SMB_VFS_FALLOCATE(fsp
, VFS_FALLOCATE_EXTEND_SIZE
,
1617 pst
->st_ex_size
, space_to_write
);
1618 if (ret
== ENOSPC
) {
1625 DEBUG(10,("strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with "
1626 "error %d. Falling back to slow manual allocation\n", ret
));
1628 /* available disk space is enough or not? */
1629 space_avail
= get_dfree_info(fsp
->conn
,
1630 fsp
->fsp_name
->base_name
, false,
1631 &bsize
,&dfree
,&dsize
);
1632 /* space_avail is 1k blocks */
1633 if (space_avail
== (uint64_t)-1 ||
1634 ((uint64_t)space_to_write
/1024 > space_avail
) ) {
1639 /* Write out the real space on disk. */
1640 ret
= vfs_slow_fallocate(fsp
, pst
->st_ex_size
, space_to_write
);
1649 static int vfswrap_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
, off_t len
)
1652 SMB_STRUCT_STAT
*pst
;
1656 START_PROFILE(syscall_ftruncate
);
1658 if (lp_strict_allocate(SNUM(fsp
->conn
)) && !fsp
->is_sparse
) {
1659 result
= strict_allocate_ftruncate(handle
, fsp
, len
);
1660 END_PROFILE(syscall_ftruncate
);
1664 /* we used to just check HAVE_FTRUNCATE_EXTEND and only use
1665 ftruncate if the system supports it. Then I discovered that
1666 you can have some filesystems that support ftruncate
1667 expansion and some that don't! On Linux fat can't do
1668 ftruncate extend but ext2 can. */
1670 result
= ftruncate(fsp
->fh
->fd
, len
);
1674 /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
1675 extend a file with ftruncate. Provide alternate implementation
1678 /* Do an fstat to see if the file is longer than the requested
1679 size in which case the ftruncate above should have
1680 succeeded or shorter, in which case seek to len - 1 and
1681 write 1 byte of zero */
1682 status
= vfs_stat_fsp(fsp
);
1683 if (!NT_STATUS_IS_OK(status
)) {
1686 pst
= &fsp
->fsp_name
->st
;
1689 if (S_ISFIFO(pst
->st_ex_mode
)) {
1695 if (pst
->st_ex_size
== len
) {
1700 if (pst
->st_ex_size
> len
) {
1701 /* the ftruncate should have worked */
1705 if (SMB_VFS_PWRITE(fsp
, &c
, 1, len
-1)!=1) {
1713 END_PROFILE(syscall_ftruncate
);
1717 static int vfswrap_fallocate(vfs_handle_struct
*handle
,
1719 enum vfs_fallocate_mode mode
,
1725 START_PROFILE(syscall_fallocate
);
1726 if (mode
== VFS_FALLOCATE_EXTEND_SIZE
) {
1727 result
= sys_posix_fallocate(fsp
->fh
->fd
, offset
, len
);
1728 } else if (mode
== VFS_FALLOCATE_KEEP_SIZE
) {
1729 result
= sys_fallocate(fsp
->fh
->fd
, mode
, offset
, len
);
1734 END_PROFILE(syscall_fallocate
);
1738 static bool vfswrap_lock(vfs_handle_struct
*handle
, files_struct
*fsp
, int op
, off_t offset
, off_t count
, int type
)
1742 START_PROFILE(syscall_fcntl_lock
);
1743 result
= fcntl_lock(fsp
->fh
->fd
, op
, offset
, count
, type
);
1744 END_PROFILE(syscall_fcntl_lock
);
1748 static int vfswrap_kernel_flock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1749 uint32 share_mode
, uint32 access_mask
)
1751 START_PROFILE(syscall_kernel_flock
);
1752 kernel_flock(fsp
->fh
->fd
, share_mode
, access_mask
);
1753 END_PROFILE(syscall_kernel_flock
);
1757 static bool vfswrap_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
, off_t
*poffset
, off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1761 START_PROFILE(syscall_fcntl_getlock
);
1762 result
= fcntl_getlock(fsp
->fh
->fd
, poffset
, pcount
, ptype
, ppid
);
1763 END_PROFILE(syscall_fcntl_getlock
);
1767 static int vfswrap_linux_setlease(vfs_handle_struct
*handle
, files_struct
*fsp
,
1772 START_PROFILE(syscall_linux_setlease
);
1774 #ifdef HAVE_KERNEL_OPLOCKS_LINUX
1775 result
= linux_setlease(fsp
->fh
->fd
, leasetype
);
1779 END_PROFILE(syscall_linux_setlease
);
1783 static int vfswrap_symlink(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
1787 START_PROFILE(syscall_symlink
);
1788 result
= symlink(oldpath
, newpath
);
1789 END_PROFILE(syscall_symlink
);
1793 static int vfswrap_readlink(vfs_handle_struct
*handle
, const char *path
, char *buf
, size_t bufsiz
)
1797 START_PROFILE(syscall_readlink
);
1798 result
= readlink(path
, buf
, bufsiz
);
1799 END_PROFILE(syscall_readlink
);
1803 static int vfswrap_link(vfs_handle_struct
*handle
, const char *oldpath
, const char *newpath
)
1807 START_PROFILE(syscall_link
);
1808 result
= link(oldpath
, newpath
);
1809 END_PROFILE(syscall_link
);
1813 static int vfswrap_mknod(vfs_handle_struct
*handle
, const char *pathname
, mode_t mode
, SMB_DEV_T dev
)
1817 START_PROFILE(syscall_mknod
);
1818 result
= sys_mknod(pathname
, mode
, dev
);
1819 END_PROFILE(syscall_mknod
);
1823 static char *vfswrap_realpath(vfs_handle_struct
*handle
, const char *path
)
1827 START_PROFILE(syscall_realpath
);
1828 #ifdef REALPATH_TAKES_NULL
1829 result
= realpath(path
, NULL
);
1831 result
= SMB_MALLOC_ARRAY(char, PATH_MAX
+1);
1833 char *resolved_path
= realpath(path
, result
);
1834 if (!resolved_path
) {
1837 /* SMB_ASSERT(result == resolved_path) ? */
1838 result
= resolved_path
;
1842 END_PROFILE(syscall_realpath
);
1846 static NTSTATUS
vfswrap_notify_watch(vfs_handle_struct
*vfs_handle
,
1847 struct sys_notify_context
*ctx
,
1850 uint32_t *subdir_filter
,
1851 void (*callback
)(struct sys_notify_context
*ctx
,
1853 struct notify_event
*ev
),
1854 void *private_data
, void *handle
)
1857 * So far inotify is the only supported default notify mechanism. If
1858 * another platform like the the BSD's or a proprietary Unix comes
1859 * along and wants another default, we can play the same trick we
1860 * played with Posix ACLs.
1862 * Until that is the case, hard-code inotify here.
1865 if (lp_kernel_change_notify(vfs_handle
->conn
->params
)) {
1866 return inotify_watch(ctx
, path
, filter
, subdir_filter
,
1867 callback
, private_data
, handle
);
1871 * Do nothing, leave everything to notify_internal.c
1873 return NT_STATUS_OK
;
1876 static int vfswrap_chflags(vfs_handle_struct
*handle
, const char *path
,
1880 return chflags(path
, flags
);
1887 static struct file_id
vfswrap_file_id_create(struct vfs_handle_struct
*handle
,
1888 const SMB_STRUCT_STAT
*sbuf
)
1892 /* the ZERO_STRUCT ensures padding doesn't break using the key as a
1896 key
.devid
= sbuf
->st_ex_dev
;
1897 key
.inode
= sbuf
->st_ex_ino
;
1898 /* key.extid is unused by default. */
1903 static NTSTATUS
vfswrap_streaminfo(vfs_handle_struct
*handle
,
1904 struct files_struct
*fsp
,
1906 TALLOC_CTX
*mem_ctx
,
1907 unsigned int *pnum_streams
,
1908 struct stream_struct
**pstreams
)
1910 SMB_STRUCT_STAT sbuf
;
1911 struct stream_struct
*tmp_streams
= NULL
;
1914 if ((fsp
!= NULL
) && (fsp
->is_directory
)) {
1916 * No default streams on directories
1921 if ((fsp
!= NULL
) && (fsp
->fh
->fd
!= -1)) {
1922 ret
= SMB_VFS_FSTAT(fsp
, &sbuf
);
1925 struct smb_filename smb_fname
;
1927 ZERO_STRUCT(smb_fname
);
1928 smb_fname
.base_name
= discard_const_p(char, fname
);
1930 if (lp_posix_pathnames()) {
1931 ret
= SMB_VFS_LSTAT(handle
->conn
, &smb_fname
);
1933 ret
= SMB_VFS_STAT(handle
->conn
, &smb_fname
);
1935 sbuf
= smb_fname
.st
;
1939 return map_nt_error_from_unix(errno
);
1942 if (S_ISDIR(sbuf
.st_ex_mode
)) {
1946 tmp_streams
= talloc_realloc(mem_ctx
, *pstreams
, struct stream_struct
,
1947 (*pnum_streams
) + 1);
1948 if (tmp_streams
== NULL
) {
1949 return NT_STATUS_NO_MEMORY
;
1951 tmp_streams
[*pnum_streams
].name
= talloc_strdup(tmp_streams
, "::$DATA");
1952 if (tmp_streams
[*pnum_streams
].name
== NULL
) {
1953 return NT_STATUS_NO_MEMORY
;
1955 tmp_streams
[*pnum_streams
].size
= sbuf
.st_ex_size
;
1956 tmp_streams
[*pnum_streams
].alloc_size
= SMB_VFS_GET_ALLOC_SIZE(handle
->conn
, fsp
, &sbuf
);
1959 *pstreams
= tmp_streams
;
1961 return NT_STATUS_OK
;
1964 static int vfswrap_get_real_filename(struct vfs_handle_struct
*handle
,
1967 TALLOC_CTX
*mem_ctx
,
1971 * Don't fall back to get_real_filename so callers can differentiate
1972 * between a full directory scan and an actual case-insensitive stat.
1978 static const char *vfswrap_connectpath(struct vfs_handle_struct
*handle
,
1981 return handle
->conn
->connectpath
;
1984 static NTSTATUS
vfswrap_brl_lock_windows(struct vfs_handle_struct
*handle
,
1985 struct byte_range_lock
*br_lck
,
1986 struct lock_struct
*plock
,
1988 struct blocking_lock_record
*blr
)
1990 SMB_ASSERT(plock
->lock_flav
== WINDOWS_LOCK
);
1992 /* Note: blr is not used in the default implementation. */
1993 return brl_lock_windows_default(br_lck
, plock
, blocking_lock
);
1996 static bool vfswrap_brl_unlock_windows(struct vfs_handle_struct
*handle
,
1997 struct messaging_context
*msg_ctx
,
1998 struct byte_range_lock
*br_lck
,
1999 const struct lock_struct
*plock
)
2001 SMB_ASSERT(plock
->lock_flav
== WINDOWS_LOCK
);
2003 return brl_unlock_windows_default(msg_ctx
, br_lck
, plock
);
2006 static bool vfswrap_brl_cancel_windows(struct vfs_handle_struct
*handle
,
2007 struct byte_range_lock
*br_lck
,
2008 struct lock_struct
*plock
,
2009 struct blocking_lock_record
*blr
)
2011 SMB_ASSERT(plock
->lock_flav
== WINDOWS_LOCK
);
2013 /* Note: blr is not used in the default implementation. */
2014 return brl_lock_cancel_default(br_lck
, plock
);
2017 static bool vfswrap_strict_lock(struct vfs_handle_struct
*handle
,
2019 struct lock_struct
*plock
)
2021 SMB_ASSERT(plock
->lock_type
== READ_LOCK
||
2022 plock
->lock_type
== WRITE_LOCK
);
2024 return strict_lock_default(fsp
, plock
);
2027 static void vfswrap_strict_unlock(struct vfs_handle_struct
*handle
,
2029 struct lock_struct
*plock
)
2031 SMB_ASSERT(plock
->lock_type
== READ_LOCK
||
2032 plock
->lock_type
== WRITE_LOCK
);
2034 strict_unlock_default(fsp
, plock
);
2037 /* NT ACL operations. */
2039 static NTSTATUS
vfswrap_fget_nt_acl(vfs_handle_struct
*handle
,
2041 uint32 security_info
,
2042 struct security_descriptor
**ppdesc
)
2046 START_PROFILE(fget_nt_acl
);
2047 result
= posix_fget_nt_acl(fsp
, security_info
, ppdesc
);
2048 END_PROFILE(fget_nt_acl
);
2052 static NTSTATUS
vfswrap_get_nt_acl(vfs_handle_struct
*handle
,
2054 uint32 security_info
,
2055 struct security_descriptor
**ppdesc
)
2059 START_PROFILE(get_nt_acl
);
2060 result
= posix_get_nt_acl(handle
->conn
, name
, security_info
, ppdesc
);
2061 END_PROFILE(get_nt_acl
);
2065 static NTSTATUS
vfswrap_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
, uint32 security_info_sent
, const struct security_descriptor
*psd
)
2069 START_PROFILE(fset_nt_acl
);
2070 result
= set_nt_acl(fsp
, security_info_sent
, psd
);
2071 END_PROFILE(fset_nt_acl
);
2075 static NTSTATUS
vfswrap_audit_file(struct vfs_handle_struct
*handle
,
2076 struct smb_filename
*file
,
2077 struct security_acl
*sacl
,
2078 uint32_t access_requested
,
2079 uint32_t access_denied
)
2081 return NT_STATUS_OK
; /* Nothing to do here ... */
2084 static int vfswrap_chmod_acl(vfs_handle_struct
*handle
, const char *name
, mode_t mode
)
2092 START_PROFILE(chmod_acl
);
2093 result
= chmod_acl(handle
->conn
, name
, mode
);
2094 END_PROFILE(chmod_acl
);
2099 static int vfswrap_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
, mode_t mode
)
2107 START_PROFILE(fchmod_acl
);
2108 result
= fchmod_acl(fsp
, mode
);
2109 END_PROFILE(fchmod_acl
);
2114 static SMB_ACL_T
vfswrap_sys_acl_get_file(vfs_handle_struct
*handle
, const char *path_p
, SMB_ACL_TYPE_T type
)
2116 return sys_acl_get_file(handle
, path_p
, type
);
2119 static SMB_ACL_T
vfswrap_sys_acl_get_fd(vfs_handle_struct
*handle
, files_struct
*fsp
)
2121 return sys_acl_get_fd(handle
, fsp
);
2124 static int vfswrap_sys_acl_set_file(vfs_handle_struct
*handle
, const char *name
, SMB_ACL_TYPE_T acltype
, SMB_ACL_T theacl
)
2126 return sys_acl_set_file(handle
, name
, acltype
, theacl
);
2129 static int vfswrap_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
, SMB_ACL_T theacl
)
2131 return sys_acl_set_fd(handle
, fsp
, theacl
);
2134 static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct
*handle
, const char *path
)
2136 return sys_acl_delete_def_file(handle
, path
);
2139 /****************************************************************
2140 Extended attribute operations.
2141 *****************************************************************/
2143 static ssize_t
vfswrap_getxattr(struct vfs_handle_struct
*handle
,const char *path
, const char *name
, void *value
, size_t size
)
2145 return getxattr(path
, name
, value
, size
);
2148 static ssize_t
vfswrap_fgetxattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, void *value
, size_t size
)
2150 return fgetxattr(fsp
->fh
->fd
, name
, value
, size
);
2153 static ssize_t
vfswrap_listxattr(struct vfs_handle_struct
*handle
, const char *path
, char *list
, size_t size
)
2155 return listxattr(path
, list
, size
);
2158 static ssize_t
vfswrap_flistxattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, char *list
, size_t size
)
2160 return flistxattr(fsp
->fh
->fd
, list
, size
);
2163 static int vfswrap_removexattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
)
2165 return removexattr(path
, name
);
2168 static int vfswrap_fremovexattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
)
2170 return fremovexattr(fsp
->fh
->fd
, name
);
2173 static int vfswrap_setxattr(struct vfs_handle_struct
*handle
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
2175 return setxattr(path
, name
, value
, size
, flags
);
2178 static int vfswrap_fsetxattr(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *name
, const void *value
, size_t size
, int flags
)
2180 return fsetxattr(fsp
->fh
->fd
, name
, value
, size
, flags
);
2183 static bool vfswrap_aio_force(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
)
2188 static bool vfswrap_is_offline(struct vfs_handle_struct
*handle
,
2189 const struct smb_filename
*fname
,
2190 SMB_STRUCT_STAT
*sbuf
)
2194 bool offline
= false;
2196 if (ISDOT(fname
->base_name
) || ISDOTDOT(fname
->base_name
)) {
2200 if (!lp_dmapi_support(SNUM(handle
->conn
)) || !dmapi_have_session()) {
2201 #if defined(ENOTSUP)
2207 status
= get_full_smb_filename(talloc_tos(), fname
, &path
);
2208 if (!NT_STATUS_IS_OK(status
)) {
2209 errno
= map_errno_from_nt_status(status
);
2213 offline
= (dmapi_file_flags(path
) & FILE_ATTRIBUTE_OFFLINE
) != 0;
2220 static int vfswrap_set_offline(struct vfs_handle_struct
*handle
,
2221 const struct smb_filename
*fname
)
2223 /* We don't know how to set offline bit by default, needs to be overriden in the vfs modules */
2224 #if defined(ENOTSUP)
2230 static NTSTATUS
vfswrap_durable_cookie(struct vfs_handle_struct
*handle
,
2231 struct files_struct
*fsp
,
2232 TALLOC_CTX
*mem_ctx
,
2235 return vfs_default_durable_cookie(fsp
, mem_ctx
, cookie
);
2238 static NTSTATUS
vfswrap_durable_disconnect(struct vfs_handle_struct
*handle
,
2239 struct files_struct
*fsp
,
2240 const DATA_BLOB old_cookie
,
2241 TALLOC_CTX
*mem_ctx
,
2242 DATA_BLOB
*new_cookie
)
2244 return vfs_default_durable_disconnect(fsp
, old_cookie
, mem_ctx
,
2248 static NTSTATUS
vfswrap_durable_reconnect(struct vfs_handle_struct
*handle
,
2249 struct smb_request
*smb1req
,
2250 struct smbXsrv_open
*op
,
2251 const DATA_BLOB old_cookie
,
2252 TALLOC_CTX
*mem_ctx
,
2253 struct files_struct
**fsp
,
2254 DATA_BLOB
*new_cookie
)
2256 return vfs_default_durable_reconnect(handle
->conn
, smb1req
, op
,
2257 old_cookie
, mem_ctx
,
2261 static struct vfs_fn_pointers vfs_default_fns
= {
2262 /* Disk operations */
2264 .connect_fn
= vfswrap_connect
,
2265 .disconnect_fn
= vfswrap_disconnect
,
2266 .disk_free_fn
= vfswrap_disk_free
,
2267 .get_quota_fn
= vfswrap_get_quota
,
2268 .set_quota_fn
= vfswrap_set_quota
,
2269 .get_shadow_copy_data_fn
= vfswrap_get_shadow_copy_data
,
2270 .statvfs_fn
= vfswrap_statvfs
,
2271 .fs_capabilities_fn
= vfswrap_fs_capabilities
,
2272 .get_dfs_referrals_fn
= vfswrap_get_dfs_referrals
,
2274 /* Directory operations */
2276 .opendir_fn
= vfswrap_opendir
,
2277 .fdopendir_fn
= vfswrap_fdopendir
,
2278 .readdir_fn
= vfswrap_readdir
,
2279 .seekdir_fn
= vfswrap_seekdir
,
2280 .telldir_fn
= vfswrap_telldir
,
2281 .rewind_dir_fn
= vfswrap_rewinddir
,
2282 .mkdir_fn
= vfswrap_mkdir
,
2283 .rmdir_fn
= vfswrap_rmdir
,
2284 .closedir_fn
= vfswrap_closedir
,
2285 .init_search_op_fn
= vfswrap_init_search_op
,
2287 /* File operations */
2289 .open_fn
= vfswrap_open
,
2290 .create_file_fn
= vfswrap_create_file
,
2291 .close_fn
= vfswrap_close
,
2292 .read_fn
= vfswrap_read
,
2293 .pread_fn
= vfswrap_pread
,
2294 .pread_send_fn
= vfswrap_pread_send
,
2295 .pread_recv_fn
= vfswrap_asys_ssize_t_recv
,
2296 .write_fn
= vfswrap_write
,
2297 .pwrite_fn
= vfswrap_pwrite
,
2298 .pwrite_send_fn
= vfswrap_pwrite_send
,
2299 .pwrite_recv_fn
= vfswrap_asys_ssize_t_recv
,
2300 .lseek_fn
= vfswrap_lseek
,
2301 .sendfile_fn
= vfswrap_sendfile
,
2302 .recvfile_fn
= vfswrap_recvfile
,
2303 .rename_fn
= vfswrap_rename
,
2304 .fsync_fn
= vfswrap_fsync
,
2305 .fsync_send_fn
= vfswrap_fsync_send
,
2306 .fsync_recv_fn
= vfswrap_asys_int_recv
,
2307 .stat_fn
= vfswrap_stat
,
2308 .fstat_fn
= vfswrap_fstat
,
2309 .lstat_fn
= vfswrap_lstat
,
2310 .get_alloc_size_fn
= vfswrap_get_alloc_size
,
2311 .unlink_fn
= vfswrap_unlink
,
2312 .chmod_fn
= vfswrap_chmod
,
2313 .fchmod_fn
= vfswrap_fchmod
,
2314 .chown_fn
= vfswrap_chown
,
2315 .fchown_fn
= vfswrap_fchown
,
2316 .lchown_fn
= vfswrap_lchown
,
2317 .chdir_fn
= vfswrap_chdir
,
2318 .getwd_fn
= vfswrap_getwd
,
2319 .ntimes_fn
= vfswrap_ntimes
,
2320 .ftruncate_fn
= vfswrap_ftruncate
,
2321 .fallocate_fn
= vfswrap_fallocate
,
2322 .lock_fn
= vfswrap_lock
,
2323 .kernel_flock_fn
= vfswrap_kernel_flock
,
2324 .linux_setlease_fn
= vfswrap_linux_setlease
,
2325 .getlock_fn
= vfswrap_getlock
,
2326 .symlink_fn
= vfswrap_symlink
,
2327 .readlink_fn
= vfswrap_readlink
,
2328 .link_fn
= vfswrap_link
,
2329 .mknod_fn
= vfswrap_mknod
,
2330 .realpath_fn
= vfswrap_realpath
,
2331 .notify_watch_fn
= vfswrap_notify_watch
,
2332 .chflags_fn
= vfswrap_chflags
,
2333 .file_id_create_fn
= vfswrap_file_id_create
,
2334 .streaminfo_fn
= vfswrap_streaminfo
,
2335 .get_real_filename_fn
= vfswrap_get_real_filename
,
2336 .connectpath_fn
= vfswrap_connectpath
,
2337 .brl_lock_windows_fn
= vfswrap_brl_lock_windows
,
2338 .brl_unlock_windows_fn
= vfswrap_brl_unlock_windows
,
2339 .brl_cancel_windows_fn
= vfswrap_brl_cancel_windows
,
2340 .strict_lock_fn
= vfswrap_strict_lock
,
2341 .strict_unlock_fn
= vfswrap_strict_unlock
,
2342 .translate_name_fn
= vfswrap_translate_name
,
2343 .fsctl_fn
= vfswrap_fsctl
,
2345 /* NT ACL operations. */
2347 .fget_nt_acl_fn
= vfswrap_fget_nt_acl
,
2348 .get_nt_acl_fn
= vfswrap_get_nt_acl
,
2349 .fset_nt_acl_fn
= vfswrap_fset_nt_acl
,
2350 .audit_file_fn
= vfswrap_audit_file
,
2352 /* POSIX ACL operations. */
2354 .chmod_acl_fn
= vfswrap_chmod_acl
,
2355 .fchmod_acl_fn
= vfswrap_fchmod_acl
,
2357 .sys_acl_get_file_fn
= vfswrap_sys_acl_get_file
,
2358 .sys_acl_get_fd_fn
= vfswrap_sys_acl_get_fd
,
2359 .sys_acl_set_file_fn
= vfswrap_sys_acl_set_file
,
2360 .sys_acl_set_fd_fn
= vfswrap_sys_acl_set_fd
,
2361 .sys_acl_delete_def_file_fn
= vfswrap_sys_acl_delete_def_file
,
2363 /* EA operations. */
2364 .getxattr_fn
= vfswrap_getxattr
,
2365 .fgetxattr_fn
= vfswrap_fgetxattr
,
2366 .listxattr_fn
= vfswrap_listxattr
,
2367 .flistxattr_fn
= vfswrap_flistxattr
,
2368 .removexattr_fn
= vfswrap_removexattr
,
2369 .fremovexattr_fn
= vfswrap_fremovexattr
,
2370 .setxattr_fn
= vfswrap_setxattr
,
2371 .fsetxattr_fn
= vfswrap_fsetxattr
,
2373 /* aio operations */
2374 .aio_force_fn
= vfswrap_aio_force
,
2376 /* offline operations */
2377 .is_offline_fn
= vfswrap_is_offline
,
2378 .set_offline_fn
= vfswrap_set_offline
,
2380 /* durable handle operations */
2381 .durable_cookie_fn
= vfswrap_durable_cookie
,
2382 .durable_disconnect_fn
= vfswrap_durable_disconnect
,
2383 .durable_reconnect_fn
= vfswrap_durable_reconnect
,
2386 NTSTATUS
vfs_default_init(void);
2387 NTSTATUS
vfs_default_init(void)
2389 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
2390 DEFAULT_VFS_MODULE_NAME
, &vfs_default_fns
);