1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
8 SDESC[standard]= Monitor files and directories for changes
9 HOMEPAGE= https://gitlab.gnome.org/Archive/gamin
10 CONTACT= Michael_Reim[kraileth@elderlinux.org]
13 SITES[main]= https://download.gnome.org/sources/gamin/0.1/
14 DISTFILE[1]= gamin-0.1.10.tar.gz:main
16 SPKGS[standard]= single
18 OPTIONS_AVAILABLE= none
19 OPTIONS_STANDARD= none
21 USES= gettext-runtime gmake libtool pkgconfig fbsd10fix
22 GNOME_COMPONENTS= glib
24 LICENSE= LGPL20+:single
25 LICENSE_TERMS= single:{{WRKDIR}}/TERMS
26 LICENSE_FILE= LGPL20+:{{WRKSRC}}/COPYING
27 LICENSE_AWK= TERMS:"^$$"
28 LICENSE_SOURCE= TERMS:{{WRKSRC}}/server/gam_poll_basic.c
31 FPC_EQUIVALENT= devel/gamin
36 PLIST_SUB= FAMVERSION=0.0.0
39 CPPFLAGS= -DHAVE_LINUX
42 ${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/*.so*
44 [FILE:284:descriptions/desc.single]
45 Gamin is a file and directory monitoring system defined to be a subset of
46 the FAM (File Alteration Monitor) system. This is a service provided by a
47 library which allows to detect when a file or a directory has been
50 It uses kqueue/kevent on FreeBSD and inotify on Linux.
54 28085f0ae8be10eab582ff186af4fb0be92cc6c62b5cc19cd09b295c7c2899a1 653392 gamin-0.1.10.tar.gz
57 [FILE:236:manifests/plist.single]
62 libfam.so.%%FAMMAJOR%%
63 libfam.so.%%FAMVERSION%%
66 libgamin-1.so.%%SOMAJOR%%
67 libgamin-1.so.%%SOVERSION%%
69 lib/pkgconfig/gamin.pc
73 [FILE:247:patches/patch-lib_gam__event.h]
74 --- lib/gam_event.h.orig 2007-07-04 13:36:49 UTC
77 #ifndef __MD_EVENT_H__
78 #define __MD_EVENT_H__
80 +#define G_CONST_RETURN const
83 GAMIN_EVENT_CHANGED = 1 << 4,
84 GAMIN_EVENT_CREATED = 1 << 5,
87 [FILE:4380:freebsd/patch-libgamin_gam__api.c]
88 --- libgamin/gam_api.c.orig 2007-08-27 03:21:03.000000000 -0700
89 +++ libgamin/gam_api.c 2013-02-16 15:51:11.927100135 -0800
91 #include <sys/socket.h>
96 #include "gam_protocol.h"
99 if (user_name[0] != 0)
103 + pw = getpwuid(geteuid());
105 pw = getpwuid(getuid());
109 strncpy(user_name, pw->pw_name, 99);
115 + if (st.st_uid != geteuid()) {
117 if (st.st_uid != getuid()) {
119 gam_error(DEBUG_INFO,
120 "Socket directory %s has different owner\n",
127 + if (st.st_uid != geteuid()) {
129 if (st.st_uid != getuid()) {
131 gam_error(DEBUG_INFO,
132 "Socket %s has different owner\n",
134 @@ -428,10 +441,10 @@
136 char data[2] = { 0, 0 };
138 -#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS)
140 +#if defined(HAVE_CMSGCRED) && (!defined(LOCAL_CREDS) || defined(__FreeBSD__))
143 - struct cmsgcred cred;
144 + char cred[CMSG_SPACE (sizeof (struct cmsgcred))];
148 @@ -443,16 +456,16 @@
152 - msg.msg_control = &cmsg;
153 - msg.msg_controllen = sizeof (cmsg);
154 + msg.msg_control = (caddr_t) &cmsg;
155 + msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
156 memset (&cmsg, 0, sizeof (cmsg));
157 - cmsg.hdr.cmsg_len = sizeof (cmsg);
158 + cmsg.hdr.cmsg_len = CMSG_LEN (sizeof (struct cmsgcred));
159 cmsg.hdr.cmsg_level = SOL_SOCKET;
160 cmsg.hdr.cmsg_type = SCM_CREDS;
164 -#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS)
165 +#if defined(HAVE_CMSGCRED) && (!defined(LOCAL_CREDS) || defined(__FreeBSD__))
166 written = sendmsg(fd, &msg, 0);
168 written = write(fd, &data[0], 1);
169 @@ -654,15 +667,20 @@
174 + struct cmsgcred *cred;
177 - struct cmsgcred cred;
178 + char cred[CMSG_SPACE (sizeof (struct cmsgcred))];
188 -#if defined(LOCAL_CREDS) && defined(HAVE_CMSGCRED)
189 +#if defined(LOCAL_CREDS) && defined(HAVE_CMSGCRED) && !defined(__FreeBSD__)
190 /* Set the socket to receive credentials on the next message */
196 memset(&cmsg, 0, sizeof(cmsg));
197 - msg.msg_control = &cmsg;
198 - msg.msg_controllen = sizeof(cmsg);
199 + msg.msg_control = (caddr_t) &cmsg;
200 + msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
208 - if (cmsg.hdr.cmsg_len < sizeof(cmsg) || cmsg.hdr.cmsg_type != SCM_CREDS) {
209 + if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred)) || cmsg.hdr.cmsg_type != SCM_CREDS) {
210 GAM_DEBUG(DEBUG_INFO,
211 "Message from recvmsg() was not SCM_CREDS\n");
216 #elif defined(HAVE_CMSGCRED)
217 - c_pid = cmsg.cred.cmcred_pid;
218 - c_uid = cmsg.cred.cmcred_euid;
219 - c_gid = cmsg.cred.cmcred_groups[0];
220 + cred = (struct cmsgcred *) CMSG_DATA (&cmsg);
221 + c_pid = cred->cmcred_pid;
222 + c_uid = cred->cmcred_euid;
223 + c_gid = cred->cmcred_groups[0];
224 #else /* !SO_PEERCRED && !HAVE_CMSGCRED */
225 GAM_DEBUG(DEBUG_INFO,
226 "Socket credentials not supported on this OS\n");
227 @@ -1288,14 +1307,17 @@
229 // FIXME: drop and reacquire lock while blocked?
230 gamin_data_lock(conn);
231 - if (!gamin_data_event_ready(conn)) {
232 + while ((ret = gamin_data_event_ready(conn)) == 0) {
233 if (gamin_read_data(conn, fc->fd, 1) < 0) {
234 gamin_try_reconnect(conn, fc->fd);
235 FAMErrno = FAM_CONNECT;
239 - ret = gamin_data_read_event(conn, fe);
242 + ret = gamin_data_read_event(conn, fe);
244 gamin_data_unlock(conn);
249 [FILE:3112:freebsd/patch-libgamin_gam__fork.c]
250 --- libgamin/gam_fork.c.orig 2007-07-04 06:36:48.000000000 -0700
251 +++ libgamin/gam_fork.c 2013-02-16 20:37:31.298176973 -0800
258 + * gamin_drop_privileges
260 + * Attempt to drop privileges to another user and group before forking
261 + * a copy of the gam server
263 + * Return 0 in case of success or -1 in case of detected error.
266 +gamin_drop_privileges(int to_uid, int to_gid)
268 + GAM_DEBUG(DEBUG_INFO, "Dropping privileges to %d:%d before forking server\n", to_uid, to_gid);
270 + /* Get the current real user and group */
271 + int from_uid = getuid();
272 + int from_gid = getgid();
274 + /* Make sure we were able to get the user and group values */
275 + if ( from_uid == -1 || to_uid == -1 || from_gid == -1 || to_gid == -1 ) {
276 + gam_error(DEBUG_INFO, "failed to get user or group info, unable to drop privileges\n");
280 + /* Refuse to run setuid if it would escalate privileges */
281 + if ( from_uid != 0 && to_uid == 0 )
283 + gam_error(DEBUG_INFO, "refusing to escalate user privileges from=%d to=%d\n", from_uid, to_uid);
287 + /* Refuse to run setgid if it would escalate privileges */
288 + if ( from_gid != 0 && to_gid == 0 )
290 + gam_error(DEBUG_INFO, "refusing to escalate group privileges from=%d to=%d\n", from_gid, to_gid);
294 + /* Run setuid to drop privileges to the effective user */
295 + if ( from_uid != to_uid ) {
296 + GAM_DEBUG(DEBUG_INFO, "Attempting setuid from=%d to=%d\n", from_uid, to_uid);
298 + /* run setuid and check for errors */
299 + if (setuid(to_uid) == -1) {
300 + gam_error(DEBUG_INFO, "failed to run setuid from=%d to=%d\n", from_uid, to_uid);
305 + GAM_DEBUG(DEBUG_INFO, "Already running as effective user, skipping setuid\n");
308 + /* Run setgid to drop privileges to the effective group */
309 + if ( from_gid != to_gid ) {
310 + GAM_DEBUG(DEBUG_INFO, "Attempting setgid from=%d to=%d\n", from_gid, to_gid);
312 + /* run setuid and check for errors */
313 + if (setgid(to_gid) == -1) {
314 + gam_error(DEBUG_INFO, "failed to run setgid from=%d to=%d\n", from_gid, to_gid);
319 + GAM_DEBUG(DEBUG_INFO, "Already running as effective group, skipping setgid\n");
322 + GAM_DEBUG(DEBUG_INFO, "Succeeded in dropping privileges from %d:%d to %d:%d\n", from_uid, from_gid, to_uid, to_gid);
330 * @fam_client_id: the client ID string to use
336 + /* Drop privileges to the current effective uid/gid and return on failure */
337 + if(gamin_drop_privileges( geteuid(), getegid() ) == -1) {
342 /* don't hold open fd opened from the client of the library */
343 open_max = sysconf (_SC_OPEN_MAX);
344 for (i = 0; i < open_max; i++)
347 [FILE:313:freebsd/patch-libgamin_gam__fork.h]
348 --- libgamin/gam_fork.h.orig 2007-07-04 06:36:48.000000000 -0700
349 +++ libgamin/gam_fork.h 2013-02-16 20:38:00.328594608 -0800
353 int gamin_fork_server (const char *fam_client_id);
355 +int gamin_drop_privileges (int to_uid, int to_gid);
362 [FILE:4065:freebsd/patch-server_gam__channel.c]
363 --- server/gam_channel.c.orig Tue Aug 9 12:17:39 2005
364 +++ server/gam_channel.c Fri Feb 10 01:22:46 2006
366 #include <sys/stat.h>
370 #include "gam_error.h"
371 #include "gam_connection.h"
372 #include "gam_channel.h"
373 @@ -30,10 +31,10 @@ gam_client_conn_send_cred(int fd)
375 char data[2] = { 0, 0 };
377 -#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS)
379 +#if defined(HAVE_CMSGCRED) && (!defined(LOCAL_CREDS) || defined(__FreeBSD__))
382 - struct cmsgcred cred;
383 + char cred[CMSG_SPACE (sizeof (struct cmsgcred))];
387 @@ -45,16 +46,16 @@ gam_client_conn_send_cred(int fd)
391 - msg.msg_control = &cmsg;
392 - msg.msg_controllen = sizeof (cmsg);
393 + msg.msg_control = (caddr_t) &cmsg;
394 + msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
395 memset (&cmsg, 0, sizeof (cmsg));
396 - cmsg.hdr.cmsg_len = sizeof (cmsg);
397 + cmsg.hdr.cmsg_len = CMSG_LEN (sizeof (struct cmsgcred));
398 cmsg.hdr.cmsg_level = SOL_SOCKET;
399 cmsg.hdr.cmsg_type = SCM_CREDS;
403 -#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS)
404 +#if defined(HAVE_CMSGCRED) && (!defined(LOCAL_CREDS) || defined(__FreeBSD__))
405 written = sendmsg(fd, &msg, 0);
407 written = write(fd, &data[0], 1);
408 @@ -95,15 +96,16 @@ gam_client_conn_check_cred(GIOChannel *
413 + struct cmsgcred *cred;
416 - struct cmsgcred cred;
417 + char cred[CMSG_SPACE (sizeof (struct cmsgcred))];
423 -#if defined(LOCAL_CREDS) && defined(HAVE_CMSGCRED)
424 +#if defined(LOCAL_CREDS) && defined(HAVE_CMSGCRED) && !defined(__FreeBSD__)
425 /* Set the socket to receive credentials on the next message */
428 @@ -124,8 +126,8 @@ gam_client_conn_check_cred(GIOChannel *
431 memset(&cmsg, 0, sizeof(cmsg));
432 - msg.msg_control = &cmsg;
433 - msg.msg_controllen = sizeof(cmsg);
434 + msg.msg_control = (caddr_t) &cmsg;
435 + msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
439 @@ -142,7 +144,7 @@ gam_client_conn_check_cred(GIOChannel *
443 - if (cmsg.hdr.cmsg_len < sizeof(cmsg) || cmsg.hdr.cmsg_type != SCM_CREDS) {
444 + if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred)) || cmsg.hdr.cmsg_type != SCM_CREDS) {
445 GAM_DEBUG(DEBUG_INFO,
446 "Message from recvmsg() was not SCM_CREDS\n");
448 @@ -168,9 +170,10 @@ gam_client_conn_check_cred(GIOChannel *
451 #elif defined(HAVE_CMSGCRED)
452 - c_pid = cmsg.cred.cmcred_pid;
453 - c_uid = cmsg.cred.cmcred_euid;
454 - c_gid = cmsg.cred.cmcred_groups[0];
455 + cred = (struct cmsgcred *) CMSG_DATA (&cmsg);
456 + c_pid = cred->cmcred_pid;
457 + c_uid = cred->cmcred_euid;
458 + c_gid = cred->cmcred_groups[0];
459 #else /* !SO_PEERCRED && !HAVE_CMSGCRED */
460 GAM_DEBUG(DEBUG_INFO,
461 "Socket credentials not supported on this OS\n");
462 @@ -620,6 +621,7 @@ gam_listen_unix_socket(const char *path)
465 struct sockaddr_un addr;
468 fd = socket(PF_UNIX, SOCK_STREAM, 0);
470 @@ -640,8 +642,18 @@ gam_listen_unix_socket(const char *path)
471 * some extra protection checks. Also make sure the socket is created
472 * with restricted mode
474 - if (!gam_check_secure_path(path)) {
475 + if (!gam_check_secure_dir()) {
480 + if (stat(path, &st) == 0) {
481 + /* bind() will fail if the socket already exists */
482 + if (unlink(path) < 0) {
483 + GAM_DEBUG(DEBUG_INFO, "Failed to remove %s\n", path);
488 strncpy(&addr.sun_path[0], path, (sizeof(addr) - 4) - 1);
492 [FILE:376:freebsd/patch-server_gam__eq.c]
493 --- server/gam_eq.c.orig 2012-05-13 19:42:20.257794534 +0400
494 +++ server/gam_eq.c 2012-05-13 19:44:41.228799909 +0400
495 @@ -124,7 +124,7 @@ gam_eq_flush (gam_eq_t *eq, GamConnDataP
497 gboolean done_work = FALSE;
502 #ifdef GAM_EQ_VERBOSE
503 GAM_DEBUG(DEBUG_INFO, "gam_eq: Flushing event queue for %s\n", gam_connection_get_pidname (conn));
506 [FILE:3702:freebsd/patch-server_gam__fs.c]
507 --- server/gam_fs.c.orig 2007-07-04 09:36:49.000000000 -0400
508 +++ server/gam_fs.c 2007-08-10 15:05:41.000000000 -0400
514 +#include <sys/param.h>
515 +#include <sys/ucred.h>
516 +#include <sys/mount.h>
518 #include "gam_error.h"
521 @@ -21,9 +26,13 @@ typedef struct _gam_fs_properties {
522 typedef struct _gam_fs {
528 static gboolean initialized = FALSE;
530 +static gboolean initializing = FALSE;
532 static GList *filesystems = NULL;
533 static GList *fs_props = NULL;
534 static struct stat mtab_sbuf;
535 @@ -110,6 +119,7 @@ gam_fs_filesystem_sort_cb (gconstpointer
536 return strlen(fsb->path) - strlen (fsa->path);
541 gam_fs_scan_mtab (void)
543 @@ -165,10 +175,41 @@ gam_fs_scan_mtab (void)
544 gam_fs_free_filesystems ();
545 filesystems = g_list_sort (new_filesystems, gam_fs_filesystem_sort_cb);
551 +gam_fs_getmntinfo (void)
553 + struct statfs *stat;
554 + GList *new_filesystems = NULL;
558 + n = getmntinfo(&stat, MNT_NOWAIT);
562 + for (i = 0; i < n; i++)
564 + fs = g_new0 (gam_fs, 1);
565 + fs->path = g_strdup (stat[i].f_mntonname);
566 + fs->fsname = g_strdup (stat[i].f_fstypename);
567 + fs->flags = stat[i].f_flags;
569 + new_filesystems = g_list_prepend (new_filesystems, fs);
572 + /* Replace the old file systems list with the new one */
573 + gam_fs_free_filesystems ();
574 + filesystems = g_list_sort (new_filesystems, gam_fs_filesystem_sort_cb);
581 +#if defined(__linux__)
582 if (initialized == FALSE)
585 @@ -181,6 +222,7 @@ gam_fs_init (void)
586 if (stat("/etc/mtab", &mtab_sbuf) != 0)
588 GAM_DEBUG(DEBUG_INFO, "Could not stat /etc/mtab\n");
593 @@ -189,6 +231,7 @@ gam_fs_init (void)
594 if (stat("/etc/mtab", &sbuf) != 0)
596 GAM_DEBUG(DEBUG_INFO, "Could not stat /etc/mtab\n");
600 /* /etc/mtab has changed */
601 @@ -199,6 +242,54 @@ gam_fs_init (void)
605 +#elif defined(__FreeBSD__)
606 + if (initialized == FALSE && initializing == FALSE)
608 + GList *iterator = NULL;
609 + GHashTable *fs_hash = NULL;
612 + initialized = TRUE;
613 + initializing = TRUE;
615 + gam_fs_getmntinfo ();
617 + iterator = filesystems;
618 + fs_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
621 + fs = iterator->data;
623 + if (!g_hash_table_lookup (fs_hash, fs->fsname)) {
624 + if (fs->flags & MNT_LOCAL)
625 + gam_fs_set (fs->fsname, GFS_MT_DEFAULT, 0);
627 + gam_fs_set (fs->fsname, GFS_MT_POLL, 5);
629 + g_hash_table_insert (fs_hash, g_strdup (fs->fsname), GINT_TO_POINTER (1));
632 + iterator = g_list_next (iterator);
635 + g_hash_table_destroy (fs_hash);
636 + initializing = FALSE;
637 + } else if (initializing == FALSE) {
640 + if (stat ("/etc/fstab", &sbuf) != 0) {
641 + GAM_DEBUG(DEBUG_INFO, "Could not stat /etc/fstab\n");
645 + if (sbuf.st_mtime != mtab_sbuf.st_mtime) {
646 + GAM_DEBUG(DEBUG_INFO, "Updating list of mounted filesystems\n");
647 + gam_fs_getmntinfo ();
656 @@ -210,7 +301,11 @@ gam_fs_get_mon_type (const char *path)
657 props = gam_fs_find_fs_props (path);
660 +#ifdef USE_GAMIN_POLLER
661 + return GFS_MT_POLL;
663 return GFS_MT_DEFAULT;
666 return props->mon_type;
670 [FILE:10104:freebsd/patch-server_gam__kqueue.c]
671 --- server/gam_kqueue.c.orig 2007-07-04 09:50:41.000000000 -0400
672 +++ server/gam_kqueue.c 2009-06-03 13:43:38.000000000 -0400
675 * * http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=bks&fname=/SGI_Developer/books/IIDsktp_IG/sgi_html/ch08.html
676 * states that FAM does not follow monitored symbolic links: we
677 - * do the same (note that regarding
678 + * do NOT do the same to preserve compatibility with SGI FAM (note
680 * http://oss.sgi.com/bugzilla/show_bug.cgi?id=405, we do what
681 * FAM should do: we do not call g_dir_open() if the file is a
684 * - kqueue needs to be augmented with a filename-based
685 * monitoring facility;
687 - * - kqueue needs to be moved out the UFS code.
689 * Copyright (C) 2005 Joe Marcus Clarke <marcus@FreeBSD.org>
690 - * Copyright (C) 2005 Jean-Yves Lefort <jylefort@FreeBSD.org>
691 + * Copyright (C) 2005, 2006 Jean-Yves Lefort <jylefort@FreeBSD.org>
692 + * Copyright (C) 2006 Alex Dupre <ale@FreeBSD.org>
694 * This library is free software; you can redistribute it and/or
695 * modify it under the terms of the GNU Lesser General Public
699 #include <sys/param.h>
700 +#ifndef USE_GAMIN_POLLER
701 +#include <sys/mount.h>
703 #include <sys/types.h>
704 #include <sys/sysctl.h>
705 #include <sys/stat.h>
707 #include "gam_error.h"
708 #include "gam_kqueue.h"
709 #include "gam_event.h"
710 +#include "gam_excludes.h"
711 #include "gam_server.h"
712 #include "gam_poll_basic.h"
714 @@ -130,7 +134,7 @@ typedef struct
715 HashTableRemoveFunc remove;
716 HashTablePostRemoveFunc post_remove;
721 * A hash table which can be modified while iterating over it.
723 @@ -281,8 +285,8 @@ static void
724 gam_kqueue_mini_lstat (const char *pathname, MiniStat *mini_sb)
728 - if (lstat(pathname, &sb) < 0)
730 + if (stat(pathname, &sb) < 0)
731 memset(mini_sb, 0, sizeof(*mini_sb));
734 @@ -319,14 +323,14 @@ gam_kqueue_isdir (const char *pathname,
738 - return lstat(pathname, &sb) >= 0 && (sb.st_mode & S_IFDIR) != 0;
739 + return stat(pathname, &sb) >= 0 && (sb.st_mode & S_IFDIR) != 0;
744 gam_kqueue_get_uint_sysctl (const char *name, unsigned int *value)
746 - unsigned int value_len = sizeof(*value);
747 + size_t value_len = sizeof(*value);
749 if (sysctlbyname(name, value, &value_len, (void *)NULL, 0) < 0)
751 @@ -406,7 +410,7 @@ gam_kqueue_hash_table_foreach (HashTable
752 table->iterating = TRUE;
753 g_hash_table_foreach(table->main, func, user_data);
754 table->iterating = FALSE;
757 if (table->pending_additions)
760 @@ -509,33 +513,52 @@ static gboolean
761 gam_kqueue_monitor_enable_kqueue (Monitor *mon)
764 +#ifndef USE_GAMIN_POLLER
768 if (open_files == max_open_files)
770 GAM_DEBUG(DEBUG_INFO, "cannot open %s (max_open_files limit reached), falling back to poll\n", mon->pathname);
774 - mon->fd = open(mon->pathname, O_RDONLY | O_NOFOLLOW);
776 + if (gam_exclude_check(mon->pathname))
778 + GAM_DEBUG(DEBUG_INFO, "not using kqueue for %s since it is excluded, falling back to poll\n", mon->pathname);
782 + mon->fd = open(mon->pathname, O_RDONLY | O_NONBLOCK | O_NOFOLLOW);
785 GAM_DEBUG(DEBUG_INFO, "cannot open %s (%s), falling back to poll\n", mon->pathname, g_strerror(errno));
789 +#ifndef USE_GAMIN_POLLER
790 + if (fstatfs(mon->fd, &sb) == 0 && (sb.f_flags & MNT_LOCAL) == 0)
792 + GAM_DEBUG(DEBUG_INFO, "%s resides on a remote file system, falling back to poll\n", mon->pathname);
797 EV_SET(ev, mon->fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, VN_NOTE_ALL, 0, mon);
798 if (kevent(kq, ev, G_N_ELEMENTS(ev), NULL, 0, NULL) < 0)
800 GAM_DEBUG(DEBUG_INFO, "cannot enable kqueue notification for %s (%s), falling back to poll\n", mon->pathname, g_strerror(errno));
820 @@ -612,7 +635,7 @@ gam_kqueue_sub_monitor_free (SubMonitor
821 gam_kqueue_poller_remove_sub_monitor(&missing_smon_poller, smon);
822 gam_kqueue_poller_remove_sub_monitor(&unsupported_smon_poller, smon);
823 /* unsupported_dirs_poller is handled by _clear_fmons() below */
826 gam_kqueue_sub_monitor_clear_fmons(smon);
827 gam_kqueue_monitor_free(MONITOR(smon));
829 @@ -700,7 +723,7 @@ gam_kqueue_sub_monitor_enable_notificati
833 - exists = lstat(mon->pathname, &sb) >= 0;
834 + exists = stat(mon->pathname, &sb) >= 0;
835 flags |= (exists && (sb.st_mode & S_IFDIR) != 0) ? MONITOR_ISDIR : MONITOR_ISNOTDIR;
838 @@ -715,21 +738,21 @@ gam_kqueue_sub_monitor_enable_notificati
844 dir = g_dir_open(mon->pathname, 0, &err);
847 const char *filename;
850 while ((filename = g_dir_read_name(dir)))
853 FileMonitorFlags fmon_flags;
856 fmon = gam_kqueue_file_monitor_new(smon, filename, &fmon_flags);
857 gam_kqueue_file_monitor_emit_event(fmon, gevent, fmon_flags);
864 @@ -749,7 +772,7 @@ gam_kqueue_sub_monitor_enable_notificati
870 /* then we enable kqueue notification, falling back to poll if necessary */
872 if (! gam_kqueue_monitor_enable_kqueue(mon))
873 @@ -774,7 +797,7 @@ gam_kqueue_sub_monitor_handle_directory_
875 filenames = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
877 - if (isdir) /* do not follow symbolic links */
882 @@ -783,7 +806,7 @@ gam_kqueue_sub_monitor_handle_directory_
885 const char *filename;
888 while ((filename = g_dir_read_name(dir)))
890 g_hash_table_insert(filenames, g_strdup(filename), GINT_TO_POINTER(TRUE));
891 @@ -793,12 +816,12 @@ gam_kqueue_sub_monitor_handle_directory_
894 FileMonitorFlags fmon_flags;
897 fmon = gam_kqueue_file_monitor_new(smon, filename, &fmon_flags);
898 gam_kqueue_file_monitor_emit_event(fmon, GAMIN_EVENT_CREATED, fmon_flags);
906 @@ -840,6 +863,8 @@ gam_kqueue_sub_monitor_emit_event (SubMo
907 case GAMIN_EVENT_MOVED:
908 gam_kqueue_sub_monitor_set_missing(smon);
914 gam_server_emit_event(mon->pathname, isdir, event, smon->subs, 1);
915 @@ -931,11 +956,11 @@ gam_kqueue_file_monitor_emit_event (File
918 gboolean stat_succeeded;
921 if ((flags & MONITOR_ISDIR) == 0 && (flags & MONITOR_ISNOTDIR) == 0)
924 - stat_succeeded = lstat(mon->pathname, &sb) >= 0;
925 + stat_succeeded = stat(mon->pathname, &sb) >= 0;
926 isdir = stat_succeeded && (sb.st_mode & S_IFDIR) != 0;
929 @@ -943,7 +968,7 @@ gam_kqueue_file_monitor_emit_event (File
931 isdir = (flags & MONITOR_ISDIR) != 0;
935 gam_server_emit_event(mon->pathname, isdir, event, fmon->smon->subs, 1);
938 @@ -962,7 +987,7 @@ gam_kqueue_file_monitor_emit_event (File
940 FileMonitor *new_fmon;
941 FileMonitorFlags new_fmon_flags;
945 * The file exists again. It means that kqueue has
946 * aggregated a removal+creation into a single event. We
947 @@ -978,9 +1003,11 @@ gam_kqueue_file_monitor_emit_event (File
948 break; /* do not remove the fmon we've just created */
953 gam_kqueue_hash_table_remove(fmon->smon->fmons, fmon);
960 @@ -1033,7 +1060,7 @@ gam_kqueue_kevent_cb (GIOChannel *source
962 for (i = 0; i < nevents; i++)
963 MONITOR(ev[i].udata)->handle_kevent(MONITOR(ev[i].udata), &ev[i]);
966 return TRUE; /* keep source */
969 @@ -1042,7 +1069,7 @@ gam_kqueue_missing_smon_poll (SubMonitor
973 - if (lstat(MONITOR(smon)->pathname, &sb) >= 0)
974 + if (stat(MONITOR(smon)->pathname, &sb) >= 0)
976 gam_kqueue_poller_remove_sub_monitor(&missing_smon_poller, smon);
977 gam_kqueue_sub_monitor_enable_notification(smon, SUB_MONITOR_WAS_MISSING | ((sb.st_mode & S_IFDIR) != 0 ? MONITOR_ISDIR : MONITOR_ISNOTDIR));
978 @@ -1062,16 +1089,16 @@ gam_kqueue_unsupported_smon_poll (SubMon
979 if (gam_kqueue_monitor_enable_kqueue(mon))
980 gam_kqueue_poller_remove_sub_monitor(&missing_smon_poller, smon);
984 gam_kqueue_mini_lstat(mon->pathname, &sb);
987 if (! sb.exists && mon->sb.exists)
988 event = GAMIN_EVENT_DELETED;
989 else if (gam_kqueue_differs(&sb, &mon->sb))
990 event = GAMIN_EVENT_CHANGED;
995 memcpy(&mon->sb, &sb, sizeof(sb));
996 gam_kqueue_sub_monitor_emit_event(smon, event, (sb.mode & S_IFDIR) != 0 ? MONITOR_ISDIR : MONITOR_ISNOTDIR);
998 @@ -1167,7 +1194,10 @@ gam_kqueue_init (void)
999 channel = g_io_channel_unix_new(kq);
1000 g_io_add_watch(channel, G_IO_IN, gam_kqueue_kevent_cb, NULL);
1003 +#ifdef USE_GAMIN_POLLER
1004 + gam_poll_basic_init ();
1007 gam_server_install_kernel_hooks(GAMIN_K_KQUEUE,
1008 gam_kqueue_add_subscription,
1009 gam_kqueue_remove_subscription,
1010 @@ -1200,7 +1230,7 @@ gam_kqueue_add_subscription (GamSubscrip
1011 smon->subs = g_list_append(smon->subs, sub);
1016 smon = gam_kqueue_sub_monitor_new(sub);
1017 smon->subs = g_list_append(smon->subs, sub);
1019 @@ -1260,6 +1290,6 @@ gam_kqueue_remove_all_for (GamListener *
1029 [FILE:581:freebsd/patch-server_gam__poll__basic.c]
1030 --- server/gam_poll_basic.c.orig 2007-08-10 15:12:29.000000000 -0400
1031 +++ server/gam_poll_basic.c 2007-08-10 15:16:07.000000000 -0400
1032 @@ -345,7 +345,7 @@ gam_poll_basic_poll_file(GamNode * node)
1034 GAM_DEBUG(DEBUG_INFO, "%d %d : %d %d\n", node->sbuf.st_mtim.tv_sec, node->sbuf.st_mtim.tv_nsec, sbuf.st_mtim.tv_sec, sbuf.st_mtim.tv_nsec);
1036 - GAM_DEBUG(DEBUG_INFO, "%d : %d\n", node->sbuf.st_mtime, sbuf.st_mtim.tv_nsec);
1037 + GAM_DEBUG(DEBUG_INFO, "%d : %d\n", node->sbuf.st_mtime, sbuf.st_mtime);
1038 #endif /* ST_MTIM_NSEC */
1039 #endif /* VERBOSE_POLL */
1044 [FILE:1209:freebsd/patch-server_gam__server.c]
1045 --- server/gam_server.c.orig 2007-07-04 09:36:49.000000000 -0400
1046 +++ server/gam_server.c 2009-05-01 20:25:41.000000000 -0400
1048 #include "gam_server.h"
1049 #include "gam_channel.h"
1050 #include "gam_subscription.h"
1051 -#include "gam_poll_generic.h"
1052 +#include "gam_poll_basic.h"
1053 #ifdef ENABLE_INOTIFY
1054 #include "gam_inotify.h"
1056 @@ -200,7 +200,8 @@ gam_add_subscription(GamSubscription * s
1057 return gam_poll_add_subscription (sub);
1060 - return gam_kernel_add_subscription (sub);
1061 + /*return gam_kernel_add_subscription (sub);*/
1062 + return gam_poll_add_subscription (sub);
1064 gam_fs_mon_type type;
1065 type = gam_fs_get_mon_type (path);
1066 @@ -243,7 +244,8 @@ gam_remove_subscription(GamSubscription
1067 return gam_poll_remove_subscription (sub);
1070 - return gam_kernel_remove_subscription(sub);
1071 + /*return gam_kernel_remove_subscription(sub);*/
1072 + return gam_poll_remove_subscription (sub);
1074 gam_fs_mon_type type;
1075 type = gam_fs_get_mon_type (path);
1076 @@ -438,7 +440,7 @@ gam_server_get_kernel_handler (void)
1078 gam_server_get_poll_handler (void)
1080 - return __gam_kernel_handler;
1081 + return __gam_poll_handler;
1087 [FILE:997:freebsd/patch-tests_testing.c]
1088 --- tests/testing.c.orig Thu Oct 27 10:51:03 2005
1089 +++ tests/testing.c Tue Feb 14 17:46:01 2006
1090 @@ -376,11 +376,11 @@ processCommand(char *line, int no)
1092 printf("chmod %s to %s\n", arg, arg2);
1093 } else if (!strcmp(command, "chown")) {
1096 fprintf(stderr, "chown line %d: lacks path and owner\n", no);
1100 if (!lstat (arg, &sb)) {
1101 ret = (S_ISLNK (sb.st_mode)) ?
1102 lchown(arg, strtol(arg2, NULL, 10), -1) :
1103 @@ -486,9 +486,9 @@ processCommand(char *line, int no)
1107 - * wait at most 3 secs before declaring failure
1108 + * wait at most 7 secs before declaring failure
1110 - while ((delay < 30) && (testState.nb_events < nb_events + count)) {
1111 + while ((delay < 70) && (testState.nb_events < nb_events + count)) {
1114 /* printf("+"); fflush(stdout); */