From 22bebaf8589ff6ff95fe59f14f632b3b90471920 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 23 Dec 2020 11:50:34 +0100 Subject: [PATCH] s3:smbd: split out create_internal_fsp() from create_internal_dirfsp() That will be useful in other places as well. Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/smbd/files.c | 30 +++++++++++++++++++++++------- source3/smbd/proto.h | 3 +++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/source3/smbd/files.c b/source3/smbd/files.c index f151b01d83a..1c26b775f53 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -186,6 +186,28 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn, return NT_STATUS_OK; } +NTSTATUS create_internal_fsp(connection_struct *conn, + const struct smb_filename *smb_fname, + struct files_struct **_fsp) +{ + struct files_struct *fsp = NULL; + NTSTATUS status; + + status = file_new(NULL, conn, &fsp); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + status = fsp_set_smb_fname(fsp, smb_fname); + if (!NT_STATUS_IS_OK(status)) { + file_free(NULL, fsp); + return status; + } + + *_fsp = fsp; + return NT_STATUS_OK; +} + /* * Create an internal fsp for an *existing* directory. * @@ -199,14 +221,8 @@ NTSTATUS create_internal_dirfsp(connection_struct *conn, struct files_struct *fsp = NULL; NTSTATUS status; - status = file_new(NULL, conn, &fsp); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - status = fsp_set_smb_fname(fsp, smb_dname); + status = create_internal_fsp(conn, smb_dname, &fsp); if (!NT_STATUS_IS_OK(status)) { - file_free(NULL, fsp); return status; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 3c9815fa6db..60e4877004b 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -447,6 +447,9 @@ NTSTATUS fsp_set_smb_fname(struct files_struct *fsp, const struct smb_filename *smb_fname_in); size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen); +NTSTATUS create_internal_fsp(connection_struct *conn, + const struct smb_filename *smb_fname, + struct files_struct **_fsp); NTSTATUS create_internal_dirfsp(connection_struct *conn, const struct smb_filename *smb_dname, struct files_struct **_fsp); -- 2.11.4.GIT