|
|
inotify_glue_watch (int fd, const char *filename, __u32 mask) | inotify_glue_watch (int fd, const char *filename, __u32 mask) |
{ | { |
struct inotify_watch_request iwr; | struct inotify_watch_request iwr; |
__s32 wd; |
int file_fd, wd; |
| |
iwr.mask = mask; |
file_fd = open (filename, O_RDONLY); |
iwr.name = strdup (filename); |
if (file_fd < 0) { |
if (!iwr.name) { |
perror ("open"); |
perror ("strdup"); |
|
return -1; | return -1; |
} | } |
| |
|
iwr.fd = file_fd; |
|
iwr.mask = mask; |
|
|
wd = ioctl (fd, INOTIFY_WATCH, &iwr); | wd = ioctl (fd, INOTIFY_WATCH, &iwr); |
if (wd < 0) | if (wd < 0) |
perror ("ioctl"); | perror ("ioctl"); |
| |
free (iwr.name); |
if (close (file_fd)) |
|
perror ("close"); |
| |
return wd; | return wd; |
} | } |