Re: Listen to file changes

2012-12-14 Thread C. P. Ghost
On Fri, Dec 14, 2012 at 12:08 PM, Arthur Chance  wrote:
> On 12/14/12 10:34, Polytropon wrote:
>>
>> On Fri, 14 Dec 2012 01:45:43 -0800 (PST), Jack Mc Lauren wrote:
>>>
>>> Hi all
>>> I want to monitor files access and change time. How can I
>>> listen to specific file or directory to monitor ? I'm coding with c.
>>
>>
>> If I remember correctly, what you're searching for does already
>> exist: FAM - the File Alteration Monitor. It's in the ports
>> collection (/usr/ports/devel/fam). There are also C++ and
>> Ruby bindings, maybe you can also interface with C...
>>
>> For C: Maybe using readdir() et al. could be useful? Also see
>> "man 5 inode", "man 5 dir" and "man 3 readdir" for more info.
>> And struct ufs2_dinode in /usr/include/ufs/ufs/dinode.h should
>> have the information you need to parse for; maybe also check
>> the FILE type in /usr/include/stdio.h for access flags.
>
> See also kevent(2) and the EVFILT_VNODE system filter.

Exactly. Check out how "tail -f" works in
/usr/src/usr.bin/tail/forward.c

-cpghost.

-- 
Cordula's Web. http://www.cordula.ws/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Listen to file changes

2012-12-14 Thread Arthur Chance

On 12/14/12 10:34, Polytropon wrote:

On Fri, 14 Dec 2012 01:45:43 -0800 (PST), Jack Mc Lauren wrote:

Hi all
I want to monitor files access and change time. How can I
listen to specific file or directory to monitor ? I'm coding with c.


If I remember correctly, what you're searching for does already
exist: FAM - the File Alteration Monitor. It's in the ports
collection (/usr/ports/devel/fam). There are also C++ and
Ruby bindings, maybe you can also interface with C...

For C: Maybe using readdir() et al. could be useful? Also see
"man 5 inode", "man 5 dir" and "man 3 readdir" for more info.
And struct ufs2_dinode in /usr/include/ufs/ufs/dinode.h should
have the information you need to parse for; maybe also check
the FILE type in /usr/include/stdio.h for access flags.


See also kevent(2) and the EVFILT_VNODE system filter.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Listen to file changes

2012-12-14 Thread Polytropon
On Fri, 14 Dec 2012 01:45:43 -0800 (PST), Jack Mc Lauren wrote:
> Hi all
> I want to monitor files access and change time. How can I
> listen to specific file or directory to monitor ? I'm coding with c.

If I remember correctly, what you're searching for does already
exist: FAM - the File Alteration Monitor. It's in the ports
collection (/usr/ports/devel/fam). There are also C++ and
Ruby bindings, maybe you can also interface with C...

For C: Maybe using readdir() et al. could be useful? Also see
"man 5 inode", "man 5 dir" and "man 3 readdir" for more info.
And struct ufs2_dinode in /usr/include/ufs/ufs/dinode.h should
have the information you need to parse for; maybe also check
the FILE type in /usr/include/stdio.h for access flags.


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Listen to file changes

2012-12-14 Thread Jack Mc Lauren
Hi all
I want to monitor files access and change time. How can I listen to specific 
file or directory to monitor ? I'm coding with c.

Thanks In advance ...   
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"