All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Jan Kara <jack@suse.cz>
Cc: 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: Mon, 06 Oct 2014 22:09:12 +0200	[thread overview]
Message-ID: <5432F6E8.7010607@gmx.de> (raw)
In-Reply-To: <20141006132449.GD7526@quack.suse.cz>

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.

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().

Best regards

Heinrich Schuchardt

>>
>> 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
>>


  reply	other threads:[~2014-10-06 20:11 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 [this message]
2014-10-07 19:23     ` Jan Kara
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=5432F6E8.7010607@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=eparis@parisplace.org \
    --cc=jack@suse.cz \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.