--- zzzz-none-000/linux-3.10.107/include/linux/fsnotify.h 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/include/linux/fsnotify.h 2021-11-10 11:53:56.000000000 +0000 @@ -34,6 +34,16 @@ return __fsnotify_parent(path, dentry, mask); } + +/* Notify this dentry's parent about a child's events. */ +static inline int fsnotify_parent_recursive(struct path *path, struct dentry *dentry, struct dentry *first_parent, const char *name, __u32 mask, u32 fs_cookie) +{ + if (!dentry) + dentry = path->dentry; + + return __fsnotify_parent_recursive(path, dentry, first_parent, name, mask, fs_cookie); +} + /* simple call site for access decisions */ static inline int fsnotify_perm(struct file *file, int mask) { @@ -57,6 +67,10 @@ if (ret) return ret; + ret = fsnotify_parent_recursive(path, NULL, NULL, NULL, fsnotify_mask, 0); + if (ret) + return ret; + return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); } @@ -80,6 +94,7 @@ fsnotify(inode, FS_ATTRIB, inode, FSNOTIFY_EVENT_INODE, NULL, 0); } +extern void __fsnotify_update_child_dentry_flags(struct inode *inode); /* * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir */ @@ -92,19 +107,27 @@ __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM); __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO); const unsigned char *new_name = moved->d_name.name; + struct dentry *old_dir_dentry; - if (old_dir == new_dir) + if (old_dir == new_dir) { old_dir_mask |= FS_DN_RENAME; + old_dir_dentry = NULL; + } else { + old_dir_dentry = d_find_any_alias(old_dir); + } if (isdir) { old_dir_mask |= FS_ISDIR; new_dir_mask |= FS_ISDIR; } + fsnotify_parent_recursive(NULL, moved, old_dir_dentry, old_name, old_dir_mask, fs_cookie); fsnotify(old_dir, old_dir_mask, source, FSNOTIFY_EVENT_INODE, old_name, fs_cookie); + fsnotify_parent_recursive(NULL, moved, NULL, new_name, new_dir_mask, fs_cookie); fsnotify(new_dir, new_dir_mask, source, FSNOTIFY_EVENT_INODE, new_name, fs_cookie); + __fsnotify_update_child_dentry_flags(new_dir); if (target) fsnotify_link_count(target); @@ -112,6 +135,9 @@ if (source) fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0); audit_inode_child(new_dir, moved, AUDIT_TYPE_CHILD_CREATE); + + if (old_dir_dentry) + dput(old_dir_dentry); } /* @@ -141,6 +167,7 @@ mask |= FS_ISDIR; fsnotify_parent(NULL, dentry, mask); + fsnotify_parent_recursive(NULL, dentry, NULL, NULL, mask, 0); } /* @@ -159,6 +186,7 @@ { audit_inode_child(inode, dentry, AUDIT_TYPE_CHILD_CREATE); + fsnotify_parent_recursive(NULL, dentry, NULL, NULL, FS_CREATE, 0); fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); } @@ -172,6 +200,7 @@ fsnotify_link_count(inode); audit_inode_child(dir, new_dentry, AUDIT_TYPE_CHILD_CREATE); + fsnotify_parent_recursive(NULL, new_dentry, NULL, NULL, FS_CREATE, 0); fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0); } @@ -185,6 +214,7 @@ audit_inode_child(inode, dentry, AUDIT_TYPE_CHILD_CREATE); + fsnotify_parent_recursive(NULL, dentry, NULL, NULL, mask, 0); fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); } @@ -202,6 +232,7 @@ if (!(file->f_mode & FMODE_NONOTIFY)) { fsnotify_parent(path, NULL, mask); + fsnotify_parent_recursive(path, NULL, NULL, NULL, mask, 0); fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); } } @@ -220,6 +251,7 @@ if (!(file->f_mode & FMODE_NONOTIFY)) { fsnotify_parent(path, NULL, mask); + fsnotify_parent_recursive(path, NULL, NULL, NULL, mask, 0); fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); } } @@ -237,6 +269,7 @@ mask |= FS_ISDIR; fsnotify_parent(path, NULL, mask); + fsnotify_parent_recursive(path, NULL, NULL, NULL, mask, 0); fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); } @@ -255,6 +288,7 @@ if (!(file->f_mode & FMODE_NONOTIFY)) { fsnotify_parent(path, NULL, mask); + fsnotify_parent_recursive(path, NULL, NULL, NULL, mask, 0); fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); } } @@ -271,6 +305,7 @@ mask |= FS_ISDIR; fsnotify_parent(NULL, dentry, mask); + fsnotify_parent_recursive(NULL, dentry, NULL, NULL, mask, 0); fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); } @@ -306,6 +341,7 @@ mask |= FS_ISDIR; fsnotify_parent(NULL, dentry, mask); + fsnotify_parent_recursive(NULL, dentry, NULL, NULL, mask, 0); fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); } }