svn commit: samba r14926 - in
branches/SAMBA_4_0/source/ntvfs/sysdep: .
tridge at samba.org
tridge at samba.org
Wed Apr 5 08:52:56 GMT 2006
Author: tridge
Date: 2006-04-05 08:52:55 +0000 (Wed, 05 Apr 2006)
New Revision: 14926
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14926
Log:
change the inotify backend to implement the rather unusual semantics
for rename. The cookies in inotify tell us (indirectly!) if its a
rename between directories or not
Modified:
branches/SAMBA_4_0/source/ntvfs/sysdep/inotify.c
Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/sysdep/inotify.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/sysdep/inotify.c 2006-04-05 08:52:03 UTC (rev 14925)
+++ branches/SAMBA_4_0/source/ntvfs/sysdep/inotify.c 2006-04-05 08:52:55 UTC (rev 14926)
@@ -90,8 +90,13 @@
/*
dispatch one inotify event
+
+ the cookies are used to correctly handle renames
*/
-static void inotify_dispatch(struct inotify_private *in, struct inotify_event *e)
+static void inotify_dispatch(struct inotify_private *in,
+ struct inotify_event *e,
+ uint32_t prev_cookie,
+ uint32_t next_cookie)
{
struct watch_context *w;
struct notify_event ne;
@@ -101,11 +106,24 @@
return;
}
- /* map the inotify mask to a action */
+ /* map the inotify mask to a action. This gets complicated for
+ renames */
if (e->mask & IN_CREATE) {
ne.action = NOTIFY_ACTION_ADDED;
} else if (e->mask & IN_DELETE) {
ne.action = NOTIFY_ACTION_REMOVED;
+ } else if (e->mask & IN_MOVED_FROM) {
+ if (e->cookie == next_cookie) {
+ ne.action = NOTIFY_ACTION_OLD_NAME;
+ } else {
+ ne.action = NOTIFY_ACTION_REMOVED;
+ }
+ } else if (e->mask & IN_MOVED_TO) {
+ if (e->cookie == prev_cookie) {
+ ne.action = NOTIFY_ACTION_NEW_NAME;
+ } else {
+ ne.action = NOTIFY_ACTION_ADDED;
+ }
} else {
ne.action = NOTIFY_ACTION_MODIFIED;
}
@@ -129,6 +147,7 @@
struct inotify_private *in = talloc_get_type(private, struct inotify_private);
int bufsize = 0;
struct inotify_event *e0, *e;
+ uint32_t prev_cookie=0;
/*
we must use FIONREAD as we cannot predict the length of the
@@ -152,9 +171,14 @@
/* we can get more than one event in the buffer */
while (bufsize >= sizeof(*e)) {
- inotify_dispatch(in, e);
+ struct inotify_event *e2 = NULL;
bufsize -= e->len + sizeof(*e);
- e = (struct inotify_event *)(e->len + sizeof(*e) + (char *)e);
+ if (bufsize >= sizeof(*e)) {
+ e2 = (struct inotify_event *)(e->len + sizeof(*e) + (char *)e);
+ }
+ inotify_dispatch(in, e, prev_cookie, e2?e2->cookie:0);
+ prev_cookie = e->cookie;
+ e = e2;
}
talloc_free(e0);
More information about the samba-cvs
mailing list