Subject: bug#66381: 29.1; Auto-revert not polling files when notifications are enabled

From: Michael Albinus <[email-masked]>
Date: Sun, 08 Oct 2023 14:38:22 +0200

Michael Albinus <[email-masked]> writes:

Hi,

> The problem is, that in Daniel's case we get no information that file
> notification has ceased to work for the re-mounted file system (no
> IN_IGNORED event from inotify). auto-revert-notify-watch-descriptor
> still exists, and auto-revert-notify-modified-p isn't modified any
> longer. Therefore the file is not reverted even while polling.

I've debugged further, and it looks like there is a gap in forwarding
the IN_IGNORED event from inotify.c to filenotify.el. Oops.

Daniel, could you pls try the appended patch? It shall enable this to
work, meaning auto-revert-mode is informed about the unmounted file
system. I've tested with an NFS mount, 'tho.

Best regards, Michael.

diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index e9f8d4e515d..16a154723b8 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -138,7 +138,7 @@ file-notify--callback-inotify
                         ((memq action '(delete delete-self move-self)) 'deleted)
                         ((eq action 'moved-from) 'renamed-from)
                         ((eq action 'moved-to) 'renamed-to)
-                        ((eq action 'ignored) 'stopped)))
+                        ((memq action '(ignored unmount)) 'stopped)))
                      actions))
    file file1-or-cookie))

@@ -202,7 +202,7 @@ file-notify-callback
                  ((memq action '(delete delete-self move-self)) 'deleted)
                  ((eq action 'moved-from) 'renamed-from)
                  ((eq action 'moved-to) 'renamed-to)
-                 ((eq action 'ignored) 'stopped)))
+                 ((memq action '(ignored unmount)) 'stopped)))
               (if (consp actions) actions (list actions))))
    file file1-or-cookie))

@@ -339,7 +339,7 @@ file-notify--add-watch-inotify
   "Add a watch for FILE in DIR with FLAGS, using inotify."
   (inotify-add-watch dir
                      (append
-                      '(dont-follow)
+                      '(dont-follow ignored unmount)
                       (and (memq 'change flags)
                            '(create delete delete-self modify move-self move))
                       (and (memq 'attribute-change flags)
diff --git a/src/inotify.c b/src/inotify.c
index 105ff5a9d8a..247d9f03055 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -148,6 +148,11 @@ symbol_to_inotifymask (Lisp_Object symb)
   else if (EQ (symb, Qonlydir))
     return IN_ONLYDIR;

+  else if (EQ (symb, Qignored))
+    return IN_IGNORED;
+  else if (EQ (symb, Qunmount))
+    return IN_UNMOUNT;
+
   else if (EQ (symb, Qt) || EQ (symb, Qall_events))
     return IN_ALL_EVENTS;
   else