/* Normal share - initialise with disk access functions */
vfs_init_default(conn);
+
+ /* No need to load vfs modules for printer connections */
+ if (conn->printer) {
+ return True;
+ }
+
vfs_objects = lp_vfs_objects(SNUM(conn));
/* Override VFS functions if 'vfs object' was not specified*/
int vfs_ChDir(connection_struct *conn, const char *path)
{
- int res;
+ int ret;
if (!LastDir) {
LastDir = SMB_STRDUP("");
}
- if (strcsequal(path,"."))
- return(0);
+ if (strcsequal(path,".")) {
+ return 0;
+ }
- if (*path == '/' && strcsequal(LastDir,path))
- return(0);
+ if (*path == '/' && strcsequal(LastDir,path)) {
+ return 0;
+ }
DEBUG(4,("vfs_ChDir to %s\n",path));
- res = SMB_VFS_CHDIR(conn,path);
- if (!res) {
+ ret = SMB_VFS_CHDIR(conn,path);
+ if (ret == 0) {
+ /* Global cache. */
SAFE_FREE(LastDir);
LastDir = SMB_STRDUP(path);
+
+ /* conn cache. */
+ TALLOC_FREE(conn->cwd);
+ conn->cwd = vfs_GetWd(conn, conn);
+ DEBUG(4,("vfs_ChDir got %s\n",conn->cwd));
}
- return(res);
+ return ret;
}
/*******************************************************************
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(priv_paths);
}
+ TALLOC_FREE(dir_name);
return status;
}
p++;
if (strcmp(fname, p)!=0) {
DEBUG(2, ("check_reduced_name: Bad access "
- "attempt: %s is a symlink\n",
- fname));
+ "attempt: %s is a symlink to %s\n",
+ fname, p));
SAFE_FREE(resolved_name);
return NT_STATUS_ACCESS_DENIED;
}
return handle->fns->fsync_fn(handle, fsp);
}
+struct smb_vfs_call_fsync_state {
+ int (*recv_fn)(struct tevent_req *req, int *err);
+ int retval;
+};
+
+static void smb_vfs_call_fsync_done(struct tevent_req *subreq);
+
+struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct files_struct *fsp)
+{
+ struct tevent_req *req, *subreq;
+ struct smb_vfs_call_fsync_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct smb_vfs_call_fsync_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ VFS_FIND(fsync_send);
+ state->recv_fn = handle->fns->fsync_recv_fn;
+
+ subreq = handle->fns->fsync_send_fn(handle, state, ev, fsp);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, smb_vfs_call_fsync_done, req);
+ return req;
+}
+
+static void smb_vfs_call_fsync_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct smb_vfs_call_fsync_state *state = tevent_req_data(
+ req, struct smb_vfs_call_fsync_state);
+ int err;
+
+ state->retval = state->recv_fn(subreq, &err);
+ TALLOC_FREE(subreq);
+ if (state->retval == -1) {
+ tevent_req_error(req, err);
+ return;
+ }
+ tevent_req_done(req);
+}
+
+int SMB_VFS_FSYNC_RECV(struct tevent_req *req, int *perrno)
+{
+ struct smb_vfs_call_fsync_state *state = tevent_req_data(
+ req, struct smb_vfs_call_fsync_state);
+ int err;
+
+ if (tevent_req_is_unix_error(req, &err)) {
+ *perrno = err;
+ return -1;
+ }
+ return state->retval;
+}
+
+
int smb_vfs_call_stat(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname)
{
uint32_t *out_len)
{
VFS_FIND(fsctl);
- return handle->fns->fsctl_fn(handle, fsp, ctx, function, req_flags,
- in_data, in_len, out_data, max_out_len,
+ return handle->fns->fsctl_fn(handle, fsp, ctx, function, req_flags,
+ in_data, in_len, out_data, max_out_len,
out_len);
}
+struct tevent_req *smb_vfs_call_copy_chunk_send(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct files_struct *src_fsp,
+ off_t src_off,
+ struct files_struct *dest_fsp,
+ off_t dest_off,
+ off_t num)
+{
+ VFS_FIND(copy_chunk_send);
+ return handle->fns->copy_chunk_send_fn(handle, mem_ctx, ev, src_fsp,
+ src_off, dest_fsp, dest_off, num);
+}
+
+NTSTATUS smb_vfs_call_copy_chunk_recv(struct vfs_handle_struct *handle,
+ struct tevent_req *req,
+ off_t *copied)
+{
+ VFS_FIND(copy_chunk_recv);
+ return handle->fns->copy_chunk_recv_fn(handle, req, copied);
+}
+
+NTSTATUS smb_vfs_call_snap_check_path(vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ const char *service_path,
+ char **base_volume)
+{
+ VFS_FIND(snap_check_path);
+ return handle->fns->snap_check_path_fn(handle, mem_ctx, service_path,
+ base_volume);
+}
+
+struct tevent_req *smb_vfs_call_snap_create_send(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ const char *base_volume,
+ time_t *tstamp,
+ bool rw)
+{
+ VFS_FIND(snap_create_send);
+ return handle->fns->snap_create_send_fn(handle, mem_ctx, ev,
+ base_volume, tstamp, rw);
+}
+
+NTSTATUS smb_vfs_call_snap_create_recv(struct vfs_handle_struct *handle,
+ struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ char **base_path, char **snap_path)
+{
+ VFS_FIND(snap_create_recv);
+ return handle->fns->snap_create_recv_fn(handle, req, mem_ctx,
+ base_path, snap_path);
+}
+
+struct tevent_req *smb_vfs_call_snap_delete_send(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ char *snap_path)
+{
+ VFS_FIND(snap_delete_send);
+ return handle->fns->snap_delete_send_fn(handle, mem_ctx, ev, snap_path);
+}
+
+NTSTATUS smb_vfs_call_snap_delete_recv(struct vfs_handle_struct *handle,
+ struct tevent_req *req)
+{
+ VFS_FIND(snap_delete_recv);
+ return handle->fns->snap_delete_recv_fn(handle, req);
+}
+
NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32 security_info,
+ TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
{
VFS_FIND(fget_nt_acl);
return handle->fns->fget_nt_acl_fn(handle, fsp, security_info,
- ppdesc);
+ mem_ctx, ppdesc);
}
NTSTATUS smb_vfs_call_get_nt_acl(struct vfs_handle_struct *handle,
const char *name,
uint32 security_info,
+ TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
{
VFS_FIND(get_nt_acl);
- return handle->fns->get_nt_acl_fn(handle, name, security_info, ppdesc);
+ return handle->fns->get_nt_acl_fn(handle, name, security_info, mem_ctx, ppdesc);
}
NTSTATUS smb_vfs_call_fset_nt_acl(struct vfs_handle_struct *handle,
return handle->fns->fchmod_acl_fn(handle, fsp, mode);
}
-int smb_vfs_call_sys_acl_get_entry(struct vfs_handle_struct *handle,
- SMB_ACL_T theacl, int entry_id,
- SMB_ACL_ENTRY_T *entry_p)
-{
- VFS_FIND(sys_acl_get_entry);
- return handle->fns->sys_acl_get_entry_fn(handle, theacl, entry_id,
- entry_p);
-}
-
-int smb_vfs_call_sys_acl_get_tag_type(struct vfs_handle_struct *handle,
- SMB_ACL_ENTRY_T entry_d,
- SMB_ACL_TAG_T *tag_type_p)
-{
- VFS_FIND(sys_acl_get_tag_type);
- return handle->fns->sys_acl_get_tag_type_fn(handle, entry_d,
- tag_type_p);
-}
-
-int smb_vfs_call_sys_acl_get_permset(struct vfs_handle_struct *handle,
- SMB_ACL_ENTRY_T entry_d,
- SMB_ACL_PERMSET_T *permset_p)
-{
- VFS_FIND(sys_acl_get_permset);
- return handle->fns->sys_acl_get_permset_fn(handle, entry_d, permset_p);
-}
-
-void * smb_vfs_call_sys_acl_get_qualifier(struct vfs_handle_struct *handle,
- SMB_ACL_ENTRY_T entry_d)
-{
- VFS_FIND(sys_acl_get_qualifier);
- return handle->fns->sys_acl_get_qualifier_fn(handle, entry_d);
-}
-
SMB_ACL_T smb_vfs_call_sys_acl_get_file(struct vfs_handle_struct *handle,
const char *path_p,
- SMB_ACL_TYPE_T type)
+ SMB_ACL_TYPE_T type,
+ TALLOC_CTX *mem_ctx)
{
VFS_FIND(sys_acl_get_file);
- return handle->fns->sys_acl_get_file_fn(handle, path_p, type);
+ return handle->fns->sys_acl_get_file_fn(handle, path_p, type, mem_ctx);
}
SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
- struct files_struct *fsp)
+ struct files_struct *fsp,
+ TALLOC_CTX *mem_ctx)
{
VFS_FIND(sys_acl_get_fd);
- return handle->fns->sys_acl_get_fd_fn(handle, fsp);
-}
-
-int smb_vfs_call_sys_acl_clear_perms(struct vfs_handle_struct *handle,
- SMB_ACL_PERMSET_T permset)
-{
- VFS_FIND(sys_acl_clear_perms);
- return handle->fns->sys_acl_clear_perms_fn(handle, permset);
-}
-
-int smb_vfs_call_sys_acl_add_perm(struct vfs_handle_struct *handle,
- SMB_ACL_PERMSET_T permset,
- SMB_ACL_PERM_T perm)
-{
- VFS_FIND(sys_acl_add_perm);
- return handle->fns->sys_acl_add_perm_fn(handle, permset, perm);
-}
-
-char * smb_vfs_call_sys_acl_to_text(struct vfs_handle_struct *handle,
- SMB_ACL_T theacl, ssize_t *plen)
-{
- VFS_FIND(sys_acl_to_text);
- return handle->fns->sys_acl_to_text_fn(handle, theacl, plen);
-}
-
-SMB_ACL_T smb_vfs_call_sys_acl_init(struct vfs_handle_struct *handle,
- int count)
-{
- VFS_FIND(sys_acl_init);
- return handle->fns->sys_acl_init_fn(handle, count);
-}
-
-int smb_vfs_call_sys_acl_create_entry(struct vfs_handle_struct *handle,
- SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry)
-{
- VFS_FIND(sys_acl_create_entry);
- return handle->fns->sys_acl_create_entry_fn(handle, pacl, pentry);
-}
-
-int smb_vfs_call_sys_acl_set_tag_type(struct vfs_handle_struct *handle,
- SMB_ACL_ENTRY_T entry,
- SMB_ACL_TAG_T tagtype)
-{
- VFS_FIND(sys_acl_set_tag_type);
- return handle->fns->sys_acl_set_tag_type_fn(handle, entry, tagtype);
+ return handle->fns->sys_acl_get_fd_fn(handle, fsp, mem_ctx);
}
-int smb_vfs_call_sys_acl_set_qualifier(struct vfs_handle_struct *handle,
- SMB_ACL_ENTRY_T entry, void *qual)
+int smb_vfs_call_sys_acl_blob_get_file(struct vfs_handle_struct *handle,
+ const char *path_p,
+ TALLOC_CTX *mem_ctx,
+ char **blob_description,
+ DATA_BLOB *blob)
{
- VFS_FIND(sys_acl_set_qualifier);
- return handle->fns->sys_acl_set_qualifier_fn(handle, entry, qual);
+ VFS_FIND(sys_acl_blob_get_file);
+ return handle->fns->sys_acl_blob_get_file_fn(handle, path_p, mem_ctx, blob_description, blob);
}
-int smb_vfs_call_sys_acl_set_permset(struct vfs_handle_struct *handle,
- SMB_ACL_ENTRY_T entry,
- SMB_ACL_PERMSET_T permset)
-{
- VFS_FIND(sys_acl_set_permset);
- return handle->fns->sys_acl_set_permset_fn(handle, entry, permset);
-}
-
-int smb_vfs_call_sys_acl_valid(struct vfs_handle_struct *handle,
- SMB_ACL_T theacl)
+int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ TALLOC_CTX *mem_ctx,
+ char **blob_description,
+ DATA_BLOB *blob)
{
- VFS_FIND(sys_acl_valid);
- return handle->fns->sys_acl_valid_fn(handle, theacl);
+ VFS_FIND(sys_acl_blob_get_fd);
+ return handle->fns->sys_acl_blob_get_fd_fn(handle, fsp, mem_ctx, blob_description, blob);
}
int smb_vfs_call_sys_acl_set_file(struct vfs_handle_struct *handle,
return handle->fns->sys_acl_delete_def_file_fn(handle, path);
}
-int smb_vfs_call_sys_acl_get_perm(struct vfs_handle_struct *handle,
- SMB_ACL_PERMSET_T permset,
- SMB_ACL_PERM_T perm)
-{
- VFS_FIND(sys_acl_get_perm);
- return handle->fns->sys_acl_get_perm_fn(handle, permset, perm);
-}
-
-int smb_vfs_call_sys_acl_free_text(struct vfs_handle_struct *handle,
- char *text)
-{
- VFS_FIND(sys_acl_free_text);
- return handle->fns->sys_acl_free_text_fn(handle, text);
-}
-
-int smb_vfs_call_sys_acl_free_acl(struct vfs_handle_struct *handle,
- SMB_ACL_T posix_acl)
-{
- VFS_FIND(sys_acl_free_acl);
- return handle->fns->sys_acl_free_acl_fn(handle, posix_acl);
-}
-
-int smb_vfs_call_sys_acl_free_qualifier(struct vfs_handle_struct *handle,
- void *qualifier, SMB_ACL_TAG_T tagtype)
-{
- VFS_FIND(sys_acl_free_qualifier);
- return handle->fns->sys_acl_free_qualifier_fn(handle, qualifier,
- tagtype);
-}
-
ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle,
const char *path, const char *name, void *value,
size_t size)
return handle->fns->fsetxattr_fn(handle, fsp, name, value, size, flags);
}
-int smb_vfs_call_aio_read(struct vfs_handle_struct *handle,
- struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
-{
- VFS_FIND(aio_read);
- return handle->fns->aio_read_fn(handle, fsp, aiocb);
-}
-
-int smb_vfs_call_aio_write(struct vfs_handle_struct *handle,
- struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
-{
- VFS_FIND(aio_write);
- return handle->fns->aio_write_fn(handle, fsp, aiocb);
-}
-
-ssize_t smb_vfs_call_aio_return(struct vfs_handle_struct *handle,
- struct files_struct *fsp,
- SMB_STRUCT_AIOCB *aiocb)
-{
- VFS_FIND(aio_return);
- return handle->fns->aio_return_fn(handle, fsp, aiocb);
-}
-
-int smb_vfs_call_aio_cancel(struct vfs_handle_struct *handle,
- struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
-{
- VFS_FIND(aio_cancel);
- return handle->fns->aio_cancel_fn(handle, fsp, aiocb);
-}
-
-int smb_vfs_call_aio_error(struct vfs_handle_struct *handle,
- struct files_struct *fsp,
- SMB_STRUCT_AIOCB *aiocb)
-{
- VFS_FIND(aio_error);
- return handle->fns->aio_error_fn(handle, fsp, aiocb);
-}
-
-int smb_vfs_call_aio_fsync(struct vfs_handle_struct *handle,
- struct files_struct *fsp, int op,
- SMB_STRUCT_AIOCB *aiocb)
-{
- VFS_FIND(aio_fsync);
- return handle->fns->aio_fsync_fn(handle, fsp, op, aiocb);
-}
-
-int smb_vfs_call_aio_suspend(struct vfs_handle_struct *handle,
- struct files_struct *fsp,
- const SMB_STRUCT_AIOCB * const aiocb[], int n,
- const struct timespec *timeout)
-{
- VFS_FIND(aio_suspend);
- return handle->fns->aio_suspend_fn(handle, fsp, aiocb, n, timeout);
-}
-
bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
struct files_struct *fsp)
{
VFS_FIND(set_offline);
return handle->fns->set_offline_fn(handle, fname);
}
+
+NTSTATUS smb_vfs_call_durable_cookie(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *cookie)
+{
+ VFS_FIND(durable_cookie);
+ return handle->fns->durable_cookie_fn(handle, fsp, mem_ctx, cookie);
+}
+
+NTSTATUS smb_vfs_call_durable_disconnect(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ const DATA_BLOB old_cookie,
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *new_cookie)
+{
+ VFS_FIND(durable_disconnect);
+ return handle->fns->durable_disconnect_fn(handle, fsp, old_cookie,
+ mem_ctx, new_cookie);
+}
+
+NTSTATUS smb_vfs_call_durable_reconnect(struct vfs_handle_struct *handle,
+ struct smb_request *smb1req,
+ struct smbXsrv_open *op,
+ const DATA_BLOB old_cookie,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct **fsp,
+ DATA_BLOB *new_cookie)
+{
+ VFS_FIND(durable_reconnect);
+ return handle->fns->durable_reconnect_fn(handle, smb1req, op,
+ old_cookie, mem_ctx, fsp,
+ new_cookie);
+}