From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-f195.google.com ([209.85.219.195]:38511 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731569AbeISXPz (ORCPT ); Wed, 19 Sep 2018 19:15:55 -0400 Received: by mail-yb1-f195.google.com with SMTP id e190-v6so2722958ybb.5 for ; Wed, 19 Sep 2018 10:36:57 -0700 (PDT) MIME-Version: 1.0 References: <20180918154434.10299-1-amir73il@gmail.com> <20180919134703.GA3970@quack2.suse.cz> In-Reply-To: <20180919134703.GA3970@quack2.suse.cz> From: Amir Goldstein Date: Wed, 19 Sep 2018 20:36:44 +0300 Message-ID: Subject: Re: [PATCH] fanotify: store fanotify_init() flags in group's fanotify_data To: Jan Kara Cc: nixiaoming@huawei.com, linux-fsdevel Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Sep 19, 2018 at 4:47 PM Jan Kara wrote: > > On Tue 18-09-18 18:44:34, Amir Goldstein wrote: > > This averts the need to re-generate flags in fanotify_show_fdinfo() > > and sets the scene for addition of more upcoming flags without growing > > new members to the fanotify_data struct. > > > > Signed-off-by: Amir Goldstein > > Thanks. I've taken this patch to my tree for the next merge window. > Actually, could you please grab the later version of this patch, which is a bit nicer, from: https://github.com/amir73il/linux/commits/fanotify_unpriv I was going to post v2, but you beat me to it. Below is v1..v2 diff. Thanks! Amir. ---- diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 0562738a4c51..afa89eafe79f 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -191,8 +191,7 @@ static int process_access_response(struct fsnotify_group *group, if (fd < 0) return -EINVAL; - if ((response & FAN_AUDIT) && - !(group->fanotify_data.flags & FAN_ENABLE_AUDIT)) + if ((response & FAN_AUDIT) && !FAN_GROUP_FLAG(group, FAN_ENABLE_AUDIT)) return -EINVAL; event = dequeue_event(group, fd); diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h index 096c96f4f16a..9c5ea3bdfaa0 100644 --- a/include/linux/fanotify.h +++ b/include/linux/fanotify.h @@ -6,4 +6,8 @@ /* not valid from userspace, only kernel internal */ #define FAN_MARK_ONDIR 0x00000100 + +#define FAN_GROUP_FLAG(group, flag) \ + ((group)->fanotify_data.flags & (flag)) + #endif /* _LINUX_FANOTIFY_H */