summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/smbd/files.c43
-rw-r--r--source3/smbd/proto.h3
2 files changed, 46 insertions, 0 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 1fe5596acf..50ce1b50ca 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -581,6 +581,49 @@ 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 *fsp;
+
+ if (smb2req->compat_chain_fsp != NULL) {
+ return smb2req->compat_chain_fsp;
+ }
+
+ if (persistent_id != volatile_id) {
+ return NULL;
+ }
+
+ if (volatile_id > UINT16_MAX) {
+ return NULL;
+ }
+
+ fsp = file_fnum(smb2req->sconn, (uint16_t)volatile_id);
+ if (fsp == NULL) {
+ return NULL;
+ }
+
+ if (smb2req->tcon == NULL) {
+ return NULL;
+ }
+
+ if (smb2req->tcon->compat_conn != fsp->conn) {
+ return NULL;
+ }
+
+ if (smb2req->session == NULL) {
+ return NULL;
+ }
+
+ if (smb2req->session->vuid != fsp->vuid) {
+ return NULL;
+ }
+
+ smb2req->compat_chain_fsp = fsp;
+ return fsp;
+}
+
/****************************************************************************
Duplicate the file handle part for a DOS or FCB open.
****************************************************************************/
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index d81feef073..e7bc3eb5b4 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -387,6 +387,9 @@ bool file_find_subpath(files_struct *dir_fsp);
void file_sync_all(connection_struct *conn);
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_smb2(struct smbd_smb2_request *smb2req,
+ uint64_t persistent_id,
+ uint64_t volatile_id);
NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *from,
uint32 access_mask, uint32 share_access,
uint32 create_options, files_struct *to);