From: Tim Prouty Date: Sun, 7 Dec 2008 00:08:35 +0000 (-0800) Subject: Fix a delete on close divergence from windows [2/2] X-Git-Tag: samba-3.3.0rc2~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8512b4bde5a315dfccabbeb1a3938f4eace63336;p=thirdparty%2Fsamba.git Fix a delete on close divergence from windows [2/2] This second patch cleans up by removing all of the code that is made obsolete by the first patch. It should cause no functional changes. (cherry picked from commit c39c35f3e67a726c6464c1497e46fe7a2eb3dc77) --- diff --git a/source/include/proto.h b/source/include/proto.h index 4c06863694b..41624c95235 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -5213,7 +5213,7 @@ bool is_valid_share_mode_entry(const struct share_mode_entry *e); bool is_deferred_open_entry(const struct share_mode_entry *e); bool is_unused_share_mode_entry(const struct share_mode_entry *e); void set_share_mode(struct share_mode_lock *lck, files_struct *fsp, - uid_t uid, uint16 mid, uint16 op_type, bool initial_delete_on_close_allowed); + uid_t uid, uint16 mid, uint16 op_type); void add_deferred_open(struct share_mode_lock *lck, uint16 mid, struct timeval request_time, struct file_id id); @@ -5223,11 +5223,9 @@ bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp); bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp); NTSTATUS can_set_delete_on_close(files_struct *fsp, bool delete_on_close, uint32 dosmode); -bool can_set_initial_delete_on_close(const struct share_mode_lock *lck); void set_delete_on_close_token(struct share_mode_lock *lck, UNIX_USER_TOKEN *tok); void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, UNIX_USER_TOKEN *tok); bool set_delete_on_close(files_struct *fsp, bool delete_on_close, UNIX_USER_TOKEN *tok); -bool set_allow_initial_delete_on_close(struct share_mode_lock *lck, files_struct *fsp, bool delete_on_close); bool set_sticky_write_time(struct file_id fileid, struct timespec write_time); bool set_write_time(struct file_id fileid, struct timespec write_time); int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *, diff --git a/source/include/smb.h b/source/include/smb.h index bcf7de900f4..7f82f729ede 100644 --- a/source/include/smb.h +++ b/source/include/smb.h @@ -717,7 +717,6 @@ struct pending_message_list { }; #define SHARE_MODE_FLAG_POSIX_OPEN 0x1 -#define SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE 0x2 /* struct returned by get_share_modes */ struct share_mode_entry { diff --git a/source/locking/locking.c b/source/locking/locking.c index 368ab1687cc..c30a1052240 100644 --- a/source/locking/locking.c +++ b/source/locking/locking.c @@ -1067,13 +1067,10 @@ static void add_share_mode_entry(struct share_mode_lock *lck, } void set_share_mode(struct share_mode_lock *lck, files_struct *fsp, - uid_t uid, uint16 mid, uint16 op_type, bool initial_delete_on_close_allowed) + uid_t uid, uint16 mid, uint16 op_type) { struct share_mode_entry entry; fill_share_mode_entry(&entry, fsp, uid, mid, op_type); - if (initial_delete_on_close_allowed) { - entry.flags |= SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE; - } add_share_mode_entry(lck, &entry); } @@ -1271,22 +1268,6 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, bool delete_on_close, return NT_STATUS_OK; } -/**************************************************************************** - Do we have an open file handle that created this entry ? -****************************************************************************/ - -bool can_set_initial_delete_on_close(const struct share_mode_lock *lck) -{ - int i; - - for (i=0; inum_share_modes; i++) { - if (lck->share_modes[i].flags & SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE) { - return True; - } - } - return False; -} - /************************************************************************* Return a talloced copy of a UNIX_USER_TOKEN. NULL on fail. (Should this be in locking.c.... ?). @@ -1380,31 +1361,6 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close, UNIX_USER_TOKE return True; } -/**************************************************************************** - Sets the allow initial delete on close flag for this share mode. -****************************************************************************/ - -bool set_allow_initial_delete_on_close(struct share_mode_lock *lck, files_struct *fsp, bool delete_on_close) -{ - struct share_mode_entry entry, *e; - - /* Don't care about the pid owner being correct here - just a search. */ - fill_share_mode_entry(&entry, fsp, (uid_t)-1, 0, NO_OPLOCK); - - e = find_share_mode_entry(lck, &entry); - if (e == NULL) { - return False; - } - - if (delete_on_close) { - e->flags |= SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE; - } else { - e->flags &= ~SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE; - } - lck->modified = True; - return True; -} - bool set_sticky_write_time(struct file_id fileid, struct timespec write_time) { struct share_mode_lock *lck; diff --git a/source/smbd/open.c b/source/smbd/open.c index 74c1c2223d6..7043f512e84 100644 --- a/source/smbd/open.c +++ b/source/smbd/open.c @@ -1962,7 +1962,7 @@ static NTSTATUS open_file_ntcreate_internal(connection_struct *conn, } set_share_mode(lck, fsp, conn->server_info->utok.uid, 0, - fsp->oplock_type, new_file_created); + fsp->oplock_type); /* Handle strange delete on close create semantics. */ if (create_options & FILE_DELETE_ON_CLOSE) { @@ -2433,8 +2433,7 @@ NTSTATUS open_directory(connection_struct *conn, return status; } - set_share_mode(lck, fsp, conn->server_info->utok.uid, 0, NO_OPLOCK, - True); + set_share_mode(lck, fsp, conn->server_info->utok.uid, 0, NO_OPLOCK); /* For directories the delete on close bit at open time seems always to be honored on close... See test 19 in Samba4 BASE-DELETE. */ diff --git a/source/smbd/reply.c b/source/smbd/reply.c index afcb5b286ad..7e8f17a286c 100644 --- a/source/smbd/reply.c +++ b/source/smbd/reply.c @@ -5650,8 +5650,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, * depends on these semantics. JRA. */ - set_allow_initial_delete_on_close(lck, fsp, True); - if (create_options & FILE_DELETE_ON_CLOSE) { status = can_set_delete_on_close(fsp, True, 0);