Add FileSystemHost.Notify for kernel cache invalidation#1
Merged
Conversation
Adds FspFileSystemNotify P/Invoke + FspFsctlNotifyInfo struct + FileNotify constants + public FileSystemHost.Notify(filter, action, fileName) so user-mode file systems can invalidate the WinFsp kernel FileInfo cache after path-mutating operations (rename, delete, overwrite, create, set-size, set-attrs). Required for correctness when FileInfoTimeout is large or uint.MaxValue — otherwise the kernel can serve stale Open/Read results from cache without consulting user-mode. Concrete failure: leveldb's atomic-rename pattern reads zero bytes from a freshly-renamed CURRENT file, breaking every Chromium leveldb component (Local Storage, GCM Store, Sync Data, ...). Also adds FileOperationInfo.FileName so callbacks like OverwriteFile (whose IFileSystem signature does not include a path parameter) can issue Notify without storing the path on Context themselves. Bumped to 0.1.2-pre.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
xUnit's IClassFixture<T> creates one fixture instance per test class.
NotifyTests + SyncTests both used IClassFixture<SyncFixture>, so xUnit
instantiated SyncFixture twice in the same process — the second mount
collided on the same UNC prefix and failed STATUS_OBJECT_NAME_COLLISION
(0x80070050).
Switching to [CollectionDefinition] / [Collection("Sync")] makes the fixture
shared across both classes — one mount, run all tests, one unmount.
The same pattern is applied to SyncCompleted and TrueAsync for consistency.
Did not surface locally because NotifyTests was usually filtered to run
alone; on CI the full suite runs and exposed the collision.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hooyao
added a commit
that referenced
this pull request
May 3, 2026
v0.1.2-pre.2 tag was pushed before PR review, and the early CI failure (fixture collision now fixed in #1) prevented the release workflow from publishing. Cutting a fresh pre-release from merged main so the published package corresponds to a green commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FspFileSystemNotifyP/Invoke +FspFsctlNotifyInfostruct (12-byte, matches thestatic_assertinwinfsp/fsctl.h)FileNotifyconstants class (Change*filters,Action*actions) — values cross-checked againstWinNT.hFileSystemHost.Notify(filter, action, fileName)— stack-allocated buffer (≤ 4 KB),ArrayPoolfallback for longer paths, returns NTSTATUS unchangedfuse.creference implementation)FileOperationInfo.FileNameso callbacks likeOverwriteFile(whoseIFileSystemsignature has no path parameter) can issueNotifywithout storing the path onContextthemselvesNotifyTests(struct size, packing, case sensitivity, oversized rejection, constants)Why
User-mode file systems built on this binding could not invalidate the WinFsp kernel
FileInfocache after path-mutating operations — because the actualFspFileSystemNotifyAPI was not exposed in the binding (only the unusedBegin/Endframing was). Concrete failure: leveldb's atomic-rename pattern reads zero bytes from a freshly-renamedCURRENTfile whenFileInfoTimeout > 0, breaking every Chromium leveldb component (Local Storage, GCM Store, Sync Data, Site Characteristics Database, …).The downstream RamDrive change that consumes this API is at https://github.com/hooyao/RamDrive (PR will follow after this one merges and the package is published to NuGet).
Version bumped to
0.1.2-pre.2and taggedv0.1.2-pre.2.Test plan
dotnet test tests/WinFsp.Native.Tests --filter NotifyTests— 5/5 passFileSystemHostTestsstill pass (no regression in TestMemFs fixture)dotnet pack -c Release -o ./artifactsproducesWinFsp.Native.0.1.2-pre.2.nupkg🤖 Generated with Claude Code