From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:44624 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726028AbfADKR5 (ORCPT ); Fri, 4 Jan 2019 05:17:57 -0500 Date: Fri, 4 Jan 2019 11:17:55 +0100 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v4 13/15] fanotify: support events with data type FSNOTIFY_EVENT_INODE Message-ID: <20190104101755.GH22409@quack2.suse.cz> References: <20181202113826.32133-1-amir73il@gmail.com> <20181202113826.32133-14-amir73il@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181202113826.32133-14-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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()? Honza -- Jan Kara SUSE Labs, CR