K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
Loading...
Searching...
No Matches
Atomic file replacement

Functions

int kfsw_snapshot_write (const char *path, const char *temporary_path, const uint8_t *data, size_t size)
 

Description

Function Documentation

◆ kfsw_snapshot_write()

int kfsw_snapshot_write ( const char *  path,
const char *  temporary_path,
const uint8_t *  data,
size_t  size 
)

#include <snapshot.h>

Replace a file's contents atomically.

Writes a temporary file beside the target, syncs and closes it, then renames it over the target, so a reset during the write leaves the old contents.

Parameters
pathTarget file.
temporary_pathScratch file beside it, on the same mount.
dataBytes to write.
sizeHow many.
Return values
0The target now holds data.
-ENODEVStorage is not mounted.
<0An errno from the filesystem; the target is unchanged.