From 3ca8e9b706ed5683c2e3bea851369fcc12090f52 Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Thu, 19 May 2022 17:04:23 -0700 Subject: [PATCH] ANDROID: fsnotify: Notify lower fs of open If the filesystem being watched supports d_canonical_path, notify the lower filesystem of the open as well. Note: I've changed the Change-Id since this was previously present, but disappeared at some point. Fixes: f37e05049bf8 ("ANDROID: vfs: d_canonical_path for stacked FS") Test: atest CtsOsTestCases:android.os.cts.FileObserverTest Bug: 70706497 Change-Id: I7bf5c2bb2d6da18c831a8ece9ad9cf9ef3661b6b Signed-off-by: Daniel Rosenberg Signed-off-by: Paul Lawrence Signed-off-by: Alessio Balsini (cherry picked from commit b289d1706b672f064bbe04c3a8bfb1a5e8ac0923) --- include/linux/fsnotify.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 278620e063ab..b57568d66fc4 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -128,6 +128,25 @@ static inline int fsnotify_file(struct file *file, __u32 mask) FSNOTIFY_PRIO_CONTENT)) return 0; + /* + * Open calls notify early on, so lower file system must be notified + */ + if (mask & FS_OPEN) { + if (path->dentry->d_op && + path->dentry->d_op->d_canonical_path) { + struct path lower_path; + int ret; + + path->dentry->d_op->d_canonical_path(path, &lower_path); + ret = fsnotify_parent(lower_path.dentry, mask, + &lower_path, FSNOTIFY_EVENT_PATH); + path_put(&lower_path); + + if (ret) + return ret; + } + } + return fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH); }