diff options
Diffstat (limited to 'source/smbd/close.c')
-rw-r--r-- | source/smbd/close.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/source/smbd/close.c b/source/smbd/close.c index ca030ed1404..38270fbfe31 100644 --- a/source/smbd/close.c +++ b/source/smbd/close.c @@ -91,13 +91,14 @@ static int close_filestruct(files_struct *fsp) connection_struct *conn = fsp->conn; int ret = 0; - if(flush_write_cache(fsp, CLOSE_FLUSH) == -1) - ret = -1; + if (fsp->fd != -1) { + if(flush_write_cache(fsp, CLOSE_FLUSH) == -1) + ret = -1; - delete_write_cache(fsp); + delete_write_cache(fsp); + } fsp->is_directory = False; - fsp->stat_open = False; conn->num_files_open--; SAFE_FREE(fsp->wbmpx_ptr); @@ -160,7 +161,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close) GET_DELETE_ON_CLOSE_FLAG(share_entry->share_mode) ) delete_on_close = True; - safe_free(share_entry); + SAFE_FREE(share_entry); /* * NT can set delete_on_close of the last open @@ -170,7 +171,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close) if (normal_close && delete_on_close) { DEBUG(5,("close_file: file %s. Delete on close was set - deleting file.\n", fsp->fsp_name)); - if(fsp->conn->vfs_ops.unlink(conn,dos_to_unix(fsp->fsp_name, False)) != 0) { + if(fsp->conn->vfs_ops.unlink(conn,dos_to_unix_static(fsp->fsp_name)) != 0) { /* * This call can potentially fail as another smbd may have * had the file open with delete on close set and deleted @@ -263,22 +264,6 @@ static int close_directory(files_struct *fsp, BOOL normal_close) } /**************************************************************************** - Close a file opened with null permissions in order to read permissions. -****************************************************************************/ - -static int close_statfile(files_struct *fsp, BOOL normal_close) -{ - close_filestruct(fsp); - - if (fsp->fsp_name) - string_free(&fsp->fsp_name); - - file_free(fsp); - - return 0; -} - -/**************************************************************************** Close a directory opened by an NT SMB call. ****************************************************************************/ @@ -286,7 +271,5 @@ int close_file(files_struct *fsp, BOOL normal_close) { if(fsp->is_directory) return close_directory(fsp, normal_close); - else if(fsp->stat_open) - return close_statfile(fsp, normal_close); return close_normal_file(fsp, normal_close); } |