]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move file_fsp() to smb1_utils.c
authorVolker Lendecke <vl@samba.org>
Thu, 23 Oct 2025 15:18:16 +0000 (17:18 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 10 Nov 2025 13:29:30 +0000 (13:29 +0000)
16-bit file ids are a smb1 thing

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/smbd/files.c
source3/smbd/proto.h
source3/smbd/smb1_utils.c
source3/smbd/smb1_utils.h

index 38270779bc0a6576d8fc9415b88644de46f0ea2b..7cb7ecfa965ea835e19399dc5fd55a983e23ca9c 100644 (file)
@@ -2444,63 +2444,6 @@ void file_free(struct smb_request *req, files_struct *fsp)
                 sconn->num_files);
 }
 
-/****************************************************************************
- Get an fsp from a packet given a 16 bit fnum.
-****************************************************************************/
-
-files_struct *file_fsp(struct smb_request *req, uint16_t fid)
-{
-       struct smbXsrv_open *op;
-       NTSTATUS status;
-       NTTIME now = 0;
-       files_struct *fsp;
-
-       if (req == NULL) {
-               /*
-                * We should never get here. req==NULL could in theory
-                * only happen from internal opens with a non-zero
-                * root_dir_fid. Internal opens just don't do that, at
-                * least they are not supposed to do so. And if they
-                * start to do so, they better fake up a smb_request
-                * from which we get the right smbd_server_conn. While
-                * this should never happen, let's return NULL here.
-                */
-               return NULL;
-       }
-
-       if (req->chain_fsp != NULL) {
-               if (req->chain_fsp->fsp_flags.closing) {
-                       return NULL;
-               }
-               return req->chain_fsp;
-       }
-
-       if (req->xconn == NULL) {
-               return NULL;
-       }
-
-       now = timeval_to_nttime(&req->request_time);
-
-       status = smb1srv_open_lookup(req->xconn,
-                                    fid, now, &op);
-       if (!NT_STATUS_IS_OK(status)) {
-               return NULL;
-       }
-
-       fsp = op->compat;
-       if (fsp == NULL) {
-               return NULL;
-       }
-
-       if (fsp->fsp_flags.closing) {
-               return NULL;
-       }
-
-       req->chain_fsp = fsp;
-       fsp->fsp_name->st.cached_dos_attributes = FILE_ATTRIBUTE_INVALID;
-       return fsp;
-}
-
 struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req,
                                  uint64_t persistent_id,
                                  uint64_t volatile_id)
index 6af2dd3a1db0ff0f64c54efbc4c30d4ba0a221c9..1fee322dad65a8ba63202d1d15c1ad717b1c7723 100644 (file)
@@ -344,7 +344,6 @@ struct files_struct *file_find_one_fsp_from_lease_key(
 bool file_find_subpath(files_struct *dir_fsp);
 void fsp_unbind_smb(struct smb_request *req, files_struct *fsp);
 void file_free(struct smb_request *req, files_struct *fsp);
-files_struct *file_fsp(struct smb_request *req, uint16_t fid);
 struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req,
                                  uint64_t persistent_id,
                                  uint64_t volatile_id);
index afd9b50c12c5a22a9ae809ba336496fbcb16883a..059f1bcc12a3f68c3cc056d807aea3f9f00b8b5d 100644 (file)
@@ -25,6 +25,7 @@
 #include "libcli/security/security.h"
 #include "lib/util/sys_rw_data.h"
 #include "smbd/fd_handle.h"
+#include "source3/smbd/smbXsrv_open.h"
 
 /****************************************************************************
  Special FCB or DOS processing in the case of a sharing violation.
@@ -286,3 +287,60 @@ NTSTATUS filename_convert_smb1_search_path(TALLOC_CTX *ctx,
 
        return status;
 }
+
+/****************************************************************************
+ Get an fsp from a packet given a 16 bit fnum.
+****************************************************************************/
+
+files_struct *file_fsp(struct smb_request *req, uint16_t fid)
+{
+       struct smbXsrv_open *op;
+       NTSTATUS status;
+       NTTIME now = 0;
+       files_struct *fsp;
+
+       if (req == NULL) {
+               /*
+                * We should never get here. req==NULL could in theory
+                * only happen from internal opens with a non-zero
+                * root_dir_fid. Internal opens just don't do that, at
+                * least they are not supposed to do so. And if they
+                * start to do so, they better fake up a smb_request
+                * from which we get the right smbd_server_conn. While
+                * this should never happen, let's return NULL here.
+                */
+               return NULL;
+       }
+
+       if (req->chain_fsp != NULL) {
+               if (req->chain_fsp->fsp_flags.closing) {
+                       return NULL;
+               }
+               return req->chain_fsp;
+       }
+
+       if (req->xconn == NULL) {
+               return NULL;
+       }
+
+       now = timeval_to_nttime(&req->request_time);
+
+       status = smb1srv_open_lookup(req->xconn,
+                                    fid, now, &op);
+       if (!NT_STATUS_IS_OK(status)) {
+               return NULL;
+       }
+
+       fsp = op->compat;
+       if (fsp == NULL) {
+               return NULL;
+       }
+
+       if (fsp->fsp_flags.closing) {
+               return NULL;
+       }
+
+       req->chain_fsp = fsp;
+       fsp->fsp_name->st.cached_dos_attributes = FILE_ATTRIBUTE_INVALID;
+       return fsp;
+}
index 539648e28cad9e6e49c0d42e89f3d857eba12c9c..d5eb7a2deed8bd155e7952173c06551f7f9e9740 100644 (file)
@@ -42,5 +42,6 @@ NTSTATUS filename_convert_smb1_search_path(TALLOC_CTX *ctx,
                                           struct files_struct **_dirfsp,
                                           struct smb_filename **_smb_fname_out,
                                           char **_mask_out);
+struct files_struct *file_fsp(struct smb_request *req, uint16_t fid);
 
 #endif