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 | |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 14 | #include <linux/fsnotify_backend.h> |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame] | 15 | #include <linux/audit.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 16 | #include <linux/slab.h> |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 17 | |
| 18 | /* |
Nick Piggin | c32ccd8 | 2006-03-25 03:07:09 -0800 | [diff] [blame] | 19 | * fsnotify_d_instantiate - instantiate a dentry for inode |
| 20 | * Called with dcache_lock held. |
| 21 | */ |
| 22 | static inline void fsnotify_d_instantiate(struct dentry *entry, |
| 23 | struct inode *inode) |
| 24 | { |
Eric Paris | c28f7e5 | 2009-05-21 17:01:29 -0400 | [diff] [blame] | 25 | __fsnotify_d_instantiate(entry, inode); |
Nick Piggin | c32ccd8 | 2006-03-25 03:07:09 -0800 | [diff] [blame] | 26 | } |
| 27 | |
Eric Paris | c28f7e5 | 2009-05-21 17:01:29 -0400 | [diff] [blame] | 28 | /* Notify this dentry's parent about a child's events. */ |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 29 | static inline void fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask) |
Eric Paris | c28f7e5 | 2009-05-21 17:01:29 -0400 | [diff] [blame] | 30 | { |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 31 | BUG_ON(file && dentry); |
| 32 | |
| 33 | if (file) |
| 34 | dentry = file->f_path.dentry; |
| 35 | |
| 36 | __fsnotify_parent(file, dentry, mask); |
Eric Paris | c28f7e5 | 2009-05-21 17:01:29 -0400 | [diff] [blame] | 37 | } |
| 38 | |
Nick Piggin | c32ccd8 | 2006-03-25 03:07:09 -0800 | [diff] [blame] | 39 | /* |
| 40 | * fsnotify_d_move - entry has been moved |
| 41 | * Called with dcache_lock and entry->d_lock held. |
| 42 | */ |
| 43 | static inline void fsnotify_d_move(struct dentry *entry) |
| 44 | { |
Eric Paris | c28f7e5 | 2009-05-21 17:01:29 -0400 | [diff] [blame] | 45 | /* |
| 46 | * On move we need to update entry->d_flags to indicate if the new parent |
| 47 | * cares about events from this entry. |
| 48 | */ |
| 49 | __fsnotify_update_dcache_flags(entry); |
Nick Piggin | c32ccd8 | 2006-03-25 03:07:09 -0800 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | /* |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 53 | * fsnotify_link_count - inode's link count changed |
| 54 | */ |
| 55 | static inline void fsnotify_link_count(struct inode *inode) |
| 56 | { |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 57 | fsnotify(inode, FS_ATTRIB, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | /* |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 61 | * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir |
| 62 | */ |
| 63 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, |
Al Viro | 123df29 | 2009-12-25 04:57:57 -0500 | [diff] [blame] | 64 | const char *old_name, |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 65 | int isdir, struct inode *target, struct dentry *moved) |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 66 | { |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 67 | struct inode *source = moved->d_inode; |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 68 | u32 fs_cookie = fsnotify_get_cookie(); |
Eric Paris | ff52cc2 | 2009-06-11 11:09:47 -0400 | [diff] [blame] | 69 | __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM); |
| 70 | __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO); |
Al Viro | 123df29 | 2009-12-25 04:57:57 -0500 | [diff] [blame] | 71 | const char *new_name = moved->d_name.name; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 72 | |
Eric Paris | ff52cc2 | 2009-06-11 11:09:47 -0400 | [diff] [blame] | 73 | if (old_dir == new_dir) |
| 74 | old_dir_mask |= FS_DN_RENAME; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 75 | |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 76 | if (isdir) { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 77 | old_dir_mask |= FS_IN_ISDIR; |
| 78 | new_dir_mask |= FS_IN_ISDIR; |
| 79 | } |
| 80 | |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 81 | fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie); |
| 82 | fsnotify(new_dir, new_dir_mask, new_dir, FSNOTIFY_EVENT_INODE, new_name, fs_cookie); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 83 | |
Eric Paris | 2dfc1ca | 2009-12-17 20:30:52 -0500 | [diff] [blame] | 84 | if (target) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 85 | fsnotify_link_count(target); |
John McCutchan | 89204c4 | 2005-08-15 12:13:28 -0400 | [diff] [blame] | 86 | |
Eric Paris | 2dfc1ca | 2009-12-17 20:30:52 -0500 | [diff] [blame] | 87 | if (source) |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 88 | fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
Al Viro | cccc6bb | 2009-12-25 05:07:33 -0500 | [diff] [blame] | 89 | audit_inode_child(moved, new_dir); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | /* |
Eric Paris | 3be25f4 | 2009-05-21 17:01:26 -0400 | [diff] [blame] | 93 | * fsnotify_inode_delete - and inode is being evicted from cache, clean up is needed |
| 94 | */ |
| 95 | static inline void fsnotify_inode_delete(struct inode *inode) |
| 96 | { |
| 97 | __fsnotify_inode_delete(inode); |
| 98 | } |
| 99 | |
| 100 | /* |
John McCutchan | 7a91bf7 | 2005-08-08 13:52:16 -0400 | [diff] [blame] | 101 | * fsnotify_nameremove - a filename was removed from a directory |
| 102 | */ |
| 103 | static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) |
| 104 | { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 105 | __u32 mask = FS_DELETE; |
| 106 | |
John McCutchan | 7a91bf7 | 2005-08-08 13:52:16 -0400 | [diff] [blame] | 107 | if (isdir) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 108 | mask |= FS_IN_ISDIR; |
Eric Paris | c28f7e5 | 2009-05-21 17:01:29 -0400 | [diff] [blame] | 109 | |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 110 | fsnotify_parent(NULL, dentry, mask); |
John McCutchan | 7a91bf7 | 2005-08-08 13:52:16 -0400 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | /* |
| 114 | * fsnotify_inoderemove - an inode is going away |
| 115 | */ |
| 116 | static inline void fsnotify_inoderemove(struct inode *inode) |
| 117 | { |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 118 | fsnotify(inode, FS_DELETE_SELF, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
Eric Paris | 3be25f4 | 2009-05-21 17:01:26 -0400 | [diff] [blame] | 119 | __fsnotify_inode_delete(inode); |
Jan Kara | ece9591 | 2008-02-06 01:37:13 -0800 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | /* |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 123 | * fsnotify_create - 'name' was linked in |
| 124 | */ |
Amy Griffis | f38aa94 | 2005-11-03 15:57:06 +0000 | [diff] [blame] | 125 | static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 126 | { |
Al Viro | cccc6bb | 2009-12-25 05:07:33 -0500 | [diff] [blame] | 127 | audit_inode_child(dentry, inode); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 128 | |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 129 | fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | /* |
Jan Kara | ece9591 | 2008-02-06 01:37:13 -0800 | [diff] [blame] | 133 | * fsnotify_link - new hardlink in 'inode' directory |
| 134 | * Note: We have to pass also the linked inode ptr as some filesystems leave |
| 135 | * new_dentry->d_inode NULL and instantiate inode pointer later |
| 136 | */ |
| 137 | static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry) |
| 138 | { |
Jan Kara | ece9591 | 2008-02-06 01:37:13 -0800 | [diff] [blame] | 139 | fsnotify_link_count(inode); |
Al Viro | cccc6bb | 2009-12-25 05:07:33 -0500 | [diff] [blame] | 140 | audit_inode_child(new_dentry, dir); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 141 | |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 142 | fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0); |
Jan Kara | ece9591 | 2008-02-06 01:37:13 -0800 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | /* |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 146 | * fsnotify_mkdir - directory 'name' was created |
| 147 | */ |
Amy Griffis | f38aa94 | 2005-11-03 15:57:06 +0000 | [diff] [blame] | 148 | static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 149 | { |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 150 | __u32 mask = (FS_CREATE | FS_IN_ISDIR); |
| 151 | struct inode *d_inode = dentry->d_inode; |
| 152 | |
Al Viro | cccc6bb | 2009-12-25 05:07:33 -0500 | [diff] [blame] | 153 | audit_inode_child(dentry, inode); |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 154 | |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 155 | fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /* |
| 159 | * fsnotify_access - file was read |
| 160 | */ |
Eric Paris | 2a12a9d | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 161 | static inline void fsnotify_access(struct file *file) |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 162 | { |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 163 | struct inode *inode = file->f_path.dentry->d_inode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 164 | __u32 mask = FS_ACCESS; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 165 | |
| 166 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 167 | mask |= FS_IN_ISDIR; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 168 | |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 169 | fsnotify_parent(file, NULL, mask); |
Eric Paris | 2a12a9d | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 170 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | /* |
| 174 | * fsnotify_modify - file was modified |
| 175 | */ |
Eric Paris | 2a12a9d | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 176 | static inline void fsnotify_modify(struct file *file) |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 177 | { |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 178 | struct inode *inode = file->f_path.dentry->d_inode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 179 | __u32 mask = FS_MODIFY; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 180 | |
| 181 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 182 | mask |= FS_IN_ISDIR; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 183 | |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 184 | fsnotify_parent(file, NULL, mask); |
Eric Paris | 2a12a9d | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 185 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | /* |
| 189 | * fsnotify_open - file was opened |
| 190 | */ |
Eric Paris | 2a12a9d | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 191 | static inline void fsnotify_open(struct file *file) |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 192 | { |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 193 | struct inode *inode = file->f_path.dentry->d_inode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 194 | __u32 mask = FS_OPEN; |
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 | |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 199 | fsnotify_parent(file, NULL, mask); |
Eric Paris | 2a12a9d | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 200 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | /* |
| 204 | * fsnotify_close - file was closed |
| 205 | */ |
| 206 | static inline void fsnotify_close(struct file *file) |
| 207 | { |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 208 | struct inode *inode = file->f_path.dentry->d_inode; |
Al Viro | aeb5d72 | 2008-09-02 15:28:45 -0400 | [diff] [blame] | 209 | fmode_t mode = file->f_mode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 210 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 211 | |
| 212 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 213 | mask |= FS_IN_ISDIR; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 214 | |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 215 | fsnotify_parent(file, NULL, mask); |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 216 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | /* |
| 220 | * fsnotify_xattr - extended attributes were changed |
| 221 | */ |
| 222 | static inline void fsnotify_xattr(struct dentry *dentry) |
| 223 | { |
| 224 | struct inode *inode = dentry->d_inode; |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 225 | __u32 mask = FS_ATTRIB; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 226 | |
| 227 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 9058652 | 2009-05-21 17:01:20 -0400 | [diff] [blame] | 228 | mask |= FS_IN_ISDIR; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 229 | |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 230 | fsnotify_parent(NULL, dentry, mask); |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 231 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | /* |
| 235 | * fsnotify_change - notify_change event. file was modified and/or metadata |
| 236 | * was changed. |
| 237 | */ |
| 238 | static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid) |
| 239 | { |
| 240 | struct inode *inode = dentry->d_inode; |
Eric Paris | 3c5119c | 2009-05-21 17:01:33 -0400 | [diff] [blame] | 241 | __u32 mask = 0; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 242 | |
Eric Paris | 3c5119c | 2009-05-21 17:01:33 -0400 | [diff] [blame] | 243 | if (ia_valid & ATTR_UID) |
| 244 | mask |= FS_ATTRIB; |
| 245 | if (ia_valid & ATTR_GID) |
| 246 | mask |= FS_ATTRIB; |
| 247 | if (ia_valid & ATTR_SIZE) |
| 248 | mask |= FS_MODIFY; |
| 249 | |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 250 | /* both times implies a utime(s) call */ |
| 251 | if ((ia_valid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME)) |
Eric Paris | 3c5119c | 2009-05-21 17:01:33 -0400 | [diff] [blame] | 252 | mask |= FS_ATTRIB; |
| 253 | else if (ia_valid & ATTR_ATIME) |
| 254 | mask |= FS_ACCESS; |
| 255 | else if (ia_valid & ATTR_MTIME) |
| 256 | mask |= FS_MODIFY; |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 257 | |
Eric Paris | 3c5119c | 2009-05-21 17:01:33 -0400 | [diff] [blame] | 258 | if (ia_valid & ATTR_MODE) |
| 259 | mask |= FS_ATTRIB; |
| 260 | |
| 261 | if (mask) { |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 262 | if (S_ISDIR(inode->i_mode)) |
Eric Paris | 3c5119c | 2009-05-21 17:01:33 -0400 | [diff] [blame] | 263 | mask |= FS_IN_ISDIR; |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 264 | |
| 265 | fsnotify_parent(NULL, dentry, mask); |
Eric Paris | 47882c6 | 2009-05-21 17:01:47 -0400 | [diff] [blame] | 266 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | |
Eric Paris | 2dfc1ca | 2009-12-17 20:30:52 -0500 | [diff] [blame] | 270 | #if defined(CONFIG_FSNOTIFY) /* notify helpers */ |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 271 | |
| 272 | /* |
| 273 | * fsnotify_oldname_init - save off the old filename before we change it |
| 274 | */ |
| 275 | static inline const char *fsnotify_oldname_init(const char *name) |
| 276 | { |
| 277 | return kstrdup(name, GFP_KERNEL); |
| 278 | } |
| 279 | |
| 280 | /* |
| 281 | * fsnotify_oldname_free - free the name we got from fsnotify_oldname_init |
| 282 | */ |
| 283 | static inline void fsnotify_oldname_free(const char *old_name) |
| 284 | { |
| 285 | kfree(old_name); |
| 286 | } |
| 287 | |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 288 | #else /* CONFIG_FSNOTIFY */ |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 289 | |
| 290 | static inline const char *fsnotify_oldname_init(const char *name) |
| 291 | { |
| 292 | return NULL; |
| 293 | } |
| 294 | |
| 295 | static inline void fsnotify_oldname_free(const char *old_name) |
| 296 | { |
| 297 | } |
| 298 | |
Eric Paris | 28c60e3 | 2009-12-17 21:24:21 -0500 | [diff] [blame] | 299 | #endif /* CONFIG_FSNOTIFY */ |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 300 | |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 301 | #endif /* _LINUX_FS_NOTIFY_H */ |