linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Jan Kara <jack@suse.cz>, Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Eric Paris <eparis@parisplace.org>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	John McCutchan <john@johnmccutchan.com>,
	Robert Love <rlove@rlove.org>
Subject: Re: [PATCH 1/1] ftruncate: create FAN_MODIFY and IN_MODIFY events
Date: Tue, 7 Oct 2014 21:23:30 +0200	[thread overview]
Message-ID: <20141007192330.GE30038@quack.suse.cz> (raw)
In-Reply-To: <5432F6E8.7010607@gmx.de>

On Mon 06-10-14 22:09:12, Heinrich Schuchardt wrote:
> On 06.10.2014 15:24, Jan Kara wrote:
> >On Fri 03-10-14 20:16:30, Heinrich Schuchardt wrote:
> >>The fanotify and the inotify API can be used to monitor changes of the file
> >>system.
> >>
> >>System call ftruncate modifies files. Hence it should trigger the corresponding
> >>fanotify (FAN_MODIFY) and inotify (IN_MODIFY) events.
> >   Hum, I would think that the appropriate event gets generated by
> >fsnotify_change() called from notify_change()?
> >
> >								Honza
> 
> Hello Jan,
> 
> thank you for reviewing.
> 
> fsnotify_change() calls
> fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
> 
> fsnotify_modify() calls
> fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
> 
> Only with FSNOTIFY_EVENT_PATH a mount is determined in fsnotify().
> 
> So a FAN_MODIFY event for a mount cannot occur. But I also did not
> see a FAN_MODIFY event when watching a file either.
  Yeah, fanotify processes only FSNOTIFY_EVENT_PATH events (without a path
it cannot create an fd to pass to userspace).

> IN_MODIFY events are actually created.
> 
> So would it be better to do the change in do_truncate and replace
> the call to notify_change by a call to fsnotify_modify?
> 
> I just had a look at
> http://lxr.free-electrons.com/ident?i=notify_change
> 
> There seem to be some other usages of notify_change that deserve
> consideration, e.g. in ecryptfs_truncate().
  Yeah, so the reason why we don't generate FSNOTIFY_EVENT_PATH in
notify_change() is because we have only dentry available there. OTOH from a
quick look it doesn't look impossible to pass path there from the callers.
So I'd rather propagate path to notify_change() and generate also fanotify
events there than generating truncate events for fanotify separately
somewhere else...

								Honza

> >>Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> >>---
> >>  fs/open.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >>
> >>diff --git a/fs/open.c b/fs/open.c
> >>index d6fd3ac..e36f26e 100644
> >>--- a/fs/open.c
> >>+++ b/fs/open.c
> >>@@ -189,6 +189,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
> >>  		error = security_path_truncate(&f.file->f_path);
> >>  	if (!error)
> >>  		error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
> >>+	if (!error)
> >>+		fsnotify_modify(f.file);
> >>  	sb_end_write(inode->i_sb);
> >>  out_putf:
> >>  	fdput(f);
> >>--
> >>2.1.0
> >>
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

  reply	other threads:[~2014-10-07 19:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 18:16 [PATCH 1/1] ftruncate: create FAN_MODIFY and IN_MODIFY events Heinrich Schuchardt
2014-10-06 13:24 ` Jan Kara
2014-10-06 20:09   ` Heinrich Schuchardt
2014-10-07 19:23     ` Jan Kara [this message]
2014-10-23 21:35       ` [PATCH v2 1/1] ftruncate, truncate: create fanotify events Heinrich Schuchardt
2014-11-10 20:30         ` Jan Kara
2014-11-10 23:10           ` Heinrich Schuchardt
2014-11-11  7:34           ` Christoph Hellwig
2014-11-11 11:09             ` Jan Kara
2014-11-11 19:55               ` Heinrich Schuchardt
2014-11-14 10:01                 ` Jan Kara
2014-11-14 21:30                   ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141007192330.GE30038@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=eparis@parisplace.org \
    --cc=john@johnmccutchan.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=rlove@rlove.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).