aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJohn McCutchan <ttb@tentacle.dhs.org>2005-09-06 18:18:02 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 19:57:39 -0400
commit7ea6040b0eff07d3a9a4e2d248ac137c6ad02d42 (patch)
tree0a7bcce73c623f89cd5e8a97d2da7946da3293e3 /fs
parent8191151d0933d65fb6b659ffbd765479f0f200e1 (diff)
[PATCH] inotify: fix event loss on hardlinked files
People have run into a problem when they do this: watch (file1, all_events); watch (file2, some_events); if file2 is a hard link to file1, some events will be missed because by default we replace the mask. The patch below adds a flag IN_MASK_ADD which will cause inotify to add to the existing mask if present. Signed-off-by: John McCutchan <ttb@tentacle.dhs.org> Signed-off-by: Robert Love <rml@novell.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/inotify.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/inotify.c b/fs/inotify.c
index 2fd97ef547ff..a37e9fb1da58 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -931,6 +931,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
931 struct nameidata nd; 931 struct nameidata nd;
932 struct file *filp; 932 struct file *filp;
933 int ret, fput_needed; 933 int ret, fput_needed;
934 int mask_add = 0;
934 935
935 filp = fget_light(fd, &fput_needed); 936 filp = fget_light(fd, &fput_needed);
936 if (unlikely(!filp)) 937 if (unlikely(!filp))
@@ -953,6 +954,9 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
953 down(&inode->inotify_sem); 954 down(&inode->inotify_sem);
954 down(&dev->sem); 955 down(&dev->sem);
955 956
957 if (mask & IN_MASK_ADD)
958 mask_add = 1;
959
956 /* don't let user-space set invalid bits: we don't want flags set */ 960 /* don't let user-space set invalid bits: we don't want flags set */
957 mask &= IN_ALL_EVENTS; 961 mask &= IN_ALL_EVENTS;
958 if (unlikely(!mask)) { 962 if (unlikely(!mask)) {
@@ -966,7 +970,10 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
966 */ 970 */
967 old = inode_find_dev(inode, dev); 971 old = inode_find_dev(inode, dev);
968 if (unlikely(old)) { 972 if (unlikely(old)) {
969 old->mask = mask; 973 if (mask_add)
974 old->mask |= mask;
975 else
976 old->mask = mask;
970 ret = old->wd; 977 ret = old->wd;
971 goto out; 978 goto out;
972 } 979 }