ANDROID: fsnotify: Notify lower fs of open
authorDaniel Rosenberg <drosen@google.com>
Tue, 23 Jan 2018 23:02:50 +0000 (15:02 -0800)
committerDaniel Rosenberg <drosen@google.com>
Sat, 3 Feb 2018 04:04:44 +0000 (20:04 -0800)
If the filesystem being watched supports d_canonical_path,
notify the lower filesystem of the open as well.

Change-Id: I2b1739e068afbaf5eb39950516072bff8345ebfe
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 70706497

include/linux/fsnotify.h

index bdaf22582f6ea5c59a1eb9e4e7c319854087df42..4636b8f8893e1908fd013fcca7f5aeec02e82546 100644 (file)
@@ -214,12 +214,19 @@ static inline void fsnotify_modify(struct file *file)
 static inline void fsnotify_open(struct file *file)
 {
        const struct path *path = &file->f_path;
+       struct path lower_path;
        struct inode *inode = path->dentry->d_inode;
        __u32 mask = FS_OPEN;
 
        if (S_ISDIR(inode->i_mode))
                mask |= FS_ISDIR;
 
+       if (path->dentry->d_op && path->dentry->d_op->d_canonical_path) {
+               path->dentry->d_op->d_canonical_path(path, &lower_path);
+               fsnotify_parent(&lower_path, NULL, mask);
+               fsnotify(lower_path.dentry->d_inode, mask, &lower_path, FSNOTIFY_EVENT_PATH, NULL, 0);
+               path_put(&lower_path);
+       }
        fsnotify_parent(path, NULL, mask);
        fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
 }