# file alteration monitors



## tajudd (Dec 22, 2010)

Hi alls.

How is a FAM leveraged?  I see local/libexec/gam_server and a few libraries.  The executable that needs to run with a FAM is linked (ldd) to the binary.  I don't see a rc.d startup script to run gam_server.

I'm not quite sure what (if anything) I need to do to enable (fully) the FAM functionality.  Documentation on the subject is nil and I don't want to run around trying to solve something that's not broken.



Any FAM experts out there that would mind briefly explaining if anything else other than linking FAM to a binary is necessary?


----------



## SirDice (Dec 22, 2010)

If you are talking about devel/gamin then depending on how you built it it'll use kqueue(2) or it's build in monitor. By default it'll use kqueue.


----------



## tajudd (Dec 22, 2010)

Perhaps I didn't make my question clear.

Is getting a binary linked with libfam.so.0 all I need to successfully do in order to introduce FAM functions to the binary?  what's gam_server then used for?
Do I need to start maybe an assisting binary like gam_server above?


thanks.


----------



## SirDice (Dec 22, 2010)

tajudd said:
			
		

> Is getting a binary linked with libfam.so.0 all I need to successfully do in order to introduce FAM functions to the binary?


That's the idea of a library, yes.



> what's gam_server then used for?
> Do I need to start maybe an assisting binary like gam_server above?




```
dice@molly:/usr/ports/devel/fam>cat files/pkg-message.in
************************************************************************

1. In order to run this port, please add the following line to /etc/rpc if
it is not already there:

--------------------------------------------------------------------
sgi_fam         391002
--------------------------------------------------------------------

2. To run fam from inetd (the recommended method), then please add the
following lines to /etc/inetd.conf if they are not already there:

--------------------------------------------------------------------
# FAM: File Alteration Monitor [devel/fam]
sgi_fam/1-2     stream rpc/tcp wait root %%LOCALBASE%%/bin/fam  fam
--------------------------------------------------------------------

After modifying /etc/inetd.conf, you must (as root) run:

        killall -HUP inetd

Fam also requires that portmapper is running.  Add the appropriate
entry to /etc/rc.conf:

For 4.x:
Add portmap_enable="YES" and either reboot or run /usr/sbin/portmap.

For 5.x and later:
Add rpcbind_enable="YES" and either reboot or run /etc/rc.d/rpcbind start.

************************************************************************
```


----------



## gordon@ (Dec 22, 2010)

If you are okay with making your program FreeBSD specific, use kqueue() instead. It doesn't require any additional daemons running like FAM does.


----------



## tajudd (Dec 23, 2010)

gordon@ said:
			
		

> If you are okay with making your program FreeBSD specific, use kqueue() instead. It doesn't require any additional daemons running like FAM does.



Only if I was so good for that.  I'm working on programs already in ports.  The current maintainer didn't seem to be too willing to help me make it updated, so I reinvented that wheel.

Still working on perfecting it.


----------



## astounding (Jan 7, 2011)

*File system notifications -- Any progress?*

Hi,

Does anyone know of progress on a file notification system for monitoring changes to a set of files/directories/subdirectories?

I think Ilya Putsikau had a 2010 summer of code project in this area.  Anyone know what happened to that code?  Was anything useful developed?

Is there anything like Linux's inotify, or better, Mac OS X's FSEvents API?

Using kqueue is evil, as one has to maintain an open file descriptor for each and every file/directory monitored, and that's a bad idea, at least in the uses I need it for.  (I think the Gamin file alteration monitor project uses kqueue on FreeBSD and has to resort to this awful work-around.  Ugh.)

Wondering,
Aaron out.


----------



## tajudd (Jan 8, 2011)

SirDice said:
			
		

> That's the idea of a library, yes.
> 
> 
> 
> ...


I'm still having problems.
Lack of documentation is my #1 problem here.  I read Google and everything I can think of...
The above instructions are for devel/fam instead of devel/gamin (which is now the default in ports).  The documentation that is available for gamin is "read the docs for fam, it's the same".  It is not the same.

I am getting the errors such as below:

```
Jan  7 22:22:17 mail imapd: Failed to connect to socket /tmp/fam-vmail/fam-
Jan  7 22:22:17 mail imapd: LOGIN, user=tajudd@<domain>, ip=[10.1.10.80], port=[61844], protocol=IMAP
Jan  7 22:22:18 mail imapd: Failed to connect to socket /tmp/fam-vmail/fam-
Jan  7 22:22:18 mail imapd: Failed to create cache file: maildirwatch (tajudd@<domain>)
Jan  7 22:22:18 mail imapd: Error: Input/output error
Jan  7 22:22:18 mail imapd: Check for proper operation and configuration
Jan  7 22:22:18 mail imapd: of the File Access Monitor daemon (famd).
```

I updated inetd.conf to point to the only executable gamin installs (gam_server) but all the other instructions are the same.  Getting errors.  Would like some proper documentation for what's going on here.


----------



## tajudd (Jan 8, 2011)

*PARTIAL solve - FAM setup*

Lacking documentation, oh my gosh.
Helpful post to those who are interested in finding my status.

I made a package of everything compiled with devel/gamin support.  Getting less than nowhere with gamin, I then removed everything.  Recompiled everything (including dependent packages) with devel/fam support.  Used the skimpy documentation on devel/fam and various postings to troubleshoot.  Well, currently, I'm no longer getting the above errors.  What I've done:


removed my /tmp symlink and made a traditional directory
*chmod 1777 /tmp*
create (if not already existing) a local user to be used for the authentication library
edited the local user defined to have a *valid* home directory (/tmp)

Restarted my mail client and I did not get any errors.  Now I'm trying to test the mail subsystem from point A to point Z.


----------

