2008-12-20 06:51:45

by Niraj kumar

[permalink] [raw]
Subject: [Question] inotify : process based filtering of events

All,

I am trying to use inotify to monitor filesystem events but
my problem is that I am only interested in changes that
is being done by a particular process and it's children
(could be the same process which used inotify APIs).

Is it possible to achieve this process based filtering of events
using inotify infrastructure?

-Niraj


2008-12-20 10:40:59

by Evgeniy Polyakov

[permalink] [raw]
Subject: Re: [Question] inotify : process based filtering of events

Hi.

On Sat, Dec 20, 2008 at 12:21:33PM +0530, Niraj kumar ([email protected]) wrote:
> I am trying to use inotify to monitor filesystem events but
> my problem is that I am only interested in changes that
> is being done by a particular process and it's children
> (could be the same process which used inotify APIs).
>
> Is it possible to achieve this process based filtering of events
> using inotify infrastructure?

You can try using inotify nested attributes patch [1] and filter events
in userspace based on reported pid/tid. With the fsnotify changes coming
it may be possible to have similar functionality there.

1. Inotify nested attributes.
http://lkml.org/lkml/2008/11/25/272

2. Example usage and test application.
http://www.ioremap.net/node/73

--
Evgeniy Polyakov

2008-12-20 13:13:15

by Niraj kumar

[permalink] [raw]
Subject: Re: [Question] inotify : process based filtering of events

>>
>> Is it possible to achieve this process based filtering of events
>> using inotify infrastructure?
>
> You can try using inotify nested attributes patch [1] and filter events
> in userspace based on reported pid/tid.

I saw your patch and the related discussion...
But I am thinking that filtering in userspace based on pid/tid
could be too much overhead when the data that I am interested
in might be just a small fraction of the whole thing...

I was hoping to add a flag (similar to IN_ATTRS that you have added)
which, when used, will only collect events for the calling
process and it's children...

-Niraj

2008-12-20 17:13:57

by Evgeniy Polyakov

[permalink] [raw]
Subject: Re: [Question] inotify : process based filtering of events

On Sat, Dec 20, 2008 at 06:43:01PM +0530, Niraj kumar ([email protected]) wrote:
> I was hoping to add a flag (similar to IN_ATTRS that you have added)
> which, when used, will only collect events for the calling
> process and it's children...

With nested attributes patch you can add your own callback which will
check private list of interested pids and only add event into the queue
when current credentials match stored data. IMHO that will br much
smaller amount of work than extending inotify with new flag and redoing
new event structure processing. But it is up to you to decide of course
:)

--
Evgeniy Polyakov