Skip to content

feat(notify): use inotify as the FreeBSD backend - #952

Merged
JohnTitor merged 3 commits into
notify-rs:mainfrom
kev009:freebsd-inotify
Jul 31, 2026
Merged

feat(notify): use inotify as the FreeBSD backend#952
JohnTitor merged 3 commits into
notify-rs:mainfrom
kev009:freebsd-inotify

Conversation

@kev009

@kev009 kev009 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

FreeBSD 15.0+ provides in-kernel inotify(2) and libc wrappers. Enable
the freebsd_inotify feature by default so INotifyWatcher is
RecommendedWatcher on FreeBSD (same as Linux/Android), keep kqueue
available, and bump inotify to 0.11.4.

FreeBSD 14.x has no inotify in base: build with default-features = false
to use kqueue. Native linkage is handled in inotify-sys 0.1.8.

Test adjustments for FreeBSD event semantics:
- set_file_mtime accepts any Modify (Linux: IN_MODIFY, FreeBSD: IN_ATTRIB)
- hardlink write-through test is Linux-only (dirent- vs inode-centric)

CI: FreeBSD 15.1 with defaults; FreeBSD 14.4 with --no-default-features.
Document the platform split in README/changelog.

Related Issues

@kev009
kev009 force-pushed the freebsd-inotify branch from 0d4c70c to c14d290 Compare July 8, 2026 22:50
@kev009

kev009 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Unfortunately inotify support was not added in 14.4.

I added a matrix build to deal with this, we prefer inotify on 15.0+ and offer an opt out for someone stuck on 14.x.

FreeBSD 15.0+ provides in-kernel inotify(2) and libc wrappers. Enable
the freebsd_inotify feature by default so INotifyWatcher is
RecommendedWatcher on FreeBSD (same as Linux/Android), keep kqueue
available, and bump inotify to 0.11.4.

FreeBSD 14.x has no inotify in base: build with default-features = false
to use kqueue. Native linkage is handled in inotify-sys 0.1.8.

Test adjustments for FreeBSD event semantics:
- set_file_mtime accepts any Modify (Linux: IN_MODIFY, FreeBSD: IN_ATTRIB)
- hardlink write-through test is Linux-only (dirent- vs inode-centric)

CI: FreeBSD 15.1 with defaults; FreeBSD 14.4 with --no-default-features.
Document the platform split in README/changelog.
@kev009
kev009 force-pushed the freebsd-inotify branch from c14d290 to 2efbed7 Compare July 24, 2026 01:00
@JohnTitor

Copy link
Copy Markdown
Member

Defaulting to inotify is too rush to me, given the FreeBSD 14 's EoL is far enough (Nov. 2028). Let's stay on kqueue by default and opt-in inotify with a feature flag.

@JohnTitor JohnTitor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@JohnTitor
JohnTitor merged commit 776c5dc into notify-rs:main Jul 31, 2026
21 checks passed
@kev009

kev009 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@JohnTitor many thanks.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296835 prompted me to do this. for whatever reason kqueue is not happy with common consumers of this crate (Zed, codex, grok for example) where it will hang and the crash dump can take a very long time and is uninterruptible until this fix which is not in 14 or 15 yet.

Is there a way to make Cargo change preference at build time? It would fit FreeBSD well to use inotify when it detects FreeBSD 15 or newer, and the way binaries are built on FreeBSD this is a safe decision.

@JohnTitor

Copy link
Copy Markdown
Member

Hm, it sounds worth addressing then. We cannot do anything before dependency solution but could add a FreeBSD version detector and switch the default by it (n<15 or 15<=n). Let me add such a tweak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants