#ifndef FILE_CREATE_LOCKED_H
#define FILE_CREATE_LOCKED_H
#include "file-lock.h"
struct file_create_settings {
/* 0 = try locking without waiting */
unsigned int lock_timeout_secs;
/* 0 = 0600 */
int mode;
/* 0 = default */
/* 0 = default */
const char *gid_origin;
/* If parent directory doesn't exist, mkdir() it with this mode.
0 = don't mkdir(). The parent directories are assumed to be
potentially rmdir() simultaneously, so the mkdir()+locking may be
attempted multiple times. */
int mkdir_mode;
/* 0 = default */
/* 0 = default */
const char *mkdir_gid_origin;
};
/* Either open an existing file and lock it, or create the file locked.
The creation is done by creating a temp file and link()ing it to path.
If link() fails, opening is retried again. Returns fd on success,
-1 on error. errno is preserved for the last failed syscall, so most
importantly ENOENT could mean that the directory doesn't exist and EAGAIN
means locking timed out.
If this function is used to create lock files, file_lock_set_unlink_on_free()
should be used for the resulting lock. It attempts to avoid unlinking the
file if there are already other processes using the lock. That can help to
avoid "Creating a locked file ... keeps failing" errors */
const char **error_r);
#endif