Not receiving MOVE_TO events with inotify

From: Michal Suchanek
Date: Wed Oct 12 2005 - 15:26:58 EST


I tried the inotify feature and I found I do not receive MOVE_TO events.
I use linux 2.6.13 from Debian, ext3 filesystem.

I set a watch on /tmp. When I move /tmp/file_a to /tmp/file_b I
receive only one event on file_a (I assume it is move_from, I did not
decode it).

Attaching a small C program that I used to print events that occur on /tmp.


Michal Suchanek

Support the freedom of music!
Maybe it's a weird genre .. but weird is *not* illegal.
Maybe next time they will send a special forces commando to your picnic ..
.. because they think you are weird.
#include <linux/inotify.h>
#include <sys/syscall.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>

static inline _syscall0(int, inotify_init);

static inline _syscall3(int, inotify_add_watch, int, fd, const char *, path, __u32, mask);

static inline _syscall2(int, inotify_rm_watch, int, fd, int, wd);

#define BUFSIZE 4096

typedef struct inotify_event ine;

int main (int argc, char ** argv)
int fd = inotify_init();
int wd = inotify_add_watch(fd, "/tmp", IN_ALL_EVENTS);
static char buf[BUFSIZE];
size_t len;

ine * pev;
len = read(fd, buf, BUFSIZE);
if(!len) { putchar('.'); sleep(5); continue;}
pev = (ine *) buf;
while(buf + len > (char *)pev) {
fprintf(stderr, "%s(%u): %x\n", pev->len ? pev->name : "(self)" , pev->wd, pev->mask);
pev = (ine *)((char *)(pev + 1)) + pev->len;