Documentation
¶
Overview ¶
Package fsutil provides durable filesystem helpers shared by the agent library and the agent commands.
Index ¶
- func FileSHA256(path string) ([sha256.Size]byte, error)
- func InstallFile(source, target string, mode os.FileMode) (err error)
- func MountedNoexec(path string) (bool, error)
- func SyncDir(path string) error
- func SyncFilesystems(paths ...string) error
- func SyncOpenFilesystems(files []*os.File, syncfs func(int) error) error
- func WriteFileAtomic(path string, data []byte, mode os.FileMode) error
- func WriteFileDurable(path string, data []byte, mode os.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileSHA256 ¶ added in v0.13.0
FileSHA256 returns the SHA-256 digest of the file at path.
func InstallFile ¶
InstallFile streams source onto target atomically. Large executables are copied rather than buffered in memory.
func MountedNoexec ¶ added in v0.13.0
MountedNoexec reports whether the filesystem holding path is mounted without permission to run programs from it, so a binary placed there cannot run.
func SyncFilesystems ¶
SyncFilesystems persists every filesystem backing the given paths.
func SyncOpenFilesystems ¶
SyncOpenFilesystems synchronizes each distinct filesystem once, using open handles that stay valid after teardown removes their paths.
func WriteFileAtomic ¶ added in v0.23.0
WriteFileAtomic writes data to path through a uniquely named temporary file in the same directory and a rename, creating missing parent directories with mode 0755. It is durable: the file is synced before the rename, and the directory holding it, and every parent it created, is synced after, so a crash leaves either the old content or the new one and never a missing or partial file. Two concurrent writers never share a temporary file.
Types ¶
This section is empty.