aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Albinus2023-10-10 19:51:22 +0200
committerMichael Albinus2023-10-10 19:51:22 +0200
commitf7185ca29b5086b1b0f32e64b7a5ba0bc21152c8 (patch)
treed49081a3d1523e43beb3deea51eeec3a9562f13a /src
parent294567d171c9f1fbc961ea43c899269f46140570 (diff)
downloademacs-f7185ca29b5086b1b0f32e64b7a5ba0bc21152c8.tar.gz
emacs-f7185ca29b5086b1b0f32e64b7a5ba0bc21152c8.zip
File notifications report unmount events (bug#66381)
* doc/lispref/os.texi (File Notifications): Unmounting a watched filesystem is reported now. * etc/NEWS: File notifications report unmount events now. Fix typos. * lisp/filenotify.el (file-notify--callback-inotify) (file-notify--add-watch-inotify): Handle `unmount'. (file-notify--callback-kqueue, file-notify--add-watch-kqueue): Handle `revoke'. (file-notify--callback-gfilenotify): Handle `unmounted'. (file-notify-callback): Handle `unmount' and `unmounted'. (file-notify--add-watch-inotify): * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-notify-add-watch): Handle `unmounted'. * lisp/net/tramp-sh.el (tramp-sh-handle-file-notify-add-watch): Handle `unmount' and `unmounted'. * src/gfilenotify.c (dir_monitor_callback): Handle Qunmounted. * src/inotify.c (symbol_to_inotifymask): Handle IN_IGNORED and IN_UNMOUNT. * src/kqueue.c (kqueue_callback, Fkqueue_add_watch): Handle NOTE_REVOKE. (Fkqueue_add_watch): Adapt docstring. (syms_of_kqueue): Declare `revoke.
Diffstat (limited to 'src')
-rw-r--r--src/gfilenotify.c8
-rw-r--r--src/inotify.c5
-rw-r--r--src/kqueue.c10
3 files changed, 18 insertions, 5 deletions
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index de09ffe5fd3..3dd6390db10 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -88,7 +88,9 @@ dir_monitor_callback (GFileMonitor *monitor,
88 && !NILP (Fmember (symbol, list5 (Qchanged, Qchanges_done_hint, 88 && !NILP (Fmember (symbol, list5 (Qchanged, Qchanges_done_hint,
89 Qdeleted, Qcreated, Qmoved)))) 89 Qdeleted, Qcreated, Qmoved))))
90 || (!NILP (Fmember (Qattribute_change, flags)) 90 || (!NILP (Fmember (Qattribute_change, flags))
91 && EQ (symbol, Qattribute_changed))) 91 && EQ (symbol, Qattribute_changed))
92 || (!NILP (Fmember (Qwatch_mounts, flags))
93 && EQ (symbol, Qunmounted)))
92 { 94 {
93 /* Construct an event. */ 95 /* Construct an event. */
94 EVENT_INIT (event); 96 EVENT_INIT (event);
@@ -105,8 +107,8 @@ dir_monitor_callback (GFileMonitor *monitor,
105 /* XD_DEBUG_MESSAGE ("%s", XD_OBJECT_TO_STRING (event.arg)); */ 107 /* XD_DEBUG_MESSAGE ("%s", XD_OBJECT_TO_STRING (event.arg)); */
106 } 108 }
107 109
108 /* Cancel monitor if file or directory is deleted. */ 110 /* Cancel monitor if file or directory is deleted or unmounted. */
109 if (!NILP (Fmember (symbol, list2 (Qdeleted, Qmoved))) 111 if (!NILP (Fmember (symbol, list3 (Qdeleted, Qmoved, Qunmounted)))
110 && strcmp (name, SSDATA (XCAR (XCDR (watch_object)))) == 0 112 && strcmp (name, SSDATA (XCAR (XCDR (watch_object)))) == 0
111 && !g_file_monitor_is_cancelled (monitor)) 113 && !g_file_monitor_is_cancelled (monitor))
112 g_file_monitor_cancel (monitor); 114 g_file_monitor_cancel (monitor);
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)
148 else if (EQ (symb, Qonlydir)) 148 else if (EQ (symb, Qonlydir))
149 return IN_ONLYDIR; 149 return IN_ONLYDIR;
150 150
151 else if (EQ (symb, Qignored))
152 return IN_IGNORED;
153 else if (EQ (symb, Qunmount))
154 return IN_UNMOUNT;
155
151 else if (EQ (symb, Qt) || EQ (symb, Qall_events)) 156 else if (EQ (symb, Qt) || EQ (symb, Qall_events))
152 return IN_ALL_EVENTS; 157 return IN_ALL_EVENTS;
153 else 158 else
diff --git a/src/kqueue.c b/src/kqueue.c
index 22c279b7ce3..43d5f40624b 100644
--- a/src/kqueue.c
+++ b/src/kqueue.c
@@ -320,13 +320,16 @@ kqueue_callback (int fd, void *data)
320 directory is monitored. */ 320 directory is monitored. */
321 if (kev.fflags & NOTE_RENAME) 321 if (kev.fflags & NOTE_RENAME)
322 actions = Fcons (Qrename, actions); 322 actions = Fcons (Qrename, actions);
323 if (kev.fflags & NOTE_REVOKE)
324 actions = Fcons (Qrevoke, actions);
323 325
324 /* Create the event. */ 326 /* Create the event. */
325 if (! NILP (actions)) 327 if (! NILP (actions))
326 kqueue_generate_event (watch_object, actions, file, Qnil); 328 kqueue_generate_event (watch_object, actions, file, Qnil);
327 329
328 /* Cancel monitor if file or directory is deleted or renamed. */ 330 /* Cancel monitor if file or directory is deleted or renamed or
329 if (kev.fflags & (NOTE_DELETE | NOTE_RENAME)) 331 the file system is unmounted. */
332 if (kev.fflags & (NOTE_DELETE | NOTE_RENAME | NOTE_REVOKE))
330 Fkqueue_rm_watch (descriptor); 333 Fkqueue_rm_watch (descriptor);
331 } 334 }
332 return; 335 return;
@@ -351,6 +354,7 @@ following symbols:
351 `attrib' -- a FILE attribute was changed 354 `attrib' -- a FILE attribute was changed
352 `link' -- a FILE's link count was changed 355 `link' -- a FILE's link count was changed
353 `rename' -- FILE was moved to FILE1 356 `rename' -- FILE was moved to FILE1
357 `revoke' -- FILE was unmounted
354 358
355When any event happens, Emacs will call the CALLBACK function passing 359When any event happens, Emacs will call the CALLBACK function passing
356it a single argument EVENT, which is of the form 360it a single argument EVENT, which is of the form
@@ -437,6 +441,7 @@ only when the upper directory of the renamed file is watched. */)
437 if (! NILP (Fmember (Qattrib, flags))) fflags |= NOTE_ATTRIB; 441 if (! NILP (Fmember (Qattrib, flags))) fflags |= NOTE_ATTRIB;
438 if (! NILP (Fmember (Qlink, flags))) fflags |= NOTE_LINK; 442 if (! NILP (Fmember (Qlink, flags))) fflags |= NOTE_LINK;
439 if (! NILP (Fmember (Qrename, flags))) fflags |= NOTE_RENAME; 443 if (! NILP (Fmember (Qrename, flags))) fflags |= NOTE_RENAME;
444 if (! NILP (Fmember (Qrevoke, flags))) fflags |= NOTE_REVOKE;
440 445
441 /* Register event. */ 446 /* Register event. */
442 EV_SET (&kev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, 447 EV_SET (&kev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR,
@@ -526,6 +531,7 @@ syms_of_kqueue (void)
526 DEFSYM (Qattrib, "attrib"); /* NOTE_ATTRIB */ 531 DEFSYM (Qattrib, "attrib"); /* NOTE_ATTRIB */
527 DEFSYM (Qlink, "link"); /* NOTE_LINK */ 532 DEFSYM (Qlink, "link"); /* NOTE_LINK */
528 DEFSYM (Qrename, "rename"); /* NOTE_RENAME */ 533 DEFSYM (Qrename, "rename"); /* NOTE_RENAME */
534 DEFSYM (Qrevoke, "revoke"); /* NOTE_REVOKE */
529 535
530 staticpro (&watch_list); 536 staticpro (&watch_list);
531 537