|
Lines 37-42
Link Here
|
| 37 |
#include <asm/ioctls.h> |
37 |
#include <asm/ioctls.h> |
| 38 |
|
38 |
|
| 39 |
static atomic_t inotify_cookie; |
39 |
static atomic_t inotify_cookie; |
|
|
40 |
static atomic_t inotify_watches; |
| 40 |
|
41 |
|
| 41 |
static kmem_cache_t *watch_cachep; |
42 |
static kmem_cache_t *watch_cachep; |
| 42 |
static kmem_cache_t *event_cachep; |
43 |
static kmem_cache_t *event_cachep; |
|
Lines 175-180
Link Here
|
| 175 |
if (atomic_dec_and_test(&dev->count)) { |
176 |
if (atomic_dec_and_test(&dev->count)) { |
| 176 |
atomic_dec(&dev->user->inotify_devs); |
177 |
atomic_dec(&dev->user->inotify_devs); |
| 177 |
free_uid(dev->user); |
178 |
free_uid(dev->user); |
|
|
179 |
idr_destroy(&dev->idr); |
| 178 |
kfree(dev); |
180 |
kfree(dev); |
| 179 |
} |
181 |
} |
| 180 |
} |
182 |
} |
|
Lines 370-376
Link Here
|
| 370 |
if (error) |
372 |
if (error) |
| 371 |
return error; |
373 |
return error; |
| 372 |
/* you can only watch an inode if you have read permissions on it */ |
374 |
/* you can only watch an inode if you have read permissions on it */ |
| 373 |
error = permission(nd->dentry->d_inode, MAY_READ, NULL); |
375 |
error = vfs_permission(nd, MAY_READ); |
| 374 |
if (error) |
376 |
if (error) |
| 375 |
path_release(nd); |
377 |
path_release(nd); |
| 376 |
return error; |
378 |
return error; |
|
Lines 422-427
Link Here
|
| 422 |
get_inotify_watch(watch); |
424 |
get_inotify_watch(watch); |
| 423 |
|
425 |
|
| 424 |
atomic_inc(&dev->user->inotify_watches); |
426 |
atomic_inc(&dev->user->inotify_watches); |
|
|
427 |
atomic_inc(&inotify_watches); |
| 425 |
|
428 |
|
| 426 |
return watch; |
429 |
return watch; |
| 427 |
} |
430 |
} |
|
Lines 454-459
Link Here
|
| 454 |
list_del(&watch->d_list); |
457 |
list_del(&watch->d_list); |
| 455 |
|
458 |
|
| 456 |
atomic_dec(&dev->user->inotify_watches); |
459 |
atomic_dec(&dev->user->inotify_watches); |
|
|
460 |
atomic_dec(&inotify_watches); |
| 457 |
idr_remove(&dev->idr, watch->wd); |
461 |
idr_remove(&dev->idr, watch->wd); |
| 458 |
put_inotify_watch(watch); |
462 |
put_inotify_watch(watch); |
| 459 |
} |
463 |
} |
|
Lines 532-537
Link Here
|
| 532 |
struct dentry *parent; |
536 |
struct dentry *parent; |
| 533 |
struct inode *inode; |
537 |
struct inode *inode; |
| 534 |
|
538 |
|
|
|
539 |
if (!atomic_read (&inotify_watches)) |
| 540 |
return; |
| 541 |
|
| 535 |
spin_lock(&dentry->d_lock); |
542 |
spin_lock(&dentry->d_lock); |
| 536 |
parent = dentry->d_parent; |
543 |
parent = dentry->d_parent; |
| 537 |
inode = parent->d_inode; |
544 |
inode = parent->d_inode; |
|
Lines 925-930
Link Here
|
| 925 |
struct nameidata nd; |
932 |
struct nameidata nd; |
| 926 |
struct file *filp; |
933 |
struct file *filp; |
| 927 |
int ret, fput_needed; |
934 |
int ret, fput_needed; |
|
|
935 |
int mask_add = 0; |
| 928 |
|
936 |
|
| 929 |
filp = fget_light(fd, &fput_needed); |
937 |
filp = fget_light(fd, &fput_needed); |
| 930 |
if (unlikely(!filp)) |
938 |
if (unlikely(!filp)) |
|
Lines 947-952
Link Here
|
| 947 |
down(&inode->inotify_sem); |
955 |
down(&inode->inotify_sem); |
| 948 |
down(&dev->sem); |
956 |
down(&dev->sem); |
| 949 |
|
957 |
|
|
|
958 |
if (mask & IN_MASK_ADD) |
| 959 |
mask_add = 1; |
| 960 |
|
| 950 |
/* don't let user-space set invalid bits: we don't want flags set */ |
961 |
/* don't let user-space set invalid bits: we don't want flags set */ |
| 951 |
mask &= IN_ALL_EVENTS; |
962 |
mask &= IN_ALL_EVENTS; |
| 952 |
if (unlikely(!mask)) { |
963 |
if (unlikely(!mask)) { |
|
Lines 960-966
Link Here
|
| 960 |
*/ |
971 |
*/ |
| 961 |
old = inode_find_dev(inode, dev); |
972 |
old = inode_find_dev(inode, dev); |
| 962 |
if (unlikely(old)) { |
973 |
if (unlikely(old)) { |
| 963 |
old->mask = mask; |
974 |
if (mask_add) |
|
|
975 |
old->mask |= mask; |
| 976 |
else |
| 977 |
old->mask = mask; |
| 964 |
ret = old->wd; |
978 |
ret = old->wd; |
| 965 |
goto out; |
979 |
goto out; |
| 966 |
} |
980 |
} |
|
Lines 1043-1048
Link Here
|
| 1043 |
inotify_max_user_watches = 8192; |
1057 |
inotify_max_user_watches = 8192; |
| 1044 |
|
1058 |
|
| 1045 |
atomic_set(&inotify_cookie, 0); |
1059 |
atomic_set(&inotify_cookie, 0); |
|
|
1060 |
atomic_set(&inotify_watches, 0); |
| 1046 |
|
1061 |
|
| 1047 |
watch_cachep = kmem_cache_create("inotify_watch_cache", |
1062 |
watch_cachep = kmem_cache_create("inotify_watch_cache", |
| 1048 |
sizeof(struct inotify_watch), |
1063 |
sizeof(struct inotify_watch), |