Lying to Zed to get its remote server running on FreeBSD
By tricking Zed's remote server into seeing FreeBSD as Linux, an engineer uncovered and patched a directory-listing bug in FreeBSD's Linux compatibility layer.
read it A technical postmortem detailing a wrapper hack and deep kernel debugging in FreeBSD's Linuxulator.
summary
Running Zed's remote server on FreeBSD required spoofing a Linux environment with a wrapper script, which exposed an underlying directory-listing kernel bug. Investigation revealed a regression in FreeBSD's Linuxulator where buffer size round-ups triggered EINVAL errors and dropped file listings. An engineer-contributed kernel patch corrected the batch sizing logic and landed in the stable release.
key points
- A simple uname wrapper spoofing Linux allows Zed's remote server to execute on FreeBSD via its Linux compatibility layer.
- A kernel regression in linux_getdents64 rounded small buffer requests up to 512 bytes, causing EINVAL and dropped file listings.
- The fix restricts block-boundary rounding to requests larger than or equal to DEV_BSIZE, eliminating the directory read failures.
who should read it
FreeBSD users and systems engineers interested in kernel debugging and compatibility layers.
discussion positive
consensus
Most participants find the workaround clever and appreciate the kernel deep-dive, though some note standard SSH suffices without a remote server.
pushback
One commenter pointed out that needing to patch the kernel just to run a text editor highlights the friction of non-Linux platforms.
> Please support FreeBSD, oh and btw I immediately ran headfirst into a kernel bug related to listing directories that I had to fix
This wouldn’t fill me with confidence if I was Zed.
Captures the dry humor of hitting a severe kernel bug immediately after forcing an unsupported tool to run.
Generated by an LLM from the article and thread. Check the sources before relying on it.