tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Examples of kfilter_register(9)?

On Monday 31 August 2009, Hubert Feyrer wrote:
> Unless I'm totally off-track here, there is a userland interface: The
> code below watches a given directory, and if any file is written or
> linked to it runs a given command. Maybe that helps... based on code
> by someone elase (I forgot who... sorry! :).
>   - Hubert
>      qd = kqueue();
>      EV_SET( &filter, fd, EVFILT_VNODE, EV_ADD,

The kevent/kqueue stuff provides a very neat little 
inotify-like-but-more-unified interface to kernel events from userland; 
however, the kfilter_register(9) interface is apparently there to 
create new filters beyond the EVFILT_VNODE/friends system-supplied 
ones. They are given an actual string-ified name and you have to 
provide little functions to the struct you pass it that run when a 
knote arrives.

However, knote(9) only describes the interface for kernel systems to 
deliver notes, not what notes are available to a kfilter_* custom 
filter, and not details of what the impacts are on the system. It looks 
like you can subscribe to specific notes, and in the kernel I see notes 
like NOTE_WRITE and NOTE_RENAME and so forth in sys/sys/event.h.

In the knote(9) manpage, "(which is
     passed to the appropriate filter routine)" suggests that it does 
only run specific kfilters, and then in kfilter_register, the struct 
filterops seems to have a place to hook your filter into specific 
hints, and that appears to be an OR'd list of NOTE_*.

But, my issue is that there doesn't seem to be any code--anywhere--that 
actually makes use of kfilter_register() and so I became curious. :-)

Anyway, I did find sys/sys/event.h which lists a pile of NOTE_*, but..  
I always liked the additional comments in the manpages to guide me is 
all. Sometimes it seems like there are assumptions about..  say.. CPU 
scheduling.. that just plain elude me.

Home | Main Index | Thread Index | Old Index