FreeBSD Bugzilla – Attachment 190711 Details for
Bug 214338
[PATCH] devel/glib20: new kqueue() backend for file monitoring
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
tool to test
gkqueuefilemonitor.c (text/plain), 2.77 KB, created by
Ivan Rozhuk
on 2018-02-17 02:43:48 UTC
(
hide
)
Description:
tool to test
Filename:
MIME Type:
Creator:
Ivan Rozhuk
Created:
2018-02-17 02:43:48 UTC
Size:
2.77 KB
patch
obsolete
> > >/* cc gkqueuefilemonitor.c kq_fnm.c -O0 -DDEBUG -lpthread -o gkqueuefilemonitor */ > >#include <sys/param.h> >#include <sys/types.h> > >#include <inttypes.h> >#include <stdlib.h> /* malloc, exit */ >#include <stdio.h> /* snprintf, fprintf */ >#include <unistd.h> /* close, write, sysconf */ >#include <string.h> /* bcopy, bzero, memcpy, memmove, memset, strerror... */ >#include <errno.h> >#include <err.h> >#include <pthread.h> >#include <sys/mount.h> > >#include "kqueue_fnm.h" > > >#define LOG_INFO_FMT(fmt, args...) \ > fprintf(stdout, fmt"\n", ##args) > >static volatile kq_fnm_p kq_fnm = NULL; > > >static void >signal_install(sig_t func) { > > signal(SIGINT, func); > signal(SIGTERM, func); > //signal(SIGKILL, func); > signal(SIGHUP, func); > signal(SIGUSR1, func); > signal(SIGUSR2, func); > signal(SIGPIPE, SIG_IGN); >} > >static void >signal_handler(int sig) { > kq_fnm_p kfnm; > > switch (sig) { > case SIGINT: > case SIGTERM: > case SIGKILL: > kfnm = kq_fnm; > kq_fnm = NULL; > kq_fnm_free(kfnm); > break; > case SIGHUP: > case SIGUSR1: > case SIGUSR2: > break; > } >} > >static void >kq_file_mon_event_handler(kq_fnm_p kfnm, > kq_fnmo_p fnmo __unused, void *udata __unused, uint32_t event, > const char *base, const char *filename, const char *new_filename) { > > if (NULL == kfnm || NULL == filename) > return; > switch (event) { > case KF_EVENT_CREATED: > LOG_INFO_FMT("add %s: %s", base, filename); > break; > case KF_EVENT_DELETED: > LOG_INFO_FMT("del %s: %s", base, filename); > break; > case KF_EVENT_RENAMED: > LOG_INFO_FMT("ren %s: %s -> %s", base, filename, new_filename); > break; > case KF_EVENT_CHANGED: > LOG_INFO_FMT("mod %s: %s", base, filename); > break; > } >} > > >int >main(int argc __unused, char *argv[] __unused) { > int idx; > struct statfs stfs; > kq_file_mon_settings_t kfms; > static const char *non_local_fs[] = { > "fusefs.sshfs", > NULL > }; > const char *paths[] = { > "/", > "/home/rim/", > "/home/rim/mnt/storage/", > "/tmp", > "/tmp/sdfgeshehe", > "/proc", > "/usr", > "/usr/ports", > "/usr/ports/devel", > "/usr/ports/devel/glib20", > "/usr/ports/devel/glib20/files", > "/home/rim/mnt/172.16.0.254/tmp/", > NULL > }; > > signal_install(signal_handler); > > memset(&kfms, 0x00, sizeof(kq_file_mon_settings_t)); > kfms.rate_limit_time_init = 1000; > kfms.rate_limit_time_max = 16000; > kfms.rate_limit_time_mul = 2; > kfms.max_dir_files = 128; > kfms.mon_local_subfiles = 1; > kfms.mon_local_subdirs = 0; > kfms.local_fs = NULL; > kfms.non_local_fs = non_local_fs; > kq_fnm = kq_fnm_create(&kfms, kq_file_mon_event_handler); > > for (idx = 0; NULL != paths[idx]; idx ++) { > statfs(paths[idx], &stfs); > LOG_INFO_FMT("%s, local = %i", > stfs.f_fstypename, > (int)(0 != (MNT_LOCAL & stfs.f_flags))); > kq_fnm_add(kq_fnm, paths[idx], NULL); > } > >#if 1 > for (; NULL != kq_fnm;) { > sleep(1); > } >#else > sleep(2); > signal_handler(SIGKILL); >#endif > > return (0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 214338
:
176801
|
178938
|
181557
|
181816
|
182423
|
182749
|
184001
|
184287
|
184290
|
184301
|
184456
|
188088
|
188134
|
188144
|
188261
|
188262
| 190711 |
190712
|
191448
|
195450
|
195570
|
195597
|
195598
|
195618
|
195619
|
195649
|
195650
|
198889
|
198900
|
199221
|
199229
|
202832
|
202839
|
202935
|
202948
|
204279
|
204331
|
218219
|
222442