diff options
author | John McCutchan <jmccutchan@novell.com> | 2005-08-15 12:13:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-08-15 12:50:31 -0400 |
commit | 89204c40a03346cd951e698d854105db4cfedc28 (patch) | |
tree | 02f52e02f9f11c13c9859217755b043fcf0bbc30 /include | |
parent | 0bf955ce98cb3cf40e20d0cc435299eb76e8819e (diff) |
[PATCH] inotify: add MOVE_SELF event
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/fsnotify.h | 6 | ||||
-rw-r--r-- | include/linux/inotify.h | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 602c305c8585..03b8e7932b83 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h | |||
@@ -21,7 +21,7 @@ | |||
21 | */ | 21 | */ |
22 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, | 22 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, |
23 | const char *old_name, const char *new_name, | 23 | const char *old_name, const char *new_name, |
24 | int isdir, struct inode *target) | 24 | int isdir, struct inode *target, struct inode *source) |
25 | { | 25 | { |
26 | u32 cookie = inotify_get_cookie(); | 26 | u32 cookie = inotify_get_cookie(); |
27 | 27 | ||
@@ -41,6 +41,10 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, | |||
41 | inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL); | 41 | inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL); |
42 | inotify_inode_is_dead(target); | 42 | inotify_inode_is_dead(target); |
43 | } | 43 | } |
44 | |||
45 | if (source) { | ||
46 | inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL); | ||
47 | } | ||
44 | } | 48 | } |
45 | 49 | ||
46 | /* | 50 | /* |
diff --git a/include/linux/inotify.h b/include/linux/inotify.h index a40c2bf0408e..93bb3afe646b 100644 --- a/include/linux/inotify.h +++ b/include/linux/inotify.h | |||
@@ -35,6 +35,7 @@ struct inotify_event { | |||
35 | #define IN_CREATE 0x00000100 /* Subfile was created */ | 35 | #define IN_CREATE 0x00000100 /* Subfile was created */ |
36 | #define IN_DELETE 0x00000200 /* Subfile was deleted */ | 36 | #define IN_DELETE 0x00000200 /* Subfile was deleted */ |
37 | #define IN_DELETE_SELF 0x00000400 /* Self was deleted */ | 37 | #define IN_DELETE_SELF 0x00000400 /* Self was deleted */ |
38 | #define IN_MOVE_SELF 0x00000800 /* Self was moved */ | ||
38 | 39 | ||
39 | /* the following are legal events. they are sent as needed to any watch */ | 40 | /* the following are legal events. they are sent as needed to any watch */ |
40 | #define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */ | 41 | #define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */ |
@@ -56,7 +57,8 @@ struct inotify_event { | |||
56 | */ | 57 | */ |
57 | #define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ | 58 | #define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ |
58 | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \ | 59 | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \ |
59 | IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF) | 60 | IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \ |
61 | IN_MOVE_SELF) | ||
60 | 62 | ||
61 | #ifdef __KERNEL__ | 63 | #ifdef __KERNEL__ |
62 | 64 | ||