Annotation of wikisrc/projects/project/gio-file-monitoring.mdwn, revision 1.4

1.1       jmmv        1: [[!template id=project
                      3: title="Add kqueue support to GIO"
                      5: contact="""
                      6: [tech-pkg](, [tech-kern](
                      7: """
                      9: mentors="""
                     10: [Julio Merino](
                     11: """
1.2       jmmv       13: category="pkgsrc"
                     14: difficulty="medium"
1.1       jmmv       15: duration="3 months"
                     17: description="""
                     18: Monitoring of file system activity is a key piece of a modern desktop environment because it provides instant feedback to the user about any changes performed to the disk. In particular, file monitoring is an internal component of the Gnome infrastructure that allows the desktop to receive notifications when files or directories change. This way, if, say, you are viewing the Downloads folder in Nautilus and you start downloading a file from Epiphany into that folder, Nautilus will realize the new file and show it immediately without requiring a manual refresh.
                     20: How to monitor the file system depends on the operating system. There are basically two approaches: polling and asynchronous notifications. Polling is suboptimal because the notifications are usually delayed. Asynchronous notifications are tied to the operating system: Linux provides [inotify](, NetBSD provides [kqueue]( and other systems provide their own APIs.
                     22: In the past, Gnome monitored the file system via a combination of [FAM]( (a system-level service that provides an API to file system monitoring) and GNOME VFS (a high-level layer that hides the interaction with FAM). This approach was good in spirit (client/server separation) but didn't work well in NetBSD:
                     24: * FAM is abandoned.
                     25: * Does not support kqueue out of the box.
                     26: * FAM runs as root.
                     27: * FAM is too hard to set up: it requires rpcbind, an addition to etc/services, a sysctl tweak, and the configuration of a system-level daemon.
                     29: To solve some of these problems, a drop-in replacement for FAM was started. [Gamin](, as it is known, still does not fix everything:
                     31: * Gamin is abandoned.
                     32: * Supports kqueue out of the box, but does not work very well.
                     33: * Actually, Gamin itself does not work. Running the tests provided by the distfile in a modern Linux system results in several test failures.
                     35: Did you notice the abandoned pattern above? This is important: in the new world order, Gnome does not use FAM any more.
                     37: The new structure to monitor files is: the low-level glib library provides the [gio]( module, which has a new file system monitoring API. The GVFS module provides higher level abstractions to file system management, and relies on gio for file system monitoring. There is no GNOME VFS any more.
                     39: The problematic point is: gio uses inotify directly; no abstraction layers in between. FAM support is still there for platforms without inotify, but as it is not used in Linux any more, both the FAM package and the support for it rot.
                     41: The goal of this project is to fix this situation. There are two possible approaches. The first is to extend the gio library with a new module to support kqueue, the native interface in NetBSD for file monitoring; this new module can be submitted upstream and will benefit all other BSD systems, but it will not help other applications that use inotify. The second is to write a compatibility library that exposes an inotify interface on top of kqueue; this cannot be sent upstream but it helps any application using inotify.
                     43: The preferred method is to write a new gio plugin to support kqueue. Henceforth, the deliverables for the project include a new gio module to support kqueue and, if time permits, a standalone library that implements an inotify interface on top of kqueue.
                     45: Assuming you are not familiar with kqueue, you might want to follow these steps to get started:
                     47: 1. Read the kqueue(2) manual page to get a general idea of the API and this [example for starters](
                     48: 2. Analyze the kqueue support for FAM which is in [pkgsrc/sysutils/fam/files/IMonKQueue.c++]( This might be helpful to see how to apply kqueue to monitor for the events used by GNOME.
                     49: 3. Read the modules/inotify* files in gnome-vfs and inspect how they are used in the "file method". The modules/ contains a list of related sources in the libfile_la_SOURCES variable.
                     50: 4. Possibly the hardest part: write the required stuff (modules/kqueue*) to add kqueue support.
                     52: """
1.4     ! jmmv       53: 
        !            54: done_by="Dmitry Matveev"
1.1       jmmv       55: ]]
                     57: [[!tag gsoc]]

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb