Commit Graph

11 Commits

Author SHA1 Message Date
Warren
4620475ba8 Implement SMB 3.x Lease support Phase 4
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- CLOSE handler unregister lease_key from LeaseManager
- Extract lease_key from Open struct before close

All 229 tests pass.
2026-06-21 01:24:02 +08:00
Warren
344d13435e Implement SMB 3.x Lease support Phase 3
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled
- CREATE handler parse RqLs create context
- Extract LeaseKey (16 bytes) + LeaseState (4 bytes)
- Check can_grant() before registration
- Register with LeaseManager
- Set Open.lease_key/lease_state fields

All 229 tests pass.
2026-06-21 01:23:32 +08:00
Warren
21a9c3c6c4 Implement SMB 3.x Lease support Phase 1-2
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
Phase 1: Open struct lease fields
- lease_key: Option<[u8; 16]> - LeaseKey GUID
- lease_state: Option<u32> - READ/HANDLE/WRITE flags
- lease_flags: Option<u32> - BREAKING etc.

Phase 2: LeaseManager
- LeaseEntry with lease_key/state/flags
- register/unregister/can_grant methods
- break_lease returns LeaseBreakNotification
- LeaseBreakNotification struct (MS-SMB2 §2.2.26)

ServerState: lease_manager field added

All 229 tests pass.
2026-06-21 01:20:18 +08:00
Warren
3cf503d05f Implement Oplock Break Acknowledgement handler (MS-SMB2 §2.2.24)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- Parse client's OPLOCK_BREAK_ACK
- Update Open.oplock_level in Open struct
- Update OplockManager entry via update_oplock_level()
- Return confirmation response

All 229 tests pass.
2026-06-21 01:15:21 +08:00
Warren
063a697e83 Add READ handler oplock break (Phase 5.5)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- Trigger oplock break before read if conflicting opens exist
- Use granted_access from Open struct
- Send notifications via notification_tx channel
- Fix WRITE handler granted_access source (from Tree)

All 229 tests pass.
2026-06-21 01:13:35 +08:00
Warren
2dd50e4cb6 Implement SMB Oplocks Phase 3+5
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
Phase 3: NotificationQueue
- Add notification_tx to Connection struct
- Modify writer.rs to use tokio::select! for response + notification
- Add write_to_bytes() to OplockBreakNotification
- Support server→client async messages

Phase 5: WRITE Handler oplock break
- Get path/share_access before write
- Trigger OplockManager.break_oplock()
- Send OPLOCK_BREAK_NOTIFICATION to affected clients
- Encode and send via notification channel

All 229 tests pass.
2026-06-21 00:35:48 +08:00
Warren
276308af12 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.
2026-06-21 00:25:55 +08:00
Warren
54ce0d6916 Implement SMB Oplocks Phase 4+6
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
Phase 4: CREATE Handler dynamic oplock granting
- Use OplockManager.can_grant() to determine oplock level
- Register OplockEntry if oplock granted
- Support ShareAccess compatibility checking
- Grant Level II if exclusive/batch oplock exists

Phase 6: CLOSE Handler oplock cleanup
- Unregister from OplockManager when file closed
- Only unregister if oplock_level > 0

All 229 tests pass.
2026-06-21 00:19:51 +08:00
Warren
27707bbe0e 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.
2026-06-21 00:17:24 +08:00
Warren
24029501d9 Add placeholder smb-server integration test files
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
2026-06-20 21:07:27 +08:00
Warren
7eb528d35f SMB Server Phase 2: VFS backend build fix + integration test
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled
- Add VfsFile: Send supertrait for Mutex compatibility
- Fix SmbServerCommand: struct → Subcommand enum with Start variant
- Fix tracing_subscriber::init() → try_init() to avoid panic when
  logger already initialized
- Fix CLI subcommand name: smb-server → smb-start (flatten naming)
- Add #[command(name = "smb-start")] for CLI disambiguation
- Fix unused variable warnings (smb_fs.rs, smb_server_backend.rs)
- Remove unused VfsFile imports (webdav.rs, scp_handler.rs)
- Integration test: Docker smbclient verified (list, upload, read)
2026-06-20 19:42:29 +08:00