svn commit: samba r15658 - in trunk/source: printing smbd

vlendec at samba.org vlendec at samba.org
Wed May 17 12:59:31 GMT 2006


Author: vlendec
Date: 2006-05-17 12:59:30 +0000 (Wed, 17 May 2006)
New Revision: 15658

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

Log:
Micro-step towards getting rid of set_saved_error & friends. Lift
set_saved_ntstatus up from file_new one level. The plan is to work the way up
to open_file_ntcreate and higher.

Volker

Modified:
   trunk/source/printing/printfsp.c
   trunk/source/smbd/fake_file.c
   trunk/source/smbd/files.c
   trunk/source/smbd/open.c


Changeset:
Modified: trunk/source/printing/printfsp.c
===================================================================
--- trunk/source/printing/printfsp.c	2006-05-17 11:14:26 UTC (rev 15657)
+++ trunk/source/printing/printfsp.c	2006-05-17 12:59:30 UTC (rev 15658)
@@ -32,11 +32,15 @@
 {
 	int jobid;
 	SMB_STRUCT_STAT sbuf;
-	files_struct *fsp = file_new(conn);
+	files_struct *fsp;
 	fstring name;
+	NTSTATUS status;
 
-	if(!fsp)
+	status = file_new(conn, &fsp);
+	if(!NT_STATUS_IS_OK(status)) {
+		set_saved_ntstatus(status);
 		return NULL;
+	}
 
 	fstrcpy( name, "Remote Downlevel Document");
 	if (fname) {

Modified: trunk/source/smbd/fake_file.c
===================================================================
--- trunk/source/smbd/fake_file.c	2006-05-17 11:14:26 UTC (rev 15657)
+++ trunk/source/smbd/fake_file.c	2006-05-17 12:59:30 UTC (rev 15658)
@@ -107,6 +107,7 @@
 				uint32 access_mask)
 {
 	files_struct *fsp = NULL;
+	NTSTATUS status;
 
 	/* access check */
 	if (current_user.ut.uid != 0) {
@@ -116,8 +117,9 @@
 		return NULL;
 	}
 
-	fsp = file_new(conn);
-	if(!fsp) {
+	status = file_new(conn, &fsp);
+	if(!NT_STATUS_IS_OK(status)) {
+		set_saved_ntstatus(status);
 		return NULL;
 	}
 

Modified: trunk/source/smbd/files.c
===================================================================
--- trunk/source/smbd/files.c	2006-05-17 11:14:26 UTC (rev 15657)
+++ trunk/source/smbd/files.c	2006-05-17 12:59:30 UTC (rev 15658)
@@ -61,7 +61,7 @@
  Find first available file slot.
 ****************************************************************************/
 
-files_struct *file_new(connection_struct *conn)
+NTSTATUS file_new(connection_struct *conn, files_struct **result)
 {
 	int i;
 	static int first_file;
@@ -84,23 +84,19 @@
 		/* TODO: We have to unconditionally return a DOS error here,
 		 * W2k3 even returns ERRDOS/ERRnofids for ntcreate&x with
 		 * NTSTATUS negotiated */
-		set_saved_ntstatus(NT_STATUS_TOO_MANY_OPENED_FILES);
-		return NULL;
+		return NT_STATUS_TOO_MANY_OPENED_FILES;
 	}
 
 	fsp = SMB_MALLOC_P(files_struct);
 	if (!fsp) {
-		set_saved_ntstatus(NT_STATUS_NO_MEMORY);
-		return NULL;
+		return NT_STATUS_NO_MEMORY;
 	}
 
 	ZERO_STRUCTP(fsp);
 
 	fsp->fh = SMB_MALLOC_P(struct fd_handle);
 	if (!fsp->fh) {
-		SAFE_FREE(fsp);
-		set_saved_ntstatus(NT_STATUS_NO_MEMORY);
-		return NULL;
+		return NT_STATUS_NO_MEMORY;
 	}
 
 	ZERO_STRUCTP(fsp->fh);
@@ -133,8 +129,9 @@
 	if (fsp_fi_cache.fsp == NULL) {
 		ZERO_STRUCT(fsp_fi_cache);
 	}
-	
-	return fsp;
+
+	*result = fsp;
+	return NT_STATUS_OK;
 }
 
 /****************************************************************************
@@ -529,9 +526,13 @@
 				uint32 share_access,
 				uint32 create_options)
 {
-	files_struct *dup_fsp = file_new(fsp->conn);
+	NTSTATUS status;
+	files_struct *dup_fsp;
 
-	if (!dup_fsp) {
+	status = file_new(fsp->conn, &dup_fsp);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		set_saved_ntstatus(status);
 		return NULL;
 	}
 

Modified: trunk/source/smbd/open.c
===================================================================
--- trunk/source/smbd/open.c	2006-05-17 11:14:26 UTC (rev 15657)
+++ trunk/source/smbd/open.c	2006-05-17 12:59:30 UTC (rev 15658)
@@ -1336,8 +1336,9 @@
 		return NULL;
 	}
 
-	fsp = file_new(conn);
-	if(!fsp) {
+	status = file_new(conn, &fsp);
+	if(!NT_STATUS_IS_OK(status)) {
+		set_saved_ntstatus(status);
 		return NULL;
 	}
 
@@ -1775,13 +1776,15 @@
 {
 	files_struct *fsp = NULL;
 	BOOL fsp_open;
+	NTSTATUS status;
 
 	if (!VALID_STAT(*psbuf)) {
 		return NULL;
 	}
 
-	fsp = file_new(conn);
-	if(!fsp) {
+	status = file_new(conn, &fsp);
+	if(!NT_STATUS_IS_OK(status)) {
+		set_saved_ntstatus(status);
 		return NULL;
 	}
 
@@ -1933,8 +1936,9 @@
 		}
 	}
 
-	fsp = file_new(conn);
-	if(!fsp) {
+	status = file_new(conn, &fsp);
+	if(!NT_STATUS_IS_OK(status)) {
+		set_saved_ntstatus(status);
 		return NULL;
 	}
 
@@ -2027,6 +2031,7 @@
 			     SMB_STRUCT_STAT *psbuf)
 {
 	files_struct *fsp = NULL;
+	NTSTATUS status;
 
 	if (!VALID_STAT(*psbuf))
 		return NULL;
@@ -2035,9 +2040,11 @@
 	if(S_ISDIR(psbuf->st_mode))
 		return NULL;
 
-	fsp = file_new(conn);
-	if(!fsp)
+	status = file_new(conn, &fsp);
+	if(!fsp) {
+		set_saved_ntstatus(status);
 		return NULL;
+	}
 
 	DEBUG(5,("open_file_stat: 'opening' file %s\n", fname));
 



More information about the samba-cvs mailing list