r11344: I don't think share mode conflicts occur on deleting
authorJeremy Allison <jra@samba.org>
Thu, 27 Oct 2005 23:30:25 +0000 (23:30 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:05:13 +0000 (11:05 -0500)
a directory when you've got permissions. Need to write
a smbtorture test for this.
Jeremy.
(This used to be commit e959a5be393eb59b8987eb6967a2ee5d11978f41)

source3/smbd/close.c
source3/smbd/notify.c

index 44ab168a3af721d2052f63ff5789eb482dd73d44..fcea62e1aa4bdbf3a116618459e917fb54263f28 100644 (file)
@@ -300,8 +300,6 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
        struct share_mode_lock *lck = 0;
        BOOL delete_dir = False;
 
-       remove_pending_change_notify_requests_by_fid(fsp);
-
        /*
         * NT can set delete_on_close of the last open
         * reference to a directory also.
@@ -320,18 +318,7 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
 
        delete_dir = lck->delete_on_close;
 
-       if (delete_dir) {
-               int i;
-               /* See if others still have the file open. If this is the
-                * case, then don't delete */
-               for (i=0; i<lck->num_share_modes; i++) {
-                       if (is_valid_share_mode_entry(&lck->share_modes[i])) {
-                               delete_dir = False;
-                               break;
-                       }
-               }
-       }
-
+       talloc_free(lck);
 
        if (normal_close && delete_dir) {
                BOOL ok = rmdir_internals(fsp->conn, fsp->fsp_name);
@@ -344,13 +331,15 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
                 */
 
                if(ok) {
-                       remove_pending_change_notify_requests_by_filename(fsp);
+                       remove_pending_change_notify_requests_by_fid(fsp, NT_STATUS_DELETE_PENDING);
+                       remove_pending_change_notify_requests_by_filename(fsp, NT_STATUS_DELETE_PENDING);
+
                }
                process_pending_change_notify_queue((time_t)0);
+       } else {
+               remove_pending_change_notify_requests_by_fid(fsp, NT_STATUS_CANCELLED);
        }
 
-       talloc_free(lck);
-
        /*
         * Do the code common to files and directories.
         */
index ad49dc0a2115b112dcecde9ab3e1081252f0b726..bc76cfb322fb3542d4da07de3861b8a5b9c58094 100644 (file)
@@ -82,13 +82,14 @@ static void change_notify_remove(struct change_notify *cnbp)
  Delete entries by fnum from the change notify pending queue.
 *****************************************************************************/
 
-void remove_pending_change_notify_requests_by_fid(files_struct *fsp)
+void remove_pending_change_notify_requests_by_fid(files_struct *fsp, NTSTATUS status)
 {
        struct change_notify *cnbp, *next;
 
        for (cnbp=change_notify_list; cnbp; cnbp=next) {
                next=cnbp->next;
                if (cnbp->fsp->fnum == fsp->fnum) {
+                       change_notify_reply_packet(cnbp->request_buf,status);
                        change_notify_remove(cnbp);
                }
        }
@@ -116,7 +117,7 @@ void remove_pending_change_notify_requests_by_mid(int mid)
  Always send reply.
 *****************************************************************************/
 
-void remove_pending_change_notify_requests_by_filename(files_struct *fsp)
+void remove_pending_change_notify_requests_by_filename(files_struct *fsp, NTSTATUS status)
 {
        struct change_notify *cnbp, *next;
 
@@ -127,7 +128,7 @@ void remove_pending_change_notify_requests_by_filename(files_struct *fsp)
                 * the filename are identical.
                 */
                if((cnbp->fsp->conn == fsp->conn) && strequal(cnbp->fsp->fsp_name,fsp->fsp_name)) {
-                       change_notify_reply_packet(cnbp->request_buf,NT_STATUS_CANCELLED);
+                       change_notify_reply_packet(cnbp->request_buf,status);
                        change_notify_remove(cnbp);
                }
        }