astrid-runtime/astrid · error

Windows drive target is already in use: {}

Error message

Windows drive target is already in use: {}

What it means

When the requested mountpoint is a drive target (a drive root like `F:\`), `prepare_mountpoint` checks whether that drive already exists via `std::fs::metadata`. If metadata succeeds, the drive letter is occupied (by another volume, subst mapping, or network drive) and WinFsp cannot claim it, so the provider bails with this message including the offending path.

Source

Thrown at crates/astrid-storage-provider-winfsp/src/main.rs:348

            bail!("kernel refused storage unmount authorization: {error}")
        },
        _ => bail!("kernel returned an unexpected storage unmount response"),
    }
}

#[cfg(windows)]
fn prepare_mountpoint(
    requested: Option<PathBuf>,
    view: &astrid_core::storage_provider::StorageProviderViewV1,
) -> Result<(PathBuf, bool)> {
    let _ = view;
    let mountpoint = requested.map_or_else(first_free_drive, Ok)?;
    if !mountpoint.is_absolute() {
        bail!("mountpoint must be absolute");
    }
    if is_drive_target(&mountpoint) {
        if std::fs::metadata(&mountpoint).is_ok() {
            bail!(
                "Windows drive target is already in use: {}",
                mountpoint.display()
            );
        }
        return Ok((mountpoint, false));
    }

    let parent = mountpoint
        .parent()
        .context("WinFsp directory mountpoint has no parent")?;
    std::fs::create_dir_all(parent)
        .with_context(|| format!("create mountpoint parent {}", parent.display()))?;
    astrid_core::platform_fs::verify_no_redirects(parent)
        .with_context(|| format!("reject redirected mountpoint parent {}", parent.display()))?;
    if !std::fs::symlink_metadata(parent)?.is_dir() {
        bail!("mountpoint parent is not a directory: {}", parent.display());
    }
    match std::fs::symlink_metadata(&mountpoint) {

View on GitHub (pinned to affd8760f4)

Solutions

  1. Choose a different, unused drive letter for the mountpoint
  2. Unmount or disconnect whatever currently occupies the drive letter, then retry
  3. Omit the mountpoint argument so `first_free_drive` automatically picks a free letter from D: to Z:

Example fix

// before
mount(provider, Some(PathBuf::from("E:\\"))).await?; // E: already in use
// after
mount(provider, None).await?; // auto-picks first free drive
Defensive patterns

Strategy: validation

Validate before calling

// Check drive availability before requesting it
fn drive_free(letter: char) -> bool {
    !std::fs::metadata(format!("{letter}:\\")).is_ok()
}
if !drive_free('E') { /* pick another letter or pass None for auto-select */ }

Prevention

When it happens

Trigger: `mount` is called with an explicit drive-root mountpoint (e.g. `E:\`) that already resolves to an existing volume, or a reserved drive letter collides with an existing device on the machine.

Common situations: Hard-coding a drive letter that is already used by a USB stick or mapped network drive on the target machine; re-running a mount without unmounting first; multi-tenant machines where drive letters are contested.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/829713b2daee508a. Report an issue: GitHub.