inotify does not work on /proc
Hi,
I wrote a simple inotify program for monitoring the changes in a file system.
But the code seems to work for other directories except /proc.
#include <stdio.h>
#include <stdlib.h>
#include <sys/inotify.h>
#include <sys/types.h>
#define EVENT_SIZE (sizeof (struct inotify_event))
#define BUF_LEN (1024 * (EVENT_SIZE + 16) )
int
main (int argc, char *argv[])
{
int wd;
int fd;
char buf[BUF_LEN];
int len, i = 0;
fd = inotify_init ();
if (fd < 0)
{
exit (-1);
}
wd = inotify_add_watch (fd, "/proc", IN_CREATE);
if (wd < 0)
exit(-1);
else
{
len = read (fd, buf, BUF_LEN);
while (i < len)
{
struct inotify_event *event;
event = (struct inotify_event *) &buf[i];
printf ("wd=%d mask=%u cookie=%u len=%u\n",
event->wd, event->mask, event->cookie, event->len);
if (event->len)
printf ("name=%s\n", event->name);
i += EVENT_SIZE + event->len;
}
}
return 0;
}
Could any body help me...
Thanks.
|