summaryrefslogtreecommitdiff
path: root/source3/smbd/close.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-07-08 04:51:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:58:18 -0500
commitaf8a691db11a5072865f8b03fd1cbd3aab5cb6d7 (patch)
tree0779dd2d2c6d9ea3eae0f094803f6ba3b3c56f24 /source3/smbd/close.c
parent22268d79265d79b8d86d1152a7bfe2ebc8988905 (diff)
downloadsamba-af8a691db11a5072865f8b03fd1cbd3aab5cb6d7.tar.gz
samba-af8a691db11a5072865f8b03fd1cbd3aab5cb6d7.tar.bz2
samba-af8a691db11a5072865f8b03fd1cbd3aab5cb6d7.zip
r8219: Merge the new open code from HEAD to 3.0. Haven't yet run the torture
tests on this as it's very late NY time (just wanted to get this work into the tree). I'll test this over the weekend.... Jerry - in looking at the difference between the two trees there seem to be some printing/ntprinting.c and registry changes we might want to examine to try keep in sync. Jeremy. (This used to be commit c7fe18761e2c753afbffd3a78abff46472a9b8eb)
Diffstat (limited to 'source3/smbd/close.c')
-rw-r--r--source3/smbd/close.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index b7649bcce4..3fc7fdb059 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -3,6 +3,7 @@
file closing
Copyright (C) Andrew Tridgell 1992-1998
Copyright (C) Jeremy Allison 1992-2004.
+ Copyright (C) Volker Lendecke 2005
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -92,7 +93,7 @@ static int close_filestruct(files_struct *fsp)
connection_struct *conn = fsp->conn;
int ret = 0;
- if (fsp->fd != -1) {
+ if (fsp->fh->fd != -1) {
if(flush_write_cache(fsp, CLOSE_FLUSH) == -1)
ret = -1;
@@ -148,7 +149,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
{
share_mode_entry *share_entry = NULL;
size_t share_entry_count = 0;
- BOOL delete_on_close = False;
+ BOOL delete_file = False;
connection_struct *conn = fsp->conn;
int saved_errno = 0;
int err = 0;
@@ -194,34 +195,16 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
lock_share_entry_fsp(fsp);
- if (fsp->delete_on_close) {
-
- /*
- * Modify the share mode entry for all files open
- * on this device and inode to tell other smbds we have
- * changed the delete on close flag. The last closer will delete the file
- * if flag is set.
- */
-
- NTSTATUS status =set_delete_on_close_over_all(fsp, fsp->delete_on_close);
- if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_OK))
- DEBUG(0,("close_normal_file: failed to change delete on close flag for file %s\n",
- fsp->fsp_name ));
- }
-
- share_entry_count = del_share_mode(fsp, &share_entry);
+ share_entry_count = del_share_mode(fsp, &share_entry,
+ &delete_file);
DEBUG(10,("close_normal_file: share_entry_count = %lu for file %s\n",
(unsigned long)share_entry_count, fsp->fsp_name ));
- /*
- * We delete on close if it's the last open, and the
- * delete on close flag was set in the entry we just deleted.
- */
-
- if ((share_entry_count == 0) && share_entry &&
- GET_DELETE_ON_CLOSE_FLAG(share_entry->share_mode) )
- delete_on_close = True;
+ if (share_entry_count != 0) {
+ /* We're not the last ones -- don't delete */
+ delete_file = False;
+ }
SAFE_FREE(share_entry);
@@ -233,7 +216,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
* reference to a file.
*/
- if (normal_close && delete_on_close) {
+ if (normal_close && delete_file) {
DEBUG(5,("close_file: file %s. Delete on close was set - deleting file.\n",
fsp->fsp_name));
if(SMB_VFS_UNLINK(conn,fsp->fsp_name) != 0) {
@@ -311,7 +294,8 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
* reference to a directory also.
*/
- if (normal_close && fsp->directory_delete_on_close) {
+ if (normal_close &&
+ get_delete_on_close_flag(fsp->dev, fsp->inode)) {
BOOL ok = rmdir_internals(fsp->conn, fsp->fsp_name);
DEBUG(5,("close_directory: %s. Delete on close was set - deleting directory %s.\n",
fsp->fsp_name, ok ? "succeeded" : "failed" ));
@@ -321,8 +305,9 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
* now fail as the directory has been deleted.
*/
- if(ok)
+ if(ok) {
remove_pending_change_notify_requests_by_filename(fsp);
+ }
process_pending_change_notify_queue((time_t)0);
}
@@ -331,8 +316,9 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
*/
close_filestruct(fsp);
- if (fsp->fsp_name)
+ if (fsp->fsp_name) {
string_free(&fsp->fsp_name);
+ }
file_free(fsp);
return 0;