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