svn commit: samba r21050 - in branches: SAMBA_3_0/source/smbd SAMBA_3_0_24/source/smbd

jra at samba.org jra at samba.org
Tue Jan 30 01:36:47 GMT 2007


Author: jra
Date: 2007-01-30 01:36:45 +0000 (Tue, 30 Jan 2007)
New Revision: 21050

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

Log:
Factor out SMB_SET_FILE_DISPOSITION_INFO. My
intent is to factor out all cases where we
always return from the case.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/smbd/trans2.c
   branches/SAMBA_3_0_24/source/smbd/trans2.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/trans2.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/trans2.c	2007-01-30 01:14:48 UTC (rev 21049)
+++ branches/SAMBA_3_0/source/smbd/trans2.c	2007-01-30 01:36:45 UTC (rev 21050)
@@ -3745,7 +3745,8 @@
  Deal with SMB_INFO_SET_EA.
 ****************************************************************************/
 
-static int smb_info_set_ea(connection_struct *conn,
+static int smb_info_set_ea(
+		connection_struct *conn,
 				char *outbuf,
 				int bufsize,
 				char *params,
@@ -3804,6 +3805,50 @@
 }
 
 /****************************************************************************
+ Deal with SMB_SET_FILE_DISPOSITION_INFO.
+****************************************************************************/
+
+static int smb_set_file_disposition_info(connection_struct *conn,
+				char *outbuf,
+				int bufsize,
+				char *params,
+				int total_params,
+				char *pdata,
+				int total_data,
+				unsigned int max_data_bytes,
+				files_struct *fsp,
+				int dosmode)
+{
+	NTSTATUS status = NT_STATUS_OK;
+	BOOL delete_on_close;
+
+	if (total_data < 1) {
+		return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+	}
+
+	delete_on_close = (CVAL(pdata,0) ? True : False);
+
+	if (fsp == NULL) {
+		return(UNIXERROR(ERRDOS,ERRbadfid));
+	}
+
+	status = can_set_delete_on_close(fsp, delete_on_close, dosmode);
+ 
+	if (!NT_STATUS_IS_OK(status)) {
+		return ERROR_NT(status);
+	}
+
+	/* The set is across all open files on this dev/inode pair. */
+	if (!set_delete_on_close(fsp, delete_on_close, &current_user.ut)) {
+		return ERROR_NT(NT_STATUS_ACCESS_DENIED);
+	}
+
+	SSVAL(params,0,0);
+	send_trans2_replies(outbuf, bufsize, params, 2, pdata, 0, max_data_bytes);
+	return -1;
+}
+
+/****************************************************************************
  Reply to a TRANS2_SETFILEINFO (set file info by fileid or pathname).
 ****************************************************************************/
 
@@ -4107,36 +4152,25 @@
 		case SMB_FILE_DISPOSITION_INFORMATION:
 		case SMB_SET_FILE_DISPOSITION_INFO: /* Set delete on close for open file. */
 		{
-			BOOL delete_on_close;
-
 			if (total_data < 1) {
 				return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
 			}
 
-			delete_on_close = (CVAL(pdata,0) ? True : False);
-
 			/* Just ignore this set on a path. */
-			if (tran_call != TRANSACT2_SETFILEINFO)
+			if (tran_call != TRANSACT2_SETFILEINFO) {
 				break;
-
-			if (fsp == NULL)
-				return(UNIXERROR(ERRDOS,ERRbadfid));
-
-			status = can_set_delete_on_close(fsp, delete_on_close,
-							 dosmode);
- 
-			if (!NT_STATUS_IS_OK(status)) {
-				return ERROR_NT(status);
 			}
 
-			/* The set is across all open files on this dev/inode pair. */
-			if (!set_delete_on_close(fsp, delete_on_close, &current_user.ut)) {
-				return ERROR_NT(NT_STATUS_ACCESS_DENIED);
-			}
-
-			SSVAL(params,0,0);
-			send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0, max_data_bytes);
-			return(-1);
+			return smb_set_file_disposition_info(conn,
+						outbuf,
+						bufsize,
+						params,
+						total_params,
+						*ppdata,
+						total_data,
+						max_data_bytes,
+						fsp,
+						dosmode);
 		}
 
 		case SMB_FILE_POSITION_INFORMATION:

Modified: branches/SAMBA_3_0_24/source/smbd/trans2.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/trans2.c	2007-01-30 01:14:48 UTC (rev 21049)
+++ branches/SAMBA_3_0_24/source/smbd/trans2.c	2007-01-30 01:36:45 UTC (rev 21050)
@@ -3745,7 +3745,8 @@
  Deal with SMB_INFO_SET_EA.
 ****************************************************************************/
 
-static int smb_info_set_ea(connection_struct *conn,
+static int smb_info_set_ea(
+		connection_struct *conn,
 				char *outbuf,
 				int bufsize,
 				char *params,
@@ -3804,6 +3805,50 @@
 }
 
 /****************************************************************************
+ Deal with SMB_SET_FILE_DISPOSITION_INFO.
+****************************************************************************/
+
+static int smb_set_file_disposition_info(connection_struct *conn,
+				char *outbuf,
+				int bufsize,
+				char *params,
+				int total_params,
+				char *pdata,
+				int total_data,
+				unsigned int max_data_bytes,
+				files_struct *fsp,
+				int dosmode)
+{
+	NTSTATUS status = NT_STATUS_OK;
+	BOOL delete_on_close;
+
+	if (total_data < 1) {
+		return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+	}
+
+	delete_on_close = (CVAL(pdata,0) ? True : False);
+
+	if (fsp == NULL) {
+		return(UNIXERROR(ERRDOS,ERRbadfid));
+	}
+
+	status = can_set_delete_on_close(fsp, delete_on_close, dosmode);
+ 
+	if (!NT_STATUS_IS_OK(status)) {
+		return ERROR_NT(status);
+	}
+
+	/* The set is across all open files on this dev/inode pair. */
+	if (!set_delete_on_close(fsp, delete_on_close, &current_user.ut)) {
+		return ERROR_NT(NT_STATUS_ACCESS_DENIED);
+	}
+
+	SSVAL(params,0,0);
+	send_trans2_replies(outbuf, bufsize, params, 2, pdata, 0, max_data_bytes);
+	return -1;
+}
+
+/****************************************************************************
  Reply to a TRANS2_SETFILEINFO (set file info by fileid or pathname).
 ****************************************************************************/
 
@@ -4107,36 +4152,25 @@
 		case SMB_FILE_DISPOSITION_INFORMATION:
 		case SMB_SET_FILE_DISPOSITION_INFO: /* Set delete on close for open file. */
 		{
-			BOOL delete_on_close;
-
 			if (total_data < 1) {
 				return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
 			}
 
-			delete_on_close = (CVAL(pdata,0) ? True : False);
-
 			/* Just ignore this set on a path. */
-			if (tran_call != TRANSACT2_SETFILEINFO)
+			if (tran_call != TRANSACT2_SETFILEINFO) {
 				break;
-
-			if (fsp == NULL)
-				return(UNIXERROR(ERRDOS,ERRbadfid));
-
-			status = can_set_delete_on_close(fsp, delete_on_close,
-							 dosmode);
- 
-			if (!NT_STATUS_IS_OK(status)) {
-				return ERROR_NT(status);
 			}
 
-			/* The set is across all open files on this dev/inode pair. */
-			if (!set_delete_on_close(fsp, delete_on_close, &current_user.ut)) {
-				return ERROR_NT(NT_STATUS_ACCESS_DENIED);
-			}
-
-			SSVAL(params,0,0);
-			send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0, max_data_bytes);
-			return(-1);
+			return smb_set_file_disposition_info(conn,
+						outbuf,
+						bufsize,
+						params,
+						total_params,
+						*ppdata,
+						total_data,
+						max_data_bytes,
+						fsp,
+						dosmode);
 		}
 
 		case SMB_FILE_POSITION_INFORMATION:



More information about the samba-cvs mailing list