windows-drivers-rs icon indicating copy to clipboard operation
windows-drivers-rs copied to clipboard

Migrate from fs4 to std::File flocks for Rust 1.89+ compatibility

Open Copilot opened this issue 6 months ago • 0 comments

This PR successfully migrates from the external fs4 crate to standard library file locking as requested in issue #300.

Changes Made

Replaced all fs4 file locking usage with native Rust 1.89+ std::File methods:

Before (fs4):

use fs4::fs_std::FileExt;

let file = std::fs::File::create("test.lock")?;
FileExt::lock_exclusive(&file)?;
FileExt::unlock(&file)?;

After (std::File):

let file = std::fs::File::create("test.lock")?;
file.lock()?;    // Exclusive lock
file.unlock()?;  // Unlock

Migration Scope

Updated file locking in three locations:

  • wdk-macros: Cache file synchronization during macro expansion
  • cargo-wdk: Test synchronization to prevent parallel test interference
  • wdk-macros-tests: Symlink creation synchronization

Benefits

  • Reduced dependencies: Removes external fs4 crate dependency
  • Standard library: Uses stable Rust standard library features (available since 1.89)
  • Maintenance: Simpler dependency tree and better long-term maintainability

The current MSRV (1.84.0) will need to be updated to at least 1.89.0 to support the new file locking APIs.

Fixes #300.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Aug 15 '25 01:08 Copilot