[PATCH 09/17] smbd: split out file_fsp_get from file_fsp_smb2

David Disseldorp ddiss at samba.org
Tue Jan 15 09:23:04 MST 2013


Obtain the files_struct from smb2req, persistent_id and
volatile_id.
---
 source3/smbd/files.c |   34 ++++++++++++++++++++++++----------
 source3/smbd/proto.h |    3 +++
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index ef229a4..cba79ae 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -582,22 +582,15 @@ files_struct *file_fsp(struct smb_request *req, uint16 fid)
 	return fsp;
 }
 
-struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
-				   uint64_t persistent_id,
-				   uint64_t volatile_id)
+struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req,
+				  uint64_t persistent_id,
+				  uint64_t volatile_id)
 {
 	struct smbXsrv_open *op;
 	NTSTATUS status;
 	NTTIME now = 0;
 	struct files_struct *fsp;
 
-	if (smb2req->compat_chain_fsp != NULL) {
-		if (smb2req->compat_chain_fsp->deferred_close) {
-			return NULL;
-		}
-		return smb2req->compat_chain_fsp;
-	}
-
 	now = timeval_to_nttime(&smb2req->request_time);
 
 	status = smb2srv_open_lookup(smb2req->sconn->conn,
@@ -636,6 +629,27 @@ struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
 		return NULL;
 	}
 
+	return fsp;
+}
+
+struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
+				   uint64_t persistent_id,
+				   uint64_t volatile_id)
+{
+	struct files_struct *fsp;
+
+	if (smb2req->compat_chain_fsp != NULL) {
+		if (smb2req->compat_chain_fsp->deferred_close) {
+			return NULL;
+		}
+		return smb2req->compat_chain_fsp;
+	}
+
+	fsp = file_fsp_get(smb2req, persistent_id, volatile_id);
+	if (fsp == NULL) {
+		return NULL;
+	}
+
 	smb2req->compat_chain_fsp = fsp;
 	return fsp;
 }
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 7727302..603114e 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -387,6 +387,9 @@ void file_sync_all(connection_struct *conn);
 void fsp_free(files_struct *fsp);
 void file_free(struct smb_request *req, files_struct *fsp);
 files_struct *file_fsp(struct smb_request *req, uint16 fid);
+struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req,
+				  uint64_t persistent_id,
+				  uint64_t volatile_id);
 struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
 				   uint64_t persistent_id,
 				   uint64_t volatile_id);
-- 
1.7.10.4



More information about the samba-technical mailing list