diff -Naur fam-2.7.0/src/FileSystem.c++ fam-2.7.0-macosx/src/FileSystem.c++ --- fam-2.7.0/src/FileSystem.c++ Sat Jan 18 06:18:12 2003 +++ fam-2.7.0-macosx/src/FileSystem.c++ Thu Apr 1 22:40:37 2004 @@ -22,7 +22,7 @@ #include "FileSystem.h" -#include +#include "mntent.h" #include #include "Event.h" diff -Naur fam-2.7.0/src/FileSystemTable.c++ fam-2.7.0-macosx/src/FileSystemTable.c++ --- fam-2.7.0/src/FileSystemTable.c++ Sat Jan 18 06:18:12 2003 +++ fam-2.7.0-macosx/src/FileSystemTable.c++ Thu Apr 1 22:40:38 2004 @@ -255,7 +255,10 @@ // create_fs_by_name initializes our "root" member variable. if (!fs_by_name) { create_fs_by_name(); +#if !defined(__APPLE__) + /* there is no mtab "file" in freebsd! */ mtab_watcher = new InternalClient(mtab_name, mtab_event_handler, NULL); +#endif } cr.become_user(); diff -Naur fam-2.7.0/src/IMon.c++ fam-2.7.0-macosx/src/IMon.c++ --- fam-2.7.0/src/IMon.c++ Sat Jan 18 06:18:12 2003 +++ fam-2.7.0-macosx/src/IMon.c++ Thu Apr 1 22:40:38 2004 @@ -34,7 +34,9 @@ #endif #endif -#include +#if !defined(__APPLE__) +# include +#endif #include #include "Interest.h" diff -Naur fam-2.7.0/src/Interest.c++ fam-2.7.0-macosx/src/Interest.c++ --- fam-2.7.0/src/Interest.c++ Sat Jan 18 06:18:12 2003 +++ fam-2.7.0-macosx/src/Interest.c++ Thu Apr 1 22:40:38 2004 @@ -23,7 +23,9 @@ #include "Interest.h" #include -#include +#if !defined(__APPLE__) +# include +#endif #include #include diff -Naur fam-2.7.0/src/Listener.c++ fam-2.7.0-macosx/src/Listener.c++ --- fam-2.7.0/src/Listener.c++ Sun Jan 19 16:37:29 2003 +++ fam-2.7.0-macosx/src/Listener.c++ Thu Apr 1 22:57:39 2004 @@ -208,8 +208,8 @@ putenv("TMPDIR="); #endif - char *tmpfile = tempnam("/tmp", ".fam"); -#ifdef HAVE_SOCKADDR_SUN_LEN + char *tmpfile = mktemp("/tmp/fam.XXXXXX"); +#if defined(__APPLE__) 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 +#if defined(__APPLE__) struct sockaddr_un sun = { sizeof(sockaddr_un), AF_UNIX, "" }; #else struct sockaddr_un sun = { AF_UNIX, "" }; @@ -349,7 +349,7 @@ void Listener::dirty_ugly_hack() { -#ifdef HAVE_SOCKADDR_SUN_LEN +#if defined(__APPLE__) static sockaddr_un sun = { sizeof (sockaddr_un), AF_UNIX, "/tmp/.fam_socket" }; #else static sockaddr_un sun = { AF_UNIX, "/tmp/.fam_socket" }; diff -Naur fam-2.7.0/src/Log.c++ fam-2.7.0-macosx/src/Log.c++ --- fam-2.7.0/src/Log.c++ Sat Jan 18 06:18:12 2003 +++ fam-2.7.0-macosx/src/Log.c++ Thu Apr 1 23:01:57 2004 @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -259,6 +261,7 @@ delete[] buf; } +/* #ifndef NDEBUG // New back end for assert() will log to syslog, put core file diff -Naur fam-2.7.0/src/Makefile.am fam-2.7.0-macosx/src/Makefile.am --- fam-2.7.0/src/Makefile.am Sun Jan 19 04:00:17 2003 +++ fam-2.7.0-macosx/src/Makefile.am Thu Apr 1 22:40:38 2004 @@ -71,6 +71,7 @@ main.c++ \ timeval.c++ \ timeval.h \ + mntent_compat.c++ \ @MONITOR_FUNCS@.c++ EXTRA_famd_SOURCES = IMonIrix.c++ IMonLinux.c++ IMonNone.c++ diff -Naur fam-2.7.0/src/StringTable.h fam-2.7.0-macosx/src/StringTable.h --- fam-2.7.0/src/StringTable.h Sat Jan 18 06:18:12 2003 +++ fam-2.7.0-macosx/src/StringTable.h Thu Apr 1 22:40:38 2004 @@ -25,6 +25,7 @@ #include #include +#include "mntent.h" // A StringTable maps C strings onto values. It is a cheap O(n) // implementation, suitable only for small tables that are diff -Naur fam-2.7.0/src/mntent.h fam-2.7.0-macosx/src/mntent.h --- fam-2.7.0/src/mntent.h Wed Dec 31 16:00:00 1969 +++ fam-2.7.0-macosx/src/mntent.h Thu Apr 1 22:40:38 2004 @@ -0,0 +1,56 @@ +/* + * mntent + * mntent.h - compatability header for FreeBSD + * + * Copyright (c) 2001 David Rufino + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(HAVE_MNTENT_H) +#include +#else +#ifndef _MNTENT_H +#define _MNTENT_H +#include + +#define MOUNTED "dummy" + +#define MNTTYPE_NFS "nfs" + +struct mntent { + char *mnt_fsname; + char *mnt_dir; + char *mnt_type; + char *mnt_opts; + int mnt_freq; + int mnt_passno; +}; + +#define setmntent(x,y) ((FILE *)0x1) +struct mntent *getmntent __P ((FILE *fp)); +char *hasmntopt __P ((const struct mntent *mnt, const char *option)); +#define endmntent(x) ((int)1) + +#endif /* _MNTENT_H */ +#endif /* HAVE_MNTENT_H */ diff -Naur fam-2.7.0/src/mntent_compat.c++ fam-2.7.0-macosx/src/mntent_compat.c++ --- fam-2.7.0/src/mntent_compat.c++ Wed Dec 31 16:00:00 1969 +++ fam-2.7.0-macosx/src/mntent_compat.c++ Fri Apr 2 19:47:25 2004 @@ -0,0 +1,151 @@ +/* + * Copyright (c) 1980, 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 2001 + * David Rufino + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* most of this was ripped from the mount(3) source */ + +#include "config.h" +#include "mntent.h" +#if !defined(HAVE_MNTENT_H) +#include +#include +#include +#include +#include + +static int pos = -1; +static int mntsize = -1; +static struct mntent _mntent; + +char * +hasmntopt (const struct mntent *mnt, const char *option) +{ + int found; + char *opt, *optbuf; + + optbuf = strdup(mnt->mnt_opts); + found = 0; + for (opt = optbuf; (opt = strtok(opt, " ")) != NULL; opt = NULL) { + if (!strcasecmp(opt, option)) { + opt = opt - optbuf + mnt->mnt_opts; + free (optbuf); + return (opt); + } + } + free (optbuf); + return (NULL); +} + +static char * +catopt (char *s0, const char *s1) +{ + size_t i; + char *cp; + + if (s1 == NULL || *s1 == '\0') + return s0; + if (s0 && *s0) { + i = strlen(s0) + strlen(s1) + 1 + 1; + if ((cp = (char *)malloc(i)) == NULL) + return (NULL); + (void)snprintf(cp, i, "%s %s", s0, s1); + } else + cp = strdup(s1); + + if (s0) + free(s0); + return (cp); +} + + +static char * +flags2opts (int flags) +{ + char *res; + res = NULL; + res = catopt(res, (flags & MNT_RDONLY) ? "ro" : "rw"); + if (flags & MNT_SYNCHRONOUS) res = catopt(res, "sync"); + if (flags & MNT_NOEXEC) res = catopt(res, "noexec"); + if (flags & MNT_NOSUID) res = catopt(res, "nosuid"); + if (flags & MNT_NODEV) res = catopt(res, "nodev"); + if (flags & MNT_UNION) res = catopt(res, "union"); + if (flags & MNT_ASYNC) res = catopt(res, "async"); + // if (flags & MNT_NOATIME) res = catopt(res, "noatime"); + // if (flags & MNT_NOCLUSTERR) res = catopt(res, "noclusterr"); + // if (flags & MNT_NOCLUSTERW) res = catopt(res, "noclusterw"); + // if (flags & MNT_NOSYMFOLLOW) res = catopt(res, "nosymfollow"); + // if (flags & MNT_SUIDDIR) res = catopt(res, "suiddir"); + + return res; +} + +static struct mntent * +statfs_to_mntent (struct statfs *mntbuf) +{ + static char opts_buf[40], *tmp; + + _mntent.mnt_fsname = mntbuf->f_mntfromname; + _mntent.mnt_dir = mntbuf->f_mntonname; + _mntent.mnt_type = mntbuf->f_fstypename; + tmp = flags2opts (mntbuf->f_flags); + if (tmp) { + opts_buf[sizeof(opts_buf)-1] = '\0'; + strncpy (opts_buf, tmp, sizeof(opts_buf)-1); + free (tmp); + } else { + *opts_buf = '\0'; + } + _mntent.mnt_opts = opts_buf; + _mntent.mnt_freq = _mntent.mnt_passno = 0; + return (&_mntent); +} + +struct mntent * +getmntent (FILE *fp) +{ + struct statfs *mntbuf; + + if (pos == -1 || mntsize == -1) + mntsize = getmntinfo (&mntbuf, MNT_NOWAIT); + + ++pos; + if (pos == mntsize) { + pos = mntsize = -1; + return (NULL); + } + + return (statfs_to_mntent (&mntbuf[pos])); +} + +#endif /* HAVE_MNTENT_H */