From f79aae70dd10877311243b5b2a55e1f130bd54b6 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Sat, 22 Nov 2008 19:40:09 -0800 Subject: s3: Simplify the create_file_unix_path->open_file_ntcreate path Also removed open_file_ntcreate/open_file from proto.h so they can no longer be called directly. --- source3/include/proto.h | 24 --------- source3/smbd/open.c | 131 ++++++++++++++---------------------------------- 2 files changed, 38 insertions(+), 117 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index c32234a1d8..08ecbfd1e5 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -8100,34 +8100,10 @@ bool map_open_params_to_ntcreate(const char *fname, int deny_mode, int open_func uint32 *pshare_mode, uint32 *pcreate_disposition, uint32 *pcreate_options); -NTSTATUS open_file_ntcreate(connection_struct *conn, - struct smb_request *req, - const char *fname, - SMB_STRUCT_STAT *psbuf, - uint32 access_mask, /* access bits (FILE_READ_DATA etc.) */ - uint32 share_access, /* share constants (FILE_SHARE_READ etc) */ - uint32 create_disposition, /* FILE_OPEN_IF etc. */ - uint32 create_options, /* options such as delete on close. */ - uint32 new_dos_attributes, /* attributes used for new file. */ - int oplock_request, /* internal Samba oplock codes. */ - /* Information (FILE_EXISTS etc.) */ - int *pinfo, - files_struct **result); NTSTATUS open_file_fchmod(struct smb_request *req, connection_struct *conn, const char *fname, SMB_STRUCT_STAT *psbuf, files_struct **result); NTSTATUS close_file_fchmod(struct smb_request *req, files_struct *fsp); -NTSTATUS open_directory(connection_struct *conn, - struct smb_request *req, - const char *fname, - SMB_STRUCT_STAT *psbuf, - uint32 access_mask, - uint32 share_access, - uint32 create_disposition, - uint32 create_options, - uint32 file_attributes, - int *pinfo, - files_struct **result); NTSTATUS create_directory(connection_struct *conn, struct smb_request *req, const char *directory); void msg_file_was_renamed(struct messaging_context *msg, void *private_data, diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 2e34115071..d2068dde47 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1277,7 +1277,7 @@ static NTSTATUS calculate_access_mask(connection_struct *conn, Open a file with a share mode. Passed in an already created files_struct *. ****************************************************************************/ -static NTSTATUS open_file_ntcreate_internal(connection_struct *conn, +static NTSTATUS open_file_ntcreate(connection_struct *conn, struct smb_request *req, const char *fname, SMB_STRUCT_STAT *psbuf, @@ -2073,55 +2073,6 @@ static NTSTATUS open_file_ntcreate_internal(connection_struct *conn, return NT_STATUS_OK; } -/**************************************************************************** - Open a file with a share mode. -****************************************************************************/ - -NTSTATUS open_file_ntcreate(connection_struct *conn, - struct smb_request *req, - const char *fname, - SMB_STRUCT_STAT *psbuf, - uint32 access_mask, /* access bits (FILE_READ_DATA etc.) */ - uint32 share_access, /* share constants (FILE_SHARE_READ etc) */ - uint32 create_disposition, /* FILE_OPEN_IF etc. */ - uint32 create_options, /* options such as delete on close. */ - uint32 new_dos_attributes, /* attributes used for new file. */ - int oplock_request, /* internal Samba oplock codes. */ - /* Information (FILE_EXISTS etc.) */ - int *pinfo, - files_struct **result) -{ - NTSTATUS status; - files_struct *fsp = NULL; - - *result = NULL; - - status = file_new(req, conn, &fsp); - if(!NT_STATUS_IS_OK(status)) { - return status; - } - - status = open_file_ntcreate_internal(conn, - req, - fname, - psbuf, - access_mask, - share_access, - create_disposition, - create_options, - new_dos_attributes, - oplock_request, - pinfo, - fsp); - - if(!NT_STATUS_IS_OK(status)) { - file_free(req, fsp); - return status; - } - - *result = fsp; - return status; -} /**************************************************************************** Open a file for for write to ensure that we can fchmod it. @@ -2282,17 +2233,17 @@ static NTSTATUS mkdir_internal(connection_struct *conn, Open a directory from an NT SMB call. ****************************************************************************/ -NTSTATUS open_directory(connection_struct *conn, - struct smb_request *req, - const char *fname, - SMB_STRUCT_STAT *psbuf, - uint32 access_mask, - uint32 share_access, - uint32 create_disposition, - uint32 create_options, - uint32 file_attributes, - int *pinfo, - files_struct **result) +static NTSTATUS open_directory(connection_struct *conn, + struct smb_request *req, + const char *fname, + SMB_STRUCT_STAT *psbuf, + uint32 access_mask, + uint32 share_access, + uint32 create_disposition, + uint32 create_options, + uint32 file_attributes, + int *pinfo, + files_struct **result) { files_struct *fsp = NULL; bool dir_existed = VALID_STAT(*psbuf) ? True : False; @@ -2932,41 +2883,35 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, * Ordinary file case. */ - if (base_fsp) { - /* - * We're opening the stream element of a base_fsp - * we already opened. We need to initialize - * the fsp first, and set up the base_fsp pointer. - */ - status = file_new(req, conn, &fsp); - if(!NT_STATUS_IS_OK(status)) { - goto fail; - } + status = file_new(req, conn, &fsp); + if(!NT_STATUS_IS_OK(status)) { + goto fail; + } + /* + * We're opening the stream element of a base_fsp + * we already opened. Set up the base_fsp pointer. + */ + if (base_fsp) { fsp->base_fsp = base_fsp; + } - status = open_file_ntcreate_internal(conn, - req, - fname, - &sbuf, - access_mask, - share_access, - create_disposition, - create_options, - file_attributes, - oplock_request, - &info, - fsp); - - if(!NT_STATUS_IS_OK(status)) { - file_free(req, fsp); - fsp = NULL; - } - } else { - status = open_file_ntcreate( - conn, req, fname, &sbuf, access_mask, share_access, - create_disposition, create_options, file_attributes, - oplock_request, &info, &fsp); + status = open_file_ntcreate(conn, + req, + fname, + &sbuf, + access_mask, + share_access, + create_disposition, + create_options, + file_attributes, + oplock_request, + &info, + fsp); + + if(!NT_STATUS_IS_OK(status)) { + file_free(req, fsp); + fsp = NULL; } if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) { -- cgit