Skip to main content

load_or_create_digest_key_at

Function load_or_create_digest_key_at 

Source
pub fn load_or_create_digest_key_at(
    path: &Path,
) -> Result<TraceDigestKey, TraceKeyError>
Expand description

Load (or atomically create) the digest key at path.

Guarantees:

  • the parent directory is created 0700 via the Phase 1 private-fs helper; the key file is created 0600 with no broader interval (mode set at open, never create-then-chmod);
  • a symlink planted at the key path is refused, never followed;
  • a non-regular file (FIFO, device, directory) at the key path is refused with TraceKeyError::NotRegularFile, promptly and without blocking;
  • a pre-existing key file with a broader mode is repaired to exactly 0600 via the already-open handle (no path re-resolution);
  • at most 33 bytes are read; any length other than exactly 32 is TraceKeyError::Corrupt;
  • concurrent first-time creation converges: the key is fully written to a 0600 temp file and published with an atomic link(2); losers read the winner’s key, so every caller observes the same key bytes.