Documentation
¶
Overview ¶
Package fsatomic implements the single durable-write primitive required by §3.1: every durable write in PayCLI goes through Write.
The sequence is: create a temp file in the *same* directory as the target (so the rename cannot cross a filesystem boundary) named "<base>.<pid>.<rand6>.tmp" -> write -> fsync the file -> chmod to the requested mode -> close -> rename over the target -> fsync the directory.
The explicit chmod matters: O_CREATE applies the process umask, so a file created with 0600 under umask 077 is fine but under an exotic umask could be created 0400 and later reads would fail. Chmod after the write pins the mode exactly, which is what §5.2's 0600 credentials.json depends on.
Index ¶
Constants ¶
const DirPerm fs.FileMode = 0o700
DirPerm is the mode used for parent directories created by Write. 0700 because PayCLI's state directories hold credentials (§5.2).
Variables ¶
This section is empty.
Functions ¶
func Write ¶
Write atomically replaces path with data, leaving the file mode at perm.
The parent directory is created with DirPerm when it does not exist, so callers never need a separate MkdirAll step. A reader of path always observes either the previous contents or the complete new contents, never a prefix.
Types ¶
This section is empty.