FS(3) Library Functions Manual FS(3)

KS_fs_replace, KS_fs_tmpfdfile system utility functions

#include <libks/fs.h>

int
KS_fs_replace(const char *path, const char *buf, size_t buflen);

int
KS_fs_tmpfd(const char *buf, size_t buflen, char *path, size_t pathsiz);

The fs API provides functions for file system interactions.

The () function replaces the contents of path with buflen bytes from buf in an atomic fashion.

The () function creates a temporary read/write file descriptor and writes out buflen number of bytes from buf to it. The same file descriptor can be accessed through the path buffer which must have a capacity of at least PATH_MAX, communicated through pathsiz.

KS_fs_replace() returns zero on success. On failure, -1 is returned and errno is set accordingly.

KS_fs_tmpfd() returns a file descriptor greater to or equal to zero on success. On failure, -1 is returned and errno is set accordingly.

Anton Lindqvist <anton@basename.se>

OpenBSD 7.8 December 25, 2023 FS(3)