aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2008-02-06 04:37:13 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:05 -0500
commitece95912db94d98e202cbedb8f35206deb29d83d (patch)
tree7900aa32e8f8ee26f708471664a5b4024997be40 /fs/namei.c
parent6d9851618104a21dbf5ee8260b5f2d4b5229c77e (diff)
inotify: send IN_ATTRIB events when link count changes
Currently, no notification event has been sent when inode's link count changed. This is inconvenient for the application in some cases: Suppose you have the following directory structure foo/test bar/ and you watch test. If someone does "mv foo/test bar/", you get event IN_MOVE_SELF and you know something has happened with the file "test". However if someone does "ln foo/test bar/test" and "rm foo/test" you get no inotify event for the file "test" (only directories "foo" and "bar" receive events). Furthermore it could be argued that link count belongs to file's metadata and thus IN_ATTRIB should be sent when it changes. The following patch implements sending of IN_ATTRIB inotify events when link count of the inode changes, i.e., when a hardlink to the inode is created or when it is removed. This event is sent in addition to all the events sent so far. In particular, when a last link to a file is removed, IN_ATTRIB event is sent in addition to IN_DELETE_SELF event. Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: Morten Welinder <mwelinder@gmail.com> Cc: Robert Love <rlove@google.com> Cc: John McCutchan <ttb@tentacle.dhs.org> Cc: Steven French <sfrench@us.ibm.com> Cc: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 73e2e665817a..241cff423653 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2188,6 +2188,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
2188 2188
2189 /* We don't d_delete() NFS sillyrenamed files--they still exist. */ 2189 /* We don't d_delete() NFS sillyrenamed files--they still exist. */
2190 if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) { 2190 if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
2191 fsnotify_link_count(dentry->d_inode);
2191 d_delete(dentry); 2192 d_delete(dentry);
2192 } 2193 }
2193 2194
@@ -2360,7 +2361,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
2360 error = dir->i_op->link(old_dentry, dir, new_dentry); 2361 error = dir->i_op->link(old_dentry, dir, new_dentry);
2361 mutex_unlock(&old_dentry->d_inode->i_mutex); 2362 mutex_unlock(&old_dentry->d_inode->i_mutex);
2362 if (!error) 2363 if (!error)
2363 fsnotify_create(dir, new_dentry); 2364 fsnotify_link(dir, old_dentry->d_inode, new_dentry);
2364 return error; 2365 return error;
2365} 2366}
2366 2367