Return-Path: Received: from mx2.suse.de ([195.135.220.15]:59044 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725913AbfADMT6 (ORCPT ); Fri, 4 Jan 2019 07:19:58 -0500 Date: Fri, 4 Jan 2019 13:19:56 +0100 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , Matthew Bobrowski , linux-fsdevel , linux-api@vger.kernel.org Subject: Re: [PATCH v4 15/15] fanotify: report FAN_ONDIR to listener with FAN_REPORT_FID Message-ID: <20190104121956.GQ22409@quack2.suse.cz> References: <20181202113826.32133-1-amir73il@gmail.com> <20181202113826.32133-16-amir73il@gmail.com> <20190104105709.GJ22409@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri 04-01-19 13:42:33, Amir Goldstein wrote: > On Fri, Jan 4, 2019 at 12:57 PM Jan Kara wrote: > > > @@ -145,12 +146,38 @@ static u32 fanotify_group_event_mask(struct fsnotify_group *group, > > > marks_ignored_mask |= mark->ignored_mask; > > > } > > > > > > + test_mask = event_mask & marks_mask & ~marks_ignored_mask; > > > + > > > + /* > > > + * dirent modification events (create/delete/move) do not carry the > > > + * child entry name/inode information. Instead, we report FAN_ONDIR > > > + * for mkdir/rmdir so user can differentiate them from creat/unlink. > > > + * > > > + * For backward compatibility and consistency, do not report FAN_ONDIR > > > + * to user in legacy fanotify mode (reporting fd) and report FAN_ONDIR > > > + * to user in FAN_REPORT_FID mode for all event types. > > > + */ > > > + if (FAN_GROUP_FLAG(group, FAN_REPORT_FID)) { > > > + /* Do not report FAN_ONDIR without an event type */ > > > + BUILD_BUG_ON(FANOTIFY_EVENT_TYPES & FANOTIFY_EVENT_FLAGS); > > > + if (!(test_mask & FANOTIFY_EVENT_TYPES)) > > > + return 0; > > > + > > > + user_mask |= FAN_ONDIR; > > > + } > > > + > > > + /* > > > + * Unlike legacy fanotify events (open/access/close), dirent events > > > + * for subdir entries (mkdir/rmdir) will be reported regardless if > > > + * user requested FAN_ONDIR, but the FAN_ONDIR flag itself will only > > > + * be reported if the user asked for it. > > > + */ > > > if (event_mask & FS_ISDIR && > > > + !(event_mask & ALL_FSNOTIFY_DIRENT_EVENTS) && > > > > I disagree with this. It just seems inconsistent for dirent events for > > directories to get reported without FAN_ONDIR. I understand there's not > > great use for not reporting directory dirent events but it's not like > > adding FAN_ONDIR to the mark mask is that big deal for userspace. And it > > makes the API more consistent. You could possibly remind the reader in the > > manpage that FAN_ONDIR is required to get all dirent events. > > I see your point. > I have no problem with requiring FAN_ONDIR for mkdir events. > I believe the strongest argument should be which way is easier > to document/understand. > > Matthew, if you agree that it looks easier to document Jan's proposal, > please go a head with this and we will see how man page looks like > before making the final decision. Agreed. Honza -- Jan Kara SUSE Labs, CR