Files
libfreemkv/docs/fsync.md
T
Matthew Jackson 6e14fc0c0c libfreemkv: 1.7.0 groundwork — sector-recycle soundness + CI hardening
Security
- Remove the unsafe Vec::set_len over recycled sector buffers — UB reachable
  from safe code (GHSA-j8ww-f5fg-9pmh, low). Uses Vec::resize; pooling unchanged.

CI / tooling
- clippy on stable with the MSRV single-sourced from Cargo.toml; cargo-deny
  dependency-audit gate with first-party git sources allowed (#15); audience-based
  comment-guard (#17).

Docs
- README (keydb ownership, BD-J parser count), drive-access transport/reset
  notes, mux timeline module-doc links.
2026-09-02 12:40:55 -07:00

1.1 KiB

io::fsync — platform-aware crash-durability primitives

Two flush operations need OS-specific handling to make a write survive a crash / power loss:

  • dir — fsync a directory so a prior rename(2) into it is durable. After a crash a renamed file's dirent can otherwise be lost even though the rename returned, because it is still page-cache-only. This is a POSIX concept: on Windows std cannot even open a directory as a File (it does not set FILE_FLAG_BACKUP_SEMANTICS), and NTFS/ReFS commit the rename's dirent without an explicit directory flush — so it is a no-op there rather than a failed open that logs on every marker write.

  • file_durable — fsync a file's contents + metadata. Opens the file read+write: on Windows File::sync_all maps to FlushFileBuffers, which requires a handle with write access and returns ERROR_ACCESS_DENIED (os error 5) on a read-only handle. (A read-only File::open + sync_all is legal on POSIX, which is why that bug only bit Windows.) The open mode is platform-uniform, so this lives here with no dispatch.