|
Lines 85-104
Link Here
|
| 85 |
inotify_glue_watch (int fd, const char *filename, __u32 mask) |
85 |
inotify_glue_watch (int fd, const char *filename, __u32 mask) |
| 86 |
{ |
86 |
{ |
| 87 |
struct inotify_watch_request iwr; |
87 |
struct inotify_watch_request iwr; |
| 88 |
__s32 wd; |
88 |
int file_fd, wd; |
| 89 |
|
89 |
|
| 90 |
iwr.mask = mask; |
90 |
file_fd = open (filename, O_RDONLY); |
| 91 |
iwr.name = strdup (filename); |
91 |
if (file_fd < 0) { |
| 92 |
if (!iwr.name) { |
92 |
perror ("open"); |
| 93 |
perror ("strdup"); |
|
|
| 94 |
return -1; |
93 |
return -1; |
| 95 |
} |
94 |
} |
| 96 |
|
95 |
|
|
|
96 |
iwr.fd = file_fd; |
| 97 |
iwr.mask = mask; |
| 98 |
|
| 97 |
wd = ioctl (fd, INOTIFY_WATCH, &iwr); |
99 |
wd = ioctl (fd, INOTIFY_WATCH, &iwr); |
| 98 |
if (wd < 0) |
100 |
if (wd < 0) |
| 99 |
perror ("ioctl"); |
101 |
perror ("ioctl"); |
| 100 |
|
102 |
|
| 101 |
free (iwr.name); |
103 |
if (close (file_fd)) |
|
|
104 |
perror ("close"); |
| 102 |
|
105 |
|
| 103 |
return wd; |
106 |
return wd; |
| 104 |
} |
107 |
} |