svn commit: samba r24499 - in branches: SAMBA_3_0_25/source/include SAMBA_3_0_25/source/smbd SAMBA_3_2_0/source/include SAMBA_3_2_0/source/smbd

jra at samba.org jra at samba.org
Thu Aug 16 22:51:01 GMT 2007


Author: jra
Date: 2007-08-16 22:50:57 +0000 (Thu, 16 Aug 2007)
New Revision: 24499

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24499

Log:
Move the checks for DOS error codes on open to a function.
Jeremy.

Modified:
   branches/SAMBA_3_0_25/source/include/smb_macros.h
   branches/SAMBA_3_0_25/source/smbd/error.c
   branches/SAMBA_3_0_25/source/smbd/nttrans.c
   branches/SAMBA_3_0_25/source/smbd/reply.c
   branches/SAMBA_3_0_25/source/smbd/trans2.c
   branches/SAMBA_3_2_0/source/include/smb_macros.h
   branches/SAMBA_3_2_0/source/smbd/error.c
   branches/SAMBA_3_2_0/source/smbd/nttrans.c
   branches/SAMBA_3_2_0/source/smbd/reply.c
   branches/SAMBA_3_2_0/source/smbd/trans2.c


Changeset:
Modified: branches/SAMBA_3_0_25/source/include/smb_macros.h
===================================================================
--- branches/SAMBA_3_0_25/source/include/smb_macros.h	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_0_25/source/include/smb_macros.h	2007-08-16 22:50:57 UTC (rev 24499)
@@ -166,6 +166,7 @@
 
 #define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__)
 #define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__)
+#define ERROR_OPEN(status) error_open(outbuf,status,__LINE__,__FILE__)
 #define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__)
 #define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__)
 

Modified: branches/SAMBA_3_0_25/source/smbd/error.c
===================================================================
--- branches/SAMBA_3_0_25/source/smbd/error.c	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_0_25/source/smbd/error.c	2007-08-16 22:50:57 UTC (rev 24499)
@@ -132,3 +132,22 @@
 	error_packet_set(outbuf, eclass, ecode, ntstatus, line, file);
 	return outsize;
 }
+
+/*******************************************************************************
+ Special error map processing needed for returning DOS errors on open calls.
+*******************************************************************************/
+
+int error_open(char *outbuf, NTSTATUS status, int line, const char *file)
+{
+	if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+		/*
+		 * We hit an existing file, and if we're returning DOS
+		 * error codes OBJECT_NAME_COLLISION would map to
+		 * ERRDOS/183, we need to return ERRDOS/80, see bug
+		 * 4852.
+		 */
+		return error_packet(outbuf, ERRDOS, ERRfilexists,
+				NT_STATUS_OBJECT_NAME_COLLISION, line, file);
+	}
+	return error_packet(outbuf,0,0,status,line,file);
+}

Modified: branches/SAMBA_3_0_25/source/smbd/nttrans.c
===================================================================
--- branches/SAMBA_3_0_25/source/smbd/nttrans.c	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_0_25/source/smbd/nttrans.c	2007-08-16 22:50:57 UTC (rev 24499)
@@ -800,18 +800,7 @@
 			return -1;
 		}
 
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-					ERRDOS, ERRfilexists);
-
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	file_len = sbuf.st_size;
@@ -1457,18 +1446,7 @@
 			return -1;
 		}
 
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-					ERRDOS, ERRfilexists);
-
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	/*

Modified: branches/SAMBA_3_0_25/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0_25/source/smbd/reply.c	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_0_25/source/smbd/reply.c	2007-08-16 22:50:57 UTC (rev 24499)
@@ -1321,17 +1321,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	size = sbuf.st_size;
@@ -1465,17 +1455,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-					  ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	/* Setting the "size" field in vwv9 and vwv10 causes the file to be set to this size,
@@ -1664,17 +1644,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
  
 	ts[0] = get_atimespec(&sbuf); /* atime. */
@@ -1776,17 +1746,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	outsize = set_message(outbuf,1,0,True);

Modified: branches/SAMBA_3_0_25/source/smbd/trans2.c
===================================================================
--- branches/SAMBA_3_0_25/source/smbd/trans2.c	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_0_25/source/smbd/trans2.c	2007-08-16 22:50:57 UTC (rev 24499)
@@ -872,17 +872,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	size = get_file_size(sbuf);
@@ -6048,16 +6038,8 @@
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
 			return ERROR_BOTH(NT_STATUS_PATH_NOT_COVERED, ERRSRV, ERRbadpath);
 		}
