#include "xroad_string.h"
#include "xroad_typed_containers.h"
#include <unistd.h>
#include <limits.h>
#include <sys/uio.h>
#include <fcntl.h>
Go to the source code of this file.
|
|
#define | __xroad_fd_dtor__ __dtor__(xroad_cleanup_fdclose) |
| | Helper macro to declare destructable variable: int fd __xroad_fd_dtor__ = open("my_file.txt", O_RDONLY);
|
| |
|
|
xroad_errno_t | xroad_writev_all (int fd, struct iovec *iov, size_t c) |
| | Function to write all data from an array of struct iovec structures to a file descriptor.
|
| |
| xroad_errno_t | xroad_dir_ls (xroad_str_t path, uint32_t flags, xroad_str_hset_t *dirs) |
| |
|
int | xroad_file_open_and_lock (const char *name, bool create) |
| | Open (possibly create) for read/write and lock a file.
|
| |
| int | xroad_file_lock (int fd, bool exclusive, bool block) |
| |
| int | xroad_file_unlock (int fd) |
| |
| int | xroad_file_lock_byte (int fd, off_t offset, bool exclusive, bool block) |
| |
| int | xroad_file_unlock_byte (int fd, off_t offset) |
| |
| int | xroad_file_lock_byte_ofd (int fd, off_t offset, bool exclusive, bool block) |
| |
| int | xroad_file_unlock_byte_ofd (int fd, off_t offset) |
| |
| const char * | xroad_get_cwd (void) |
| |
◆ xroad_dir_ls_flags_t
| Enumerator |
|---|
| xroad_dir_ls_flags_hidden | ls hidden (started with .)
|
◆ xroad_dir_ls()
| xroad_errno_t xroad_dir_ls |
( |
xroad_str_t |
path, |
|
|
uint32_t |
flags, |
|
|
xroad_str_hset_t * |
dirs |
|
) |
| |
read(ls) directory content into set
- Parameters
-
| [in] | path | - directory to read |
| [in] | flags | - see xroad_dir_ls_flags_t for details |
- Returns
- XROAD_OK - done, XROAD_FAILED - some error happened, see errno for details
◆ xroad_file_lock()
| int xroad_file_lock |
( |
int |
fd, |
|
|
bool |
exclusive, |
|
|
bool |
block |
|
) |
| |
Lock the whole file using fcntl lock.
- Parameters
-
| fd | File descriptor |
| exclusive | true = write lock, false = read lock |
| block | true = wait for lock, false = fail if unavailable |
- Returns
- 0 on success, -1 on error (check errno)
◆ xroad_file_lock_byte()
| int xroad_file_lock_byte |
( |
int |
fd, |
|
|
off_t |
offset, |
|
|
bool |
exclusive, |
|
|
bool |
block |
|
) |
| |
Lock a single byte in a file
- Parameters
-
| fd | File descriptor |
| offset | Byte position to lock |
| exclusive | true = write lock, false = read lock |
| block | true = wait for lock, false = fail if unavailable |
- Returns
- 0 on success, -1 on error (check errno)
◆ xroad_file_lock_byte_ofd()
| int xroad_file_lock_byte_ofd |
( |
int |
fd, |
|
|
off_t |
offset, |
|
|
bool |
exclusive, |
|
|
bool |
block |
|
) |
| |
Lock a single byte in a file using OFD lock
◆ xroad_file_unlock()
| int xroad_file_unlock |
( |
int |
fd | ) |
|
Unlock a the file using fcntl lock.
- Parameters
-
- Returns
- 0 on success, -1 on error (check errno)
◆ xroad_file_unlock_byte()
| int xroad_file_unlock_byte |
( |
int |
fd, |
|
|
off_t |
offset |
|
) |
| |
Unlock a single byte in a file
- Parameters
-
| fd | File descriptor |
| offset | Byte position to unlock |
- Returns
- 0 on success, -1 on error (check errno)
◆ xroad_file_unlock_byte_ofd()
| int xroad_file_unlock_byte_ofd |
( |
int |
fd, |
|
|
off_t |
offset |
|
) |
| |
Release OFD lock of a single byte in a file
◆ xroad_get_cwd()
| const char* xroad_get_cwd |
( |
void |
| ) |
|
Returns current working directory