summaryrefslogtreecommitdiff
path: root/src/inotify.c
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2013-07-04 11:29:28 +0200
committerMichael Albinus <michael.albinus@gmx.de>2013-07-04 11:29:28 +0200
commit86dfb7a8155ba4705f6bdc8e9be3a38388ad207e (patch)
tree21a64fb64ad3dd89a0a9f43e62e5fe573ca402c5 /src/inotify.c
parent2c1c974b061b14ec69b29c436214b0350872f14c (diff)
downloademacs-86dfb7a8155ba4705f6bdc8e9be3a38388ad207e.tar.gz
* 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/inotify.c')
-rw-r--r--src/inotify.c34
1 files changed, 19 insertions, 15 deletions
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)
return list2 (list4 (make_watch_descriptor (ev->wd),
mask_to_aspects (ev->mask),
- make_number (ev->cookie),
- name),
+ name,
+ make_number (ev->cookie)),
XCDR (watch_object));
}
@@ -158,15 +158,17 @@ inotify_callback (int fd, void *_)
to_read = 0;
if (ioctl (fd, FIONREAD, &to_read) == -1)
- report_file_error ("Error while trying to retrieve file system events",
- Qnil);
+ xsignal1
+ (Qfile_notify_error,
+ build_string ("Error while trying to retrieve file system events"));
buffer = xmalloc (to_read);
n = read (fd, buffer, to_read);
if (n < 0)
{
xfree (buffer);
- report_file_error ("Error while trying to read file system events",
- Qnil);
+ xsignal1
+ (Qfile_notify_error,
+ build_string ("Error while trying to read file system events"));
}
EVENT_INIT (event);
@@ -242,7 +244,7 @@ symbol_to_inotifymask (Lisp_Object symb)
else if (EQ (symb, Qt) || EQ (symb, Qall_events))
return IN_ALL_EVENTS;
else
- signal_error ("Unknown aspect", symb);
+ xsignal2 (Qfile_notify_error, build_string ("Unknown aspect"), symb);
}
static uint32_t
@@ -298,7 +300,7 @@ Watching a directory is not recursive. CALLBACK gets called in case of an
event. It gets passed a single argument EVENT which contains an event structure
of the format
-(WATCH-DESCRIPTOR ASPECTS COOKIE NAME)
+(WATCH-DESCRIPTOR ASPECTS NAME COOKIE)
WATCH-DESCRIPTOR is the same object that was returned by this function. It can
be tested for equality using `equal'. ASPECTS describes the event. It is a
@@ -310,11 +312,11 @@ isdir
q-overflow
unmount
+If a directory is watched then NAME is the name of file that caused the event.
+
COOKIE is an object that can be compared using `equal' to identify two matching
renames (moved-from and moved-to).
-If a directory is watched then NAME is the name of file that caused the event.
-
See inotify(7) and inotify_add_watch(2) for further information. The inotify fd
is managed internally and there is no corresponding inotify_init. Use
`inotify-rm-watch' to remove a watch.
@@ -335,8 +337,9 @@ is managed internally and there is no corresponding inotify_init. Use
if (inotifyfd == -1)
{
inotifyfd = uninitialized;
- report_file_error ("File watching feature (inotify) is not available",
- Qnil);
+ xsignal1
+ (Qfile_notify_error,
+ build_string ("File watching feature (inotify) is not available"));
}
watch_list = Qnil;
add_read_fd (inotifyfd, &inotify_callback, NULL);
@@ -346,7 +349,8 @@ is managed internally and there is no corresponding inotify_init. Use
encoded_file_name = ENCODE_FILE (file_name);
watchdesc = inotify_add_watch (inotifyfd, SSDATA (encoded_file_name), mask);
if (watchdesc == -1)
- report_file_error ("Could not add watch for file", Fcons (file_name, Qnil));
+ xsignal2 (Qfile_notify_error,
+ build_string ("Could not add watch for file"), file_name);
watch_descriptor = make_watch_descriptor (watchdesc);
@@ -375,8 +379,8 @@ See inotify_rm_watch(2) for more information.
int wd = XINT (watch_descriptor);
if (inotify_rm_watch (inotifyfd, wd) == -1)
- report_file_error ("Could not rm watch", Fcons (watch_descriptor,
- Qnil));
+ xsignal2 (Qfile_notify_error,
+ build_string ("Could not rm watch"), watch_descriptor);
/* Remove watch descriptor from watch list. */
watch_object = Fassoc (watch_descriptor, watch_list);