Skip to content

kbfs/dokan: port binding to Dokan 2.x API - #29880

Open
cehojac wants to merge 1 commit into
keybase:masterfrom
cehojac:dokan2
Open

cehojac wants to merge 1 commit into
keybase:masterfrom
cehojac:dokan2

Conversation

@cehojac

@cehojac cehojac commented Nov 7, 2026

Copy link
Copy Markdown

Summary

Ports the Dokan user-mode filesystem binding (go/kbfs/dokan) from the Dokan 1.2 API to the Dokan 2.3.1 API (dokan2.dll/dokan2.sys).

Dokan 1.x is unmaintained and has no signed ARM64 driver — the Dokany 1.5.x arm64 binaries shipped unsigned in the zip and fail to load, which is why KBFS is completely broken on Windows on ARM64 devices (Surface Pro/Laptop ARM, Snapdragon X, etc). Dokany 2.2+ ships an official signed Dokan_ARM64.msi. This port fixes #27989 and also moves Windows off the legacy API for x64.

Changes

  • Vendor Dokan 2.3.1.1000 headers in dokan_header/ (the same UNICODE_STRING-in-mingw comment-out is re-applied)
  • loaddll.go: load DOKAN2.DLL, require DokanVersion() >= 200, resolve DokanInit/DokanShutdown
  • bridge.c: call DokanInit() before DokanMain and DokanShutdown() after it returns (required by the 2.x library)
  • Mounted callback updated to the 2.x signature (LPCWSTR MountPoint added)
  • DOKAN_FILE_INFO.DeleteOnClose → DeletePending (2.x rename)

Everything else is unchanged: all 25 DOKAN_OPERATIONS keep identical names/signatures, DOKAN_OPTION_* flags keep the same values, and the 2.x delete semantics already match the existing code (DeleteFile/DeleteDirectory stay check-only; the real delete still happens in Cleanup when DeletePending is set).

Important packaging note

This PR makes kbfsdokan require Dokan 2.x at runtime — a system with only Dokan 1.x installed will fail the version check. The Windows installer currently bundles DokanSetup_redist.exe 1.4.0.1000, which must be updated to a 2.x redistributable for the GUI "install Dokan" flow to keep working (see the upgrade process in packaging/windows/readme.md). Note that Dokany 2.x no longer publishes DokanSetup_redist.exe — releases ship per-arch MSIs (Dokan_x64.msi, Dokan_ARM64.msi), so the packaging may need to switch bundling mechanism. A full ARM64 installer (Electron --arch=arm64, WiX Platform=arm64) is out of scope here.

Test plan

  • go test ./kbfs/dokan — TestEmptyFS mounts a real filesystem on T:\ against the signed Dokany 2.3.1 ARM64 driver; all callbacks exercised
  • Real KBFS mount on Windows 11 ARM64: kbfsdokan.exe K:\ → Dokan version: 231 driver 400 → K:\private/K:\public serve real encrypted folders
  • x64 Windows sanity check against Dokan 2.x would be appreciated from a maintainer with an x64 box

Generated with Devin

Port the Dokan user-mode filesystem binding from the Dokan 1.2 API to
the Dokan 2.3.1 API (dokan2.dll/dokan2.sys). Dokan 1.x is no longer
maintained and has no signed ARM64 driver, which leaves KBFS broken on
Windows on ARM64 devices.

Changes:
- Vendor Dokan 2.3.1.1000 headers (dokan.h, fileinfo.h, public.h)
- Load DOKAN2.DLL and require DokanVersion() >= 200
- Resolve and call DokanInit()/DokanShutdown() around DokanMain()
- Update the Mounted callback to the 2.x signature (adds MountPoint)
- DOKAN_FILE_INFO.DeleteOnClose was renamed to DeletePending
- Keep the UNICODE_STRING typedef commented out (mingw ntdef.h)

The 2.x delete semantics match the existing implementation: DeleteFile
and DeleteDirectory remain check-only and the actual delete still
happens in Cleanup when DeletePending is set.

Tested on Windows 11 ARM64 against the signed Dokany 2.3.1 ARM64
driver: TestEmptyFS mounts a real filesystem on T:\ and a real KBFS
mount on K:\ serves private folders correctly.

Fixes keybase#27989
@cehojac

cehojac commented Nov 7, 2026

Copy link
Copy Markdown
Author

@chrisnojima ping for review — this makes KBFS work on Windows ARM64 (fixes #27989). Tested on a Surface Laptop 7: service + Dokan 2.3.1 driver + K: mount verified end-to-end, MSI install persists across reboot.

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.

Keybase Files Dokan no work in windows 11 ARM64

1 participant