astrid-runtime/astrid · error · io::Error

stable private directory identity is unavailable

Error message

stable private directory identity is unavailable

What it means

file_identity retrieves a stable (device, file-index) identity for an open directory. On platforms that are neither Unix nor Windows, no stable identity API exists, so the function unconditionally returns ErrorKind::Unsupported. This is a platform-capability limitation, not a data problem.

Source

Thrown at crates/astrid-storage/src/engine/durable/native_io.rs:151

    use windows_sys::Win32::Storage::FileSystem::{
        BY_HANDLE_FILE_INFORMATION, GetFileInformationByHandle,
    };

    let mut info = BY_HANDLE_FILE_INFORMATION::default();
    // SAFETY: `file` owns a live Windows handle and `info` is writable.
    #[allow(unsafe_code)]
    if unsafe { GetFileInformationByHandle(file.as_raw_handle().cast(), &raw mut info) } == 0 {
        return Err(io::Error::last_os_error());
    }
    Ok((
        u64::from(info.dwVolumeSerialNumber),
        (u64::from(info.nFileIndexHigh) << 32) | u64::from(info.nFileIndexLow),
    ))
}

#[cfg(not(any(unix, windows)))]
fn file_identity(_file: &NativeFile) -> io::Result<(u64, u64)> {
    Err(io::Error::new(
        io::ErrorKind::Unsupported,
        "stable private directory identity is unavailable",
    ))
}

fn configure_no_follow(options: &mut OpenOptions) {
    #[cfg(unix)]
    {
        use cap_std::fs::OpenOptionsExt as _;
        options.custom_flags(libc::O_NOFOLLOW | libc::O_NONBLOCK);
    }
    #[cfg(windows)]
    {
        use cap_std::fs::OpenOptionsExt as _;
        use windows_sys::Win32::Storage::FileSystem::FILE_FLAG_OPEN_REPARSE_POINT;
        options.custom_flags(FILE_FLAG_OPEN_REPARSE_POINT);
    }
}

View on GitHub (pinned to affd8760f4)

Solutions

  1. Run the principal-store on a supported platform (Linux, macOS, other Unix, or Windows)
  2. Enable the cfg(unix)/cfg(windows) code path by building for a supported target triple
  3. Provide a platform-specific file_identity implementation for your target and contribute/gate it in native_io.rs
  4. Avoid the durable engine on unsupported platforms; use an in-memory or alternative storage backend

Example fix

// before
#[cfg(not(any(unix, windows)))]
fn file_identity(_file: &NativeFile) -> io::Result<(u64, u64)> { Err(...) }
// after
#[cfg(target_os = "myos")]
fn file_identity(file: &NativeFile) -> io::Result<(u64, u64)> {
    myos::stat_index(file.as_raw_fd())
}
Defensive patterns

Strategy: fallback

Validate before calling

#[cfg(not(any(unix, windows)))]
compile_error!("principal-store durable engine requires unix or windows");

Type guard

const FILE_IDENTITY_SUPPORTED: bool = cfg!(any(unix, windows));

Try / catch

match open_store(path) {
    Err(e) if e.kind() == io::ErrorKind::Unsupported => switch_to_memory_backend(),
    r => r,
}

Prevention

When it happens

Trigger: Calling open_directory (which compares directory identities) on a target platform outside cfg(unix) and cfg(windows) — e.g. wasm32 or a custom OS target — where native_io.rs compiles the fallback stub.

Common situations: Cross-compiling the storage engine for wasm/embedded targets; running the durable store inside a non-standard sandbox that exposes neither Unix nor Windows file semantics.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


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