Implement SMB Oplocks Phase 1-2
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

Phase 1: Data structures
- Add oplock_level and share_access fields to Open struct
- Update Open::new() signature with new parameters
- Update handlers/create.rs to pass oplock params

Phase 2: OplockManager
- Create oplock.rs with OplockManager struct
- OplockEntry for tracking per-client oplock state
- can_grant() - check ShareAccess compatibility
- register() / unregister() - lifecycle management
- break_oplock() - generate OPLOCK_BREAK_NOTIFICATION
- Add OplockManager to ServerState
- Add Hash trait to SmbPath for HashMap key

All 229 tests pass.
This commit is contained in:
Warren
2026-06-21 00:17:24 +08:00
parent 487b4450f8
commit 27707bbe0e
6 changed files with 195 additions and 2 deletions

View File

@@ -294,6 +294,9 @@ pub struct Open {
pub is_directory: bool,
pub delete_on_close: bool,
pub search_state: Option<DirCursor>,
// Oplock fields (MS-SMB2 §2.2.13 / §2.2.14)
pub oplock_level: u8,
pub share_access: u32,
}
impl Open {
@@ -304,6 +307,8 @@ impl Open {
last_path: SmbPath,
is_directory: bool,
delete_on_close: bool,
oplock_level: u8,
share_access: u32,
) -> Self {
Self {
file_id,
@@ -313,6 +318,8 @@ impl Open {
is_directory,
delete_on_close,
search_state: None,
oplock_level,
share_access,
}
}
}