-		if (info_level == SMB_POSIX_PATH_OPEN &&
-				NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
+		if (info_level == SMB_POSIX_PATH_OPEN) {
+			return ERROR_OPEN(status);
 		}
 		return ERROR_NT(status);
 	}

Modified: branches/SAMBA_3_2_0/source/include/smb_macros.h
===================================================================
--- branches/SAMBA_3_2_0/source/include/smb_macros.h	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_2_0/source/include/smb_macros.h	2007-08-16 22:50:57 UTC (rev 24499)
@@ -166,6 +166,7 @@
 
 #define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__)
 #define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__)
+#define ERROR_OPEN(status) error_open(outbuf,status,__LINE__,__FILE__)
 #define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__)
 #define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__)
 

Modified: branches/SAMBA_3_2_0/source/smbd/error.c
===================================================================
--- branches/SAMBA_3_2_0/source/smbd/error.c	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_2_0/source/smbd/error.c	2007-08-16 22:50:57 UTC (rev 24499)
@@ -131,3 +131,22 @@
 	error_packet_set(outbuf, eclass, ecode, ntstatus, line, file);
 	return outsize;
 }
+
+/*******************************************************************************
+ Special error map processing needed for returning DOS errors on open calls.
+*******************************************************************************/
+
+int error_open(char *outbuf, NTSTATUS status, int line, const char *file)
+{
+	if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+		/*
+		 * We hit an existing file, and if we're returning DOS
+		 * error codes OBJECT_NAME_COLLISION would map to
+		 * ERRDOS/183, we need to return ERRDOS/80, see bug
+		 * 4852.
+		 */
+		return error_packet(outbuf, ERRDOS, ERRfilexists,
+				NT_STATUS_OBJECT_NAME_COLLISION, line, file);
+	}
+	return error_packet(outbuf,0,0,status,line,file);
+}

Modified: branches/SAMBA_3_2_0/source/smbd/nttrans.c
===================================================================
--- branches/SAMBA_3_2_0/source/smbd/nttrans.c	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_2_0/source/smbd/nttrans.c	2007-08-16 22:50:57 UTC (rev 24499)
@@ -742,7 +742,6 @@
 					file_attributes,
 					&info, &fsp);
 
-		TALLOC_FREE(case_state);
 	} else {
 
 		/*
@@ -826,18 +825,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	file_len = sbuf.st_size;
@@ -1493,10 +1481,6 @@
 							create_options,
 							file_attributes,
 							&info, &fsp);
-				if(!NT_STATUS_IS_OK(status)) {
-					TALLOC_FREE(case_state);
-					return ERROR_NT(status);
-				}
 			}
 		}
 	}
@@ -1504,23 +1488,11 @@
 	TALLOC_FREE(case_state);
 
 	if(!NT_STATUS_IS_OK(status)) {
-
 		if (open_was_deferred(SVAL(inbuf,smb_mid))) {
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	/*

Modified: branches/SAMBA_3_2_0/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_2_0/source/smbd/reply.c	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_2_0/source/smbd/reply.c	2007-08-16 22:50:57 UTC (rev 24499)
@@ -1367,17 +1367,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	size = sbuf.st_size;
@@ -1515,17 +1505,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-					  ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	/* Setting the "size" field in vwv9 and vwv10 causes the file to be set to this size,
@@ -1718,17 +1698,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
  
 	ts[0] = get_atimespec(&sbuf); /* atime. */
@@ -1834,17 +1804,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	outsize = set_message(outbuf,1,0,True);

Modified: branches/SAMBA_3_2_0/source/smbd/trans2.c
===================================================================
--- branches/SAMBA_3_2_0/source/smbd/trans2.c	2007-08-16 17:42:34 UTC (rev 24498)
+++ branches/SAMBA_3_2_0/source/smbd/trans2.c	2007-08-16 22:50:57 UTC (rev 24499)
@@ -876,17 +876,7 @@
 			/* We have re-scheduled this call. */
 			return -1;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-		}
-		return ERROR_NT(status);
+		return ERROR_OPEN(status);
 	}
 
 	size = get_file_size(sbuf);
@@ -6187,16 +6177,8 @@
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
 			return ERROR_BOTH(NT_STATUS_PATH_NOT_COVERED, ERRSRV, ERRbadpath);
 		}
-		if (info_level == SMB_POSIX_PATH_OPEN &&
-				NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			return ERROR_BOTH(NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
+		if (info_level == SMB_POSIX_PATH_OPEN) {
+			return ERROR_OPEN(status);
 		}
 		return ERROR_NT(status);
 	}



More information about the samba-cvs mailing list