Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 1 | #ifndef _LINUX_FS_NOTIFY_H |
| 2 | #define _LINUX_FS_NOTIFY_H |
| 3 | |
| 4 | /* |
| 5 | * include/linux/fsnotify.h - generic hooks for filesystem notification, to |
| 6 | * reduce in-source duplication from both dnotify and inotify. |
| 7 | * |
| 8 | * We don't compile any of this away in some complicated menagerie of ifdefs. |
| 9 | * Instead, we rely on the code inside to optimize away as needed. |
| 10 | * |
| 11 | * (C) Copyright 2005 Robert Love |
| 12 | */ |
| 13 | |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 14 | #include <linux/dnotify.h> |
| 15 | #include <linux/inotify.h> |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 16 | #include <linux/fsnotify_backend.h> |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame] | 17 | #include <linux/audit.h> |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 18 | |
| 19 | /* |
Nick Piggin | c32ccd8 | 2006-03-25 03:07:09 -0800 | [diff] [blame] | 20 | * fsnotify_d_instantiate - instantiate a dentry for inode |
| 21 | * Called with dcache_lock held. |
| 22 | */ |
| 23 | static inline void fsnotify_d_instantiate(struct dentry *entry, |
| 24 | struct inode *inode) |
| 25 | { |
| 26 | inotify_d_instantiate(entry, inode); |
| 27 | } |
| 28 | |
| 29 | /* |
| 30 | * fsnotify_d_move - entry has been moved |
| 31 | * Called with dcache_lock and entry->d_lock held. |
| 32 | */ |
| 33 | static inline void fsnotify_d_move(struct dentry *entry) |
| 34 | { |
| 35 | inotify_d_move(entry); |
| 36 | } |
| 37 | |
| 38 | /* |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 39 | * fsnotify_link_count - inode's link count changed |
| 40 | */ |
| 41 | static inline void fsnotify_link_count(struct inode *inode) |
| 42 | { |
| 43 | inotify_inode_queue_event(inode, IN_ATTRIB, 0, NULL, NULL); |
| 44 | |
| 45 | fsnotify(inode, FS_ATTRIB, inode, FSNOTIFY_EVENT_INODE); |
| 46 | } |
| 47 | |
| 48 | /* |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 49 | * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir |
| 50 | */ |
| 51 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, |
| 52 | const char *old_name, const char *new_name, |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 53 | int isdir, struct inode *target, struct dentry *moved) |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 54 | { |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 55 | struct inode *source = moved->d_inode; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 56 | u32 cookie = inotify_get_cookie(); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 57 | __u32 old_dir_mask = 0; |
| 58 | __u32 new_dir_mask = 0; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 59 | |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 60 | if (old_dir == new_dir) { |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 61 | inode_dir_notify(old_dir, DN_RENAME); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 62 | old_dir_mask = FS_DN_RENAME; |
| 63 | } else { |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 64 | inode_dir_notify(old_dir, DN_DELETE); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 65 | old_dir_mask = FS_DELETE; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 66 | inode_dir_notify(new_dir, DN_CREATE); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 67 | new_dir_mask = FS_CREATE; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 68 | } |
| 69 | |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 70 | if (isdir) { |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 71 | isdir = IN_ISDIR; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 72 | old_dir_mask |= FS_IN_ISDIR; |
| 73 | new_dir_mask |= FS_IN_ISDIR; |
| 74 | } |
| 75 | |
| 76 | old_dir_mask |= FS_MOVED_FROM; |
| 77 | new_dir_mask |= FS_MOVED_TO; |
| 78 | |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 79 | inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name, |
| 80 | source); |
| 81 | inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name, |
| 82 | source); |
John McCutchan | 7544953 | 2005-08-01 11:00:45 -0400 | [diff] [blame] | 83 | |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 84 | fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE); |
| 85 | fsnotify(new_dir, new_dir_mask, new_dir, FSNOTIFY_EVENT_INODE); |
| 86 | |
John McCutchan | 7544953 | 2005-08-01 11:00:45 -0400 | [diff] [blame] | 87 | if (target) { |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 88 | inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL, NULL); |
John McCutchan | 7544953 | 2005-08-01 11:00:45 -0400 | [diff] [blame] | 89 | inotify_inode_is_dead(target); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 90 | |
| 91 | /* this is really a link_count change not a removal */ |
| 92 | fsnotify_link_count(target); |
John McCutchan | 7544953 | 2005-08-01 11:00:45 -0400 | [diff] [blame] | 93 | } |
John McCutchan | 89204c4 | 2005-08-15 12:13:28 -0400 | [diff] [blame] | 94 | |
| 95 | if (source) { |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 96 | inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 97 | fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE); |
John McCutchan | 89204c4 | 2005-08-15 12:13:28 -0400 | [diff] [blame] | 98 | } |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 99 | audit_inode_child(new_name, moved, new_dir); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /* |
John McCutchan | 7a91bf7 | 2005-08-08 13:52:16 -0400 | [diff] [blame] | 103 | * fsnotify_nameremove - a filename was removed from a directory |
| 104 | */ |
| 105 | static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) |
| 106 | { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 107 | __u32 mask = FS_DELETE; |
| 108 | |
John McCutchan | 7a91bf7 | 2005-08-08 13:52:16 -0400 | [diff] [blame] | 109 | if (isdir) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 110 | mask |= FS_IN_ISDIR; |
John McCutchan | 7a91bf7 | 2005-08-08 13:52:16 -0400 | [diff] [blame] | 111 | dnotify_parent(dentry, DN_DELETE); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 112 | inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); |
John McCutchan | 7a91bf7 | 2005-08-08 13:52:16 -0400 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /* |
| 116 | * fsnotify_inoderemove - an inode is going away |
| 117 | */ |
| 118 | static inline void fsnotify_inoderemove(struct inode *inode) |
| 119 | { |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 120 | inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL, NULL); |
John McCutchan | 7a91bf7 | 2005-08-08 13:52:16 -0400 | [diff] [blame] | 121 | inotify_inode_is_dead(inode); |
John McCutchan | 7a91bf7 | 2005-08-08 13:52:16 -0400 | [diff] [blame] | 122 | |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 123 | fsnotify(inode, FS_DELETE_SELF, inode, FSNOTIFY_EVENT_INODE); |
Jan Kara | ece9591 | 2008-02-06 01:37:13 -0800 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /* |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 127 | * fsnotify_create - 'name' was linked in |
| 128 | */ |
Amy Griffis | f38aa94 | 2005-11-03 15:57:06 +0000 | [diff] [blame] | 129 | static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 130 | { |
| 131 | inode_dir_notify(inode, DN_CREATE); |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 132 | inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name, |
| 133 | dentry->d_inode); |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 134 | audit_inode_child(dentry->d_name.name, dentry, inode); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 135 | |
| 136 | fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | /* |
Jan Kara | ece9591 | 2008-02-06 01:37:13 -0800 | [diff] [blame] | 140 | * fsnotify_link - new hardlink in 'inode' directory |
| 141 | * Note: We have to pass also the linked inode ptr as some filesystems leave |
| 142 | * new_dentry->d_inode NULL and instantiate inode pointer later |
| 143 | */ |
| 144 | static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry) |
| 145 | { |
| 146 | inode_dir_notify(dir, DN_CREATE); |
| 147 | inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name, |
| 148 | inode); |
| 149 | fsnotify_link_count(inode); |
| 150 | audit_inode_child(new_dentry->d_name.name, new_dentry, dir); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 151 | |
| 152 | fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE); |
Jan Kara | ece9591 | 2008-02-06 01:37:13 -0800 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | /* |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 156 | * fsnotify_mkdir - directory 'name' was created |
| 157 | */ |
Amy Griffis | f38aa94 | 2005-11-03 15:57:06 +0000 | [diff] [blame] | 158 | static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 159 | { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 160 | __u32 mask = (FS_CREATE | FS_IN_ISDIR); |
| 161 | struct inode *d_inode = dentry->d_inode; |
| 162 | |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 163 | inode_dir_notify(inode, DN_CREATE); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 164 | inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode); |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 165 | audit_inode_child(dentry->d_name.name, dentry, inode); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 166 | |
| 167 | fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | /* |
| 171 | * fsnotify_access - file was read |
| 172 | */ |
| 173 | static inline void fsnotify_access(struct dentry *dentry) |
| 174 | { |
| 175 | struct inode *inode = dentry->d_inode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 176 | __u32 mask = FS_ACCESS; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 177 | |
| 178 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 179 | mask |= FS_IN_ISDIR; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 180 | |
| 181 | dnotify_parent(dentry, DN_ACCESS); |
| 182 | inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 183 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 184 | |
| 185 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | /* |
| 189 | * fsnotify_modify - file was modified |
| 190 | */ |
| 191 | static inline void fsnotify_modify(struct dentry *dentry) |
| 192 | { |
| 193 | struct inode *inode = dentry->d_inode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 194 | __u32 mask = FS_MODIFY; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 195 | |
| 196 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 197 | mask |= FS_IN_ISDIR; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 198 | |
| 199 | dnotify_parent(dentry, DN_MODIFY); |
| 200 | inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 201 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 202 | |
| 203 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | /* |
| 207 | * fsnotify_open - file was opened |
| 208 | */ |
| 209 | static inline void fsnotify_open(struct dentry *dentry) |
| 210 | { |
| 211 | struct inode *inode = dentry->d_inode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 212 | __u32 mask = FS_OPEN; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 213 | |
| 214 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 215 | mask |= FS_IN_ISDIR; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 216 | |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 217 | inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 218 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 219 | |
| 220 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | /* |
| 224 | * fsnotify_close - file was closed |
| 225 | */ |
| 226 | static inline void fsnotify_close(struct file *file) |
| 227 | { |
Josef "Jeff" Sipek | 0f7fc9e | 2006-12-08 02:36:35 -0800 | [diff] [blame] | 228 | struct dentry *dentry = file->f_path.dentry; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 229 | struct inode *inode = dentry->d_inode; |
| 230 | const char *name = dentry->d_name.name; |
Al Viro | aeb5d72 | 2008-09-02 15:28:45 -0400 | [diff] [blame] | 231 | fmode_t mode = file->f_mode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 232 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 233 | |
| 234 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 235 | mask |= FS_IN_ISDIR; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 236 | |
| 237 | inotify_dentry_parent_queue_event(dentry, mask, 0, name); |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 238 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 239 | |
| 240 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | /* |
| 244 | * fsnotify_xattr - extended attributes were changed |
| 245 | */ |
| 246 | static inline void fsnotify_xattr(struct dentry *dentry) |
| 247 | { |
| 248 | struct inode *inode = dentry->d_inode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 249 | __u32 mask = FS_ATTRIB; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 250 | |
| 251 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 252 | mask |= FS_IN_ISDIR; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 253 | |
| 254 | inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 255 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 256 | |
| 257 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | /* |
| 261 | * fsnotify_change - notify_change event. file was modified and/or metadata |
| 262 | * was changed. |
| 263 | */ |
| 264 | static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid) |
| 265 | { |
| 266 | struct inode *inode = dentry->d_inode; |
| 267 | int dn_mask = 0; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 268 | __u32 in_mask = 0; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 269 | |
| 270 | if (ia_valid & ATTR_UID) { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 271 | in_mask |= FS_ATTRIB; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 272 | dn_mask |= DN_ATTRIB; |
| 273 | } |
| 274 | if (ia_valid & ATTR_GID) { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 275 | in_mask |= FS_ATTRIB; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 276 | dn_mask |= DN_ATTRIB; |
| 277 | } |
| 278 | if (ia_valid & ATTR_SIZE) { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 279 | in_mask |= FS_MODIFY; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 280 | dn_mask |= DN_MODIFY; |
| 281 | } |
| 282 | /* both times implies a utime(s) call */ |
| 283 | if ((ia_valid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME)) |
| 284 | { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 285 | in_mask |= FS_ATTRIB; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 286 | dn_mask |= DN_ATTRIB; |
| 287 | } else if (ia_valid & ATTR_ATIME) { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 288 | in_mask |= FS_ACCESS; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 289 | dn_mask |= DN_ACCESS; |
| 290 | } else if (ia_valid & ATTR_MTIME) { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 291 | in_mask |= FS_MODIFY; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 292 | dn_mask |= DN_MODIFY; |
| 293 | } |
| 294 | if (ia_valid & ATTR_MODE) { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 295 | in_mask |= FS_ATTRIB; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 296 | dn_mask |= DN_ATTRIB; |
| 297 | } |
| 298 | |
| 299 | if (dn_mask) |
| 300 | dnotify_parent(dentry, dn_mask); |
| 301 | if (in_mask) { |
| 302 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 303 | in_mask |= FS_IN_ISDIR; |
Amy Griffis | 7c29772 | 2006-06-01 13:11:01 -0700 | [diff] [blame] | 304 | inotify_inode_queue_event(inode, in_mask, 0, NULL, NULL); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 305 | inotify_dentry_parent_queue_event(dentry, in_mask, 0, |
| 306 | dentry->d_name.name); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 307 | fsnotify(inode, in_mask, inode, FSNOTIFY_EVENT_INODE); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 311 | #if defined(CONFIG_INOTIFY) || defined(CONFIG_FSNOTIFY) /* notify helpers */ |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 312 | |
| 313 | /* |
| 314 | * fsnotify_oldname_init - save off the old filename before we change it |
| 315 | */ |
| 316 | static inline const char *fsnotify_oldname_init(const char *name) |
| 317 | { |
| 318 | return kstrdup(name, GFP_KERNEL); |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 | * fsnotify_oldname_free - free the name we got from fsnotify_oldname_init |
| 323 | */ |
| 324 | static inline void fsnotify_oldname_free(const char *old_name) |
| 325 | { |
| 326 | kfree(old_name); |
| 327 | } |
| 328 | |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame^] | 329 | #else /* CONFIG_INOTIFY || CONFIG_FSNOTIFY */ |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 330 | |
| 331 | static inline const char *fsnotify_oldname_init(const char *name) |
| 332 | { |
| 333 | return NULL; |
| 334 | } |
| 335 | |
| 336 | static inline void fsnotify_oldname_free(const char *old_name) |
| 337 | { |
| 338 | } |
| 339 | |
| 340 | #endif /* ! CONFIG_INOTIFY */ |
| 341 | |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 342 | #endif /* _LINUX_FS_NOTIFY_H */ |