From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f65.google.com ([209.85.221.65]:33650 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbeLBLi4 (ORCPT ); Sun, 2 Dec 2018 06:38:56 -0500 Received: by mail-wr1-f65.google.com with SMTP id c14so9327020wrr.0 for ; Sun, 02 Dec 2018 03:38:52 -0800 (PST) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH v4 12/15] fanotify: check FS_ISDIR flag instead of d_is_dir() Date: Sun, 2 Dec 2018 13:38:23 +0200 Message-Id: <20181202113826.32133-13-amir73il@gmail.com> In-Reply-To: <20181202113826.32133-1-amir73il@gmail.com> References: <20181202113826.32133-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 a5dd8b8d92b7..5a958b1d0cb6 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -144,7 +144,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 8de8f390cce2..14e1f43c38c9 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -92,6 +92,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