]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] inotify: add MOVE_SELF event
authorJohn McCutchan <jmccutchan@novell.com>
Mon, 15 Aug 2005 16:13:28 +0000 (12:13 -0400)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 15 Aug 2005 16:50:31 +0000 (09:50 -0700)
This adds a MOVE_SELF event to inotify.  It is sent whenever the inode
you are watching is moved.  We need this event so that we can catch
something like this:

 - app1:
watch /etc/mtab

 - app2:
cp /etc/mtab /tmp/mtab-work
mv /etc/mtab /etc/mtab~
mv /tmp/mtab-work /etc/mtab

app1 still thinks it's watching /etc/mtab but it's actually watching
/etc/mtab~.

Signed-off-by: John McCutchan <ttb@tentacle.dhs.org>
Signed-off-by: Robert Love <rml@novell.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/namei.c
include/linux/fsnotify.h
include/linux/inotify.h

index 57046d98a746f06d9ce51b2321a417de7955391f..b85f158aef0c8509867693a8c705e19f50fd6b1a 100644 (file)
@@ -2216,7 +2216,8 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
        if (!error) {
                const char *new_name = old_dentry->d_name.name;
-               fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir, new_dentry->d_inode);
+               fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir,
+                             new_dentry->d_inode, old_dentry->d_inode);
        }
        fsnotify_oldname_free(old_name);
 
index 602c305c8585fcb6b175bfd27750fe09ca718da8..03b8e7932b830a3f1bfffcc531ec4ee9b1662b1e 100644 (file)
@@ -21,7 +21,7 @@
  */
 static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
                                 const char *old_name, const char *new_name,
-                                int isdir, struct inode *target)
+                                int isdir, struct inode *target, struct inode *source)
 {
        u32 cookie = inotify_get_cookie();
 
@@ -41,6 +41,10 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
                inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL);
                inotify_inode_is_dead(target);
        }
+
+       if (source) {
+               inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL);
+       }
 }
 
 /*
index a40c2bf0408e0b7014388e26d0f2ae83592a51ee..93bb3afe646bc315d1ce17849acdad149e9b8684 100644 (file)
@@ -35,6 +35,7 @@ struct inotify_event {
 #define IN_CREATE              0x00000100      /* Subfile was created */
 #define IN_DELETE              0x00000200      /* Subfile was deleted */
 #define IN_DELETE_SELF         0x00000400      /* Self was deleted */
+#define IN_MOVE_SELF           0x00000800      /* Self was moved */
 
 /* the following are legal events.  they are sent as needed to any watch */
 #define IN_UNMOUNT             0x00002000      /* Backing fs was unmounted */
@@ -56,7 +57,8 @@ struct inotify_event {
  */
 #define IN_ALL_EVENTS  (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
                         IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
-                        IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF)
+                        IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
+                        IN_MOVE_SELF)
 
 #ifdef __KERNEL__