--- fam-2.7.0.orig/debian/changelog
+++ fam-2.7.0/debian/changelog
@@ -0,0 +1,541 @@
+fam (2.7.0-17.1b1) staging; urgency=high
+
+  * No-change rebuild against libstdc++6
+
+ -- Philip Muškovac <yofel@kubuntu.org>  Thu, 27 Aug 2015 23:32:48 +0000
+
+fam (2.7.0-17.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * debian/control, debian/rules: Update to automake1.11. (Closes:
+    #724366)
+
+ -- Eric Dorland <eric@debian.org>  Sun, 16 Feb 2014 02:54:43 -0500
+
+fam (2.7.0-17) unstable; urgency=low
+
+  * Increase the number of declared error message slots (FAM_NUM_ERRORS)
+    using patch by Loïc Minier (closes: #438345)
+  * Use a variable of type (const char *) to receive the return value of
+    strstr to avoid build failure with gcc 4.4 due to the "Strict
+    null-terminated sequence utilities" feature
+  * Bump to Standards-Version 3.9.0.0 (no change necessary)
+  * Add debian/source/format (1.0)
+
+ -- Chuan-kai Lin <cklin@debian.org>  Mon, 02 Aug 2010 21:25:43 -0700
+
+fam (2.7.0-16) unstable; urgency=low
+
+  * Update to Standards-Version 3.8.3.0
+  * Define DEB_AUTO_UPDATE_ACLOCAL in debian/rules to fix FTBFS with cdbs
+    0.4.61 (Closes: #544653)
+
+ -- Chuan-kai Lin <cklin@debian.org>  Sat, 05 Sep 2009 12:48:21 -0700
+
+fam (2.7.0-15) unstable; urgency=low
+
+  * Suppress status_of_proc failure message at start
+    (Closes: #537545, #539200)
+  * Make libfam0 Suggests instead of Recommends fam (Closes: #400836)
+
+ -- Chuan-kai Lin <cklin@debian.org>  Mon, 03 Aug 2009 10:33:04 -0700
+
+fam (2.7.0-14) unstable; urgency=low
+
+  * Update to Standards-Version 3.8.2.0
+  * Upgrade build dependency to automake-1.10
+  * Upgrade to debhelper compatibility level 7
+  * Declare ${misc:Depends} for debhelper
+  * Update copyright file with copyright notice and applicable GPL and
+    LGPL version numbers
+  * Set -e flag in preinst
+  * Apply patch from Glenn Wurster to eliminate partial socket send
+    assertion error (Closes: #435274)
+  * Link famd against librt and libpthread to solve 100% CPU usage problem;
+    suggested by Wil Evers on the fam mailing list
+    (http://oss.sgi.com/projects/fam/mail_archive/200301/msg00011.html)
+    (Closes: #252896, #500387, #501081)
+  * Add init.d status support (patch from Peter Eisentraut)
+    (Closes: #527312)
+  * Fix fam.conf typo and comment-out default settings (Closes: #470071)
+  * Allow user to specify as a command-line argument which port should
+    famd bind (patch from Glenn Wurster) (Closes: #435267)
+  * Ensure init.d start does not fail when famd is already running
+    (Closes: #377039)
+
+ -- Chuan-kai Lin <cklin@debian.org>  Mon, 06 Jul 2009 15:33:15 -0700
+
+fam (2.7.0-13.4) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Fix FTBFS because of missing include.  Closes: #518888.
+
+ -- Daniel Schepler <schepler@debian.org>  Sat, 02 May 2009 09:15:40 -0700
+
+fam (2.7.0-13.3) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Fix grep call in init.d script to not fail if /etc/inetd.conf isn't
+    present (Closes: #446631, #451344, #465345).
+
+ -- Daniel Baumann <daniel@debian.org>  Sun,  8 Jun 2008 07:43:00 +0200
+
+fam (2.7.0-13.2) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Fix GCC 4.3 compatibility (Closes: #461678)
+
+ -- Moritz Muehlenhoff <jmm@debian.org>  Thu, 20 Mar 2008 23:20:14 +0100
+
+fam (2.7.0-13.1) unstable; urgency=low
+
+  * Non-maintainer uploaded to fix release goal issue.
+  * Correct LSB header of init.d script (Closes: #458474).
+  * Add depend from fam to update-inetd, as reported by lintian.
+
+ -- Petter Reinholdtsen <pere@debian.org>  Sun, 27 Jan 2008 06:29:00 +0100
+
+fam (2.7.0-13) unstable; urgency=low
+
+  * In the fam init script, redirect /dev/null to stdin when starting famd
+    to avoid faulty if-started-by-inetd heuristic in famd when running
+    through ssh remote command execution (closes: #260516, #284998)
+  * Apply patch from Giuseppe Sacco to catch a seemingly impossible
+    runtime condition (closes: #375967)
+
+ -- Chuan-kai Lin <cklin@debian.org>  Sun, 22 Jul 2007 16:53:24 -0700
+
+fam (2.7.0-12) unstable; urgency=low
+
+  * Have libfam0 replace libfam0c102 without conflicts, to provide a
+    better upgrade path for sarge->etch based on feedback.  Thanks to
+    Steve Langasek for investigating this issue (closes: #405165)
+
+ -- Chuan-kai Lin <cklin@debian.org>  Sun,  7 Jan 2007 15:24:38 -0800
+
+fam (2.7.0-11) unstable; urgency=low
+
+  * Force pasv in watch file to avoid empty FTP indices
+  * Include memory-leak patch by David Price (closes: #381423)
+  * Use LSB init-functions from lsb-base (closes: #378116, #384860)
+  * Update to Standards-Version 3.7.2.0
+  * Relax the dependency of dummy package libfam0c102 to
+    >= ${Source-Version} instead of requiring strict equality
+
+ -- Chuan-kai Lin <cklin@debian.org>  Wed,  4 Oct 2006 15:29:13 -0700
+
+fam (2.7.0-10) unstable; urgency=low
+
+  * Use g++ 4.1 compatibility fix by Martin Michlmayr (closes: #356229)
+  * Correct comments in the fam.h header file (closes: #203858)
+  * Correct inaccuracies in the fam.3 man page (closes: #301161)
+  * Fix spelling error in libfam0 README.Debian
+
+ -- Chuan-kai Lin <cklin@debian.org>  Tue,  2 May 2006 22:02:54 -0700
+
+fam (2.7.0-9) unstable; urgency=medium
+
+  * Re-introduce the libfam0c102 dummy package to ensure that systems with
+    libfam0c102 package installed only to satisfy dependency will also
+    receive updates to new fam libraries.  Full story in README.Debian in
+    the libfam0 package.  (closes: #327241, #335564, #332847)
+  * Include stdlib.h to cure a FTBFS bug (fix by Daniel Schepler).
+    (closes: #347876)
+  * Include GNU/kFreeBSD compatibility patch (fix by Robert Millan and
+    Aurelien Jarno).  (closes: #325291)
+  * Make fam Depend on portmap again because fam cannot work without the
+    portmapper, even in a local environment.  (closes: #332790, #332665)
+  * Remove start-stop-daemon call.  (closes: #339849)
+  * Add init script dependency description.  (closes: #337645)
+
+ -- Chuan-kai Lin <cklin@debian.org>  Mon, 16 Jan 2006 17:38:05 -0800
+
+fam (2.7.0-8) unstable; urgency=low
+
+  * Acknowledge NMU (closes: #317700, #317839)
+  * Make libfam0 Provides libfam0c102
+  * Make libfam0 depend on the same version of fam (closes: #185635)
+  * Fix famd.conf typo in famd man page (closes: #324837)
+  * Upgrade build dependency to automake-1.9
+
+ -- Chuan-kai Lin <cklin@debian.org>  Sun, 28 Aug 2005 20:17:15 -0700
+
+fam (2.7.0-7.2) unstable; urgency=low
+
+  * #include <limits.h> instead of "limits.h" (Closes: 317839)
+
+ -- Mike Furr <mfurr@debian.org>  Tue, 12 Jul 2005 01:21:58 +0000
+
+fam (2.7.0-7.1) unstable; urgency=low
+
+  * Non-maintainer upload
+  * Rebuild against new CXX ABI
+    - new binary pkg is called libfam0 to match what ubuntu has done
+    - Closes: 317700
+
+ -- Mike Furr <mfurr@debian.org>  Sun, 10 Jul 2005 19:46:12 +0000
+
+fam (2.7.0-7) unstable; urgency=low
+
+  * New maintainer (closes: #303194)
+  * Port fam dnotify patch by Alexander Larsson (closes: #234787)
+  * Incorporate read-only filesystem patch by Nedko Arnaudov
+    (closes: #245448)
+  * Remove reference to INSTALL file from README (closes: #255699)
+  * Fix typo in package description (closes: #299974)
+  * Downgrade portmap dependency to Recommends (closes: #289625)
+  * Fix config file name in manual pages (closes: #269899, #280429)
+  * Make cdbs dependency versioned for DEB_UPDATE_RCD_PARAMS
+  * Add upstream version watch file
+
+ -- Chuan-kai Lin <cklin@debian.org>  Thu,  5 May 2005 23:30:19 -0700
+
+fam (2.7.0-6) unstable; urgency=high
+
+  * debian/control:
+    Set Priority to optional to avoid override disparity.
+  * debian/rules:
+    Add "defaults 21" to update-rc.d parameters causing famd to
+    be startet after inetd (closes: Bug#277528).
+    urgency=high because this is a RC bug.
+  * debian/NEWS:
+    Tell users about this change. Includes instructions for users
+    having fam already installed and should make modifications to
+    their init manually.
+
+ -- Joerg Wendland <joergland@debian.org>  Sat,  6 Nov 2004 19:51:32 +0100
+
+fam (2.7.0-5) unstable; urgency=low
+
+  * debian/fam.preinst:
+    Add a call to start-stop-daemon in upgrade phase to forcibly
+    stop all still running instances of famd.  This is because
+    some old versions (at least 2.6.0-6) missed this call in their
+    prerm.  This could be the cause of (now closed) bug #225636.
+
+ -- Joerg Wendland <joergland@debian.org>  Tue, 10 Feb 2004 12:54:32 +0100
+
+fam (2.7.0-4) unstable; urgency=low
+
+  * Update libtool upon build. (closes: Bug#230877)
+    (cdbs vars to debian/rules, Build-Depends on libtool >= 1.5-2
+     and on automake1.6 and autoconf for this)
+  * debian/patches/04_autotools.patch:
+    Remove because we are running autoconf and automake anyway.
+
+ -- Joerg Wendland <joergland@debian.org>  Tue,  3 Feb 2004 14:04:56 +0100
+
+fam (2.7.0-3) unstable; urgency=low
+
+  * Now really add the forgotten old changelog entries.
+  * Upload to unstable.
+
+ -- Joerg Wendland <joergland@debian.org>  Fri, 30 Jan 2004 18:09:36 +0100
+
+fam (2.7.0-2) experimental; urgency=low
+
+  * The last upload contained somewhat out-of-date patches and
+    not the complete changelog of its antecedent versions.
+  * 01_dnotify.patch:
+    Use newer version of this patch.
+  * 03_autotools.patch -> 04_autotools.patch
+  * 03_getgrouplist.patch:
+    Use getgrouplist(3) when retrieving a user's groups.
+  * Readd LARGEFILE defs.
+  * Readd test.c++ to libfam-dev examples.
+  * Heading of fam.conf.5 was still "famd.conf".
+
+ -- Joerg Wendland <joergland@debian.org>  Fri, 30 Jan 2004 17:53:22 +0100
+
+fam (2.7.0-1) experimental; urgency=low
+
+  * New upstream release 
+    (closes: Bug#224738):
+    - should fix problems with unmounting filesystems with
+      monitored files 
+      (closes: Bug#225636)
+  * Change build to cdbs, tarball-build and simple-patchsys
+    for easier maintenance:
+    - adapt debian/control:Build-Depends to that
+    - remove fam.postinst, fam.prerm, fam.postrm
+      (now handled by debhelper)
+  * Move debian/*.files to debian/*.install.
+  * Compile libraries with -fPIC. 
+    (closes: Bug#223799)
+  * /etc/fam.conf:
+    local_only = true
+    (closes: Bug#222851)
+  * patches in debian/patches:
+    - 00_maintainer-mode.patch: 
+      add AM_MAINTAINER_MODE to configure.ac and aclocal.m4
+    - 01_dnotify.patch: 
+      add the dnotify monitor
+    - 02_cleanup.patch:
+      still the old cleanup code stolen from fedora
+    - 03_autotools.patch:
+      add the generated autotools code (Makefile.in, configure) so that a run
+      of autoconf and automake is not needed when building this package
+  * Remove Dependency on debconf.
+
+ -- Joerg Wendland <joergland@debian.org>  Fri, 30 Jan 2004 15:24:34 +0100
+
+fam (2.6.10-6) unstable; urgency=low
+
+  * debian/patches/01_dnotify.dpatch:
+    Update DNotify patch from fedoras fam-2.6.8-12. This has some
+    performance improvements over the old one. See
+    https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=99364
+    for more info on this. Additionally I patched this patch so
+    that fam falls back to polling if dnotify is not supported.
+  * debian/patches/03_gcc32.dpatch:
+    Add some more fixes for compilation with GCC3. These are only
+    to get rid of the warnings concerning deprecated headers.
+  * debian/patches/05_largefiles.dpatch:
+    Fix largefile support. (closes: Bug#191084)
+  * debian/patches/06_getgrouplist.dpatch:
+    Another patch from fedora, to use getgrouplist(3) in Cred.c++
+    instead of iterating over groups on our own. This should
+    result in increased performance, especially when not using
+    /etc/groups (like in NIS or LDAP environments).
+  * Remove inetd service and always start fam as daemon. Therefore,
+    there are no more debconf questions, templates and config are
+    thus removed. (closes: Bug#220471, Bug#216833)
+  * debian/patches/*:
+    Fix patch descriptions.
+  * debian/README.Debian:
+    Compile patch descriptions into README.Debian, for those curious
+    users.
+  * debian/fam.init:
+    Fix restart, fam options should be given to fam when fam is started,
+    not when it is stopped.
+
+ -- Joerg Wendland <joergland@debian.org>  Mon, 17 Nov 2003 11:49:06 +0100
+
+fam (2.6.10-5) unstable; urgency=high
+
+  * debian/control:
+    - set priority of fam to optional (closes: Bug#219004)
+  * Urgency=high because of this and there being no changes to
+    the actual software.
+  * Add danish debconf translation. Thanks to Morten Brix Pedersen.
+    (closes: Bug#217290)
+
+ -- Joerg Wendland <joergland@debian.org>  Fri,  7 Nov 2003 18:37:13 +0100
+
+fam (2.6.10-4) unstable; urgency=high
+
+  * The "next time I will buy myself a powerpc" release.
+  * When disabling the maintainer-mode, config.h would only be
+    created from config.h.in. A missing "USE_DNOTIFY" in that
+    caused the compiler to choose IMon (and therefore the Pollster)
+    to be used in the fam. This should now really close this bug.
+
+ -- Joerg Wendland <joergland@debian.org>  Mon, 13 Oct 2003 23:36:56 +0200
+
+fam (2.6.10-3) unstable; urgency=high
+
+  * Next try to fix the build-bug (see below), urgency
+    set to high for this reason. Thanks to Graham Wilson for
+    his efforts to debug this. Still, please reopen this report
+    if this upload still does not fix the issues.
+    (closes: Bug#213474)
+  * configure.in:
+    include AM_MAINTAINER_MODE
+  * debian/rules:
+    - ./configure --disable-maintainer-mode
+    - use newer config.{sub,guess} and ltmain.sh to build
+      shared libraries that are named *.so (shouldn't that be
+      the default?).
+  * debian/control:
+    - bump Standards-Version to 3.6.1.0, no changes required.
+    - libfam-dev is in section libdevel
+
+ -- Joerg Wendland <joergland@debian.org>  Mon, 13 Oct 2003 15:02:03 +0200
+
+fam (2.6.10-2) unstable; urgency=high
+
+  * Acknowledge NMU by bubulle, thanks a lot.
+    (closes: Bug#198644, Bug#199084)
+  * Add japanese debconf translation, thanks to Kenshi Muto.
+    (closes: Bug#214046)
+  * Urgency is set to high because simply rebuilding this package
+    should close a grave functionality bug on PPC and no modifications
+    were made to the software itself. Feel free to reopen the relevant
+    bug reports if the bug is still not fixed.
+    (closes: Bug#213474)
+
+ -- Joerg Wendland <joergland@debian.org>  Tue,  7 Oct 2003 00:02:29 +0200
+
+fam (2.6.10-1.1) unstable; urgency=low
+
+  * NMU
+  * Switch to po-debconf for debconf templates. Closes: #198644
+  * French translation of debconf templates. Same bug nr.
+  * Corrected typo in README.Debian. Closes: #199084
+
+ -- Christian Perrier <bubulle@debian.org>  Mon, 22 Sep 2003 18:50:09 +0200
+
+fam (2.6.10-1) unstable; urgency=low
+
+  * New upstream release.
+  * After a long period of testing, I am finally sure that libfam0c102
+    definitely can provide libfam0 without introducing problems. libfam
+    is apparently completely "extern C".
+    (closes: Bug#176849, Bug#177970, Bug#181100, Bug#181104)
+  * fam.init: test for program name and program number in inetd.conf
+    avoid problems with older installations.
+    (closes: Bug#182501)
+  * Use --oknodo in stop actions in init-script.
+    (closes: Bug#185229)
+  * Use dpatch instead of own patch script.
+  * Don't patch configure.in but configure instead to not build-depend
+    on autoconf, automake and libtool. (The same for a couple of
+    Makefile.in's)
+  * Provide updated autotools in orig.tar.gz.
+  * Standards-Version 3.5.9.
+  * Remove debian/patches/01gcc3, it is now included upstream.
+  * Include patch by Robert Millan <rmh@khazad.dyndns.org> to build
+    on GNU/Hurd.
+    (closes: Bug#187701)
+
+ -- Joerg Wendland <joergland@debian.org>  Thu, 15 May 2003 08:30:06 +0200
+
+fam (2.6.9-4) unstable; urgency=low
+
+  * Link the daemon against -lrt and -lpthread for DNotify
+    to use the right implementation of SIGRTMIN. Thanks to
+    Wil Evers for pointing this out. (closes: Bug#157031)
+  * Fix fam(1m) to point to the correct path of the daemon.
+    (closes: Bug#175488)
+  * Build with new gcc-defaults to become g++-3.2-blessed.
+  * Rename libfam0 to libfam0c102.
+  
+ -- Joerg Wendland <joergland@debian.org>  Wed,  8 Jan 2003 14:36:55 +0100
+
+fam (2.6.9-3) unstable; urgency=low
+
+  * fix preinst so that now all calls to update-inetd are being
+    made conditionally (hopefully) ;-/ (closes: Bug#173561)
+
+ -- Joerg Wendland <joergland@debian.org>  Wed, 18 Dec 2002 21:20:11 +0100
+
+fam (2.6.9-2) unstable; urgency=low
+
+  * debian/fam.postrm:
+    call update-inetd only if it exists (closes: Bug#167906)
+  * debian/fam.templates:
+    describe FAM's purposes so that debconf's question about
+    FAM's launch mode is less confusing and downgrade this
+    question's priority to 'low' because starting FAM from
+    inetd is _the_ and a good default. Document the configurability
+    in README.Debian. Thanks to ejad for pointing this out.
+    (closes: Bug#168474)
+  * debian/control:
+    - remove libwrap from Build-Depends for now
+    - bump Standards-Version to 3.5.8
+    - add versioned dependency on debconf
+
+ -- Joerg Wendland <joergland@debian.org>  Fri, 13 Dec 2002 00:04:32 +0100
+
+fam (2.6.9-1) unstable; urgency=low
+
+  * New upstream release
+  * Bump Standards-Version to 3.5.7.1
+  * debian/patches/00dnotify:
+    add some debugging output
+  * debian/patches/02daemonize:
+    remove, since upstream now uses daemon(3) on Linux
+  * debian/patches/03gcc32:
+    some fixes for compilation with gcc/g++ 3.2
+  * debian/patches/04docs:
+    replace IMon with DNotify in manpage and fix "see also" and package
+    description (closes: Bug#157823)
+  * added init script to allow FAM to run as daemon and choose between
+    inetd or standalone via debconf
+  * check in config and postinst whether update-inetd is available
+    and only use it if it is available (closes: Bug#167906)
+  * replace Build-Dep automake with automake1.4
+  * use debhelper >> 4.1
+  
+ -- Joerg Wendland <joergland@debian.org>  Tue,  5 Nov 2002 21:56:39 +0100
+
+fam (2.6.8-3) unstable; urgency=low
+
+  * Add Build-Dep: libtool to let aclocal work.
+
+ -- Joerg Wendland <joergland@debian.org>  Fri, 19 Jul 2002 01:53:13 +0200
+
+fam (2.6.8-2) unstable; urgency=low
+
+  * Add Build-Dep: automake so patches to Makefile.am work
+
+ -- Joerg Wendland <joergland@debian.org>  Fri, 19 Jul 2002 01:07:41 +0200
+
+fam (2.6.8-1) unstable; urgency=low
+
+  * New upstream release.
+    (closes: Bug#151972)
+  * Bumped Standards-Version to 3.5.6.1.
+  * patches/00dnotify:
+    new dnotify patch from Alex Larsson
+  * patches/01gcc31:
+    build-patch for gcc 3.1. Stolen from Redhat's fam package.
+  * patches/02daemonize:
+    emulate IRIX' daemonize() to let famd run as daemon.
+    (closes: Bug#126953)
+  * patches/03cleanup:
+    better cleanup for local clients. Stolen from Redhat's fam package.
+  * Reverted inetd.conf entry to use RPC name again as it is included
+    in netbase now.
+  * Removed gcc3-build patch. It is now included in upstream.
+  * use polling when compiled with dnotify patch and dnotify is
+    not available (on 2.2 kernels). (closes: Bug#148853)
+  * Recommend fam for libfam0 since using libfam without fam does
+    not always make sense.
+
+ -- Joerg Wendland <joergland@debian.org>  Thu, 18 Jul 2002 22:00:48 +0200
+
+fam (2.6.6.1-4) unstable; urgency=low
+
+  * Fixed call of debian/patch. (closes: Bug#125801)
+
+ -- Joerg Wendland <joergland@debian.org>  Wed, 19 Dec 2001 18:17:17 +0100
+
+fam (2.6.6.1-3) unstable; urgency=low
+
+  * Added portmap to dependencies of fam. (closes: Bug#124057)
+  * Added some patches from Redhat's RPM fixing a race and a logging error.
+  * Fixed sources to compile with gcc3 (closes: Bug#124237)
+  * Removed creation of rpc-program entry in postinst (see below).
+  * Changed inetd.conf entry to use program number instead of RPC name since
+    we may not edit /etc/rpc due to policy (closes self-discovered Bug).
+
+ -- Joerg Wendland <joergland@debian.org>  Mon, 17 Dec 2001 22:30:36 +0100
+
+fam (2.6.6.1-2) unstable; urgency=low
+
+  * Removed unnecessary build-depend on libstdc++ (closes: Bug#123648)
+  * Added creation of 'sgi_fam' rpc-program to postinst
+
+ -- Joerg Wendland <joergland@debian.org>  Wed, 12 Dec 2001 21:23:36 +0100
+
+fam (2.6.6.1-1) unstable; urgency=low
+
+  * The "not being blind does not mean to be actually able to see" upload.
+  * Reworked the completely fucked up package.
+  * Added dnotify patch from http://people.redhat.com/alexl/files/fam_dnotify.patch.
+  * Fixed fam.postinst to correctly update inetd.conf (closes: Bug#123190)
+  * Fixed autoconf/automake/libtool scripts and files (closes: Bug#123368)
+  * Added link libfam.so -> libfam.so.0 in libfam-dev (closes: Bug#123265)
+  * Repackaged orig.tar.gz using make dist to get around with automake/libtool
+    symlinks in the tarball. Added the .1 to the upstream version to get it
+    into the archives.
+  * Added fam test program as example to libfam-dev.
+
+ -- Joerg Wendland <joergland@debian.org>  Tue, 11 Dec 2001 13:19:07 +0100
+
+fam (2.6.6-1) unstable; urgency=low
+
+  * Initial Release. (Closes: #95635)
+
+ -- Joerg Wendland <joergland@debian.org>  Tue,  4 Dec 2001 10:47:45 +0100
--- fam-2.7.0.orig/debian/compat
+++ fam-2.7.0/debian/compat
@@ -0,0 +1 @@
+7
--- fam-2.7.0.orig/debian/control
+++ fam-2.7.0/debian/control
@@ -0,0 +1,58 @@
+Source: fam
+Section: admin
+Priority: optional
+Maintainer: Chuan-kai Lin <cklin@debian.org>
+Build-Depends: debhelper (>= 7), cdbs (>= 0.4.0.1), libtool (>= 1.5-2), automake1.11, autoconf
+Standards-Version: 3.9.0.0
+Homepage: http://oss.sgi.com/projects/fam/
+
+Package: fam
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base (>= 3.2-13), portmap, update-inetd
+Description: File Alteration Monitor
+ FAM monitors files and directories, notifying interested applications
+ of changes.
+ .
+ This package provides a server that can monitor a given list of files
+ and notify applications through a socket.  If the kernel supports
+ dnotify (kernels >= 2.4.x) FAM is notified directly by the kernel.
+ Otherwise it has to poll the files' status.  FAM can also provide an
+ RPC service for monitoring remote files (such as on a mounted NFS
+ filesystem).
+
+Package: libfam0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Replaces: libfam0c102 (<< ${binary:Version})
+Provides: libfam0c102
+Suggests: fam (=${binary:Version})
+Description: Client library to control the FAM daemon
+ FAM monitors files and directories, notifying interested applications
+ of changes.
+ .
+ This package provides a shared library to allow programs to connect to
+ the FAM daemon and ask for files to be monitored.
+
+Package: libfam0c102
+Section: libs
+Architecture: all
+Depends: libfam0 (>= ${binary:Version}), ${misc:Depends}
+Description: Dummy package for libfam0
+ FAM monitors files and directories, notifying interested applications
+ of changes.
+ .
+ This is a dummy package that installs libfam0; see README.Debian for
+ libfam0 for details.  You can safely remove this package once libfam0
+ is installed.
+
+Package: libfam-dev
+Section: libdevel
+Architecture: any
+Depends: libfam0 (= ${binary:Version}), ${misc:Depends}
+Description: Client library to control the FAM daemon - development files
+ FAM monitors files and directories, notifying interested applications
+ of changes.
+ .
+ This package provides header files and static libraries to allow the
+ development of programs that interface FAM for file monitoring.
--- fam-2.7.0.orig/debian/copyright
+++ fam-2.7.0/debian/copyright
@@ -0,0 +1,15 @@
+This package was debianized by Joerg Wendland <jeorgland@debian.org> on
+Tue,  4 Dec 2001 10:47:45 +0100.
+
+It was downloaded from http://oss.sgi.com/projects/fam
+The upstream authors are the folks over at SGI, to be contacted
+via owner-fam@oss.sgi.com
+
+Copyright (C) 1999-2003 Silicon Graphics, Inc.  All Rights Reserved.
+Copyright (C) 2001 Red Hat, Inc.  All Rights Reserved.
+
+The FAM daemon is licensed under the GNU General Public License v2
+(see /usr/share/common-licenses/GPL-2), the libfam and its headers
+are licensed under the GNU Lesser General Public License v2.1 (see
+/usr/share/common-licenses/LGPL-2.1).
+
--- fam-2.7.0.orig/debian/fam.NEWS
+++ fam-2.7.0/debian/fam.NEWS
@@ -0,0 +1,16 @@
+fam (2.7.0-6) unstable; urgency=high
+
+  Versions less than 2.7.0-6 of fam installed their initscripts with
+  a priority of 20 (eg. /etc/rc2.d/S20fam).  That caused trouble since
+  the automatic allocation of port numbers for the fam daemon could
+  occupy a port that is needed by other daemons (see Bug #277528
+  at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=277528).  If you
+  installed fam for the first time this will be no issue for you to
+  think of.  If you upgraded fam from an earlier version you should
+  change the symlinks in /etc/rc*.d/ manually, for example by using
+  the following commands (as root):
+
+  update-rc.d -f fam remove
+  update-rc.d fam defaults 21
+
+ -- Joerg Wendland <joergland@debian.org>  Sat,  6 Nov 2004 19:51:32 +0100
--- fam-2.7.0.orig/debian/fam.conf
+++ fam-2.7.0/debian/fam.conf
@@ -0,0 +1,53 @@
+#  fam.conf
+#
+#  For more information on the configuration options below, see the
+#  fam.conf(5) man page.
+
+#
+#  insecure_compatibility disables authentication.  This causes
+#  untrusted_user to be ignored, because the UID presented by every client
+#  connection will be believed.
+#
+#  The -C command-line argument overrides this option.
+#
+#insecure_compatibility = false
+
+#
+#  untrusted_user is the user which will be used for unauthenticated
+#  clients.  If a file can't be stat'ed by this user, those clients won't be
+#  able to fam it.  The value can be a user name or a numeric UID.
+#
+untrusted_user = nobody
+
+#
+#  local_only makes famd ignore requests from remote clients & remote fams.
+#  Note that this is ignored if famd is started by inetd.
+#
+#  The -L command-line argument overrides this option.
+#
+local_only = true
+
+#
+#  idle_timeout sets the number of seconds famd will wait for new
+#  connections before quitting.  A value of zero will cause famd to
+#  wait indefinitely.  The default is 5.
+#
+#  The -T command-line argument overrides this option.
+#
+#idle_timeout = 5
+
+#
+#  nfs_polling_interval sets the number of seconds between polling files
+#  on NFS filesystems.  The default is 6.
+#
+#  The -t command-line argument overrides this option.
+#
+#nfs_polling_interval = 6
+
+#
+#  xtab_verification makes famd check the list of exported filesystems to
+#  verify that requests from remote hosts fall on filesystems which are
+#  exported to the hosts.
+#
+#xtab_verification = true
+
--- fam-2.7.0.orig/debian/fam.init
+++ fam-2.7.0/debian/fam.init
@@ -0,0 +1,54 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          fam
+# Required-Start:    $remote_fs $portmap
+# Required-Stop:     $remote_fs $portmap
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: File Alteration Monitor
+# Description:       Debian init script for File Alteration Monitor
+### END INIT INFO
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON="/usr/sbin/famd"
+NAME="FAM"
+DESC="file alteration monitor"
+
+FAMOPTS="-T 0"
+
+test -x $DAEMON || exit 0
+
+# Stop if we are running from inetd
+egrep -qs "^(sgi_fam|391002)" /etc/inetd.conf
+
+
+. /lib/lsb/init-functions
+set -e
+
+case "$1" in
+  start)
+        status_of_proc $DAEMON $NAME > /dev/null && exit 0
+	log_daemon_msg "Starting $DESC" "$NAME"
+	start-stop-daemon --start --quiet --exec $DAEMON -- $FAMOPTS < /dev/null
+	log_end_msg $?
+	;;
+  stop)
+	log_daemon_msg "Stopping $DESC" "$NAME"
+	start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
+	log_end_msg $?
+	;;
+  restart|force-reload)
+	$0 stop
+	sleep 1
+	$0 start
+	;;
+  status)
+	status_of_proc $DAEMON $NAME
+	;;
+  *)
+	echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
--- fam-2.7.0.orig/debian/fam.install
+++ fam-2.7.0/debian/fam.install
@@ -0,0 +1,4 @@
+usr/sbin/famd
+etc/fam.conf
+usr/share/man/man8/famd.8
+usr/share/man/man5/fam.conf.5
--- fam-2.7.0.orig/debian/fam.preinst
+++ fam-2.7.0/debian/fam.preinst
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "upgrade" ]
+then
+    # remove old inetd.conf entries and disable current ones
+    if [ -x "/usr/sbin/update-inetd" ]; then
+	update-inetd --remove "^391002/1-2.*"
+	update-inetd --disable "^sgi_fam/1-2.*"
+    fi
+fi
+
+#DEBHELPER#
--- fam-2.7.0.orig/debian/libfam-dev.examples
+++ fam-2.7.0/debian/libfam-dev.examples
@@ -0,0 +1 @@
+build-tree/fam-2.7.0/test/test.c++
--- fam-2.7.0.orig/debian/libfam-dev.install
+++ fam-2.7.0/debian/libfam-dev.install
@@ -0,0 +1,4 @@
+usr/lib/libfam.a
+usr/lib/libfam.la
+usr/include/fam.h
+usr/share/man/man3/fam.3
--- fam-2.7.0.orig/debian/libfam-dev.links
+++ fam-2.7.0/debian/libfam-dev.links
@@ -0,0 +1 @@
+usr/lib/libfam.so.0 usr/lib/libfam.so
--- fam-2.7.0.orig/debian/libfam0.README.Debian
+++ fam-2.7.0/debian/libfam0.README.Debian
@@ -0,0 +1,43 @@
+libfam0 and libfam0c102 for Debian
+----------------------------------
+
+The fam source package produces both libfam0 and libfam0c102 library
+packages to resolve a dependency problem left from the g++ 4.0 ABI
+transition.  The story goes like this:
+
+A long long time ago, Debian went through the g++ 3.2 transition.  The
+fam library package was renamed from libfam0 to libfam0c102, and then
+people discovered that the name change was completely unnecessary
+because libfam does not export any C++ symbols.  The maintainer decided
+to be nice and made libfam0c102 Provide libfam0.
+
+ * Version 2.7.0-7 contains libfam0c102, which Provides libfam0.
+
+The g++ 4.0 ABI transition kicks in, so we changed the name of the
+library package to libfam0.  Packages that Depends on libfam0c102 are
+rebuilt to depend on libfam0.
+
+ * Version 2.7.0-7.1 contains libfam0.
+
+We made the same discovery all over again.  Since, like the previous
+maintainer, I also wanted to be nice and save people some work, I made
+libfam0 Provide libfam0c102.  This move caused a stir on -devel.
+
+ * Version 2.7.0-8 contains libfam0, which Provides libfam0c102.
+
+But there is a problem.
+
+Suppose that libfam0c102 is installed on a system to satisfy a
+dependency on it.  The package will also satisfy the libfam0 dependency
+because it Provides libfam0.  As a result, the system will not upgrade
+to the new fam packages.  This is bad because the system will not
+receive any security updates to libfam.
+
+So I decided to make fam produce both libfam0 and libfam0c102 to smooth
+the upgrade path, and that is the while story.
+
+
+IF WE GO THROUGH ANOTHER C++ TRANSITION, PLEASE LEAVE FAM AS IS AND
+AVOID ALL THE TROUBLES WE HAVE WENT THROUGH.
+
+ -- Chuan-kai Lin <cklin@debian.org>, Tue,  2 May 2006 21:59:51 -0700
--- fam-2.7.0.orig/debian/libfam0.install
+++ fam-2.7.0/debian/libfam0.install
@@ -0,0 +1 @@
+usr/lib/libfam.so.0.0.0
--- fam-2.7.0.orig/debian/libfam0.links
+++ fam-2.7.0/debian/libfam0.links
@@ -0,0 +1 @@
+usr/lib/libfam.so.0.0.0 usr/lib/libfam.so.0
--- fam-2.7.0.orig/debian/patches/00_maintainer-mode.patch
+++ fam-2.7.0/debian/patches/00_maintainer-mode.patch
@@ -0,0 +1,56 @@
+diff -r caf8c411c8d4 -r e47191bdc76f aclocal.m4
+--- a/aclocal.m4	Wed Apr 12 13:48:23 2006 -0700
++++ b/aclocal.m4	Wed Apr 12 13:49:10 2006 -0700
+@@ -4475,3 +4475,41 @@
+ AC_MSG_RESULT([$SED])
+ ])
+ 
++# Add --enable-maintainer-mode option to configure.
++# From Jim Meyering
++
++# Copyright 1996, 1998, 2000, 2001, 2002  Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2, or (at your option)
++# any later version.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++# GNU General Public License for more details.
++
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
++# 02111-1307, USA.
++
++# serial 2
++
++AC_DEFUN([AM_MAINTAINER_MODE],
++[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
++  dnl maintainer-mode is disabled by default
++  AC_ARG_ENABLE(maintainer-mode,
++[  --enable-maintainer-mode enable make rules and dependencies not useful
++                          (and sometimes confusing) to the casual installer],
++      USE_MAINTAINER_MODE=$enableval,
++      USE_MAINTAINER_MODE=no)
++  AC_MSG_RESULT([$USE_MAINTAINER_MODE])
++  AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
++  MAINT=$MAINTAINER_MODE_TRUE
++  AC_SUBST(MAINT)dnl
++]
++)
++
++AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
+diff -r caf8c411c8d4 -r e47191bdc76f configure.ac
+--- a/configure.ac	Wed Apr 12 13:48:23 2006 -0700
++++ b/configure.ac	Wed Apr 12 13:49:10 2006 -0700
+@@ -5,6 +5,7 @@
+ AC_PREREQ(2.57)
+ AC_INIT(fam, 2.7.0, fam@oss.sgi.com)
+ AM_INIT_AUTOMAKE
++AM_MAINTAINER_MODE
+ dnl AC_CONFIG_SRCDIR([acconfig.h])
+ AM_CONFIG_HEADER([config.h])
+ AC_LANG(C++)
--- fam-2.7.0.orig/debian/patches/01_dnotify.patch
+++ fam-2.7.0/debian/patches/01_dnotify.patch
@@ -0,0 +1,1126 @@
+diff -r 284d9ba4146a config.h.in
+--- a/config.h.in	Mon Jul 06 13:03:38 2009 -0700
++++ b/config.h.in	Mon Jul 06 13:15:08 2009 -0700
+@@ -180,3 +180,6 @@
+ 
+ /* Define to `int' if <sys/types.h> doesn't define. */
+ #undef uid_t
++
++/* Define to 1 if you have F_NOTIFY fcntl */
++#undef USE_DNOTIFY
+diff -r 284d9ba4146a configure.ac
+--- a/configure.ac	Mon Jul 06 13:03:38 2009 -0700
++++ b/configure.ac	Mon Jul 06 13:15:08 2009 -0700
+@@ -34,7 +34,26 @@
+ AC_HEADER_DIRENT
+ AC_CHECK_HEADERS([fcntl.h limits.h linux/imon.h netinet/in.h rpc/rpc.h rpcsvc/mount.h stddef.h stdlib.h string.h syslog.h sys/imon.h sys/param.h sys/select.h sys/statvfs.h sys/syssgi.h sys/time.h sys/types.h sys/un.h unistd.h])
+ 
+-if test "$have_sys_imon_h"; then
++# Test for the linux dnotify fcntl
++AC_MSG_CHECKING([for dnotify fcntl support])
++AC_TRY_COMPILE([
++#define _GNU_SOURCE  
++#include <fcntl.h>
++#include <unistd.h>
++],
++[ int fd = 1;
++  fcntl (fd, F_NOTIFY, (DN_MODIFY|DN_CREATE|DN_DELETE|DN_RENAME|DN_ATTRIB)
++                       |DN_MULTISHOT);
++], have_dnotify=yes, have_dnotify=no)
++
++use_dnotify=false
++AC_MSG_RESULT($have_dnotify)
++
++if test "$have_dnotify" = "yes" ; then
++        MONITOR_FUNCS=IMonNone
++        AC_DEFINE(USE_DNOTIFY)
++	use_dnotify=true
++elif test "$have_sys_imon_h"; then
+ 	MONITOR_FUNCS=IMonIRIX
+ elif test "$have_linux_imon_h"; then
+ 	MONITOR_FUNCS=IMonLinux
+@@ -42,6 +61,7 @@
+ 	MONITOR_FUNCS=IMonNone
+ fi
+ AC_SUBST(MONITOR_FUNCS)
++AM_CONDITIONAL(USE_DNOTIFY, $use_dnotify)
+ 
+ # Checks for typedefs, structures, and compiler characteristics.
+ AC_HEADER_STDBOOL
+diff -r 284d9ba4146a include/BTree.h
+--- a/include/BTree.h	Mon Jul 06 13:03:38 2009 -0700
++++ b/include/BTree.h	Mon Jul 06 13:15:08 2009 -0700
+@@ -271,7 +271,7 @@
+     n += that->n + 1;
+     link[n] = that->link[that->n];
+     that->n = 0;
+-    that->link[0] = NULL;
++    that->link[0] = 0;
+ }
+ 
+ ///////////////////////////////////////////////////////////////////////////////
+@@ -280,7 +280,7 @@
+ 
+ template <class K, class V>
+ BTree<K, V>::BTree()
+-    : root(NULL), npairs(0)
++    : root(0), npairs(0)
+ {
+     assert(!(fanout % 2));
+ }
+@@ -407,7 +407,7 @@
+ typename BTree<Key, Value>::Closure
+ BTree<Key, Value>::insert(Node *p, const Key& key, const Value& value)
+ {
+-    if (!p) return Closure(key, value, NULL);
++    if (!p) return Closure(key, value, 0);
+     //  If you're running Purify on a client linking with libfam, and it says
+     //  that line is causing a 3-byte UMR for BTree<int, bool>::insert() in
+     //  FAMNextEvent() ("Reading 8 bytes from 0x... on the stack (3 bytes at
+@@ -475,7 +475,7 @@
+     case UNDER:
+ 	if (root->n == 0)
+ 	{   Node *nr = root->link[0];
+-	    root->link[0] = NULL;	// don't delete subtree
++	    root->link[0] = 0;	// don't delete subtree
+ 	    delete root;
+ 	    root = nr;
+ 	}
+@@ -507,8 +507,8 @@
+     Node *cp = p->link[i];
+     assert(cp);
+     
+-    Node *rp = i < p->n ? p->link[i + 1] : NULL;
+-    Node *lp = i > 0    ? p->link[i - 1] : NULL;
++    Node *rp = i < p->n ? p->link[i + 1] : 0;
++    Node *lp = i > 0    ? p->link[i - 1] : 0;
+     assert(!rp || rp->n >= fanout / 2);
+     assert(!lp || lp->n >= fanout / 2);
+ 
+diff -r 284d9ba4146a src/DNotify.c++
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/src/DNotify.c++	Mon Jul 06 13:15:08 2009 -0700
+@@ -0,0 +1,660 @@
++//  Copyright (C) 2001 Red Hat, Inc.  All Rights Reserved.
++//  Copyright (C) 1999 Silicon Graphics, Inc.  All Rights Reserved.
++//  
++//  This program is free software; you can redistribute it and/or modify it
++//  under the terms of version 2 of the GNU General Public License as
++//  published by the Free Software Foundation.
++//
++//  This program is distributed in the hope that it would be useful, but
++//  WITHOUT ANY WARRANTY; without even the implied warranty of
++//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  Further, any
++//  license provided herein, whether implied or otherwise, is limited to
++//  this program in accordance with the express provisions of the GNU
++//  General Public License.  Patent licenses, if any, provided herein do not
++//  apply to combinations of this program with other product or programs, or
++//  any other product whatsoever.  This program is distributed without any
++//  warranty that the program is delivered free of the rightful claim of any
++//  third person by way of infringement or the like.  See the GNU General
++//  Public License for more details.
++//
++//  You should have received a copy of the GNU General Public License along
++//  with this program; if not, write the Free Software Foundation, Inc., 59
++//  Temple Place - Suite 330, Boston MA 02111-1307, USA.
++
++#include "config.h" /* USE_DNOTIFY */
++#ifdef USE_DNOTIFY
++
++#define _GNU_SOURCE  
++#include <fcntl.h>
++
++#include <string.h>
++#include <signal.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <libgen.h>
++
++#include "DNotify.h"
++
++#include "Interest.h"
++#include "Log.h"
++#include "Scheduler.h"
++#include "alloc.h"
++
++
++int DNotify::pipe_write_fd = -2;
++int DNotify::pipe_read_fd = -2;
++volatile sig_atomic_t DNotify::queue_overflowed = 0;
++volatile sig_atomic_t DNotify::queue_changed = 0;
++int DNotify::change_queue[QUEUESIZE];
++volatile int DNotify::queue_head = 0; // Only modified by read handler
++volatile int DNotify::queue_tail = 0; // Only modified by signal handler
++DNotify::EventHandler DNotify::ehandler;
++
++DNotify::DirWatch *DNotify::dir_hash[DIR_HASHSIZE];
++DNotify::FileWatch *DNotify::file_hash[FILE_HASHSIZE];
++
++struct DNotify::FileWatch
++{
++    DirWatch **dir_watch;
++    int n_dir_watches;
++    dev_t file_dev;
++    ino_t file_ino;
++    FileWatch *hash_link;
++    
++    FileWatch(void) {
++	dir_watch = NULL;
++	n_dir_watches = 0;
++    }
++
++    void add_dir_watch (DirWatch *w);
++    bool has_dir_watch (DirWatch *w);
++};
++
++
++struct DNotify::DirWatch
++{
++    class FileWatchList {
++    public:
++	struct Node {
++	    FileWatch *watch;
++	    Node *next;
++	};
++	
++	Node *first;
++
++	FileWatchList(void) {
++	    first = NULL;
++	}
++	
++	void prepend(FileWatch *watch);
++	void remove(FileWatch *watch);
++	bool empty(void);
++	int len(void);
++	
++    };
++    
++    dev_t dir_dev;
++    ino_t dir_ino;
++    int fd;
++
++    DirWatch *hash_link;
++    FileWatchList file_watches;
++};
++
++struct DNotify::ChangeEventData
++{
++    dev_t file_dev;
++    ino_t file_ino;
++};    
++
++bool
++DNotify::FileWatch::has_dir_watch (DirWatch *w)
++{
++    int i;
++
++    for (i = 0; i < n_dir_watches; i++) {
++	if (dir_watch[i] == w)
++	    return true;
++    }
++    return false;
++}
++
++
++void
++DNotify::FileWatch::add_dir_watch (DirWatch *w)
++{
++    n_dir_watches++;
++    dir_watch = (DirWatch **)realloc (dir_watch, n_dir_watches*sizeof(DirWatch *));
++    dir_watch[n_dir_watches-1] = w;
++}
++
++bool
++DNotify::DirWatch::FileWatchList::empty(void)
++{
++    return first == NULL;
++}
++
++int
++DNotify::DirWatch::FileWatchList::len(void)
++{
++    int i;
++    Node *n;
++
++    i = 0;
++    n = first;
++    while (n) {
++	i++;
++	n = n->next;
++    }
++    
++    return i;
++}
++
++
++void
++DNotify::DirWatch::FileWatchList::prepend(FileWatch *watch)
++{
++    Node *node;
++
++    node = new Node;
++    node->watch = watch;
++    node->next = first;
++    
++    first = node;
++}
++
++void
++DNotify::DirWatch::FileWatchList::remove(FileWatch *watch) {
++    Node *l, *prev;
++    
++    l = first;
++    prev = NULL;
++    while (l) {
++	if (l->watch == watch) {
++	    if (prev)
++		prev->next = l->next;
++	    else
++		first = l->next;
++	    
++	    delete l;
++	    break;
++	}
++	prev = l;
++	l = prev->next;
++    }
++}
++
++
++DNotify::DNotify(EventHandler h)
++{
++    assert(ehandler == NULL);
++    ehandler = h;
++}
++
++DNotify::~DNotify()
++{
++    if (pipe_read_fd >= 0) {
++	//  Tell the scheduler.
++
++	(void) Scheduler::remove_read_handler(pipe_read_fd);
++
++	//  Close the pipe.
++
++	if (close(pipe_read_fd) < 0)
++	    Log::perror("can't pipe read end");
++	else
++	    Log::debug("closed pipe read end");
++	
++	if (close(pipe_write_fd) < 0)
++	    Log::perror("can't pipe write end");
++	else
++	    Log::debug("closed pipe write end");
++	pipe_read_fd = -1;
++    }
++    ehandler = NULL;
++}
++
++void
++DNotify::overflow_signal_handler(int sig, siginfo_t *si, void *data)
++{
++  char c = 'x';
++
++  {
++    char *str = "*************** overflow sigqueue ***********************\n";
++    write (STDERR_FILENO, str, strlen(str));
++  }
++
++  if (!queue_overflowed) {
++      queue_overflowed = 1;
++      // Trigger the read handler
++      write(pipe_write_fd, &c, 1);
++  }
++}
++
++void
++DNotify::signal_handler(int sig, siginfo_t *si, void *data)
++{
++  int left;
++  char c = 'x';
++
++  if (queue_head <= queue_tail)
++    left = (QUEUESIZE + queue_head) - queue_tail;
++  else 
++    left = queue_head - queue_tail;
++  
++  // Must leave at least one item unused to see difference
++  // Betweeen empty and full
++  if (left <= 1) {
++      queue_overflowed = 1;
++      {
++	char *str = "*************** overflow famqueue ****************\n";
++	write (STDERR_FILENO, str, strlen(str));
++      }
++  } else {
++      change_queue[queue_tail] = si->si_fd;
++      queue_tail = (queue_tail + 1) % QUEUESIZE;
++  }
++  
++  if (!queue_changed) {
++      queue_changed = 1;
++      // Trigger the read handler
++      write(pipe_write_fd, &c, 1);
++  }
++}
++
++bool
++DNotify::is_active()
++{
++    if (pipe_read_fd == -2) {
++        int filedes[2];
++	int res;
++	
++	res = pipe (filedes);
++	if (res >= 0) {
++	    Log::debug("opened pipe");
++   	    pipe_read_fd = filedes[0];
++   	    pipe_write_fd = filedes[1];
++
++	    // Setup signal handler:
++	    struct sigaction act;
++	    
++	    act.sa_sigaction = signal_handler;
++	    sigemptyset(&act.sa_mask);
++	    act.sa_flags = SA_SIGINFO;
++	    sigaction(SIGRTMIN, &act, NULL);
++
++	    // When the RT queue overflows we get a SIGIO
++	    act.sa_sigaction = overflow_signal_handler;
++	    sigemptyset(&act.sa_mask);
++	    sigaction(SIGIO, &act, NULL);
++
++	    (void) Scheduler::install_read_handler(pipe_read_fd, read_handler, NULL);
++	}
++    }
++    return pipe_read_fd >= 0;
++}
++
++DNotify::DirWatch *
++DNotify::lookup_dirwatch (int fd)
++{
++  DirWatch **p;
++  DirWatch *w;
++
++  p = dir_hashchain (fd);
++
++  while (*p) {
++      w = *p;
++
++      if (w->fd == fd)
++	  return w;
++
++      p = &w->hash_link;
++  }
++  
++  return *p;
++}
++
++// This colud be made faster by using another hash table.
++// But it's not that bad, since it is only used by express/revoke
++DNotify::DirWatch *
++DNotify::lookup_dirwatch (dev_t dir_dev, ino_t dir_ino)
++{
++  DirWatch *p;
++  int i;
++
++  for (i=0;i<DIR_HASHSIZE;i++) {
++      p = dir_hash[i];
++      
++      while (p) {
++	  if (p->dir_dev == dir_dev && p->dir_ino == dir_ino)
++	      return p;
++	  
++	  p = p->hash_link;
++      }
++  }
++  
++  return NULL;
++}
++
++DNotify::FileWatch *
++DNotify::lookup_filewatch (dev_t dev, ino_t ino)
++{
++  FileWatch **p;
++  FileWatch *w;
++
++  p = file_hashchain (dev, ino);
++
++  while (*p) {
++      w = *p;
++      
++      if (w->file_dev == dev && w->file_ino == ino)
++	  return w;
++
++      p = &w->hash_link;
++  }
++  
++  return *p;
++}
++
++// Make sure w is not already in the hash table before calling
++// this function.
++void
++DNotify::hash_dirwatch(DirWatch *w)
++{
++    DirWatch **p;
++    p = dir_hashchain (w->fd);
++    w->hash_link = *p;
++    *p = w;
++}
++
++// Make sure w is not already in the hash table before calling
++// this function.
++void
++DNotify::hash_filewatch(FileWatch *w)
++{
++    FileWatch **p;
++    p = file_hashchain (w->file_dev, w->file_ino);
++    w->hash_link = *p;
++    *p = w;
++}
++
++void
++DNotify::unhash_dirwatch(DirWatch *w)
++{
++  DirWatch **p;
++  
++  p = dir_hashchain (w->fd);
++  
++  while (*p) {
++      if (*p == w) {
++	  *p = w->hash_link;
++	  break;
++      }
++      p = &(*p)->hash_link;
++  }
++  w->hash_link = NULL;
++}
++
++void
++DNotify::unhash_filewatch(FileWatch *w)
++{
++  FileWatch **p;
++  
++  p = file_hashchain (w->file_dev, w->file_ino);
++  
++  while (*p) {
++      if (*p == w) {
++	  *p = w->hash_link;
++	  break;
++      }
++      p = &(*p)->hash_link;
++  }
++  w->hash_link = NULL;
++}
++
++DNotify::Status
++DNotify::watch_dir(const char *notify_dir, dev_t file_dev, ino_t file_ino)
++{
++    struct stat stat;
++    dev_t dir_dev;
++    ino_t dir_ino;
++    DirWatch *dwatch;
++    FileWatch *fw;
++    
++    if (lstat (notify_dir, &stat) == -1)
++	return BAD;
++    
++    dwatch = lookup_dirwatch(stat.st_dev, stat.st_ino);
++    if (!dwatch) {
++	Log::debug ("New DirWatch for %s (%x %x)\n",
++		    notify_dir, (int)stat.st_dev, (int)stat.st_ino);
++	dwatch = new DirWatch;
++	dwatch->hash_link = NULL;
++	dwatch->dir_dev = stat.st_dev;
++	dwatch->dir_ino = stat.st_ino;
++	dwatch->fd = open(notify_dir, O_RDONLY);
++	fcntl (dwatch->fd, F_SETSIG, SIGRTMIN);
++	fcntl (dwatch->fd, F_NOTIFY,
++	       (DN_MODIFY|DN_CREATE|DN_DELETE|DN_RENAME|DN_ATTRIB) | DN_MULTISHOT);
++	hash_dirwatch (dwatch);
++    }
++    
++    fw = lookup_filewatch(file_dev, file_ino);
++    if (fw)  {
++	if (!fw->has_dir_watch(dwatch)) {
++	    fw->add_dir_watch(dwatch);
++	    dwatch->file_watches.prepend(fw);
++	}
++	return OK;
++    }
++    
++    // No old FileWatch, need to add one:
++    Log::debug("New FileWatch for %x %x\n", (int)file_dev, (int)file_ino);
++    fw = new FileWatch;
++    fw->add_dir_watch(dwatch);
++    dwatch->file_watches.prepend(fw);
++    fw->file_dev = file_dev;
++    fw->file_ino = file_ino;
++    hash_filewatch(fw);
++    return OK;
++}
++
++char *
++dirname_dup (const char *name)
++{
++    char *copy = strdup(name);
++    char *res = dirname(copy);
++    res = strdup(res);
++    free (copy);
++    return res;
++}
++
++DNotify::Status
++DNotify::express(const char *name, struct stat *status)
++{
++    struct stat stat;
++    char *notify_dir;
++    int res;
++    Status s;
++    dev_t dev;
++    ino_t ino;
++
++    Log::debug("express() name: %s\n", name);
++
++    if (!is_active())
++	return BAD;
++
++    if (::lstat (name, &stat) == -1)
++      return BAD;
++
++    dev = stat.st_dev;
++    ino = stat.st_ino;
++    
++    if ((stat.st_mode & S_IFMT) != S_IFDIR)
++	notify_dir = dirname_dup (name);
++    else
++	notify_dir = (char *)name;
++
++    s = watch_dir (notify_dir, dev, ino);
++    if (notify_dir != name)
++        free (notify_dir);
++    if (s)
++      return s;
++
++    // Check for a race condition; if someone removed or changed the
++    // file at the same time that we are expressing interest in it,
++    // revoke the interest so we don't get notifications about changes
++    // to a recycled inode that we don't otherwise care about.
++    //
++    struct stat st;
++    if (status == NULL) {
++	status = &st;
++    }
++    if (::lstat(name, status) == -1) {
++	Log::perror("stat on \"%s\" failed", name);
++	revoke(name, stat.st_dev, stat.st_ino);
++	return BAD;
++    }
++    if (status->st_dev != stat.st_dev
++	|| status->st_ino != stat.st_ino) {
++	Log::error("File \"%s\" changed between express and stat",
++		   name);
++	revoke(name, stat.st_dev, stat.st_ino);
++	return BAD;
++    }	
++
++    Log::debug("told dnotify to monitor \"%s\" = dev %d/%d, ino %d", name,
++	       major(status->st_dev), minor(status->st_dev),
++	       status->st_ino);
++    return OK;
++}
++
++DNotify::Status
++DNotify::revoke(const char *name, dev_t dev, ino_t ino)
++{
++    FileWatch *fwatch;
++    DirWatch *dwatch;
++    int i;
++    
++    Log::debug("revoke() name: %s, dev: %x, ino: %x\n", name, dev, ino);
++
++    if (!is_active())
++	return BAD;
++
++    // Lookup FileWatch by dev:ino, and its DirWatch.
++    fwatch = lookup_filewatch (dev, ino);
++    if (fwatch == NULL)
++	return BAD;
++
++    // delete FileWatch, if last FileWatch: close fd, delete DirWatch
++    Log::debug ("Destroying FileWatch for (%x %x)\n",
++		(int)fwatch->file_dev, (int)fwatch->file_ino);
++    for (i = 0; i < fwatch->n_dir_watches; i++) {
++	dwatch = fwatch->dir_watch[i];
++	dwatch->file_watches.remove (fwatch);
++
++	if (dwatch->file_watches.empty()) {
++	    Log::debug ("Destroying DirWatch for (%x %x)\n",
++			(int)dwatch->dir_dev, (int)dwatch->dir_ino);
++	    close(dwatch->fd);
++	    unhash_dirwatch(dwatch);
++	    delete dwatch;
++	}
++    }
++    unhash_filewatch(fwatch);
++    delete fwatch;
++  
++    return OK;
++}
++
++
++void
++DNotify::all_watches_changed(void)
++{
++  int i;
++  FileWatch *fw;
++
++  for (i=0; i<FILE_HASHSIZE; i++) {
++      fw = file_hash[i];
++      while (fw) {
++	  (*ehandler)(fw->file_dev, fw->file_ino, CHANGE);
++
++	  fw = fw->hash_link;
++      }
++  }
++}
++
++
++void
++DNotify::read_handler(int fd, void *)
++{
++    static char readbuf[5000];
++    DirWatch *dw;
++    FileWatch *fw;
++    int snap_queue_tail;
++    int last_fd;
++
++    int rc = read(fd, readbuf, sizeof readbuf);
++    queue_changed = 0;
++    if (rc < 0)
++        Log::perror("pipe read");
++    else if (queue_overflowed) {
++	  // There is a *slight* race condition here. Between reading
++	  // the queue_overflow flag and resetting it. But it doesn't
++	  // matter, since I'm gonna handle the overflow after reseting
++	  // anyway.
++	  queue_overflowed = false;
++
++	  // We're soon gonna check all watches anyway, so
++	  // get rid of the current queue
++	  queue_head = queue_tail;
++	  
++	  all_watches_changed ();
++    } else {
++	// Don't read events that happen later than
++	// the initial read. (Otherwise skipping fd's
++	// might miss some changes).
++	snap_queue_tail = queue_tail;
++	last_fd = -1;
++	while (queue_head != snap_queue_tail) {
++	    fd = change_queue[queue_head];
++	    queue_head = (queue_head + 1) % QUEUESIZE;
++
++	    // Skip multiple changes to the same fd
++	    if (fd != last_fd) {
++		dw = lookup_dirwatch (fd);
++		if (dw)	{
++		    int n_watches, i;
++		    ChangeEventData *data;
++		    DirWatch::FileWatchList::Node *n;
++		    
++		    Log::debug("dnotify said dev %d/%d, ino %ld changed",
++			       major(dw->dir_dev), minor(dw->dir_dev), dw->dir_ino);
++		    
++		    n_watches = dw->file_watches.len();
++		    data = new ChangeEventData[n_watches];
++		    
++		    i = 0;
++		    for (n=dw->file_watches.first; n; n=n->next) {
++			data[i].file_dev = n->watch->file_dev;
++			data[i].file_ino = n->watch->file_ino;
++			i++;
++		    }
++		    assert(i == n_watches);
++		    
++		    for (i = 0; i < n_watches; i++) {
++			(*ehandler)(data[i].file_dev, data[i].file_ino, CHANGE);
++		    }
++		    
++		    delete[] data;
++		}
++	    }
++	    last_fd = fd;
++	}
++    }
++}
++
++#endif /* USE_DNOTIFY */
+diff -r 284d9ba4146a src/DNotify.h
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/src/DNotify.h	Mon Jul 06 13:15:08 2009 -0700
+@@ -0,0 +1,98 @@
++//  Copyright (C) 2001 Red Hat, Inc.  All Rights Reserved.
++//  Copyright (C) 1999 Silicon Graphics, Inc.  All Rights Reserved.
++//
++//  This program is free software; you can redistribute it and/or modify it
++//  under the terms of version 2 of the GNU General Public License as
++//  published by the Free Software Foundation.
++//
++//  This program is distributed in the hope that it would be useful, but
++//  WITHOUT ANY WARRANTY; without even the implied warranty of
++//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  Further, any
++//  license provided herein, whether implied or otherwise, is limited to
++//  this program in accordance with the express provisions of the GNU
++//  General Public License.  Patent licenses, if any, provided herein do not
++//  apply to combinations of this program with other product or programs, or
++//  any other product whatsoever.  This program is distributed without any
++//  warranty that the program is delivered free of the rightful claim of any
++//  third person by way of infringement or the like.  See the GNU General
++//  Public License for more details.
++//
++//  You should have received a copy of the GNU General Public License along
++//  with this program; if not, write the Free Software Foundation, Inc., 59
++//  Temple Place - Suite 330, Boston MA 02111-1307, USA.
++
++#ifndef DNotify_included
++#define DNotify_included
++
++#include "config.h"
++#include "Monitor.h"
++#include <signal.h>
++
++//  DNotify is an object encapsulating the dnotify linux fcntl.
++//  It "emulates" the IMon interface.
++//  There can only be one instantiation of the DNotify object.
++//
++//  The user of this object uses express() and revoke() to
++//  express/revoke interest in a file.  There is also
++//  a callback, the EventHandler.  When an dnotify event comes in,
++//  the EventHandler is called.
++//
++//  The user of the DNotify object is the Interest class.
++
++class DNotify : public Monitor {
++public:
++    DNotify(EventHandler h);
++    ~DNotify();
++
++    static bool is_active();
++
++    virtual Status express(const char *name, struct stat *stat_return);
++    virtual Status revoke(const char *name, dev_t dev, ino_t ino);
++
++private:
++    struct FileWatch;
++    struct DirWatch;
++    struct ChangeEventData;
++  
++    //  Class Variables
++    enum { QUEUESIZE = 1024 };
++    static int pipe_write_fd;
++    static int pipe_read_fd;
++    static int change_queue[QUEUESIZE];
++    static volatile sig_atomic_t queue_overflowed;
++    static volatile sig_atomic_t queue_changed;
++    static volatile int queue_head; // Only modified by read handler
++    static volatile int queue_tail; // Only modified by signal handler
++    static EventHandler ehandler;
++    static void overflow_signal_handler(int sig, siginfo_t *si, void *data);
++    static void signal_handler(int sig, siginfo_t *si, void *data);
++    static void read_handler(int fd, void *closure);
++ 
++    enum { DIR_HASHSIZE = 367 };
++    static DirWatch *dir_hash[DIR_HASHSIZE];
++    enum { FILE_HASHSIZE = 823 };
++    static FileWatch *file_hash[FILE_HASHSIZE];
++
++    static DirWatch **dir_hashchain(int fd)
++			  { return &dir_hash[(unsigned) (fd) % DIR_HASHSIZE]; }
++    static FileWatch **file_hashchain(dev_t d, ino_t i)
++			  { return &file_hash[(unsigned) (d+i) % FILE_HASHSIZE]; }
++
++    static DirWatch *lookup_dirwatch (int fd);
++    static DirWatch *lookup_dirwatch (dev_t dir_dev, ino_t dir_ino);
++    static FileWatch *lookup_filewatch (dev_t file_dev, ino_t file_ino);
++    static void hash_dirwatch(DirWatch *w);
++    static void hash_filewatch(FileWatch *w);
++    static void unhash_dirwatch(DirWatch *w);
++    static void unhash_filewatch(FileWatch *w);
++    static Status watch_dir(const char *notify_dir, dev_t file_dev, ino_t file_ino);
++
++    static void all_watches_changed(void);
++    
++    DNotify(const DNotify&);			// Do not copy
++    DNotify & operator = (const DNotify&);	//  or assign.
++};
++
++#endif /* !IMon_included */
++
++
+diff -r 284d9ba4146a src/IMon.h
+--- a/src/IMon.h	Mon Jul 06 13:03:38 2009 -0700
++++ b/src/IMon.h	Mon Jul 06 13:15:08 2009 -0700
+@@ -24,10 +24,7 @@
+ #define IMon_included
+ 
+ #include "config.h"
+-#include <sys/stat.h>
+-#include <sys/types.h>
+-
+-#include "Boolean.h"
++#include "Monitor.h"
+ 
+ struct stat;
+ 
+@@ -41,25 +38,18 @@
+ //
+ //  The user of the IMon object is the Interest class.
+ 
+-class IMon {
++class IMon : public Monitor {
+ 
+ public:
+-
+-    enum Status { OK = 0, BAD = -1 };
+-    enum Event { EXEC, EXIT, CHANGE };
+-
+-    typedef void (*EventHandler)(dev_t, ino_t, int event);
+-
+     IMon(EventHandler h);
+     ~IMon();
+ 
+     static bool is_active();
+ 
+-    Status express(const char *name, struct stat *stat_return);
+-    Status revoke(const char *name, dev_t dev, ino_t ino);
++    virtual Status express(const char *name, struct stat *stat_return);
++    virtual Status revoke(const char *name, dev_t dev, ino_t ino);
+ 
+ private:
+-
+     //  Class Variables
+ 
+     static int imonfd;
+diff -r 284d9ba4146a src/Interest.c++
+--- a/src/Interest.c++	Mon Jul 06 13:03:38 2009 -0700
++++ b/src/Interest.c++	Mon Jul 06 13:15:08 2009 -0700
+@@ -42,12 +42,23 @@
+ #include "Event.h"
+ #include "FileSystem.h"
+ #include "IMon.h"
++#ifdef USE_DNOTIFY
++#include "DNotify.h"
++#endif
+ #include "Log.h"
+ #include "Pollster.h"
+ #include "timeval.h"
+ 
+ Interest *Interest::hashtable[];
+-IMon      Interest::imon(imon_handler);
++
++#ifdef USE_DNOTIFY 
++static DNotify dnotify(Interest::monitor_handler);
++Monitor * Interest::monitor = &dnotify;
++#else
++static IMon imon(Interest::monitor_handler);
++Monitor * Interest::monitor = &imon;
++#endif
++
+ bool      Interest::xtab_verification = true;
+ 
+ Interest::Interest(const char *name, FileSystem *fs, in_addr host, ExportVerification ev)
+@@ -59,11 +70,11 @@
+       myhost(host),
+       mypath_exported_to_host(ev == NO_VERIFY_EXPORTED)
+ {
+-    memset(&old_stat, 0, sizeof(old_stat)); 
+-    IMon::Status s = IMon::BAD;
+-
+-    s = imon.express(name, &old_stat);
+-    if (s != IMon::OK)
++    memset(&old_stat, 0, sizeof(old_stat));
++    
++    Monitor::Status s = Monitor::BAD;
++    s = monitor->express(name, &old_stat);
++    if (s != Monitor::OK)
+     {   int rc = lstat(name, &old_stat);
+ 	if (rc < 0)
+ 	{   Log::info("can't lstat %s", name);
+@@ -100,7 +111,7 @@
+     }
+ #endif
+ 
+-    if (exported_to_host()) fs->ll_monitor(this, s == IMon::OK);
++    if (exported_to_host()) fs->ll_monitor(this, s == Monitor::OK);
+ }
+ 
+ Interest::~Interest()
+@@ -128,7 +139,7 @@
+ 		pp = &p->hashlink;	// move to next element
+ 	    }
+ 	if (!found_same)
+-	    (void) imon.revoke(name(), dev, ino);
++	  (void) monitor->revoke(name(), dev, ino);
+     }
+ }
+ 
+@@ -147,7 +158,7 @@
+ 
+         // Express interest.
+         IMon::Status s = IMon::BAD;
+-	s = imon.express(name(), NULL);
++	s = monitor->express(name(), NULL);
+         if (s != IMon::OK) {
+             return true;
+         }
+@@ -248,23 +259,23 @@
+ }
+ 
+ void
+-Interest::imon_handler(dev_t device, ino_t inumber, int event)
++Interest::monitor_handler(dev_t device, ino_t inumber, int event)
+ {
+     assert(device || inumber);
+ 
+     for (Interest *p = *hashchain(device, inumber), *next = p; p; p = next)
+     {	next = p->hashlink;
+ 	if (p->ino == inumber && p->dev == device)
+-	{   if (event == IMon::EXEC)
++	  {   if (event == Monitor::EXEC)
+ 	    {   p->cur_exec_state = EXECUTING;
+ 		(void) p->report_exec_state();
+ 	    }
+-	    else if (event == IMon::EXIT)
++	    else if (event == Monitor::EXIT)
+ 	    {   p->cur_exec_state = NOT_EXECUTING;
+ 		(void) p->report_exec_state();
+ 	    }
+ 	    else
+-	    {   assert(event == IMon::CHANGE);
++	    {   assert(event == Monitor::CHANGE);
+ 		p->scan();
+ 	    }
+ 	}
+diff -r 284d9ba4146a src/Interest.h
+--- a/src/Interest.h	Mon Jul 06 13:03:38 2009 -0700
++++ b/src/Interest.h	Mon Jul 06 13:15:08 2009 -0700
+@@ -32,7 +32,7 @@
+ 
+ class Event;
+ class FileSystem;
+-class IMon;
++class Monitor;
+ struct stat;
+ 
+ //  Interest -- abstract base class for filesystem entities of interest.
+@@ -74,7 +74,7 @@
+ 
+     //  Public Class Method
+ 
+-    static void imon_handler(dev_t, ino_t, int event);
++    static void monitor_handler(dev_t, ino_t, int event);
+ 
+     static void enable_xtab_verification(bool enable);
+ 
+@@ -121,7 +121,7 @@
+ 
+     //  Class Variables
+ 
+-    static IMon imon;
++    static Monitor *monitor;
+     static Interest *hashtable[HASHSIZE];
+     static bool xtab_verification;
+ 
+diff -r 284d9ba4146a src/Makefile.am
+--- a/src/Makefile.am	Mon Jul 06 13:03:38 2009 -0700
++++ b/src/Makefile.am	Mon Jul 06 13:15:08 2009 -0700
+@@ -2,6 +2,8 @@
+ 
+ sbin_PROGRAMS = famd
+ 
++famd_LDADD = -lrt -lpthread
++
+ famd_SOURCES = \
+   Activity.c++ \
+   Activity.h \
+@@ -71,7 +73,11 @@
+   main.c++ \
+   timeval.c++ \
+   timeval.h \
+-  @MONITOR_FUNCS@.c++
++  Monitor.h \
++  DNotify.h \
++  DNotify.c++ \
++  @MONITOR_FUNCS@.c++ 
+ 
+-EXTRA_famd_SOURCES = IMonIrix.c++ IMonLinux.c++ IMonNone.c++
++EXTRA_famd_SOURCES = IMonIrix.c++ IMonLinux.c++ IMonNone.c++ DNotify.c++ \
++  DNotify.h Monitor.h
+ 
+diff -r 284d9ba4146a src/Monitor.h
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/src/Monitor.h	Mon Jul 06 13:15:08 2009 -0700
+@@ -0,0 +1,57 @@
++//  Copyright (C) 2001 Red Hat, Inc.  All Rights Reserved.
++//  Copyright (C) 1999 Silicon Graphics, Inc.  All Rights Reserved.
++//  
++//  This program is free software; you can redistribute it and/or modify it
++//  under the terms of version 2 of the GNU General Public License as
++//  published by the Free Software Foundation.
++//
++//  This program is distributed in the hope that it would be useful, but
++//  WITHOUT ANY WARRANTY; without even the implied warranty of
++//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  Further, any
++//  license provided herein, whether implied or otherwise, is limited to
++//  this program in accordance with the express provisions of the GNU
++//  General Public License.  Patent licenses, if any, provided herein do not
++//  apply to combinations of this program with other product or programs, or
++//  any other product whatsoever.  This program is distributed without any
++//  warranty that the program is delivered free of the rightful claim of any
++//  third person by way of infringement or the like.  See the GNU General
++//  Public License for more details.
++//
++//  You should have received a copy of the GNU General Public License along
++//  with this program; if not, write the Free Software Foundation, Inc., 59
++//  Temple Place - Suite 330, Boston MA 02111-1307, USA.
++
++#ifndef Monitor_included
++#define Monitor_included
++
++#include "config.h"
++#include <sys/stat.h>
++#include <sys/types.h>
++
++struct stat;
++
++//  Monitor is an abstract baseclass for differend file monitoring
++//  systems. The original system used was IMon, and the Montor API
++//  is heavily influenced by that.
++//  There can only be one instantiation of the Monitor object.
++//
++//  The user of this object uses express() and revoke() to
++//  express/revoke interest in a file to imon.  There is also
++//  a callback, the EventHandler.  When an event comes in,
++//  the EventHandler is called.
++//
++//  The main implementers of the Monitor class is IMon and DNotify
++
++class Monitor {
++public:
++
++    enum Status { OK = 0, BAD = -1 };
++    enum Event { EXEC, EXIT, CHANGE };
++
++    typedef void (*EventHandler)(dev_t, ino_t, int event);
++
++    virtual Status express(const char *name, struct stat *stat_return) = 0;
++    virtual Status revoke(const char *name, dev_t dev, ino_t ino) = 0;
++};
++
++#endif /* !Monitor_included */
--- fam-2.7.0.orig/debian/patches/02_cleanup.patch
+++ fam-2.7.0/debian/patches/02_cleanup.patch
@@ -0,0 +1,63 @@
+diff -r 33ebdce115fd -r 08edf44d9f72 src/Listener.c++
+--- a/src/Listener.c++	Wed Apr 12 13:49:26 2006 -0700
++++ b/src/Listener.c++	Wed Apr 12 13:49:40 2006 -0700
+@@ -299,10 +299,18 @@
+     //  Keep the scheduler from helpfully cleaning this up.
+     Scheduler::remove_onetime_task(cleanup_negotiation, nc);
+ 
++    //  Remove the temp file
++    uid_t preveuid = geteuid();
++    if (preveuid) seteuid(0);
++    seteuid(nc->uid);
++    unlink(nc->sun.sun_path);
++    if (nc->uid) seteuid(0);
++    seteuid(preveuid);
++
+     Log::debug("client fd %d is local/trusted (socket %s, uid %d).",
+                client_fd, nc->sun.sun_path, nc->uid);
+     Cred cred(nc->uid, client_fd);
+-    new LocalClient(client_fd, &(nc->sun), cred);
++    new LocalClient(client_fd, cred);
+     // We don't need a reference to this object.  The constructor
+     // takes care of registering it with the Scheduler.
+ 
+diff -r 33ebdce115fd -r 08edf44d9f72 src/LocalClient.c++
+--- a/src/LocalClient.c++	Wed Apr 12 13:49:26 2006 -0700
++++ b/src/LocalClient.c++	Wed Apr 12 13:49:40 2006 -0700
+@@ -29,17 +29,12 @@
+ #include "Log.h"
+ #include "Cred.h"
+ 
+-LocalClient::LocalClient(int fd, const struct sockaddr_un *addr, Cred &cred)
++LocalClient::LocalClient(int fd, Cred &cred)
+ : TCP_Client(LOCALHOST(), fd, cred)
+ {
+     assert(cred.is_valid());
+-    sun.sun_family = AF_UNIX;
+-    strncpy(sun.sun_path, addr->sun_path, sizeof(sun.sun_path));
+-    sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
+ }
+ 
+ LocalClient::~LocalClient()
+ {
+-    if (geteuid() != cred.uid()) cred.become_user();
+-    unlink(sun.sun_path);
+ }
+diff -r 33ebdce115fd -r 08edf44d9f72 src/LocalClient.h
+--- a/src/LocalClient.h	Wed Apr 12 13:49:26 2006 -0700
++++ b/src/LocalClient.h	Wed Apr 12 13:49:40 2006 -0700
+@@ -33,13 +33,8 @@
+ 
+ public:
+ 
+-    LocalClient(int fd, const struct sockaddr_un *addr, Cred &cred);
++    LocalClient(int fd, Cred &cred);
+     ~LocalClient();
+-
+-private:
+-
+-    struct sockaddr_un sun;
+-
+ };
+ 
+ #endif /* !RemoteClient_included */
--- fam-2.7.0.orig/debian/patches/03_getgrouplist.patch
+++ fam-2.7.0/debian/patches/03_getgrouplist.patch
@@ -0,0 +1,39 @@
+diff -r 08edf44d9f72 -r 4e12baece02e config.h.in
+--- a/config.h.in	Wed Apr 12 13:49:40 2006 -0700
++++ b/config.h.in	Wed Apr 12 13:49:51 2006 -0700
+@@ -183,3 +183,6 @@
+ 
+ /* Define to 1 if you have F_NOTIFY fcntl */
+ #undef USE_DNOTIFY
++
++/* Define to 1 if you have the `getgrouplist' function */
++#undef HAVE_GETGROUPLIST
+diff -r 08edf44d9f72 -r 4e12baece02e configure.ac
+--- a/configure.ac	Wed Apr 12 13:49:40 2006 -0700
++++ b/configure.ac	Wed Apr 12 13:49:51 2006 -0700
+@@ -77,7 +77,7 @@
+ # Checks for library functions.
+ AC_FUNC_ERROR_AT_LINE
+ AC_FUNC_SELECT_ARGTYPES
+-AC_CHECK_FUNCS([bindresvport _daemonize daemon getgrmember select])
++AC_CHECK_FUNCS([bindresvport _daemonize daemon getgrmember getgrouplist select])
+ 
+ AC_CONFIG_FILES([Makefile
+                  src/Makefile
+diff -r 08edf44d9f72 -r 4e12baece02e src/Cred.c++
+--- a/src/Cred.c++	Wed Apr 12 13:49:40 2006 -0700
++++ b/src/Cred.c++	Wed Apr 12 13:49:51 2006 -0700
+@@ -71,6 +71,13 @@
+ 			pwd->pw_name, strerror(errno));
+             nAddlGroups = 0;
+         }
++#elif defined(HAVE_GETGROUPLIST)
++	if (getgrouplist(pwd->pw_name, primary_group, addlGroups, (int *)&nAddlGroups) == -1)
++	{
++	    Log::info("getgrouplist(%s, ...) failed: %s",
++	              pwd->pw_name, strerror(errno));
++	    nAddlGroups = 0;
++	}
+ #else
+         group *gbp;
+         unsigned int ii = 0;
--- fam-2.7.0.orig/debian/patches/04_detectrofs.patch
+++ fam-2.7.0/debian/patches/04_detectrofs.patch
@@ -0,0 +1,253 @@
+diff -r 4e12baece02e -r 3be87d55e7f3 conf/fam.conf
+--- a/conf/fam.conf	Wed Apr 12 13:49:51 2006 -0700
++++ b/conf/fam.conf	Wed Apr 12 13:50:14 2006 -0700
+@@ -51,3 +51,8 @@
+ #
+ #nfs_polling_interval = 6
+ 
++#
++# detect_readonly_filesystems enables automatic detection of read-only
++# filesystems. Such filesystems are assumed to never change.
++#
++#detect_readonly_filesystems = false
+diff -r 4e12baece02e -r 3be87d55e7f3 man/famd.8
+--- a/man/famd.8	Wed Apr 12 13:49:51 2006 -0700
++++ b/man/famd.8	Wed Apr 12 13:50:14 2006 -0700
+@@ -47,6 +47,9 @@
+ \fB\-L\fR
+ Only accept connections from local clients.
+ .TP
++\fB\-r\fR
++Detect read-only filesystems.
++.TP
+ \fB\-p\fR \fIprog\fR.\fIvers\fR
+ Register with the portmapper using the specifed RPC program
+ and version numbers.
+diff -r 4e12baece02e -r 3be87d55e7f3 man/famd.conf.5
+--- a/man/famd.conf.5	Wed Apr 12 13:49:51 2006 -0700
++++ b/man/famd.conf.5	Wed Apr 12 13:50:14 2006 -0700
+@@ -48,5 +48,11 @@
+ service remote requests without attempting to perform the verification.  If
+ the \fBlocal_only\fR configuration option or \fB-L\fR command line option is
+ used, \fBxtab_verification\fR has no effect.
++.TP
++\fBdetect_readonly_filesystems\fR
++If set to \fItrue\fR, \fBfamd\fR will try to detect read-only filesystems.
++Such filesystems are assumed to never change. This is \fIfalse\fR by default.
++Setting this option to \fBtrue\fR is the same as using the \fB\-r\fR command
++line option.
+ .SH "SEE ALSO"
+ 
+diff -r 4e12baece02e -r 3be87d55e7f3 src/ClientInterest.h
+--- a/src/ClientInterest.h	Wed Apr 12 13:49:51 2006 -0700
++++ b/src/ClientInterest.h	Wed Apr 12 13:50:14 2006 -0700
+@@ -71,6 +71,8 @@
+     ClientInterest(const char *name, Client *, Request, const Cred&, Type);
+     void post_event(const Event&, const char * = NULL);
+ 
++    virtual FileSystem * get_filesystem()  { return myfilesystem; }
++
+ private:
+ 
+     enum { ACTIVE_STATE = 1 << 0 };
+diff -r 4e12baece02e -r 3be87d55e7f3 src/FileSystem.c++
+--- a/src/FileSystem.c++	Wed Apr 12 13:49:51 2006 -0700
++++ b/src/FileSystem.c++	Wed Apr 12 13:50:14 2006 -0700
+@@ -29,7 +29,8 @@
+ 
+ FileSystem::FileSystem(const mntent& mnt)
+     : mydir   (strcpy(new char[strlen(mnt.mnt_dir   ) + 1], mnt.mnt_dir   )),
+-      myfsname(strcpy(new char[strlen(mnt.mnt_fsname) + 1], mnt.mnt_fsname))
++      myfsname(strcpy(new char[strlen(mnt.mnt_fsname) + 1], mnt.mnt_fsname)),
++      myreadonly(false)
+ { }
+ 
+ FileSystem::~FileSystem()
+@@ -69,3 +70,21 @@
+     hl_cancel(request);
+     myinterests.remove(cip);
+ }
++
++bool
++FileSystem::is_readonly() const
++{
++    return myreadonly;
++}
++
++void
++FileSystem::set_readonly()
++{
++    myreadonly = true;
++}
++
++void
++FileSystem::set_readwrite()
++{
++    myreadonly = false;
++}
+diff -r 4e12baece02e -r 3be87d55e7f3 src/FileSystem.h
+--- a/src/FileSystem.h	Wed Apr 12 13:49:51 2006 -0700
++++ b/src/FileSystem.h	Wed Apr 12 13:50:14 2006 -0700
+@@ -103,6 +103,9 @@
+     virtual bool dir_entries_scanned() const = 0;
+     void relocate_interests();
+     virtual int get_attr_cache_timeout() const = 0;
++    bool is_readonly() const;
++    void set_readonly();
++    void set_readwrite();
+ 
+     //  High level monitoring interface
+ 
+@@ -126,6 +129,7 @@
+     char *mydir;
+     char *myfsname;
+     Interests myinterests;
++    bool myreadonly;
+ 
+     virtual Request hl_monitor(ClientInterest *, ClientInterest::Type) = 0;
+     virtual void    hl_cancel(Request) = 0;
+diff -r 4e12baece02e -r 3be87d55e7f3 src/FileSystemTable.c++
+--- a/src/FileSystemTable.c++	Wed Apr 12 13:49:51 2006 -0700
++++ b/src/FileSystemTable.c++	Wed Apr 12 13:50:14 2006 -0700
+@@ -56,6 +56,8 @@
+ InternalClient		   *FileSystemTable::mtab_watcher;
+ FileSystem		   *FileSystemTable::root;
+ 
++extern bool g_detect_readonly_fs;
++
+ #ifdef HAPPY_PURIFY
+ 
+ //////////////////////////////////////////////////////////////////////////////
+@@ -168,7 +170,14 @@
+ 		assert(parent);
+ 		mount_parents.insert(parent->dir(), parent);
+ 	    }
+-	}
++
++            if (g_detect_readonly_fs && hasmntopt(mp, MNTOPT_RO))
++            {
++		Log::debug("mtab: new local \"%s\" on \"%s\" is read-only",
++			   mp->mnt_fsname, mp->mnt_dir);
++                fs->set_readonly();
++            }
++        }
+ 	if (!strcmp(mp->mnt_dir, "/"))
+ 	    root = fs;
+     }
+diff -r 4e12baece02e -r 3be87d55e7f3 src/Interest.c++
+--- a/src/Interest.c++	Wed Apr 12 13:49:51 2006 -0700
++++ b/src/Interest.c++	Wed Apr 12 13:50:14 2006 -0700
+@@ -73,7 +73,12 @@
+     memset(&old_stat, 0, sizeof(old_stat));
+     
+     Monitor::Status s = Monitor::BAD;
+-    s = monitor->express(name, &old_stat);
++
++    if (!fs->is_readonly())
++    {
++        s = monitor->express(name, &old_stat);
++    }
++
+     if (s != Monitor::OK)
+     {   int rc = lstat(name, &old_stat);
+ 	if (rc < 0)
+@@ -158,7 +163,13 @@
+ 
+         // Express interest.
+         IMon::Status s = IMon::BAD;
+-	s = monitor->express(name(), NULL);
++
++        FileSystem *fs = get_filesystem();
++        if (!fs || !fs->is_readonly())
++        {
++            s = monitor->express(name(), NULL);
++        }
++
+         if (s != IMon::OK) {
+             return true;
+         }
+diff -r 4e12baece02e -r 3be87d55e7f3 src/Interest.h
+--- a/src/Interest.h	Wed Apr 12 13:49:51 2006 -0700
++++ b/src/Interest.h	Wed Apr 12 13:50:14 2006 -0700
+@@ -89,6 +89,7 @@
+     const in_addr& host() const         { return myhost; }
+     void verify_exported_to_host();
+     bool exported_to_host() const       { return mypath_exported_to_host; }
++    virtual FileSystem * get_filesystem()   { return NULL; }
+ 
+ private:
+ 
+diff -r 4e12baece02e -r 3be87d55e7f3 src/LocalFileSystem.c++
+--- a/src/LocalFileSystem.c++	Wed Apr 12 13:49:51 2006 -0700
++++ b/src/LocalFileSystem.c++	Wed Apr 12 13:50:14 2006 -0700
+@@ -78,9 +78,8 @@
+ void
+ LocalFileSystem::ll_monitor(Interest *ip, bool imonitored)
+ {
+-    if (!imonitored)
++    if (!imonitored && !is_readonly())
+     {
+-	Log::debug("will poll %s", ip->name());
+ 	Pollster::watch(ip);
+     }
+ }
+@@ -95,5 +94,8 @@
+ void
+ LocalFileSystem::ll_notify_deleted(Interest *ip)
+ {
+-    Pollster::watch(ip);
++    if (!is_readonly())
++    {
++        Pollster::watch(ip);
++    }
+ }
+diff -r 4e12baece02e -r 3be87d55e7f3 src/main.c++
+--- a/src/main.c++	Wed Apr 12 13:49:51 2006 -0700
++++ b/src/main.c++	Wed Apr 12 13:50:14 2006 -0700
+@@ -65,6 +65,7 @@
+ #define CFG_UNTRUSTED_USER "untrusted_user"
+ #define CFG_IDLE_TIMEOUT "idle_timeout"
+ #define CFG_NFS_POLLING_INTERVAL "nfs_polling_interval"
++#define CFG_DETECT_READONLY_FILESYSTEMS "detect_readonly_filesystems"
+ static void parse_config(config_opts &opts);
+ static void parse_config_line(config_opts &opts, int line,
+                               const char *k, const char *v);
+@@ -78,6 +79,8 @@
+ 	    tail = p;
+     return tail;
+ }
++
++bool g_detect_readonly_fs = false;
+ 
+ void usage()
+ {   fprintf(stderr,
+@@ -96,6 +99,7 @@
+     fprintf(stderr, "\t-c config_file\tpath to alternate configuration file\n");
+     fprintf(stderr, "\t\t\t  (default is %s)\n", FAM_CONF);
+     fprintf(stderr, "\t-C\t\tinsecure compatibility\n");
++    fprintf(stderr, "\t-r\t\tdetect read-only filesystems\n");
+     fprintf(stderr, "\n");
+     exit(1);
+ }
+@@ -181,6 +185,10 @@
+ 
+ 	case 'l':
+ 	    opts.disable_pollster = true;
++	    break;
++
++	case 'r':
++	    g_detect_readonly_fs = true;
+ 	    break;
+ 
+ 	case 'p':
+@@ -409,6 +417,10 @@
+ //                       opts.config_file, lineno, key);
+ //        }
+     }
++    else if(!strcmp(key, CFG_DETECT_READONLY_FILESYSTEMS))
++    {
++        g_detect_readonly_fs = is_true(val);
++    }
+     else if(!strcmp(key, "disable_audit"))
+     {
+         opts.disable_audit = is_true(val);
--- fam-2.7.0.orig/debian/patches/05_man_page.patch
+++ fam-2.7.0/debian/patches/05_man_page.patch
@@ -0,0 +1,71 @@
+diff -r 3be87d55e7f3 man/fam.3
+--- a/man/fam.3	Wed Apr 12 13:50:14 2006 -0700
++++ b/man/fam.3	Wed Apr 12 16:02:21 2006 -0700
+@@ -6,6 +6,9 @@
+ .B #include <fam.h>
+ .P
+ .B "extern int FAMOpen(FAMConnection* fc);"
++.PP
++.B "extern int FAMOpen2(FAMConnection* fc,"
++.B "                    const char* appName);"
+ .PP
+ .B "extern int FAMClose(FAMConnection* fc);"
+ .PP
+@@ -201,7 +204,7 @@
+ The application opens a connection to \fBfamd\fR by calling
+ FAMOpen.  FAMOpen initializes the FAMConnection structure
+ passed in to it and returns 0 if successful, otherwise -1.
+-The variable char* appName should be set to the name of your
++The parameter appName of FAMOpen2 should be set to the name of your
+ application. The FAMConnection structure is passed to all
+ subsequent \fBFAM\fR procedure calls.
+ 
+@@ -295,7 +298,7 @@
+ 
+ .SH SEE ALSO
+ famd(8),
+-fstat(1),
++fstat(2),
+ poll(2),
+ select(2)
+ 
+diff -r 3be87d55e7f3 man/famd.8
+--- a/man/famd.8	Wed Apr 12 13:50:14 2006 -0700
++++ b/man/famd.8	Wed Apr 12 16:02:21 2006 -0700
+@@ -21,7 +21,7 @@
+ run at a time.
+ .P
+ \fBfamd\fR can be configured by editing the famd configuration
+-file (see \fIfamd.conf(5)\fR for further details) or by
++file (see \fIfam.conf(5)\fR for further details) or by
+ providing the following command line options:
+ .SH OPTIONS
+ .TP
+@@ -66,8 +66,8 @@
+ files that the client can \fBstat\fR.
+ .SH FILES
+ .TP
+-\fI/usr/local/etc/famd.conf\fR
++\fI/etc/fam.conf\fR
+ Default \fBfamd\fR configuration file.
+ .SH "SEE ALSO"
+-fam(3), famd.conf(5), inetd(8), portmap(8), stat(1), xinetd(8)
++fam(3), fam.conf(5), inetd(8), portmap(8), stat(1), xinetd(8)
+ .SH BUGS
+diff -r 3be87d55e7f3 man/famd.conf.5
+--- a/man/famd.conf.5	Wed Apr 12 13:50:14 2006 -0700
++++ b/man/famd.conf.5	Wed Apr 12 16:02:21 2006 -0700
+@@ -1,10 +1,10 @@
+-.TH FAMD.CONF "5" "January 19, 2003" "famd.conf (fam 2.6.10)" "SGI"
++.TH FAM.CONF "5" "January 19, 2003" "fam.conf (fam 2.6.10)" "SGI"
+ .SH NAME
+-famd.conf \- The File Alteration Monitor (FAM) configuration file
++fam.conf \- The File Alteration Monitor (FAM) configuration file
+ .SH SYNOPSIS
+ In addition to its command line options, \fBfamd\fR's behavior
+ can also be controlled through its configuration file.  By
+-default, this is \fI/usr/local/etc/fam.conf\fR.  The \fB\-c\fR
++default, this is \fI/etc/fam.conf\fR.  The \fB\-c\fR
+ command line option can be used to specify an alternate file.
+ .SH "FILE FORMAT"
+ Configuration lines are in the format \fBoption=value\fR.
--- fam-2.7.0.orig/debian/patches/06_readme_install.patch
+++ fam-2.7.0/debian/patches/06_readme_install.patch
@@ -0,0 +1,10 @@
+diff -r bbe1b0034cd3 -r 88d07b42269d README
+--- a/README	Wed Apr 12 13:50:33 2006 -0700
++++ b/README	Wed Apr 12 13:50:44 2006 -0700
+@@ -1,6 +1,4 @@
+ This is FAM version 2.7.0.
+-
+-For installation instructions, see the INSTALL file.
+ 
+ For the terms under which the FAM code is licensed, see the
+ COPYING file.  (To summarize: fam is GPL, libfam is LGPL.)
--- fam-2.7.0.orig/debian/patches/07_fam.h.patch
+++ fam-2.7.0/debian/patches/07_fam.h.patch
@@ -0,0 +1,71 @@
+diff -r 88d07b42269d include/fam.h
+--- a/include/fam.h	Wed Apr 12 13:50:44 2006 -0700
++++ b/include/fam.h	Wed Apr 12 14:30:43 2006 -0700
+@@ -41,7 +41,7 @@
+ *****************************************************************************/
+ 
+ /* For NAME_MAX - maximum # of chars in a filename */
+-#include "limits.h"
++#include <limits.h>
+ 
+ 
+ 
+@@ -160,12 +160,12 @@
+ *  FAMOpen, FAMClose
+ *
+ *  The first step that an application has to do is open a connection to
+-*  fam.  This is done through the FAMOpen.  FAMOpen returns a FAMConnection
+-*  data structure which is passed to all fam procedures.  FAMClose closes
+-*  a fam connection.  
+-*
+-*  On error, FAMOpen will return NULL and FAMClose will return -1 (and
+-*  FAMErrno will be set to the value of the error).  
++*  fam.  This is done through the FAMOpen.  The argument to FAMOpen is a
++*  pointer to a FAMConnection data structure, which FAMOpen will fill
++*  out so that the programmer can pass it to all fam procedures.
++*  FAMClose closes a fam connection.
++*
++*  On error, FAMOpen will return -1.
+ *****************************************************************************/
+ 
+ extern int FAMOpen(FAMConnection* fc);
+@@ -189,8 +189,7 @@
+ *  (as well as the directory file itself) and FAMMonitorFile monitors
+ *  only what happens to a particular file.
+ *
+-*  On error FAMMonitorDirectory/File will return NULL (and FAMErrno will
+-*  be set to the value of the error).  
++*  On error FAMMonitorDirectory/File will return NULL.
+ *****************************************************************************/
+ 
+ extern int FAMMonitorDirectory(FAMConnection *fc,
+@@ -229,8 +228,7 @@
+ *  The FAMRequest Structure is returned from the FAMMonitorFile/Directory
+ *  routines.
+ *
+-*  On error, FAMResume/SuspendMonitor will return -1 (and the global
+-*  FAMErrno will be set to the value of the error).
++*  On error, FAMResume/SuspendMonitor will return -1.
+ *****************************************************************************/
+ 
+ int FAMSuspendMonitor(FAMConnection *fc, const FAMRequest *fr);
+@@ -249,8 +247,7 @@
+ *  this directory anymore. Once again, the FAMRequest structure is
+ *  returned from the FAMMonitorFile/Directory routines.
+ *
+-*  On error, FAMCancelMonitor will return -1 (and the global
+-*  FAMErrno will be set to the value of the error).  This routine will free
++*  On error, FAMCancelMonitor will return -1.  This routine will free
+ *  the FAMRequest structure that is passed in.
+ *****************************************************************************/
+ 
+@@ -285,8 +282,7 @@
+ *  FAMNextEvent reads any information that is on the fam socket,
+ *  and returns it to the application (in the form of a FAMEvent).
+ *
+-*  On error, FAMNextEvent and FAMPendingEvent will return -1 (and the global
+-*  FAMErrno will be set to the value of the error).
++*  On error, FAMNextEvent and FAMPendingEvent will return -1.
+ *****************************************************************************/
+ 
+ int FAMNextEvent(FAMConnection *fc, FAMEvent *fe);
--- fam-2.7.0.orig/debian/patches/08_sockaddr_un.patch
+++ fam-2.7.0/debian/patches/08_sockaddr_un.patch
@@ -0,0 +1,56 @@
+diff -r 311775068c30 -r 91c270e9e228 config.h.in
+--- a/config.h.in	Wed Apr 12 13:50:51 2006 -0700
++++ b/config.h.in	Wed Apr 12 13:50:58 2006 -0700
+@@ -75,6 +75,9 @@
+ 
+ /* Define to 1 if `sa_len' is member of `struct sockaddr'. */
+ #undef HAVE_STRUCT_SOCKADDR_SA_LEN
++
++/* Define to 1 if `sun_len' is member of `struct sockaddr_un'. */
++#undef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
+ 
+ /* Define to 1 if you have the <syslog.h> header file. */
+ #undef HAVE_SYSLOG_H
+diff -r 311775068c30 -r 91c270e9e228 configure.ac
+--- a/configure.ac	Wed Apr 12 13:50:51 2006 -0700
++++ b/configure.ac	Wed Apr 12 13:50:58 2006 -0700
+@@ -72,7 +72,8 @@
+ AC_TYPE_PID_T
+ AC_TYPE_SIZE_T
+ AC_HEADER_TIME
+-AC_CHECK_MEMBERS(struct sockaddr.sa_len, struct sockaddr_un.sun_len)
++AC_CHECK_MEMBERS([struct sockaddr.sa_len],,, [#include <sys/socket.h>])
++AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,, [#include <sys/un.h>])
+ 
+ # Checks for library functions.
+ AC_FUNC_ERROR_AT_LINE
+diff -r 311775068c30 -r 91c270e9e228 src/Listener.c++
+--- a/src/Listener.c++	Wed Apr 12 13:50:51 2006 -0700
++++ b/src/Listener.c++	Wed Apr 12 13:50:58 2006 -0700
+@@ -209,7 +209,7 @@
+ #endif
+ 
+     char *tmpfile = tempnam("/tmp", ".fam");
+-#ifdef HAVE_SOCKADDR_SUN_LEN
++#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
+     sockaddr_un sun = { sizeof(sockaddr_un), AF_UNIX, "" };
+ #else
+     sockaddr_un sun = { AF_UNIX, "" };
+@@ -283,7 +283,7 @@
+ 
+     // Get the new socket.
+ 
+-#ifdef HAVE_SOCKADDR_SUN_LEN
++#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
+     struct sockaddr_un sun = { sizeof(sockaddr_un), AF_UNIX, "" };
+ #else
+     struct sockaddr_un sun = { AF_UNIX, "" };
+@@ -357,7 +357,7 @@
+ void
+ Listener::dirty_ugly_hack()
+ {
+-#ifdef HAVE_SOCKADDR_SUN_LEN
++#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
+     static sockaddr_un sun = { sizeof (sockaddr_un), AF_UNIX, "/tmp/.fam_socket" };
+ #else
+     static sockaddr_un sun = { AF_UNIX, "/tmp/.fam_socket" };
--- fam-2.7.0.orig/debian/patches/09_fix_leak.patch
+++ fam-2.7.0/debian/patches/09_fix_leak.patch
@@ -0,0 +1,16 @@
+diff -Naur fam-2.7.0/src/DNotify.c++ fam-2.7.0-fix-leak/src/DNotify.c++
+--- fam-2.7.0/src/DNotify.c++	2006-08-04 20:20:01.000000000 +1000
++++ fam-2.7.0-fix-leak/src/DNotify.c++	2006-08-04 20:21:31.000000000 +1000
+@@ -69,6 +69,12 @@
+ 	n_dir_watches = 0;
+     }
+ 
++    ~FileWatch(void) {
++        if (dir_watch) {
++            free(dir_watch);
++        }
++    }
++
+     void add_dir_watch (DirWatch *w);
+     bool has_dir_watch (DirWatch *w);
+ };
--- fam-2.7.0.orig/debian/patches/10_debianbug375967.patch
+++ fam-2.7.0/debian/patches/10_debianbug375967.patch
@@ -0,0 +1,38 @@
+--- a/src/NetConnection.c++	2003-01-18 15:18:12.000000000 +0100
++++ b/src/NetConnection.c++	2006-12-03 16:18:42.000000000 +0100
+@@ -208,6 +208,16 @@
+     if (fd < 0)
+ 	return;				// if closed, do nothing.
+ 
++    /*
++     * According to bug http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=375967
++     * this method is called with format=NULL from ClientConnection::send_event .
++     * But looking at the code in ClientConnection, format cannot be NULL.
++     * This assert verify this fact and will eventually show a compiler bug.
++     *
++     * Giuseppe Sacco, 20061203
++     */
++    assert(format != NULL);
++
+     va_list args;
+     va_start(args, format);
+ 
+@@ -217,7 +227,18 @@
+         msg->msg + 4, MAXMSGSIZE + 1, format, args) + 1;
+     va_end(args);
+ 
++    /*
++     * Changed from 
+     if (len <= 0 || len == MAXMSGSIZE+1) {
++     * to
++    if (len <= 0 || len > MAXMSGSIZE) {
++     * because the vsnprint return the size it would have required
++     * to store the complete string; this size may be greather than
++     * just MAXMSGSIZE+1
++     *
++     * Giuseppe Sacco, 20061203
++     */
++    if (len <= 0 || len > MAXMSGSIZE) {
+         Log::error("tried to write a message that was too big");
+         assert(0);
+         // protocol botch.  Don't send the message.
--- fam-2.7.0.orig/debian/patches/11-gcc43.patch
+++ fam-2.7.0/debian/patches/11-gcc43.patch
@@ -0,0 +1,20 @@
+Only in fam-2.7.0/lib: #Client.c++#
+diff -aur fam-2.7.0.orig/lib/Client.c++ fam-2.7.0/lib/Client.c++
+--- fam-2.7.0.orig/lib/Client.c++	2003-01-18 15:18:12.000000000 +0100
++++ fam-2.7.0/lib/Client.c++	2008-03-20 23:18:09.000000000 +0100
+@@ -29,12 +29,12 @@
+ #include <rpc/rpc.h>
+ #include <rpc/pmap_clnt.h>
+ #include <rpc/pmap_prot.h>
+-#include <string.h>  // for memset
++#include <cstring>  // for memset
+ #include <ctype.h>
+ #include <syslog.h>
+ #include <errno.h>
+ 
+-#include <iostream.h>
++#include <iostream>
+ 
+ #include "fam.h"
+ #include "Client.h"
+Only in fam-2.7.0/lib: Client.c++~
--- fam-2.7.0.orig/debian/patches/12-gcc43.patch
+++ fam-2.7.0/debian/patches/12-gcc43.patch
@@ -0,0 +1,13 @@
+diff -aur fam-2.7.0.orig/src/IMon.c++ fam-2.7.0/src/IMon.c++
+--- fam-2.7.0.orig/src/IMon.c++	2003-01-18 15:18:12.000000000 +0100
++++ fam-2.7.0/src/IMon.c++	2008-03-20 23:30:25.000000000 +0100
+@@ -40,7 +40,7 @@
+ #include "Interest.h"
+ #include "Log.h"
+ #include "Scheduler.h"
+-#include "alloc.h"
++#include <memory>
+ 
+ int		   IMon::imonfd = -2;
+ IMon::EventHandler IMon::ehandler = NULL;
+Only in fam-2.7.0/src: IMon.c++~
--- fam-2.7.0.orig/debian/patches/13-gcc43.patch
+++ fam-2.7.0/debian/patches/13-gcc43.patch
@@ -0,0 +1,13 @@
+diff -aur fam-2.7.0.orig/src/DNotify.c++ fam-2.7.0/src/DNotify.c++
+--- fam-2.7.0.orig/src/DNotify.c++	2008-03-20 23:31:08.000000000 +0100
++++ fam-2.7.0/src/DNotify.c++	2008-03-20 23:38:28.000000000 +0100
+@@ -41,7 +41,7 @@
+ #include "Interest.h"
+ #include "Log.h"
+ #include "Scheduler.h"
+-#include "alloc.h"
++#include <memory>
+ 
+ 
+ int DNotify::pipe_write_fd = -2;
+Only in fam-2.7.0/src: DNotify.c++~
--- fam-2.7.0.orig/debian/patches/14-glibc29.patch
+++ fam-2.7.0/debian/patches/14-glibc29.patch
@@ -0,0 +1,11 @@
+diff -urN fam-2.7.0.orig/src/Interest.h fam-2.7.0/src/Interest.h
+--- fam-2.7.0.orig/src/Interest.h	2009-05-02 09:11:57.000000000 -0700
++++ fam-2.7.0/src/Interest.h	2009-05-02 09:12:29.000000000 -0700
+@@ -27,6 +27,7 @@
+ #include <sys/types.h>
+ #include <sys/time.h>
+ #include <netinet/in.h>  //  for in_addr
++#include <cstdlib>
+ 
+ #include "Boolean.h"
+ 
--- fam-2.7.0.orig/debian/patches/15-partial_send.patch
+++ fam-2.7.0/debian/patches/15-partial_send.patch
@@ -0,0 +1,43 @@
+diff -Naur fam-2.7.0/fam-2.7.0/src/NetConnection.c++ fam-2.7.0-mod/fam-2.7.0/src/NetConnection.c++
+--- fam-2.7.0/fam-2.7.0/src/NetConnection.c++	2003-01-18 09:18:12.000000000 -0500
++++ fam-2.7.0-mod/fam-2.7.0/src/NetConnection.c++	2007-07-30 12:57:19.812380334 -0400
+@@ -213,6 +213,7 @@
+ 
+     msgList_t * msg = new msgList_t;
+     msg->next = NULL;
++    msg->offset = 0;
+     Length len = vsnprintf(
+         msg->msg + 4, MAXMSGSIZE + 1, format, args) + 1;
+     va_end(args);
+@@ -241,7 +242,8 @@
+ {
+     while (omsgList) 
+     {
+-	int ret = send(fd, omsgList->msg, omsgList->len, 0);
++	int ret = send(fd, omsgList->msg + omsgList->offset,
++                       omsgList->len - omsgList->offset, 0);
+         if (ret < 0 && errno == EWOULDBLOCK) 
+         {
+             break;
+@@ -249,7 +251,9 @@
+         {
+             if (ret >= 0) 
+             {
+-                assert(ret == omsgList->len);
++                omsgList->offset += ret;
++                if( omsgList->offset < omsgList->len )
++                    continue;
+             } else 
+             {
+                 /* Since the client library can close it's fd before
+diff -Naur fam-2.7.0/fam-2.7.0/src/NetConnection.h fam-2.7.0-mod/fam-2.7.0/src/NetConnection.h
+--- fam-2.7.0/fam-2.7.0/src/NetConnection.h	2003-01-18 09:18:12.000000000 -0500
++++ fam-2.7.0-mod/fam-2.7.0/src/NetConnection.h	2007-07-30 12:53:46.746803625 -0400
+@@ -80,6 +80,7 @@
+     typedef struct msgList_s {
+         char msg[MAXMSGSIZE+5];  //  + 4 for 32-bit length, + 1 for overflow
+         int len;
++        int offset;
+         msgList_s * next;
+     } msgList_t;
+     
--- fam-2.7.0.orig/debian/patches/16-port_number.patch
+++ fam-2.7.0/debian/patches/16-port_number.patch
@@ -0,0 +1,121 @@
+diff -Naur fam-2.7.0/fam-2.7.0/man/famd.8 fam-2.7.0-mod/fam-2.7.0/man/famd.8
+--- fam-2.7.0/fam-2.7.0/man/famd.8	2003-01-19 19:58:11.000000000 -0500
++++ fam-2.7.0-mod/fam-2.7.0/man/famd.8	2007-07-30 12:23:15.292527117 -0400
+@@ -51,6 +51,9 @@
+ Register with the portmapper using the specifed RPC program
+ and version numbers.
+ .TP
++\fB\-P\fR \fIport\fR
++Bind to the specified TCP port instead of choosing at random.
++.TP
+ \fB\-t\fR \fIperiod\fR
+ Poll a remove NFS server every \fIperiod\fR seconds
+ to obtain file updates if the remove server is not running \fBfamd\fR.
+diff -Naur fam-2.7.0/fam-2.7.0/src/Listener.c++ fam-2.7.0-mod/fam-2.7.0/src/Listener.c++
+--- fam-2.7.0/fam-2.7.0/src/Listener.c++	2003-01-19 19:37:29.000000000 -0500
++++ fam-2.7.0-mod/fam-2.7.0/src/Listener.c++	2007-07-26 16:32:03.863758810 -0400
+@@ -60,13 +60,14 @@
+ 
+ static void cleanup_negotiation(void *closure);
+ 
+-Listener::Listener(bool sbi, bool lo, unsigned long p, unsigned long v)
++Listener::Listener(bool sbi, bool lo, unsigned long p, unsigned long v, int pt)
+ : program(p),
+   version(v),
+   rendezvous_fd(-1),
+   started_by_inetd(sbi),
+   _ugly_sock(-1),
+-  local_only(lo)
++  local_only(lo),
++  port(pt)
+ {
+     if (started_by_inetd)
+     {
+@@ -91,11 +92,19 @@
+ 	memset(&addr, 0, sizeof addr);
+ 	addr.sin_family = AF_INET;
+         addr.sin_addr.s_addr = local_only ? htonl(INADDR_LOOPBACK) : 0;
+-	addr.sin_port = htons(0);
+-	if (bindresvport(sock, &addr) < 0)
+-	{
+-	    Log::perror("can't bind to reserved port");
+-	    exit(1);
++	addr.sin_port = htons(port);
++	Log::info( "Binding to port: %d\n", addr.sin_port );
++	if (port == 0)
++	{   if (bindresvport(sock, &addr) < 0)
++	    {   Log::perror("can't bind to reserved port");
++	        exit(1);
++	    }
++	}
++	else
++	{   if (bind(sock, (const sockaddr*)&addr, sizeof(sockaddr_in) ) < 0)
++	    {   Log::perror("can't bind to specified port");
++	        exit(1);
++	    }
+ 	}
+ 	if (listen(sock, 1) < 0)
+ 	{
+diff -Naur fam-2.7.0/fam-2.7.0/src/Listener.h fam-2.7.0-mod/fam-2.7.0/src/Listener.h
+--- fam-2.7.0/fam-2.7.0/src/Listener.h	2003-01-18 09:18:12.000000000 -0500
++++ fam-2.7.0-mod/fam-2.7.0/src/Listener.h	2007-07-26 16:32:50.682255289 -0400
+@@ -51,7 +51,9 @@
+ 
+     Listener(bool started_by_inetd,
+              bool local_only,
+-	     unsigned long program = FAMPROG, unsigned long version = FAMVERS);
++             unsigned long program = FAMPROG,
++             unsigned long version = FAMVERS,
++             int pt = 0);
+     ~Listener();
+ 
+     static void create_local_client(TCP_Client &inet_client, uid_t uid);
+@@ -66,6 +68,7 @@
+     bool started_by_inetd;
+     int _ugly_sock;
+     bool local_only;
++    int port;
+ 
+     //  Private Instance Methods
+ 
+diff -Naur fam-2.7.0/fam-2.7.0/src/main.c++ fam-2.7.0-mod/fam-2.7.0/src/main.c++
+--- fam-2.7.0/fam-2.7.0/src/main.c++	2003-01-19 01:15:51.000000000 -0500
++++ fam-2.7.0-mod/fam-2.7.0/src/main.c++	2007-05-08 16:42:35.618954322 -0400
+@@ -89,6 +89,7 @@
+     fprintf(stderr, "\t-d\t\tdebug\n");
+     fprintf(stderr, "\t-v\t\tverbose\n");
+     fprintf(stderr, "\t-l\t\tno polling\n");
++    fprintf(stderr, "\t-P\t\tbind to specified port\n");
+     fprintf(stderr, "\t-t seconds\tset polling interval (default 6 s)\n");
+     fprintf(stderr, "\t-T seconds\tset inactive timeout (default 5 s)\n");
+     fprintf(stderr, "\t-p prog.vers\tset RPC program number and version\n");
+@@ -122,6 +123,7 @@
+     bool started_by_inetd = S_ISSOCK(st.st_mode);
+ 
+     unsigned long program = Listener::FAMPROG, version = Listener::FAMVERS;
++    int port = 0;
+ 
+     program_name = basename2(argv[0]);
+     Log::name(program_name);
+@@ -196,6 +198,12 @@
+             if (argv[i] == q) usage();
+ 	    break;
+ 
++        case 'P':
++            if (++i >= argc)
++                usage();
++            port = strtol(argv[i], NULL, 10);
++            break;
++
+ 	case 't':
+ 	    if (i + 1 >= argc)
+ 		usage();
+@@ -286,7 +294,7 @@
+     // (since we poll anyway) and we don't want to create zombies.
+     (void) signal(SIGCHLD, SIG_IGN);
+ #endif
+-    new Listener(started_by_inetd, opts.local_only, program, version);
++    new Listener(started_by_inetd, opts.local_only, program, version, port);
+     Scheduler::loop();
+     return 0;
+ }
--- fam-2.7.0.orig/debian/patches/17_reserve_fam_errors.patch
+++ fam-2.7.0/debian/patches/17_reserve_fam_errors.patch
@@ -0,0 +1,18 @@
+--- fam-2.7.0/lib/fam.c++	2003-01-18 15:18:12.000000000 +0100
++++ fam-2.7.0/lib/fam.c++	2007-08-16 14:17:30.000000000 +0200
+@@ -46,7 +46,14 @@
+ #define LOCALHOSTNUMBER 0x7f000001 // Internet number for loopback.
+ 
+ // Error variables - XXX currently not dealt with
+-#define FAM_NUM_ERRORS 1
++// Debian specific change: Make the public symbol size 100 instead of 1 to
++// avoid errors when using binaries built against another version of the
++// library: if the size changes (for example when error messages are added
++// or when switching from the fam to the gamin implementation), the linker
++// warns that the FamErrlist sizes don't match, even if this isn't problematic
++// (as FAMErrno is set by the lib at runtime based on the messages it knows
++// about)
++#define FAM_NUM_ERRORS 100
+ int FAMErrno;
+ char *FamErrlist[FAM_NUM_ERRORS];
+ 
--- fam-2.7.0.orig/debian/patches/18_gcc44.patch
+++ fam-2.7.0/debian/patches/18_gcc44.patch
@@ -0,0 +1,12 @@
+diff -r 70fca8077d17 src/NFSFileSystem.c++
+--- a/src/NFSFileSystem.c++	Sun Aug 01 22:11:06 2010 -0700
++++ b/src/NFSFileSystem.c++	Sun Aug 01 22:12:31 2010 -0700
+@@ -97,7 +97,7 @@
+ 
+     attr_cache_timeout = ACREGMAX;
+ 
+-    char * p;
++    const char * p;
+         
+     if (strstr(opt, "noac")) {
+         f_noac = true;
--- fam-2.7.0.orig/debian/rules
+++ fam-2.7.0/debian/rules
@@ -0,0 +1,24 @@
+#!/usr/bin/make -f
+
+DEB_TAR_SRCDIR := fam-2.7.0
+DEB_DH_INSTALL_SOURCEDIR := debian/tmp
+
+include /usr/share/cdbs/1/rules/tarball.mk
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
+include /usr/share/cdbs/1/class/autotools.mk
+
+DEB_AUTO_UPDATE_LIBTOOL := pre
+DEB_AUTO_UPDATE_ACLOCAL := 1.11
+DEB_AUTO_UPDATE_AUTOMAKE := 1.11
+DEB_AUTO_UPDATE_AUTOCONF := 2.50
+DEB_UPDATE_RCD_PARAMS := "defaults 21"
+
+DEB_CONFIGURE_USER_FLAGS := --with-pic=yes
+CXXFLAGS = -g -Wall -O2 -Wno-sign-compare -Wno-deprecated \
+	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
+
+install/fam ::
+	cp build-tree/fam-2.7.0/man/famd.conf.5 \
+	  debian/tmp/usr/share/man/man5/fam.conf.5
+	cp debian/fam.conf debian/tmp/etc/fam.conf
--- fam-2.7.0.orig/debian/source/format
+++ fam-2.7.0/debian/source/format
@@ -0,0 +1 @@
+1.0
--- fam-2.7.0.orig/debian/watch
+++ fam-2.7.0/debian/watch
@@ -0,0 +1,2 @@
+version=3
+opts=pasv ftp://oss.sgi.com/projects/fam/download/stable/fam-([0-9.]+)\.tar\.gz
--- fam-2.7.0.orig/fam-2.7.0.tar.gz.cdbs-config_list
+++ fam-2.7.0/fam-2.7.0.tar.gz.cdbs-config_list
@@ -0,0 +1,3 @@
+fam-2.7.0/config.h.in
+fam-2.7.0/config.guess
+fam-2.7.0/config.sub
