[PATCH v2] vfs: propagate snapshot enumeration errors

David Disseldorp ddiss at samba.org
Thu Feb 27 11:41:28 MST 2014


The current FSCTL_GET_SHADOW_COPY_DATA/FSCTL_SRV_ENUMERATE_SNAPSHOTS
handler squashes all non-ENOSYS errors into an NT_STATUS_UNSUCCESSFUL
response.
This commit ensures that all errors are propagated up to the client, to
aid debugging.
The Windows Explorer "Previous Versions" dialogue doesn't appear to
distinguish between error codes. It displays "There are no previous
versions available".

Signed-off-by: David Disseldorp <ddiss at samba.org>
---
 source3/modules/vfs_default.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 56f95a0..3066bc9 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1078,19 +1078,19 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 {
 	const char *in_data = (const char *)_in_data;
 	char **out_data = (char **)_out_data;
+	NTSTATUS status;
 
 	switch (function) {
 	case FSCTL_SET_SPARSE:
 	{
 		bool set_sparse = true;
-		NTSTATUS status;
 
 		if (in_len >= 1 && in_data[0] == 0) {
 			set_sparse = false;
 		}
 
 		status = file_set_sparse(handle->conn, fsp, set_sparse);
-		
+
 		DEBUG(NT_STATUS_IS_OK(status) ? 10 : 9,
 		      ("FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\n",
 		       smb_fname_str_dbg(fsp->fsp_name), set_sparse, 
@@ -1180,16 +1180,23 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 		 * Call the VFS routine to actually do the work.
 		 */
 		if (SMB_VFS_GET_SHADOW_COPY_DATA(fsp, shadow_data, labels)!=0) {
-			TALLOC_FREE(shadow_data);
-			if (errno == ENOSYS) {
-				DEBUG(5,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\n", 
-					fsp->conn->connectpath));
-				return NT_STATUS_NOT_SUPPORTED;
+			int log_lev = 0;
+			if (errno == 0) {
+				/* broken module didn't set errno on error */
+				status = NT_STATUS_UNSUCCESSFUL;
 			} else {
-				DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, failed.\n", 
-					fsp->conn->connectpath));
-				return NT_STATUS_UNSUCCESSFUL;
+				status = map_nt_error_from_unix(errno);
+				if (NT_STATUS_EQUAL(status,
+						    NT_STATUS_NOT_SUPPORTED)) {
+					log_lev = 5;
+				}
 			}
+			DEBUG(log_lev, ("FSCTL_GET_SHADOW_COPY_DATA: "
+					"connectpath %s, failed - %s.\n",
+					fsp->conn->connectpath,
+					nt_errstr(status)));
+			TALLOC_FREE(shadow_data);
+			return status;
 		}
 
 		labels_data_count = (shadow_data->num_volumes * 2 * 
@@ -1317,7 +1324,6 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 		 * and SEEK_DATA/SEEK_HOLE on Solaris is needed to make
 		 * this FSCTL correct for sparse files.
 		 */
-		NTSTATUS status;
 		uint64_t offset, length;
 		char *out_data_tmp = NULL;
 
-- 
1.8.4.5



More information about the samba-technical mailing list