From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f67.google.com ([209.85.221.67]:41053 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbeKZAfa (ORCPT ); Sun, 25 Nov 2018 19:35:30 -0500 Received: by mail-wr1-f67.google.com with SMTP id x10so16232449wrs.8 for ; Sun, 25 Nov 2018 05:44:22 -0800 (PST) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH v3 10/13] fanotify: check FS_ISDIR flag instead of d_is_dir() Date: Sun, 25 Nov 2018 15:43:49 +0200 Message-Id: <20181125134352.21499-11-amir73il@gmail.com> In-Reply-To: <20181125134352.21499-1-amir73il@gmail.com> References: <20181125134352.21499-1-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: All fsnotify hooks set the FS_ISDIR flag for events that happen on directory victim inodes except for fsnotify_perm(). Add the missing FS_ISDIR flag in fsnotify_perm() hook and let fanotify_group_event_mask() check the FS_ISDIR flag instead of checking if path argument is a directory. This is needed for fanotify support for event types that do not carry path information. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify.c | 2 +- include/linux/fsnotify.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 90bac98dd8c7..ef567d07f5a6 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -147,7 +147,7 @@ static u32 fanotify_group_event_mask(struct fsnotify_iter_info *iter_info, marks_ignored_mask |= mark->ignored_mask; } - if (d_is_dir(path->dentry) && + if (event_mask & FS_ISDIR && !(marks_mask & FS_ISDIR & ~marks_ignored_mask)) return 0; diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 098322ec3689..c1596ca881aa 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -93,6 +93,9 @@ static inline int fsnotify_perm(struct file *file, int mask) fsnotify_mask = FS_ACCESS_PERM; } + if (S_ISDIR(inode->i_mode)) + fsnotify_mask |= FS_ISDIR; + return fsnotify_path(inode, path, fsnotify_mask); } -- 2.17.1