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"
34 #include "lib/util/tevent_ntstatus.h"
37 #define DBGC_CLASS DBGC_VFS
39 /* Check for NULL pointer parameters in vfswrap_* functions */
41 /* We don't want to have NULL function pointers lying around. Someone
42 is sure to try and execute them. These stubs are used to prevent
45 static int vfswrap_connect(vfs_handle_struct *handle, const char *service, const char *user)
47 return 0; /* Return >= 0 for success */
50 static void vfswrap_disconnect(vfs_handle_struct *handle)
56 static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize,
57 uint64_t *dfree, uint64_t *dsize)
61 result = sys_disk_free(handle->conn, path, small_query, bsize, dfree, dsize);
65 static int vfswrap_get_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
67 #ifdef HAVE_SYS_QUOTAS
70 START_PROFILE(syscall_get_quota);
71 result = sys_get_quota(handle->conn->connectpath, qtype, id, qt);
72 END_PROFILE(syscall_get_quota);
80 static int vfswrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
82 #ifdef HAVE_SYS_QUOTAS
85 START_PROFILE(syscall_set_quota);
86 result = sys_set_quota(handle->conn->connectpath, qtype, id, qt);
87 END_PROFILE(syscall_set_quota);
95 static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle,
96 struct files_struct *fsp,
97 struct shadow_copy_data *shadow_copy_data,
101 return -1; /* Not implemented. */
104 static int vfswrap_statvfs(struct vfs_handle_struct *handle, const char *path, vfs_statvfs_struct *statbuf)
106 return sys_statvfs(path, statbuf);
109 static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle,
110 enum timestamp_set_resolution *p_ts_res)
112 connection_struct *conn = handle->conn;
113 uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
114 struct smb_filename *smb_fname_cpath = NULL;
115 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 smb_fname_cpath = synthetic_smb_fname(talloc_tos(), conn->connectpath,
131 if (smb_fname_cpath == NULL) {
135 ret = SMB_VFS_STAT(conn, smb_fname_cpath);
137 TALLOC_FREE(smb_fname_cpath);
141 if (smb_fname_cpath->st.st_ex_mtime.tv_nsec ||
142 smb_fname_cpath->st.st_ex_atime.tv_nsec ||
143 smb_fname_cpath->st.st_ex_ctime.tv_nsec) {
144 /* If any of the normal UNIX directory timestamps
145 * have a non-zero tv_nsec component assume
146 * we might be able to set sub-second timestamps.
147 * See what filetime set primitives we have.
149 #if defined(HAVE_UTIMENSAT)
150 *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER;
151 #elif defined(HAVE_UTIMES)
152 /* utimes allows msec timestamps to be set. */
153 *p_ts_res = TIMESTAMP_SET_MSEC;
154 #elif defined(HAVE_UTIME)
155 /* utime only allows sec timestamps to be set. */
156 *p_ts_res = TIMESTAMP_SET_SECONDS;
159 DEBUG(10,("vfswrap_fs_capabilities: timestamp "
161 "available on share %s, directory %s\n",
162 *p_ts_res == TIMESTAMP_SET_MSEC ? "msec" : "sec",
163 lp_servicename(talloc_tos(), conn->params->service),
164 conn->connectpath ));
166 TALLOC_FREE(smb_fname_cpath);
170 static NTSTATUS vfswrap_get_dfs_referrals(struct vfs_handle_struct *handle,
171 struct dfs_GetDFSReferral *r)
173 struct junction_map *junction = NULL;
175 bool self_referral = false;
176 char *pathnamep = NULL;
177 char *local_dfs_path = NULL;
180 uint16_t max_referral_level = r->in.req.max_referral_level;
183 NDR_PRINT_IN_DEBUG(dfs_GetDFSReferral, r);
186 /* get the junction entry */
187 if (r->in.req.servername == NULL) {
188 return NT_STATUS_NOT_FOUND;
192 * Trim pathname sent by client so it begins with only one backslash.
193 * Two backslashes confuse some dfs clients
196 local_dfs_path = talloc_strdup(r, r->in.req.servername);
197 if (local_dfs_path == NULL) {
198 return NT_STATUS_NO_MEMORY;
200 pathnamep = local_dfs_path;
201 while (IS_DIRECTORY_SEP(pathnamep[0]) &&
202 IS_DIRECTORY_SEP(pathnamep[1])) {
206 junction = talloc_zero(r, struct junction_map);
207 if (junction == NULL) {
208 return NT_STATUS_NO_MEMORY;
211 /* The following call can change cwd. */
212 status = get_referred_path(r, pathnamep,
213 !handle->conn->sconn->using_smb2,
214 junction, &consumedcnt, &self_referral);
215 if (!NT_STATUS_IS_OK(status)) {
216 vfs_ChDir(handle->conn, handle->conn->connectpath);
219 vfs_ChDir(handle->conn, handle->conn->connectpath);
221 if (!self_referral) {
222 pathnamep[consumedcnt] = '\0';
225 dbgtext("setup_dfs_referral: Path %s to "
226 "alternate path(s):",
228 for (i=0; i < junction->referral_count; i++) {
230 junction->referral_list[i].alternate_path);
236 if (r->in.req.max_referral_level <= 2) {
237 max_referral_level = 2;
239 if (r->in.req.max_referral_level >= 3) {
240 max_referral_level = 3;
243 r->out.resp = talloc_zero(r, struct dfs_referral_resp);
244 if (r->out.resp == NULL) {
245 return NT_STATUS_NO_MEMORY;
248 r->out.resp->path_consumed = strlen_m(pathnamep) * 2;
249 r->out.resp->nb_referrals = junction->referral_count;
251 r->out.resp->header_flags = DFS_HEADER_FLAG_STORAGE_SVR;
253 r->out.resp->header_flags |= DFS_HEADER_FLAG_REFERAL_SVR;
256 r->out.resp->referral_entries = talloc_zero_array(r,
257 struct dfs_referral_type,
258 r->out.resp->nb_referrals);
259 if (r->out.resp->referral_entries == NULL) {
260 return NT_STATUS_NO_MEMORY;
263 switch (max_referral_level) {
265 for(i=0; i < junction->referral_count; i++) {
266 struct referral *ref = &junction->referral_list[i];
267 TALLOC_CTX *mem_ctx = r->out.resp->referral_entries;
268 struct dfs_referral_type *t =
269 &r->out.resp->referral_entries[i];
270 struct dfs_referral_v2 *v2 = &t->referral.v2;
273 v2->size = VERSION2_REFERRAL_SIZE;
275 v2->server_type = DFS_SERVER_ROOT;
277 v2->server_type = DFS_SERVER_NON_ROOT;
280 v2->proximity = ref->proximity;
282 v2->DFS_path = talloc_strdup(mem_ctx, pathnamep);
283 if (v2->DFS_path == NULL) {
284 return NT_STATUS_NO_MEMORY;
286 v2->DFS_alt_path = talloc_strdup(mem_ctx, pathnamep);
287 if (v2->DFS_alt_path == NULL) {
288 return NT_STATUS_NO_MEMORY;
290 v2->netw_address = talloc_strdup(mem_ctx,
291 ref->alternate_path);
292 if (v2->netw_address == NULL) {
293 return NT_STATUS_NO_MEMORY;
299 for(i=0; i < junction->referral_count; i++) {
300 struct referral *ref = &junction->referral_list[i];
301 TALLOC_CTX *mem_ctx = r->out.resp->referral_entries;
302 struct dfs_referral_type *t =
303 &r->out.resp->referral_entries[i];
304 struct dfs_referral_v3 *v3 = &t->referral.v3;
305 struct dfs_normal_referral *r1 = &v3->referrals.r1;
308 v3->size = VERSION3_REFERRAL_SIZE;
310 v3->server_type = DFS_SERVER_ROOT;
312 v3->server_type = DFS_SERVER_NON_ROOT;
316 r1->DFS_path = talloc_strdup(mem_ctx, pathnamep);
317 if (r1->DFS_path == NULL) {
318 return NT_STATUS_NO_MEMORY;
320 r1->DFS_alt_path = talloc_strdup(mem_ctx, pathnamep);
321 if (r1->DFS_alt_path == NULL) {
322 return NT_STATUS_NO_MEMORY;
324 r1->netw_address = talloc_strdup(mem_ctx,
325 ref->alternate_path);
326 if (r1->netw_address == NULL) {
327 return NT_STATUS_NO_MEMORY;
332 DEBUG(0,("setup_dfs_referral: Invalid dfs referral "
334 max_referral_level));
335 return NT_STATUS_INVALID_LEVEL;
339 NDR_PRINT_OUT_DEBUG(dfs_GetDFSReferral, r);
345 /* Directory operations */
347 static DIR *vfswrap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
351 START_PROFILE(syscall_opendir);
352 result = opendir(fname);
353 END_PROFILE(syscall_opendir);
357 static DIR *vfswrap_fdopendir(vfs_handle_struct *handle,
364 START_PROFILE(syscall_fdopendir);
365 result = sys_fdopendir(fsp->fh->fd);
366 END_PROFILE(syscall_fdopendir);
371 static struct dirent *vfswrap_readdir(vfs_handle_struct *handle,
373 SMB_STRUCT_STAT *sbuf)
375 struct dirent *result;
377 START_PROFILE(syscall_readdir);
378 result = readdir(dirp);
379 END_PROFILE(syscall_readdir);
381 /* Default Posix readdir() does not give us stat info.
382 * Set to invalid to indicate we didn't return this info. */
383 SET_STAT_INVALID(*sbuf);
384 #if defined(HAVE_DIRFD) && defined(HAVE_FSTATAT)
385 if (result != NULL) {
386 /* See if we can efficiently return this. */
388 int flags = (lp_posix_pathnames() ?
389 AT_SYMLINK_NOFOLLOW : 0);
390 int ret = fstatat(dirfd(dirp),
395 init_stat_ex_from_stat(sbuf,
397 lp_fake_directory_create_times(
398 SNUM(handle->conn)));
406 static void vfswrap_seekdir(vfs_handle_struct *handle, DIR *dirp, long offset)
408 START_PROFILE(syscall_seekdir);
409 seekdir(dirp, offset);
410 END_PROFILE(syscall_seekdir);
413 static long vfswrap_telldir(vfs_handle_struct *handle, DIR *dirp)
416 START_PROFILE(syscall_telldir);
417 result = telldir(dirp);
418 END_PROFILE(syscall_telldir);
422 static void vfswrap_rewinddir(vfs_handle_struct *handle, DIR *dirp)
424 START_PROFILE(syscall_rewinddir);
426 END_PROFILE(syscall_rewinddir);
429 static int vfswrap_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode)
432 bool has_dacl = False;
435 START_PROFILE(syscall_mkdir);
437 if (lp_inherit_acls(SNUM(handle->conn))
438 && parent_dirname(talloc_tos(), path, &parent, NULL)
439 && (has_dacl = directory_has_default_acl(handle->conn, parent)))
440 mode = (0777 & lp_directory_mask(SNUM(handle->conn)));
444 result = mkdir(path, mode);
446 if (result == 0 && !has_dacl) {
448 * We need to do this as the default behavior of POSIX ACLs
449 * is to set the mask to be the requested group permission
450 * bits, not the group permission bits to be the requested
451 * group permission bits. This is not what we want, as it will
452 * mess up any inherited ACL bits that were set. JRA.
454 int saved_errno = errno; /* We may get ENOSYS */
455 if ((SMB_VFS_CHMOD_ACL(handle->conn, path, mode) == -1) && (errno == ENOSYS))
459 END_PROFILE(syscall_mkdir);
463 static int vfswrap_rmdir(vfs_handle_struct *handle, const char *path)
467 START_PROFILE(syscall_rmdir);
468 result = rmdir(path);
469 END_PROFILE(syscall_rmdir);
473 static int vfswrap_closedir(vfs_handle_struct *handle, DIR *dirp)
477 START_PROFILE(syscall_closedir);
478 result = closedir(dirp);
479 END_PROFILE(syscall_closedir);
483 static void vfswrap_init_search_op(vfs_handle_struct *handle,
486 /* Default behavior is a NOOP */
489 /* File operations */
491 static int vfswrap_open(vfs_handle_struct *handle,
492 struct smb_filename *smb_fname,
493 files_struct *fsp, int flags, mode_t mode)
497 START_PROFILE(syscall_open);
499 if (smb_fname->stream_name) {
504 result = open(smb_fname->base_name, flags, mode);
506 END_PROFILE(syscall_open);
510 static NTSTATUS vfswrap_create_file(vfs_handle_struct *handle,
511 struct smb_request *req,
512 uint16_t root_dir_fid,
513 struct smb_filename *smb_fname,
514 uint32_t access_mask,
515 uint32_t share_access,
516 uint32_t create_disposition,
517 uint32_t create_options,
518 uint32_t file_attributes,
519 uint32_t oplock_request,
520 uint64_t allocation_size,
521 uint32_t private_flags,
522 struct security_descriptor *sd,
523 struct ea_list *ea_list,
524 files_struct **result,
527 return create_file_default(handle->conn, req, root_dir_fid, smb_fname,
528 access_mask, share_access,
529 create_disposition, create_options,
530 file_attributes, oplock_request,
531 allocation_size, private_flags,
536 static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp)
540 START_PROFILE(syscall_close);
541 result = fd_close_posix(fsp);
542 END_PROFILE(syscall_close);
546 static ssize_t vfswrap_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
550 START_PROFILE_BYTES(syscall_read, n);
551 result = sys_read(fsp->fh->fd, data, n);
552 END_PROFILE(syscall_read);
556 static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void *data,
557 size_t n, off_t offset)
561 #if defined(HAVE_PREAD) || defined(HAVE_PREAD64)
562 START_PROFILE_BYTES(syscall_pread, n);
563 result = sys_pread(fsp->fh->fd, data, n, offset);
564 END_PROFILE(syscall_pread);
566 if (result == -1 && errno == ESPIPE) {
567 /* Maintain the fiction that pipes can be seeked (sought?) on. */
568 result = SMB_VFS_READ(fsp, data, n);
572 #else /* HAVE_PREAD */
576 curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
577 if (curr == -1 && errno == ESPIPE) {
578 /* Maintain the fiction that pipes can be seeked (sought?) on. */
579 result = SMB_VFS_READ(fsp, data, n);
584 if (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) {
589 result = SMB_VFS_READ(fsp, data, n);
592 SMB_VFS_LSEEK(fsp, curr, SEEK_SET);
595 #endif /* HAVE_PREAD */
600 static ssize_t vfswrap_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n)
604 START_PROFILE_BYTES(syscall_write, n);
605 result = sys_write(fsp->fh->fd, data, n);
606 END_PROFILE(syscall_write);
610 static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data,
611 size_t n, off_t offset)
615 #if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)
616 START_PROFILE_BYTES(syscall_pwrite, n);
617 result = sys_pwrite(fsp->fh->fd, data, n, offset);
618 END_PROFILE(syscall_pwrite);
620 if (result == -1 && errno == ESPIPE) {
621 /* Maintain the fiction that pipes can be sought on. */
622 result = SMB_VFS_WRITE(fsp, data, n);
625 #else /* HAVE_PWRITE */
629 curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
634 if (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) {
638 result = SMB_VFS_WRITE(fsp, data, n);
641 SMB_VFS_LSEEK(fsp, curr, SEEK_SET);
644 #endif /* HAVE_PWRITE */
649 static void vfswrap_asys_finished(struct tevent_context *ev,
650 struct tevent_fd *fde,
651 uint16_t flags, void *p);
653 static bool vfswrap_init_asys_ctx(struct smbXsrv_connection *conn)
658 if (conn->asys_ctx != NULL) {
661 ret = asys_context_init(&conn->asys_ctx, aio_pending_size);
663 DEBUG(1, ("asys_context_init failed: %s\n", strerror(ret)));
667 fd = asys_signalfd(conn->asys_ctx);
669 set_blocking(fd, false);
671 conn->asys_fde = tevent_add_fd(conn->ev_ctx, conn, fd,
673 vfswrap_asys_finished,
675 if (conn->asys_fde == NULL) {
676 DEBUG(1, ("tevent_add_fd failed\n"));
677 asys_context_destroy(conn->asys_ctx);
678 conn->asys_ctx = NULL;
684 struct vfswrap_asys_state {
685 struct asys_context *asys_ctx;
686 struct tevent_req *req;
691 static int vfswrap_asys_state_destructor(struct vfswrap_asys_state *s)
693 asys_cancel(s->asys_ctx, s->req);
697 static struct tevent_req *vfswrap_pread_send(struct vfs_handle_struct *handle,
699 struct tevent_context *ev,
700 struct files_struct *fsp,
702 size_t n, off_t offset)
704 struct tevent_req *req;
705 struct vfswrap_asys_state *state;
708 req = tevent_req_create(mem_ctx, &state, struct vfswrap_asys_state);
712 if (!vfswrap_init_asys_ctx(handle->conn->sconn->conn)) {
714 return tevent_req_post(req, ev);
716 state->asys_ctx = handle->conn->sconn->conn->asys_ctx;
719 ret = asys_pread(state->asys_ctx, fsp->fh->fd, data, n, offset, req);
721 tevent_req_error(req, ret);
722 return tevent_req_post(req, ev);
724 talloc_set_destructor(state, vfswrap_asys_state_destructor);
729 static struct tevent_req *vfswrap_pwrite_send(struct vfs_handle_struct *handle,
731 struct tevent_context *ev,
732 struct files_struct *fsp,
734 size_t n, off_t offset)
736 struct tevent_req *req;
737 struct vfswrap_asys_state *state;
740 req = tevent_req_create(mem_ctx, &state, struct vfswrap_asys_state);
744 if (!vfswrap_init_asys_ctx(handle->conn->sconn->conn)) {
746 return tevent_req_post(req, ev);
748 state->asys_ctx = handle->conn->sconn->conn->asys_ctx;
751 ret = asys_pwrite(state->asys_ctx, fsp->fh->fd, data, n, offset, req);
753 tevent_req_error(req, ret);
754 return tevent_req_post(req, ev);
756 talloc_set_destructor(state, vfswrap_asys_state_destructor);
761 static struct tevent_req *vfswrap_fsync_send(struct vfs_handle_struct *handle,
763 struct tevent_context *ev,
764 struct files_struct *fsp)
766 struct tevent_req *req;
767 struct vfswrap_asys_state *state;
770 req = tevent_req_create(mem_ctx, &state, struct vfswrap_asys_state);
774 if (!vfswrap_init_asys_ctx(handle->conn->sconn->conn)) {
776 return tevent_req_post(req, ev);
778 state->asys_ctx = handle->conn->sconn->conn->asys_ctx;
781 ret = asys_fsync(state->asys_ctx, fsp->fh->fd, req);
783 tevent_req_error(req, ret);
784 return tevent_req_post(req, ev);
786 talloc_set_destructor(state, vfswrap_asys_state_destructor);
791 static void vfswrap_asys_finished(struct tevent_context *ev,
792 struct tevent_fd *fde,
793 uint16_t flags, void *p)
795 struct asys_context *asys_ctx = (struct asys_context *)p;
796 struct tevent_req *req;
797 struct vfswrap_asys_state *state;
803 if ((flags & TEVENT_FD_READ) == 0) {
808 res = asys_result(asys_ctx, &ret, &err, &private_data);
809 if (res == EINTR || res == EAGAIN) {
813 if (res == EWOULDBLOCK) {
818 if (res == ECANCELED) {
823 DEBUG(1, ("asys_result returned %s\n", strerror(res)));
827 req = talloc_get_type_abort(private_data, struct tevent_req);
828 state = tevent_req_data(req, struct vfswrap_asys_state);
830 talloc_set_destructor(state, NULL);
834 tevent_req_defer_callback(req, ev);
835 tevent_req_done(req);
839 static ssize_t vfswrap_asys_ssize_t_recv(struct tevent_req *req, int *err)
841 struct vfswrap_asys_state *state = tevent_req_data(
842 req, struct vfswrap_asys_state);
844 if (tevent_req_is_unix_error(req, err)) {
851 static int vfswrap_asys_int_recv(struct tevent_req *req, int *err)
853 struct vfswrap_asys_state *state = tevent_req_data(
854 req, struct vfswrap_asys_state);
856 if (tevent_req_is_unix_error(req, err)) {
863 static off_t vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, off_t offset, int whence)
867 START_PROFILE(syscall_lseek);
869 /* Cope with 'stat' file opens. */
870 if (fsp->fh->fd != -1)
871 result = lseek(fsp->fh->fd, offset, whence);
874 * We want to maintain the fiction that we can seek
875 * on a fifo for file system purposes. This allows
876 * people to set up UNIX fifo's that feed data to Windows
880 if((result == -1) && (errno == ESPIPE)) {
885 END_PROFILE(syscall_lseek);
889 static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr,
890 off_t offset, size_t n)
894 START_PROFILE_BYTES(syscall_sendfile, n);
895 result = sys_sendfile(tofd, fromfsp->fh->fd, hdr, offset, n);
896 END_PROFILE(syscall_sendfile);
900 static ssize_t vfswrap_recvfile(vfs_handle_struct *handle,
908 START_PROFILE_BYTES(syscall_recvfile, n);
909 result = sys_recvfile(fromfd, tofsp->fh->fd, offset, n);
910 END_PROFILE(syscall_recvfile);
914 static int vfswrap_rename(vfs_handle_struct *handle,
915 const struct smb_filename *smb_fname_src,
916 const struct smb_filename *smb_fname_dst)
920 START_PROFILE(syscall_rename);
922 if (smb_fname_src->stream_name || smb_fname_dst->stream_name) {
927 result = rename(smb_fname_src->base_name, smb_fname_dst->base_name);
930 END_PROFILE(syscall_rename);
934 static int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp)
939 START_PROFILE(syscall_fsync);
940 result = fsync(fsp->fh->fd);
941 END_PROFILE(syscall_fsync);
948 static int vfswrap_stat(vfs_handle_struct *handle,
949 struct smb_filename *smb_fname)
953 START_PROFILE(syscall_stat);
955 if (smb_fname->stream_name) {
960 result = sys_stat(smb_fname->base_name, &smb_fname->st,
961 lp_fake_directory_create_times(SNUM(handle->conn)));
963 END_PROFILE(syscall_stat);
967 static int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
971 START_PROFILE(syscall_fstat);
972 result = sys_fstat(fsp->fh->fd,
973 sbuf, lp_fake_directory_create_times(SNUM(handle->conn)));
974 END_PROFILE(syscall_fstat);
978 static int vfswrap_lstat(vfs_handle_struct *handle,
979 struct smb_filename *smb_fname)
983 START_PROFILE(syscall_lstat);
985 if (smb_fname->stream_name) {
990 result = sys_lstat(smb_fname->base_name, &smb_fname->st,
991 lp_fake_directory_create_times(SNUM(handle->conn)));
993 END_PROFILE(syscall_lstat);
997 static NTSTATUS vfswrap_translate_name(struct vfs_handle_struct *handle,
999 enum vfs_translate_direction direction,
1000 TALLOC_CTX *mem_ctx,
1003 return NT_STATUS_NONE_MAPPED;
1007 * Implement the default fsctl operation.
1009 static bool vfswrap_logged_ioctl_message = false;
1011 static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
1012 struct files_struct *fsp,
1015 uint16_t req_flags, /* Needed for UNICODE ... */
1016 const uint8_t *_in_data,
1018 uint8_t **_out_data,
1019 uint32_t max_out_len,
1022 const char *in_data = (const char *)_in_data;
1023 char **out_data = (char **)_out_data;
1026 case FSCTL_SET_SPARSE:
1028 bool set_sparse = true;
1031 if (in_len >= 1 && in_data[0] == 0) {
1035 status = file_set_sparse(handle->conn, fsp, set_sparse);
1037 DEBUG(NT_STATUS_IS_OK(status) ? 10 : 9,
1038 ("FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\n",
1039 smb_fname_str_dbg(fsp->fsp_name), set_sparse,
1040 nt_errstr(status)));
1045 case FSCTL_CREATE_OR_GET_OBJECT_ID:
1047 unsigned char objid[16];
1048 char *return_data = NULL;
1050 /* This should return the object-id on this file.
1051 * I think I'll make this be the inode+dev. JRA.
1054 DEBUG(10,("FSCTL_CREATE_OR_GET_OBJECT_ID: called on %s\n",
1055 fsp_fnum_dbg(fsp)));
1057 *out_len = MIN(max_out_len, 64);
1059 /* Hmmm, will this cause problems if less data asked for? */
1060 return_data = talloc_array(ctx, char, 64);
1061 if (return_data == NULL) {
1062 return NT_STATUS_NO_MEMORY;
1065 /* For backwards compatibility only store the dev/inode. */
1066 push_file_id_16(return_data, &fsp->file_id);
1067 memcpy(return_data+16,create_volume_objectid(fsp->conn,objid),16);
1068 push_file_id_16(return_data+32, &fsp->file_id);
1069 memset(return_data+48, 0, 16);
1070 *out_data = return_data;
1071 return NT_STATUS_OK;
1074 case FSCTL_GET_REPARSE_POINT:
1076 /* Fail it with STATUS_NOT_A_REPARSE_POINT */
1077 DEBUG(10, ("FSCTL_GET_REPARSE_POINT: called on %s. "
1078 "Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp)));
1079 return NT_STATUS_NOT_A_REPARSE_POINT;
1082 case FSCTL_SET_REPARSE_POINT:
1084 /* Fail it with STATUS_NOT_A_REPARSE_POINT */
1085 DEBUG(10, ("FSCTL_SET_REPARSE_POINT: called on %s. "
1086 "Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp)));
1087 return NT_STATUS_NOT_A_REPARSE_POINT;
1090 case FSCTL_GET_SHADOW_COPY_DATA:
1093 * This is called to retrieve the number of Shadow Copies (a.k.a. snapshots)
1094 * and return their volume names. If max_data_count is 16, then it is just
1095 * asking for the number of volumes and length of the combined names.
1097 * pdata is the data allocated by our caller, but that uses
1098 * total_data_count (which is 0 in our case) rather than max_data_count.
1099 * Allocate the correct amount and return the pointer to let
1100 * it be deallocated when we return.
1102 struct shadow_copy_data *shadow_data = NULL;
1103 bool labels = False;
1104 uint32 labels_data_count = 0;
1106 char *cur_pdata = NULL;
1108 if (max_out_len < 16) {
1109 DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) < 16 is invalid!\n",
1111 return NT_STATUS_INVALID_PARAMETER;
1114 if (max_out_len > 16) {
1118 shadow_data = talloc_zero(ctx, struct shadow_copy_data);
1119 if (shadow_data == NULL) {
1120 DEBUG(0,("TALLOC_ZERO() failed!\n"));
1121 return NT_STATUS_NO_MEMORY;
1125 * Call the VFS routine to actually do the work.
1127 if (SMB_VFS_GET_SHADOW_COPY_DATA(fsp, shadow_data, labels)!=0) {
1128 TALLOC_FREE(shadow_data);
1129 if (errno == ENOSYS) {
1130 DEBUG(5,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\n",
1131 fsp->conn->connectpath));
1132 return NT_STATUS_NOT_SUPPORTED;
1134 DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, failed.\n",
1135 fsp->conn->connectpath));
1136 return NT_STATUS_UNSUCCESSFUL;
1140 labels_data_count = (shadow_data->num_volumes * 2 *
1141 sizeof(SHADOW_COPY_LABEL)) + 2;
1146 *out_len = 12 + labels_data_count;
1149 if (max_out_len < *out_len) {
1150 DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) too small (%u) bytes needed!\n",
1151 max_out_len, *out_len));
1152 TALLOC_FREE(shadow_data);
1153 return NT_STATUS_BUFFER_TOO_SMALL;
1156 cur_pdata = talloc_zero_array(ctx, char, *out_len);
1157 if (cur_pdata == NULL) {
1158 TALLOC_FREE(shadow_data);
1159 return NT_STATUS_NO_MEMORY;
1162 *out_data = cur_pdata;
1164 /* num_volumes 4 bytes */
1165 SIVAL(cur_pdata, 0, shadow_data->num_volumes);
1168 /* num_labels 4 bytes */
1169 SIVAL(cur_pdata, 4, shadow_data->num_volumes);
1172 /* needed_data_count 4 bytes */
1173 SIVAL(cur_pdata, 8, labels_data_count);
1177 DEBUG(10,("FSCTL_GET_SHADOW_COPY_DATA: %u volumes for path[%s].\n",
1178 shadow_data->num_volumes, fsp_str_dbg(fsp)));
1179 if (labels && shadow_data->labels) {
1180 for (i=0; i<shadow_data->num_volumes; i++) {
1181 srvstr_push(cur_pdata, req_flags,
1182 cur_pdata, shadow_data->labels[i],
1183 2 * sizeof(SHADOW_COPY_LABEL),
1184 STR_UNICODE|STR_TERMINATE);
1185 cur_pdata += 2 * sizeof(SHADOW_COPY_LABEL);
1186 DEBUGADD(10,("Label[%u]: '%s'\n",i,shadow_data->labels[i]));
1190 TALLOC_FREE(shadow_data);
1192 return NT_STATUS_OK;
1195 case FSCTL_FIND_FILES_BY_SID:
1197 /* pretend this succeeded -
1199 * we have to send back a list with all files owned by this SID
1201 * but I have to check that --metze
1207 DEBUG(10, ("FSCTL_FIND_FILES_BY_SID: called on %s\n",
1208 fsp_fnum_dbg(fsp)));
1211 /* NT_STATUS_BUFFER_TOO_SMALL maybe? */
1212 return NT_STATUS_INVALID_PARAMETER;
1215 sid_len = MIN(in_len - 4,SID_MAX_SIZE);
1217 /* unknown 4 bytes: this is not the length of the sid :-( */
1218 /*unknown = IVAL(pdata,0);*/
1220 if (!sid_parse(in_data + 4, sid_len, &sid)) {
1221 return NT_STATUS_INVALID_PARAMETER;
1223 DEBUGADD(10, ("for SID: %s\n", sid_string_dbg(&sid)));
1225 if (!sid_to_uid(&sid, &uid)) {
1226 DEBUG(0,("sid_to_uid: failed, sid[%s] sid_len[%lu]\n",
1227 sid_string_dbg(&sid),
1228 (unsigned long)sid_len));
1232 /* we can take a look at the find source :-)
1234 * find ./ -uid $uid -name '*' is what we need here
1237 * and send 4bytes len and then NULL terminated unicode strings
1240 * but I don't know how to deal with the paged results
1241 * (maybe we can hang the result anywhere in the fsp struct)
1243 * but I don't know how to deal with the paged results
1244 * (maybe we can hang the result anywhere in the fsp struct)
1246 * we don't send all files at once
1247 * and at the next we should *not* start from the beginning,
1248 * so we have to cache the result
1253 /* this works for now... */
1254 return NT_STATUS_OK;
1257 case FSCTL_QUERY_ALLOCATED_RANGES:
1259 /* FIXME: This is just a dummy reply, telling that all of the
1260 * file is allocated. MKS cp needs that.
1261 * Adding the real allocated ranges via FIEMAP on Linux
1262 * and SEEK_DATA/SEEK_HOLE on Solaris is needed to make
1263 * this FSCTL correct for sparse files.
1266 uint64_t offset, length;
1267 char *out_data_tmp = NULL;
1270 DEBUG(0,("FSCTL_QUERY_ALLOCATED_RANGES: data_count(%u) != 16 is invalid!\n",
1272 return NT_STATUS_INVALID_PARAMETER;
1275 if (max_out_len < 16) {
1276 DEBUG(0,("FSCTL_QUERY_ALLOCATED_RANGES: max_out_len (%u) < 16 is invalid!\n",
1278 return NT_STATUS_INVALID_PARAMETER;
1281 offset = BVAL(in_data,0);
1282 length = BVAL(in_data,8);
1284 if (offset + length < offset) {
1285 /* No 64-bit integer wrap. */
1286 return NT_STATUS_INVALID_PARAMETER;
1289 /* Shouldn't this be SMB_VFS_STAT ... ? */
1290 status = vfs_stat_fsp(fsp);
1291 if (!NT_STATUS_IS_OK(status)) {
1296 out_data_tmp = talloc_array(ctx, char, *out_len);
1297 if (out_data_tmp == NULL) {
1298 DEBUG(10, ("unable to allocate memory for response\n"));
1299 return NT_STATUS_NO_MEMORY;
1302 if (offset > fsp->fsp_name->st.st_ex_size ||
1303 fsp->fsp_name->st.st_ex_size == 0 ||
1305 memset(out_data_tmp, 0, *out_len);
1307 uint64_t end = offset + length;
1308 end = MIN(end, fsp->fsp_name->st.st_ex_size);
1309 SBVAL(out_data_tmp, 0, 0);
1310 SBVAL(out_data_tmp, 8, end);
1313 *out_data = out_data_tmp;
1315 return NT_STATUS_OK;
1318 case FSCTL_IS_VOLUME_DIRTY:
1320 DEBUG(10,("FSCTL_IS_VOLUME_DIRTY: called on %s "
1321 "(but remotely not supported)\n", fsp_fnum_dbg(fsp)));
1323 * http://msdn.microsoft.com/en-us/library/cc232128%28PROT.10%29.aspx
1324 * says we have to respond with NT_STATUS_INVALID_PARAMETER
1326 return NT_STATUS_INVALID_PARAMETER;
1331 * Only print once ... unfortunately there could be lots of
1332 * different FSCTLs that are called.
1334 if (!vfswrap_logged_ioctl_message) {
1335 vfswrap_logged_ioctl_message = true;
1336 DEBUG(2, ("%s (0x%x): Currently not implemented.\n",
1337 __func__, function));
1341 return NT_STATUS_NOT_SUPPORTED;
1344 struct vfs_cc_state {
1349 static struct tevent_req *vfswrap_copy_chunk_send(struct vfs_handle_struct *handle,
1350 TALLOC_CTX *mem_ctx,
1351 struct tevent_context *ev,
1352 struct files_struct *src_fsp,
1354 struct files_struct *dest_fsp,
1358 struct tevent_req *req;
1359 struct vfs_cc_state *vfs_cc_state;
1362 DEBUG(10, ("performing server side copy chunk of length %lu\n",
1363 (unsigned long)num));
1365 req = tevent_req_create(mem_ctx, &vfs_cc_state, struct vfs_cc_state);
1370 status = vfs_stat_fsp(src_fsp);
1371 if (tevent_req_nterror(req, status)) {
1372 return tevent_req_post(req, ev);
1375 if (src_fsp->fsp_name->st.st_ex_size < src_off + num) {
1377 * [MS-SMB2] 3.3.5.15.6 Handling a Server-Side Data Copy Request
1378 * If the SourceOffset or SourceOffset + Length extends beyond
1379 * the end of file, the server SHOULD<240> treat this as a
1380 * STATUS_END_OF_FILE error.
1382 * <240> Section 3.3.5.15.6: Windows servers will return
1383 * STATUS_INVALID_VIEW_SIZE instead of STATUS_END_OF_FILE.
1385 tevent_req_nterror(req, NT_STATUS_INVALID_VIEW_SIZE);
1386 return tevent_req_post(req, ev);
1389 /* could use 2.6.33+ sendfile here to do this in kernel */
1390 while (vfs_cc_state->copied < num) {
1392 struct lock_struct lck;
1395 off_t this_num = MIN(sizeof(vfs_cc_state->buf),
1396 num - vfs_cc_state->copied);
1398 init_strict_lock_struct(src_fsp,
1399 src_fsp->op->global->open_persistent_id,
1405 if (!SMB_VFS_STRICT_LOCK(src_fsp->conn, src_fsp, &lck)) {
1406 tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
1407 return tevent_req_post(req, ev);
1410 ret = SMB_VFS_PREAD(src_fsp, vfs_cc_state->buf,
1413 saved_errno = errno;
1416 SMB_VFS_STRICT_UNLOCK(src_fsp->conn, src_fsp, &lck);
1419 errno = saved_errno;
1420 tevent_req_nterror(req, map_nt_error_from_unix(errno));
1421 return tevent_req_post(req, ev);
1423 if (ret != this_num) {
1424 /* zero tolerance for short reads */
1425 tevent_req_nterror(req, NT_STATUS_IO_DEVICE_ERROR);
1426 return tevent_req_post(req, ev);
1431 init_strict_lock_struct(dest_fsp,
1432 dest_fsp->op->global->open_persistent_id,
1438 if (!SMB_VFS_STRICT_LOCK(dest_fsp->conn, dest_fsp, &lck)) {
1439 tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
1440 return tevent_req_post(req, ev);
1443 ret = SMB_VFS_PWRITE(dest_fsp, vfs_cc_state->buf,
1444 this_num, dest_off);
1446 saved_errno = errno;
1449 SMB_VFS_STRICT_UNLOCK(src_fsp->conn, src_fsp, &lck);
1452 errno = saved_errno;
1453 tevent_req_nterror(req, map_nt_error_from_unix(errno));
1454 return tevent_req_post(req, ev);
1456 if (ret != this_num) {
1457 /* zero tolerance for short writes */
1458 tevent_req_nterror(req, NT_STATUS_IO_DEVICE_ERROR);
1459 return tevent_req_post(req, ev);
1463 vfs_cc_state->copied += this_num;
1466 tevent_req_done(req);
1467 return tevent_req_post(req, ev);
1470 static NTSTATUS vfswrap_copy_chunk_recv(struct vfs_handle_struct *handle,
1471 struct tevent_req *req,
1474 struct vfs_cc_state *vfs_cc_state = tevent_req_data(req,
1475 struct vfs_cc_state);
1478 if (tevent_req_is_nterror(req, &status)) {
1479 DEBUG(2, ("server side copy chunk failed: %s\n",
1480 nt_errstr(status)));
1482 tevent_req_received(req);
1486 *copied = vfs_cc_state->copied;
1487 DEBUG(10, ("server side copy chunk copied %lu\n",
1488 (unsigned long)*copied));
1489 tevent_req_received(req);
1491 return NT_STATUS_OK;
1494 static NTSTATUS vfswrap_get_compression(struct vfs_handle_struct *handle,
1495 TALLOC_CTX *mem_ctx,
1496 struct files_struct *fsp,
1497 struct smb_filename *smb_fname,
1498 uint16_t *_compression_fmt)
1500 return NT_STATUS_INVALID_DEVICE_REQUEST;
1503 static NTSTATUS vfswrap_set_compression(struct vfs_handle_struct *handle,
1504 TALLOC_CTX *mem_ctx,
1505 struct files_struct *fsp,
1506 uint16_t compression_fmt)
1508 return NT_STATUS_INVALID_DEVICE_REQUEST;
1511 /********************************************************************
1512 Given a stat buffer return the allocated size on disk, taking into
1513 account sparse files.
1514 ********************************************************************/
1515 static uint64_t vfswrap_get_alloc_size(vfs_handle_struct *handle,
1516 struct files_struct *fsp,
1517 const SMB_STRUCT_STAT *sbuf)
1521 START_PROFILE(syscall_get_alloc_size);
1523 if(S_ISDIR(sbuf->st_ex_mode)) {
1528 #if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
1529 /* The type of st_blocksize is blkcnt_t which *MUST* be
1530 signed (according to POSIX) and can be less than 64-bits.
1531 Ensure when we're converting to 64 bits wide we don't
1533 #if defined(SIZEOF_BLKCNT_T_8)
1534 result = (uint64_t)STAT_ST_BLOCKSIZE * (uint64_t)sbuf->st_ex_blocks;
1535 #elif defined(SIZEOF_BLKCNT_T_4)
1537 uint64_t bs = ((uint64_t)sbuf->st_ex_blocks) & 0xFFFFFFFFLL;
1538 result = (uint64_t)STAT_ST_BLOCKSIZE * bs;
1541 #error SIZEOF_BLKCNT_T_NOT_A_SUPPORTED_VALUE
1544 result = get_file_size_stat(sbuf);
1547 if (fsp && fsp->initial_allocation_size)
1548 result = MAX(result,fsp->initial_allocation_size);
1550 result = smb_roundup(handle->conn, result);
1553 END_PROFILE(syscall_get_alloc_size);
1557 static int vfswrap_unlink(vfs_handle_struct *handle,
1558 const struct smb_filename *smb_fname)
1562 START_PROFILE(syscall_unlink);
1564 if (smb_fname->stream_name) {
1568 result = unlink(smb_fname->base_name);
1571 END_PROFILE(syscall_unlink);
1575 static int vfswrap_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
1579 START_PROFILE(syscall_chmod);
1582 * We need to do this due to the fact that the default POSIX ACL
1583 * chmod modifies the ACL *mask* for the group owner, not the
1584 * group owner bits directly. JRA.
1589 int saved_errno = errno; /* We might get ENOSYS */
1590 if ((result = SMB_VFS_CHMOD_ACL(handle->conn, path, mode)) == 0) {
1591 END_PROFILE(syscall_chmod);
1594 /* Error - return the old errno. */
1595 errno = saved_errno;
1598 result = chmod(path, mode);
1599 END_PROFILE(syscall_chmod);
1603 static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
1607 START_PROFILE(syscall_fchmod);
1610 * We need to do this due to the fact that the default POSIX ACL
1611 * chmod modifies the ACL *mask* for the group owner, not the
1612 * group owner bits directly. JRA.
1616 int saved_errno = errno; /* We might get ENOSYS */
1617 if ((result = SMB_VFS_FCHMOD_ACL(fsp, mode)) == 0) {
1618 END_PROFILE(syscall_fchmod);
1621 /* Error - return the old errno. */
1622 errno = saved_errno;
1625 #if defined(HAVE_FCHMOD)
1626 result = fchmod(fsp->fh->fd, mode);
1632 END_PROFILE(syscall_fchmod);
1636 static int vfswrap_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
1640 START_PROFILE(syscall_chown);
1641 result = chown(path, uid, gid);
1642 END_PROFILE(syscall_chown);
1646 static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid)
1651 START_PROFILE(syscall_fchown);
1652 result = fchown(fsp->fh->fd, uid, gid);
1653 END_PROFILE(syscall_fchown);
1661 static int vfswrap_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
1665 START_PROFILE(syscall_lchown);
1666 result = lchown(path, uid, gid);
1667 END_PROFILE(syscall_lchown);
1671 static int vfswrap_chdir(vfs_handle_struct *handle, const char *path)
1675 START_PROFILE(syscall_chdir);
1676 result = chdir(path);
1677 END_PROFILE(syscall_chdir);
1681 static char *vfswrap_getwd(vfs_handle_struct *handle)
1685 START_PROFILE(syscall_getwd);
1686 result = sys_getwd();
1687 END_PROFILE(syscall_getwd);
1691 /*********************************************************************
1692 nsec timestamp resolution call. Convert down to whatever the underlying
1693 system will support.
1694 **********************************************************************/
1696 static int vfswrap_ntimes(vfs_handle_struct *handle,
1697 const struct smb_filename *smb_fname,
1698 struct smb_file_time *ft)
1702 START_PROFILE(syscall_ntimes);
1704 if (smb_fname->stream_name) {
1710 if (null_timespec(ft->atime)) {
1711 ft->atime= smb_fname->st.st_ex_atime;
1714 if (null_timespec(ft->mtime)) {
1715 ft->mtime = smb_fname->st.st_ex_mtime;
1718 if (!null_timespec(ft->create_time)) {
1719 set_create_timespec_ea(handle->conn,
1724 if ((timespec_compare(&ft->atime,
1725 &smb_fname->st.st_ex_atime) == 0) &&
1726 (timespec_compare(&ft->mtime,
1727 &smb_fname->st.st_ex_mtime) == 0)) {
1732 #if defined(HAVE_UTIMENSAT)
1734 struct timespec ts[2];
1737 result = utimensat(AT_FDCWD, smb_fname->base_name, ts, 0);
1739 result = utimensat(AT_FDCWD, smb_fname->base_name, NULL, 0);
1741 if (!((result == -1) && (errno == ENOSYS))) {
1745 #if defined(HAVE_UTIMES)
1747 struct timeval tv[2];
1748 tv[0] = convert_timespec_to_timeval(ft->atime);
1749 tv[1] = convert_timespec_to_timeval(ft->mtime);
1750 result = utimes(smb_fname->base_name, tv);
1752 result = utimes(smb_fname->base_name, NULL);
1754 if (!((result == -1) && (errno == ENOSYS))) {
1758 #if defined(HAVE_UTIME)
1760 struct utimbuf times;
1761 times.actime = convert_timespec_to_time_t(ft->atime);
1762 times.modtime = convert_timespec_to_time_t(ft->mtime);
1763 result = utime(smb_fname->base_name, ×);
1765 result = utime(smb_fname->base_name, NULL);
1767 if (!((result == -1) && (errno == ENOSYS))) {
1775 END_PROFILE(syscall_ntimes);
1779 /*********************************************************************
1780 A version of ftruncate that will write the space on disk if strict
1782 **********************************************************************/
1784 static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t len)
1786 off_t space_to_write;
1787 uint64_t space_avail;
1788 uint64_t bsize,dfree,dsize;
1791 SMB_STRUCT_STAT *pst;
1793 status = vfs_stat_fsp(fsp);
1794 if (!NT_STATUS_IS_OK(status)) {
1797 pst = &fsp->fsp_name->st;
1800 if (S_ISFIFO(pst->st_ex_mode))
1804 if (pst->st_ex_size == len)
1807 /* Shrink - just ftruncate. */
1808 if (pst->st_ex_size > len)
1809 return ftruncate(fsp->fh->fd, len);
1811 space_to_write = len - pst->st_ex_size;
1813 /* for allocation try fallocate first. This can fail on some
1814 platforms e.g. when the filesystem doesn't support it and no
1815 emulation is being done by the libc (like on AIX with JFS1). In that
1816 case we do our own emulation. fallocate implementations can
1817 return ENOTSUP or EINVAL in cases like that. */
1818 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE,
1819 pst->st_ex_size, space_to_write);
1820 if (ret == ENOSPC) {
1827 DEBUG(10,("strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with "
1828 "error %d. Falling back to slow manual allocation\n", ret));
1830 /* available disk space is enough or not? */
1831 space_avail = get_dfree_info(fsp->conn,
1832 fsp->fsp_name->base_name, false,
1833 &bsize,&dfree,&dsize);
1834 /* space_avail is 1k blocks */
1835 if (space_avail == (uint64_t)-1 ||
1836 ((uint64_t)space_to_write/1024 > space_avail) ) {
1841 /* Write out the real space on disk. */
1842 ret = vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write);
1851 static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t len)
1854 SMB_STRUCT_STAT *pst;
1858 START_PROFILE(syscall_ftruncate);
1860 if (lp_strict_allocate(SNUM(fsp->conn)) && !fsp->is_sparse) {
1861 result = strict_allocate_ftruncate(handle, fsp, len);
1862 END_PROFILE(syscall_ftruncate);
1866 /* we used to just check HAVE_FTRUNCATE_EXTEND and only use
1867 ftruncate if the system supports it. Then I discovered that
1868 you can have some filesystems that support ftruncate
1869 expansion and some that don't! On Linux fat can't do
1870 ftruncate extend but ext2 can. */
1872 result = ftruncate(fsp->fh->fd, len);
1876 /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
1877 extend a file with ftruncate. Provide alternate implementation
1880 /* Do an fstat to see if the file is longer than the requested
1881 size in which case the ftruncate above should have
1882 succeeded or shorter, in which case seek to len - 1 and
1883 write 1 byte of zero */
1884 status = vfs_stat_fsp(fsp);
1885 if (!NT_STATUS_IS_OK(status)) {
1888 pst = &fsp->fsp_name->st;
1891 if (S_ISFIFO(pst->st_ex_mode)) {
1897 if (pst->st_ex_size == len) {
1902 if (pst->st_ex_size > len) {
1903 /* the ftruncate should have worked */
1907 if (SMB_VFS_PWRITE(fsp, &c, 1, len-1)!=1) {
1915 END_PROFILE(syscall_ftruncate);
1919 static int vfswrap_fallocate(vfs_handle_struct *handle,
1921 enum vfs_fallocate_mode mode,
1927 START_PROFILE(syscall_fallocate);
1928 if (mode == VFS_FALLOCATE_EXTEND_SIZE) {
1929 result = sys_posix_fallocate(fsp->fh->fd, offset, len);
1930 } else if (mode == VFS_FALLOCATE_KEEP_SIZE) {
1931 result = sys_fallocate(fsp->fh->fd, mode, offset, len);
1936 END_PROFILE(syscall_fallocate);
1940 static bool vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int op, off_t offset, off_t count, int type)
1944 START_PROFILE(syscall_fcntl_lock);
1945 result = fcntl_lock(fsp->fh->fd, op, offset, count, type);
1946 END_PROFILE(syscall_fcntl_lock);
1950 static int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
1951 uint32 share_mode, uint32 access_mask)
1953 START_PROFILE(syscall_kernel_flock);
1954 kernel_flock(fsp->fh->fd, share_mode, access_mask);
1955 END_PROFILE(syscall_kernel_flock);
1959 static bool vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid)
1963 START_PROFILE(syscall_fcntl_getlock);
1964 result = fcntl_getlock(fsp->fh->fd, poffset, pcount, ptype, ppid);
1965 END_PROFILE(syscall_fcntl_getlock);
1969 static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1974 START_PROFILE(syscall_linux_setlease);
1976 #ifdef HAVE_KERNEL_OPLOCKS_LINUX
1977 result = linux_setlease(fsp->fh->fd, leasetype);
1981 END_PROFILE(syscall_linux_setlease);
1985 static int vfswrap_symlink(vfs_handle_struct *handle, const char *oldpath, const char *newpath)
1989 START_PROFILE(syscall_symlink);
1990 result = symlink(oldpath, newpath);
1991 END_PROFILE(syscall_symlink);
1995 static int vfswrap_readlink(vfs_handle_struct *handle, const char *path, char *buf, size_t bufsiz)
1999 START_PROFILE(syscall_readlink);
2000 result = readlink(path, buf, bufsiz);
2001 END_PROFILE(syscall_readlink);
2005 static int vfswrap_link(vfs_handle_struct *handle, const char *oldpath, const char *newpath)
2009 START_PROFILE(syscall_link);
2010 result = link(oldpath, newpath);
2011 END_PROFILE(syscall_link);
2015 static int vfswrap_mknod(vfs_handle_struct *handle, const char *pathname, mode_t mode, SMB_DEV_T dev)
2019 START_PROFILE(syscall_mknod);
2020 result = sys_mknod(pathname, mode, dev);
2021 END_PROFILE(syscall_mknod);
2025 static char *vfswrap_realpath(vfs_handle_struct *handle, const char *path)
2029 START_PROFILE(syscall_realpath);
2030 #ifdef REALPATH_TAKES_NULL
2031 result = realpath(path, NULL);
2033 result = SMB_MALLOC_ARRAY(char, PATH_MAX+1);
2035 char *resolved_path = realpath(path, result);
2036 if (!resolved_path) {
2039 /* SMB_ASSERT(result == resolved_path) ? */
2040 result = resolved_path;
2044 END_PROFILE(syscall_realpath);
2048 static NTSTATUS vfswrap_notify_watch(vfs_handle_struct *vfs_handle,
2049 struct sys_notify_context *ctx,
2052 uint32_t *subdir_filter,
2053 void (*callback)(struct sys_notify_context *ctx,
2055 struct notify_event *ev),
2056 void *private_data, void *handle)
2059 * So far inotify is the only supported default notify mechanism. If
2060 * another platform like the the BSD's or a proprietary Unix comes
2061 * along and wants another default, we can play the same trick we
2062 * played with Posix ACLs.
2064 * Until that is the case, hard-code inotify here.
2067 if (lp_kernel_change_notify(vfs_handle->conn->params)) {
2068 return inotify_watch(ctx, path, filter, subdir_filter,
2069 callback, private_data, handle);
2073 * Do nothing, leave everything to notify_internal.c
2075 return NT_STATUS_OK;
2078 static int vfswrap_chflags(vfs_handle_struct *handle, const char *path,
2082 return chflags(path, flags);
2089 static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle,
2090 const SMB_STRUCT_STAT *sbuf)
2094 /* the ZERO_STRUCT ensures padding doesn't break using the key as a
2098 key.devid = sbuf->st_ex_dev;
2099 key.inode = sbuf->st_ex_ino;
2100 /* key.extid is unused by default. */
2105 static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
2106 struct files_struct *fsp,
2108 TALLOC_CTX *mem_ctx,
2109 unsigned int *pnum_streams,
2110 struct stream_struct **pstreams)
2112 SMB_STRUCT_STAT sbuf;
2113 struct stream_struct *tmp_streams = NULL;
2116 if ((fsp != NULL) && (fsp->is_directory)) {
2118 * No default streams on directories
2123 if ((fsp != NULL) && (fsp->fh->fd != -1)) {
2124 ret = SMB_VFS_FSTAT(fsp, &sbuf);
2127 struct smb_filename smb_fname;
2129 ZERO_STRUCT(smb_fname);
2130 smb_fname.base_name = discard_const_p(char, fname);
2132 if (lp_posix_pathnames()) {
2133 ret = SMB_VFS_LSTAT(handle->conn, &smb_fname);
2135 ret = SMB_VFS_STAT(handle->conn, &smb_fname);
2137 sbuf = smb_fname.st;
2141 return map_nt_error_from_unix(errno);
2144 if (S_ISDIR(sbuf.st_ex_mode)) {
2148 tmp_streams = talloc_realloc(mem_ctx, *pstreams, struct stream_struct,
2149 (*pnum_streams) + 1);
2150 if (tmp_streams == NULL) {
2151 return NT_STATUS_NO_MEMORY;
2153 tmp_streams[*pnum_streams].name = talloc_strdup(tmp_streams, "::$DATA");
2154 if (tmp_streams[*pnum_streams].name == NULL) {
2155 return NT_STATUS_NO_MEMORY;
2157 tmp_streams[*pnum_streams].size = sbuf.st_ex_size;
2158 tmp_streams[*pnum_streams].alloc_size = SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp, &sbuf);
2161 *pstreams = tmp_streams;
2163 return NT_STATUS_OK;
2166 static int vfswrap_get_real_filename(struct vfs_handle_struct *handle,
2169 TALLOC_CTX *mem_ctx,
2173 * Don't fall back to get_real_filename so callers can differentiate
2174 * between a full directory scan and an actual case-insensitive stat.
2180 static const char *vfswrap_connectpath(struct vfs_handle_struct *handle,
2183 return handle->conn->connectpath;
2186 static NTSTATUS vfswrap_brl_lock_windows(struct vfs_handle_struct *handle,
2187 struct byte_range_lock *br_lck,
2188 struct lock_struct *plock,
2190 struct blocking_lock_record *blr)
2192 SMB_ASSERT(plock->lock_flav == WINDOWS_LOCK);
2194 /* Note: blr is not used in the default implementation. */
2195 return brl_lock_windows_default(br_lck, plock, blocking_lock);
2198 static bool vfswrap_brl_unlock_windows(struct vfs_handle_struct *handle,
2199 struct messaging_context *msg_ctx,
2200 struct byte_range_lock *br_lck,
2201 const struct lock_struct *plock)
2203 SMB_ASSERT(plock->lock_flav == WINDOWS_LOCK);
2205 return brl_unlock_windows_default(msg_ctx, br_lck, plock);
2208 static bool vfswrap_brl_cancel_windows(struct vfs_handle_struct *handle,
2209 struct byte_range_lock *br_lck,
2210 struct lock_struct *plock,
2211 struct blocking_lock_record *blr)
2213 SMB_ASSERT(plock->lock_flav == WINDOWS_LOCK);
2215 /* Note: blr is not used in the default implementation. */
2216 return brl_lock_cancel_default(br_lck, plock);
2219 static bool vfswrap_strict_lock(struct vfs_handle_struct *handle,
2221 struct lock_struct *plock)
2223 SMB_ASSERT(plock->lock_type == READ_LOCK ||
2224 plock->lock_type == WRITE_LOCK);
2226 return strict_lock_default(fsp, plock);
2229 static void vfswrap_strict_unlock(struct vfs_handle_struct *handle,
2231 struct lock_struct *plock)
2233 SMB_ASSERT(plock->lock_type == READ_LOCK ||
2234 plock->lock_type == WRITE_LOCK);
2236 strict_unlock_default(fsp, plock);
2239 /* NT ACL operations. */
2241 static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle,
2243 uint32 security_info,
2244 TALLOC_CTX *mem_ctx,
2245 struct security_descriptor **ppdesc)
2249 START_PROFILE(fget_nt_acl);
2250 result = posix_fget_nt_acl(fsp, security_info,
2252 END_PROFILE(fget_nt_acl);
2256 static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle,
2258 uint32 security_info,
2259 TALLOC_CTX *mem_ctx,
2260 struct security_descriptor **ppdesc)
2264 START_PROFILE(get_nt_acl);
2265 result = posix_get_nt_acl(handle->conn, name, security_info,
2267 END_PROFILE(get_nt_acl);
2271 static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
2275 START_PROFILE(fset_nt_acl);
2276 result = set_nt_acl(fsp, security_info_sent, psd);
2277 END_PROFILE(fset_nt_acl);
2281 static NTSTATUS vfswrap_audit_file(struct vfs_handle_struct *handle,
2282 struct smb_filename *file,
2283 struct security_acl *sacl,
2284 uint32_t access_requested,
2285 uint32_t access_denied)
2287 return NT_STATUS_OK; /* Nothing to do here ... */
2290 static int vfswrap_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode)
2298 START_PROFILE(chmod_acl);
2299 result = chmod_acl(handle->conn, name, mode);
2300 END_PROFILE(chmod_acl);
2305 static int vfswrap_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
2313 START_PROFILE(fchmod_acl);
2314 result = fchmod_acl(fsp, mode);
2315 END_PROFILE(fchmod_acl);
2320 static SMB_ACL_T vfswrap_sys_acl_get_file(vfs_handle_struct *handle,
2322 SMB_ACL_TYPE_T type,
2323 TALLOC_CTX *mem_ctx)
2325 return sys_acl_get_file(handle, path_p, type, mem_ctx);
2328 static SMB_ACL_T vfswrap_sys_acl_get_fd(vfs_handle_struct *handle,
2330 TALLOC_CTX *mem_ctx)
2332 return sys_acl_get_fd(handle, fsp, mem_ctx);
2335 static int vfswrap_sys_acl_set_file(vfs_handle_struct *handle, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
2337 return sys_acl_set_file(handle, name, acltype, theacl);
2340 static int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, SMB_ACL_T theacl)
2342 return sys_acl_set_fd(handle, fsp, theacl);
2345 static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path)
2347 return sys_acl_delete_def_file(handle, path);
2350 /****************************************************************
2351 Extended attribute operations.
2352 *****************************************************************/
2354 static ssize_t vfswrap_getxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
2356 return getxattr(path, name, value, size);
2359 static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)
2361 return fgetxattr(fsp->fh->fd, name, value, size);
2364 static ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)
2366 return listxattr(path, list, size);
2369 static ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)
2371 return flistxattr(fsp->fh->fd, list, size);
2374 static int vfswrap_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name)
2376 return removexattr(path, name);
2379 static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name)
2381 return fremovexattr(fsp->fh->fd, name);
2384 static int vfswrap_setxattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
2386 return setxattr(path, name, value, size, flags);
2389 static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags)
2391 return fsetxattr(fsp->fh->fd, name, value, size, flags);
2394 static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
2399 static bool vfswrap_is_offline(struct vfs_handle_struct *handle,
2400 const struct smb_filename *fname,
2401 SMB_STRUCT_STAT *sbuf)
2405 bool offline = false;
2407 if (ISDOT(fname->base_name) || ISDOTDOT(fname->base_name)) {
2411 if (!lp_dmapi_support(SNUM(handle->conn)) || !dmapi_have_session()) {
2412 #if defined(ENOTSUP)
2418 status = get_full_smb_filename(talloc_tos(), fname, &path);
2419 if (!NT_STATUS_IS_OK(status)) {
2420 errno = map_errno_from_nt_status(status);
2424 offline = (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0;
2431 static int vfswrap_set_offline(struct vfs_handle_struct *handle,
2432 const struct smb_filename *fname)
2434 /* We don't know how to set offline bit by default, needs to be overriden in the vfs modules */
2435 #if defined(ENOTSUP)
2441 static NTSTATUS vfswrap_durable_cookie(struct vfs_handle_struct *handle,
2442 struct files_struct *fsp,
2443 TALLOC_CTX *mem_ctx,
2446 return vfs_default_durable_cookie(fsp, mem_ctx, cookie);
2449 static NTSTATUS vfswrap_durable_disconnect(struct vfs_handle_struct *handle,
2450 struct files_struct *fsp,
2451 const DATA_BLOB old_cookie,
2452 TALLOC_CTX *mem_ctx,
2453 DATA_BLOB *new_cookie)
2455 return vfs_default_durable_disconnect(fsp, old_cookie, mem_ctx,
2459 static NTSTATUS vfswrap_durable_reconnect(struct vfs_handle_struct *handle,
2460 struct smb_request *smb1req,
2461 struct smbXsrv_open *op,
2462 const DATA_BLOB old_cookie,
2463 TALLOC_CTX *mem_ctx,
2464 struct files_struct **fsp,
2465 DATA_BLOB *new_cookie)
2467 return vfs_default_durable_reconnect(handle->conn, smb1req, op,
2468 old_cookie, mem_ctx,
2472 static struct vfs_fn_pointers vfs_default_fns = {
2473 /* Disk operations */
2475 .connect_fn = vfswrap_connect,
2476 .disconnect_fn = vfswrap_disconnect,
2477 .disk_free_fn = vfswrap_disk_free,
2478 .get_quota_fn = vfswrap_get_quota,
2479 .set_quota_fn = vfswrap_set_quota,
2480 .get_shadow_copy_data_fn = vfswrap_get_shadow_copy_data,
2481 .statvfs_fn = vfswrap_statvfs,
2482 .fs_capabilities_fn = vfswrap_fs_capabilities,
2483 .get_dfs_referrals_fn = vfswrap_get_dfs_referrals,
2485 /* Directory operations */
2487 .opendir_fn = vfswrap_opendir,
2488 .fdopendir_fn = vfswrap_fdopendir,
2489 .readdir_fn = vfswrap_readdir,
2490 .seekdir_fn = vfswrap_seekdir,
2491 .telldir_fn = vfswrap_telldir,
2492 .rewind_dir_fn = vfswrap_rewinddir,
2493 .mkdir_fn = vfswrap_mkdir,
2494 .rmdir_fn = vfswrap_rmdir,
2495 .closedir_fn = vfswrap_closedir,
2496 .init_search_op_fn = vfswrap_init_search_op,
2498 /* File operations */
2500 .open_fn = vfswrap_open,
2501 .create_file_fn = vfswrap_create_file,
2502 .close_fn = vfswrap_close,
2503 .read_fn = vfswrap_read,
2504 .pread_fn = vfswrap_pread,
2505 .pread_send_fn = vfswrap_pread_send,
2506 .pread_recv_fn = vfswrap_asys_ssize_t_recv,
2507 .write_fn = vfswrap_write,
2508 .pwrite_fn = vfswrap_pwrite,
2509 .pwrite_send_fn = vfswrap_pwrite_send,
2510 .pwrite_recv_fn = vfswrap_asys_ssize_t_recv,
2511 .lseek_fn = vfswrap_lseek,
2512 .sendfile_fn = vfswrap_sendfile,
2513 .recvfile_fn = vfswrap_recvfile,
2514 .rename_fn = vfswrap_rename,
2515 .fsync_fn = vfswrap_fsync,
2516 .fsync_send_fn = vfswrap_fsync_send,
2517 .fsync_recv_fn = vfswrap_asys_int_recv,
2518 .stat_fn = vfswrap_stat,
2519 .fstat_fn = vfswrap_fstat,
2520 .lstat_fn = vfswrap_lstat,
2521 .get_alloc_size_fn = vfswrap_get_alloc_size,
2522 .unlink_fn = vfswrap_unlink,
2523 .chmod_fn = vfswrap_chmod,
2524 .fchmod_fn = vfswrap_fchmod,
2525 .chown_fn = vfswrap_chown,
2526 .fchown_fn = vfswrap_fchown,
2527 .lchown_fn = vfswrap_lchown,
2528 .chdir_fn = vfswrap_chdir,
2529 .getwd_fn = vfswrap_getwd,
2530 .ntimes_fn = vfswrap_ntimes,
2531 .ftruncate_fn = vfswrap_ftruncate,
2532 .fallocate_fn = vfswrap_fallocate,
2533 .lock_fn = vfswrap_lock,
2534 .kernel_flock_fn = vfswrap_kernel_flock,
2535 .linux_setlease_fn = vfswrap_linux_setlease,
2536 .getlock_fn = vfswrap_getlock,
2537 .symlink_fn = vfswrap_symlink,
2538 .readlink_fn = vfswrap_readlink,
2539 .link_fn = vfswrap_link,
2540 .mknod_fn = vfswrap_mknod,
2541 .realpath_fn = vfswrap_realpath,
2542 .notify_watch_fn = vfswrap_notify_watch,
2543 .chflags_fn = vfswrap_chflags,
2544 .file_id_create_fn = vfswrap_file_id_create,
2545 .streaminfo_fn = vfswrap_streaminfo,
2546 .get_real_filename_fn = vfswrap_get_real_filename,
2547 .connectpath_fn = vfswrap_connectpath,
2548 .brl_lock_windows_fn = vfswrap_brl_lock_windows,
2549 .brl_unlock_windows_fn = vfswrap_brl_unlock_windows,
2550 .brl_cancel_windows_fn = vfswrap_brl_cancel_windows,
2551 .strict_lock_fn = vfswrap_strict_lock,
2552 .strict_unlock_fn = vfswrap_strict_unlock,
2553 .translate_name_fn = vfswrap_translate_name,
2554 .fsctl_fn = vfswrap_fsctl,
2555 .copy_chunk_send_fn = vfswrap_copy_chunk_send,
2556 .copy_chunk_recv_fn = vfswrap_copy_chunk_recv,
2557 .get_compression_fn = vfswrap_get_compression,
2558 .set_compression_fn = vfswrap_set_compression,
2560 /* NT ACL operations. */
2562 .fget_nt_acl_fn = vfswrap_fget_nt_acl,
2563 .get_nt_acl_fn = vfswrap_get_nt_acl,
2564 .fset_nt_acl_fn = vfswrap_fset_nt_acl,
2565 .audit_file_fn = vfswrap_audit_file,
2567 /* POSIX ACL operations. */
2569 .chmod_acl_fn = vfswrap_chmod_acl,
2570 .fchmod_acl_fn = vfswrap_fchmod_acl,
2572 .sys_acl_get_file_fn = vfswrap_sys_acl_get_file,
2573 .sys_acl_get_fd_fn = vfswrap_sys_acl_get_fd,
2574 .sys_acl_blob_get_file_fn = posix_sys_acl_blob_get_file,
2575 .sys_acl_blob_get_fd_fn = posix_sys_acl_blob_get_fd,
2576 .sys_acl_set_file_fn = vfswrap_sys_acl_set_file,
2577 .sys_acl_set_fd_fn = vfswrap_sys_acl_set_fd,
2578 .sys_acl_delete_def_file_fn = vfswrap_sys_acl_delete_def_file,
2580 /* EA operations. */
2581 .getxattr_fn = vfswrap_getxattr,
2582 .fgetxattr_fn = vfswrap_fgetxattr,
2583 .listxattr_fn = vfswrap_listxattr,
2584 .flistxattr_fn = vfswrap_flistxattr,
2585 .removexattr_fn = vfswrap_removexattr,
2586 .fremovexattr_fn = vfswrap_fremovexattr,
2587 .setxattr_fn = vfswrap_setxattr,
2588 .fsetxattr_fn = vfswrap_fsetxattr,
2590 /* aio operations */
2591 .aio_force_fn = vfswrap_aio_force,
2593 /* offline operations */
2594 .is_offline_fn = vfswrap_is_offline,
2595 .set_offline_fn = vfswrap_set_offline,
2597 /* durable handle operations */
2598 .durable_cookie_fn = vfswrap_durable_cookie,
2599 .durable_disconnect_fn = vfswrap_durable_disconnect,
2600 .durable_reconnect_fn = vfswrap_durable_reconnect,
2603 NTSTATUS vfs_default_init(void);
2604 NTSTATUS vfs_default_init(void)
2606 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2607 DEFAULT_VFS_MODULE_NAME, &vfs_default_fns);