From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-f67.google.com ([209.85.161.67]:35533 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727388AbfADLM1 (ORCPT ); Fri, 4 Jan 2019 06:12:27 -0500 Received: by mail-yw1-f67.google.com with SMTP id h32so14386187ywk.2 for ; Fri, 04 Jan 2019 03:12:26 -0800 (PST) MIME-Version: 1.0 References: <20181202113826.32133-1-amir73il@gmail.com> <20181202113826.32133-14-amir73il@gmail.com> <20190104101755.GH22409@quack2.suse.cz> In-Reply-To: <20190104101755.GH22409@quack2.suse.cz> From: Amir Goldstein Date: Fri, 4 Jan 2019 13:12:14 +0200 Message-ID: Subject: Re: [PATCH v4 13/15] fanotify: support events with data type FSNOTIFY_EVENT_INODE To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Jan 4, 2019 at 12:17 PM Jan Kara wrote: > > On Sun 02-12-18 13:38:24, Amir Goldstein wrote: > > When event data type is FSNOTIFY_EVENT_INODE, we don't have a refernece > > to the mount, so we will not be able to open a file descriptor when user > > reads the event. However, if the listener has enabled reporting file > > identifier with the FAN_REPORT_FID init flag, we allow repoting those > ^^^ reporting > > > events and we use an indentifier inode to encode fid. > ^^ identifier > > > The inode to use as indetifier when reporting fid depedns on the event. > ^^ identifier ^^ depends > > > For dirent modification events, we report the modified directory inode > > and we report the "victim" inode otherwise. > > For example: > > FS_ATTRIB reports the child inode even if reported on a watched parent. > > FS_CREATE reports the modified dir inode and not the created inode. > > > > Signed-off-by: Amir Goldstein > ... > > @@ -201,13 +202,34 @@ static int fanotify_encode_fid(struct fanotify_event *event, > > return FILEID_INVALID; > > } > > > > +/* > > + * The inode to use as indetifier when reporting fid depedns on the event. > ^^ identifier ^^ depends > > > + * Report the modified directory inode on dirent modification events. > > + * Report the "victim" inode otherwise. > > + * For example: > > + * FS_ATTRIB reports the child inode even if reported on a watched parent. > > + * FS_CREATE reports the modified dir inode and not the created inode. > > + */ > > +static struct inode *fanotify_report_id(struct inode *to_tell, u32 event_mask, > > + const void *data, int data_type) > > +{ > > + if (event_mask & ALL_FSNOTIFY_DIRENT_EVENTS) > > + return to_tell; > > + else if (data_type == FSNOTIFY_EVENT_INODE) > > + return (struct inode *)data; > > + else if (data_type == FSNOTIFY_EVENT_PATH) > > + return d_inode(((struct path *)data)->dentry); > > + return NULL; > > +} > > + > > Maybe call this function fanotify_fid_inode()? Sounds good. Thanks, Amir.