]> git.ipfire.org Git - thirdparty/chrony.git/commit
util: add functions for common file operations
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 22 Oct 2019 16:06:15 +0000 (18:06 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 24 Oct 2019 10:48:45 +0000 (12:48 +0200)
commit7a4c396bba8f92a3ee8018620983529152050c74
tree719e51e16260f6efaa1601aa7fc2d0073b1517c3
parent88f846f6563349c124106baeb51f9d928290aa64
util: add functions for common file operations

Add a function to open a file for reading, writing, or appending.
In uppercase modes errors are handled as fatal, i.e. the caller doesn't
need to check for NULL. To avoid string manipulations in the callers,
the function accepts an optional directory and suffix. New files are
created with specified permissions, which will be needed for saving
keys. The O_EXCL flag is used in the writing mode to make sure a new
file is created (on filesystems that support it).

Also, add a function to rename a temporary file by changing its suffix,
and a function to remove a file.

All functions log all errors, at least as debug messages.
util.c
util.h