aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Albinus2013-07-04 11:29:28 +0200
committerMichael Albinus2013-07-04 11:29:28 +0200
commit86dfb7a8155ba4705f6bdc8e9be3a38388ad207e (patch)
tree21a64fb64ad3dd89a0a9f43e62e5fe573ca402c5 /src
parent2c1c974b061b14ec69b29c436214b0350872f14c (diff)
downloademacs-86dfb7a8155ba4705f6bdc8e9be3a38388ad207e.tar.gz
emacs-86dfb7a8155ba4705f6bdc8e9be3a38388ad207e.zip
* fileio.c (Qfile_notify_error): New error symbol.
* gfilenotify.c (Fgfile_add_watch, Fgfile_rm_watch): * inotify.c (inotify_callback, symbol_to_inotifymask) (Finotify_add_watch, Finotify_rm_watch): Use it. (inotifyevent_to_event): Exchange order of cookie and file name. (Finotify_add_watch): Adapt docstring. * lisp.h (Qfile_notify_error): Declare.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog12
-rw-r--r--src/fileio.c8
-rw-r--r--src/gfilenotify.c14
-rw-r--r--src/inotify.c34
-rw-r--r--src/lisp.h1
5 files changed, 46 insertions, 23 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1bd53573086..416e60f30a4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
12013-07-04 Michael Albinus <michael.albinus@gmx.de>
2
3 * fileio.c (Qfile_notify_error): New error symbol.
4
5 * gfilenotify.c (Fgfile_add_watch, Fgfile_rm_watch):
6 * inotify.c (inotify_callback, symbol_to_inotifymask)
7 (Finotify_add_watch, Finotify_rm_watch): Use it.
8 (inotifyevent_to_event): Exchange order of cookie and file name.
9 (Finotify_add_watch): Adapt docstring.
10
11 * lisp.h (Qfile_notify_error): Declare.
12
12013-07-04 Paul Eggert <eggert@cs.ucla.edu> 132013-07-04 Paul Eggert <eggert@cs.ucla.edu>
2 14
3 Try again to fix FreeBSD bug re multithreaded memory alloc (Bug#14569). 15 Try again to fix FreeBSD bug re multithreaded memory alloc (Bug#14569).
diff --git a/src/fileio.c b/src/fileio.c
index 4a14f5a5911..3bfea20888e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -148,7 +148,7 @@ static Lisp_Object Qdelete_directory;
148#ifdef WINDOWSNT 148#ifdef WINDOWSNT
149#endif 149#endif
150 150
151Lisp_Object Qfile_error; 151Lisp_Object Qfile_error, Qfile_notify_error;
152static Lisp_Object Qfile_already_exists, Qfile_date_error; 152static Lisp_Object Qfile_already_exists, Qfile_date_error;
153static Lisp_Object Qexcl; 153static Lisp_Object Qexcl;
154Lisp_Object Qfile_name_history; 154Lisp_Object Qfile_name_history;
@@ -5887,6 +5887,7 @@ syms_of_fileio (void)
5887 DEFSYM (Qfile_error, "file-error"); 5887 DEFSYM (Qfile_error, "file-error");
5888 DEFSYM (Qfile_already_exists, "file-already-exists"); 5888 DEFSYM (Qfile_already_exists, "file-already-exists");
5889 DEFSYM (Qfile_date_error, "file-date-error"); 5889 DEFSYM (Qfile_date_error, "file-date-error");
5890 DEFSYM (Qfile_notify_error, "file-notify-error");
5890 DEFSYM (Qexcl, "excl"); 5891 DEFSYM (Qexcl, "excl");
5891 5892
5892 DEFVAR_LISP ("file-name-coding-system", Vfile_name_coding_system, 5893 DEFVAR_LISP ("file-name-coding-system", Vfile_name_coding_system,
@@ -5925,6 +5926,11 @@ of file names regardless of the current language environment. */);
5925 Fput (Qfile_date_error, Qerror_message, 5926 Fput (Qfile_date_error, Qerror_message,
5926 build_pure_c_string ("Cannot set file date")); 5927 build_pure_c_string ("Cannot set file date"));
5927 5928
5929 Fput (Qfile_notify_error, Qerror_conditions,
5930 Fpurecopy (list3 (Qfile_notify_error, Qfile_error, Qerror)));
5931 Fput (Qfile_notify_error, Qerror_message,
5932 build_pure_c_string ("File notification error"));
5933
5928 DEFVAR_LISP ("file-name-handler-alist", Vfile_name_handler_alist, 5934 DEFVAR_LISP ("file-name-handler-alist", Vfile_name_handler_alist,
5929 doc: /* Alist of elements (REGEXP . HANDLER) for file names handled specially. 5935 doc: /* Alist of elements (REGEXP . HANDLER) for file names handled specially.
5930If a file name matches REGEXP, all I/O on that file is done by calling 5936If a file name matches REGEXP, all I/O on that file is done by calling
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index c8d12ce8fa0..4e684d1fb54 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -132,15 +132,14 @@ This arranges for filesystem events pertaining to FILE to be reported
132to Emacs. Use `gfile-rm-watch' to cancel the watch. 132to Emacs. Use `gfile-rm-watch' to cancel the watch.
133 133
134Value is a descriptor for the added watch. If the file cannot be 134Value is a descriptor for the added watch. If the file cannot be
135watched for some reason, this function signals a `file-error' error. 135watched for some reason, this function signals a `file-notify-error' error.
136 136
137FLAGS is a list of conditions to set what will be watched for. It can 137FLAGS is a list of conditions to set what will be watched for. It can
138include the following symbols: 138include the following symbols:
139 139
140 'watch-mounts' -- watch for mount events 140 'watch-mounts' -- watch for mount events
141 'send-moved' -- pair 'deleted' and 'created' events caused by file 141 'send-moved' -- pair 'deleted' and 'created' events caused by file
142 renames (moves) and send a single 'event-moved' 142 renames and send a single 'renamed' event instead
143 event instead
144 143
145When any event happens, Emacs will call the CALLBACK function passing 144When any event happens, Emacs will call the CALLBACK function passing
146it a single argument EVENT, which is of the form 145it a single argument EVENT, which is of the form
@@ -193,7 +192,7 @@ will be reported only in case of the 'moved' event. */)
193 /* Enable watch. */ 192 /* Enable watch. */
194 monitor = g_file_monitor (gfile, gflags, NULL, NULL); 193 monitor = g_file_monitor (gfile, gflags, NULL, NULL);
195 if (! monitor) 194 if (! monitor)
196 xsignal2 (Qfile_error, build_string ("Cannot watch file"), file); 195 xsignal2 (Qfile_notify_error, build_string ("Cannot watch file"), file);
197 196
198 /* On all known glib platforms, converting MONITOR directly to a 197 /* On all known glib platforms, converting MONITOR directly to a
199 Lisp_Object value results is a Lisp integer, which is safe. This 198 Lisp_Object value results is a Lisp integer, which is safe. This
@@ -202,7 +201,8 @@ will be reported only in case of the 'moved' event. */)
202 if (! INTEGERP (watch_descriptor)) 201 if (! INTEGERP (watch_descriptor))
203 { 202 {
204 g_object_unref (monitor); 203 g_object_unref (monitor);
205 xsignal2 (Qfile_error, build_string ("Unsupported file watcher"), file); 204 xsignal2 (Qfile_notify_error, build_string ("Unsupported file watcher"),
205 file);
206 } 206 }
207 207
208 g_signal_connect (monitor, "changed", 208 g_signal_connect (monitor, "changed",
@@ -226,14 +226,14 @@ WATCH-DESCRIPTOR should be an object returned by `gfile-add-watch'. */)
226 Lisp_Object watch_object = assq_no_quit (watch_descriptor, watch_list); 226 Lisp_Object watch_object = assq_no_quit (watch_descriptor, watch_list);
227 227
228 if (! CONSP (watch_object)) 228 if (! CONSP (watch_object))
229 xsignal2 (Qfile_error, build_string ("Not a watch descriptor"), 229 xsignal2 (Qfile_notify_error, build_string ("Not a watch descriptor"),
230 watch_descriptor); 230 watch_descriptor);
231 231
232 eassert (INTEGERP (watch_descriptor)); 232 eassert (INTEGERP (watch_descriptor));
233 int_monitor = XLI (watch_descriptor); 233 int_monitor = XLI (watch_descriptor);
234 monitor = (GFileMonitor *) int_monitor; 234 monitor = (GFileMonitor *) int_monitor;
235 if (!g_file_monitor_cancel (monitor)) 235 if (!g_file_monitor_cancel (monitor))
236 xsignal2 (Qfile_error, build_string ("Could not rm watch"), 236 xsignal2 (Qfile_notify_error, build_string ("Could not rm watch"),
237 watch_descriptor); 237 watch_descriptor);
238 238
239 /* Remove watch descriptor from watch list. */ 239 /* Remove watch descriptor from watch list. */
diff --git a/src/inotify.c b/src/inotify.c
index 4efef9e55b7..01fb34a5c4a 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -139,8 +139,8 @@ inotifyevent_to_event (Lisp_Object watch_object, struct inotify_event const *ev)
139 139
140 return list2 (list4 (make_watch_descriptor (ev->wd), 140 return list2 (list4 (make_watch_descriptor (ev->wd),
141 mask_to_aspects (ev->mask), 141 mask_to_aspects (ev->mask),
142 make_number (ev->cookie), 142 name,
143 name), 143 make_number (ev->cookie)),
144 XCDR (watch_object)); 144 XCDR (watch_object));
145} 145}
146 146
@@ -158,15 +158,17 @@ inotify_callback (int fd, void *_)
158 158
159 to_read = 0; 159 to_read = 0;
160 if (ioctl (fd, FIONREAD, &to_read) == -1) 160 if (ioctl (fd, FIONREAD, &to_read) == -1)
161 report_file_error ("Error while trying to retrieve file system events", 161 xsignal1
162 Qnil); 162 (Qfile_notify_error,
163 build_string ("Error while trying to retrieve file system events"));
163 buffer = xmalloc (to_read); 164 buffer = xmalloc (to_read);
164 n = read (fd, buffer, to_read); 165 n = read (fd, buffer, to_read);
165 if (n < 0) 166 if (n < 0)
166 { 167 {
167 xfree (buffer); 168 xfree (buffer);
168 report_file_error ("Error while trying to read file system events", 169 xsignal1
169 Qnil); 170 (Qfile_notify_error,
171 build_string ("Error while trying to read file system events"));
170 } 172 }
171 173
172 EVENT_INIT (event); 174 EVENT_INIT (event);
@@ -242,7 +244,7 @@ symbol_to_inotifymask (Lisp_Object symb)
242 else if (EQ (symb, Qt) || EQ (symb, Qall_events)) 244 else if (EQ (symb, Qt) || EQ (symb, Qall_events))
243 return IN_ALL_EVENTS; 245 return IN_ALL_EVENTS;
244 else 246 else
245 signal_error ("Unknown aspect", symb); 247 xsignal2 (Qfile_notify_error, build_string ("Unknown aspect"), symb);
246} 248}
247 249
248static uint32_t 250static uint32_t
@@ -298,7 +300,7 @@ Watching a directory is not recursive. CALLBACK gets called in case of an
298event. It gets passed a single argument EVENT which contains an event structure 300event. It gets passed a single argument EVENT which contains an event structure
299of the format 301of the format
300 302
301(WATCH-DESCRIPTOR ASPECTS COOKIE NAME) 303(WATCH-DESCRIPTOR ASPECTS NAME COOKIE)
302 304
303WATCH-DESCRIPTOR is the same object that was returned by this function. It can 305WATCH-DESCRIPTOR is the same object that was returned by this function. It can
304be tested for equality using `equal'. ASPECTS describes the event. It is a 306be tested for equality using `equal'. ASPECTS describes the event. It is a
@@ -310,11 +312,11 @@ isdir
310q-overflow 312q-overflow
311unmount 313unmount
312 314
315If a directory is watched then NAME is the name of file that caused the event.
316
313COOKIE is an object that can be compared using `equal' to identify two matching 317COOKIE is an object that can be compared using `equal' to identify two matching
314renames (moved-from and moved-to). 318renames (moved-from and moved-to).
315 319
316If a directory is watched then NAME is the name of file that caused the event.
317
318See inotify(7) and inotify_add_watch(2) for further information. The inotify fd 320See inotify(7) and inotify_add_watch(2) for further information. The inotify fd
319is managed internally and there is no corresponding inotify_init. Use 321is managed internally and there is no corresponding inotify_init. Use
320`inotify-rm-watch' to remove a watch. 322`inotify-rm-watch' to remove a watch.
@@ -335,8 +337,9 @@ is managed internally and there is no corresponding inotify_init. Use
335 if (inotifyfd == -1) 337 if (inotifyfd == -1)
336 { 338 {
337 inotifyfd = uninitialized; 339 inotifyfd = uninitialized;
338 report_file_error ("File watching feature (inotify) is not available", 340 xsignal1
339 Qnil); 341 (Qfile_notify_error,
342 build_string ("File watching feature (inotify) is not available"));
340 } 343 }
341 watch_list = Qnil; 344 watch_list = Qnil;
342 add_read_fd (inotifyfd, &inotify_callback, NULL); 345 add_read_fd (inotifyfd, &inotify_callback, NULL);
@@ -346,7 +349,8 @@ is managed internally and there is no corresponding inotify_init. Use
346 encoded_file_name = ENCODE_FILE (file_name); 349 encoded_file_name = ENCODE_FILE (file_name);
347 watchdesc = inotify_add_watch (inotifyfd, SSDATA (encoded_file_name), mask); 350 watchdesc = inotify_add_watch (inotifyfd, SSDATA (encoded_file_name), mask);
348 if (watchdesc == -1) 351 if (watchdesc == -1)
349 report_file_error ("Could not add watch for file", Fcons (file_name, Qnil)); 352 xsignal2 (Qfile_notify_error,
353 build_string ("Could not add watch for file"), file_name);
350 354
351 watch_descriptor = make_watch_descriptor (watchdesc); 355 watch_descriptor = make_watch_descriptor (watchdesc);
352 356
@@ -375,8 +379,8 @@ See inotify_rm_watch(2) for more information.
375 int wd = XINT (watch_descriptor); 379 int wd = XINT (watch_descriptor);
376 380
377 if (inotify_rm_watch (inotifyfd, wd) == -1) 381 if (inotify_rm_watch (inotifyfd, wd) == -1)
378 report_file_error ("Could not rm watch", Fcons (watch_descriptor, 382 xsignal2 (Qfile_notify_error,
379 Qnil)); 383 build_string ("Could not rm watch"), watch_descriptor);
380 384
381 /* Remove watch descriptor from watch list. */ 385 /* Remove watch descriptor from watch list. */
382 watch_object = Fassoc (watch_descriptor, watch_list); 386 watch_object = Fassoc (watch_descriptor, watch_list);
diff --git a/src/lisp.h b/src/lisp.h
index 74f52b318f5..5d6fa760108 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3809,6 +3809,7 @@ extern void syms_of_marker (void);
3809/* Defined in fileio.c. */ 3809/* Defined in fileio.c. */
3810 3810
3811extern Lisp_Object Qfile_error; 3811extern Lisp_Object Qfile_error;
3812extern Lisp_Object Qfile_notify_error;
3812extern Lisp_Object Qfile_exists_p; 3813extern Lisp_Object Qfile_exists_p;
3813extern Lisp_Object Qfile_directory_p; 3814extern Lisp_Object Qfile_directory_p;
3814extern Lisp_Object Qinsert_file_contents; 3815extern Lisp_Object Qinsert_file_contents;