vfs: add snapshot create/delete hooks
[ddiss/samba.git] / source3 / smbd / vfs.c
index 763ef37f899984732339669965f2457c074a739c..c29f393d91e0851abaafa21a3be3d5d168cb7d0d 100644 (file)
@@ -799,26 +799,34 @@ const char *vfs_readdirname(connection_struct *conn, void *p,
 
 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;
 }
 
 /*******************************************************************
@@ -2149,28 +2157,100 @@ NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle,
                            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,
@@ -2213,28 +2293,29 @@ int smb_vfs_call_fchmod_acl(struct vfs_handle_struct *handle,
 
 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);
+       return handle->fns->sys_acl_get_fd_fn(handle, fsp, mem_ctx);
 }
 
 int smb_vfs_call_sys_acl_blob_get_file(struct vfs_handle_struct *handle,
                                       const char *path_p,
-                                      SMB_ACL_TYPE_T type,
                                       TALLOC_CTX *mem_ctx, 
                                       char **blob_description,
                                       DATA_BLOB *blob)
 {
        VFS_FIND(sys_acl_blob_get_file);
-       return handle->fns->sys_acl_blob_get_file_fn(handle, path_p, type, mem_ctx, blob_description, blob);
+       return handle->fns->sys_acl_blob_get_file_fn(handle, path_p, mem_ctx, blob_description, blob);
 }
 
 int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,