Implement SMB Byte-range Lock (Phase 7)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

- Add LockManager to oplock.rs:
  - LockRange struct for tracking byte-range locks
  - acquire() - check conflicts before granting lock
  - release() - remove specific lock by offset/length
  - clear() - clear all locks when file closed
  - ranges_overlap() - helper for conflict detection

- Add LockManager to ServerState

- Update handlers/lock.rs:
  - Parse LockRequest and LockElement
  - Process each lock element (acquire/release)
  - Support FLAG_EXCLUSIVE_LOCK, FLAG_SHARED_LOCK, FLAG_UNLOCK
  - Return STATUS_LOCK_NOT_GRANTED on conflict

- Update handlers/close.rs:
  - Clear all locks when file closed

- Add STATUS_LOCK_NOT_GRANTED to ntstatus.rs

All 229 tests pass.
This commit is contained in:
Warren
2026-06-21 00:25:55 +08:00
parent 54ce0d6916
commit 276308af12
5 changed files with 186 additions and 5 deletions

View File

@@ -52,6 +52,9 @@ pub async fn handle(
server.oplock_manager.unregister(&path, &req.file_id).await;
}
// Phase 7: Clear all byte-range locks for this file
server.lock_manager.clear(&req.file_id).await;
// Stat before closing if needed.
let info_before_close = if want_attrs {
if let Some(h) = handle.as_ref() {