Alien-Libjio
view release on metacpan or search on metacpan
libjio/libjio/libjio.h view on Meta::CPAN
* The thread will call jsync(fs) every max_sec seconds, or every max_bytes
* have been written. Only one autosync thread per open file is allowed.
*
* @param fs open file
* @param max_sec maximum number of seconds that should pass between each
* call to jsync()
* @param max_bytes maximum number of bytes that should be written between
* each call to jsync()
* @returns 0 on success, -1 on error
* @ingroup basic
*/
int jfs_autosync_start(jfs_t *fs, time_t max_sec, size_t max_bytes);
/** Stop an autosync thread that was started using jfs_autosync_start(fs).
*
* @param fs open file
* @returns 0 on success, -1 on error
* @ingroup basic
*/
int jfs_autosync_stop(jfs_t *fs);
/*
* Journal checker
*/
/** Check and repair the given path.
*
* The file MUST NOT be in use by any other thread or process. This
* requirement will be lifted in future releases.
*
* @param name path to the file to check
* @param jdir journal directory of the given file, use NULL for the default
* @param res structure where to store the result
* @param flags flags that change the checking behaviour, currently only
* J_CLEANUP is supported, which removes the journal directory after a
* successful recovery
* @see struct jfsck_result
* @returns 0 on success, < 0 on error, with the following possible negative
* values from enum jfsck_return: J_ENOENT if there was no such file with
* the given name, J_ENOJOURNAL if there was no journal at the given
* jdir, J_ENOMEM if memory could not be allocated, J_ECLEANUP if there
* was an error cleaning the journal, J_EIO if there was an I/O error.
* @ingroup check
*/
enum jfsck_return jfsck(const char *name, const char *jdir,
struct jfsck_result *res, unsigned int flags);
/*
* UNIX API wrappers
*/
/** Read from the file. Works just like UNIX read(2).
*
* @param fs file to read from
* @param buf buffer used to store the data
* @param count maximum number of bytes to read
* @returns number of bytes read on success, or -1 on error
* @see read(2)
* @ingroup unix
*/
ssize_t jread(jfs_t *fs, void *buf, size_t count);
/** Read from the file at the given offset. Works just like UNIX pread(2).
*
* @param fs file to read from
* @param buf buffer used to store the data
* @param count maximum number of bytes to read
* @param offset offset to read at
* @returns number of bytes read on success, or -1 on error
* @see pread(2)
* @ingroup unix
*/
ssize_t jpread(jfs_t *fs, void *buf, size_t count, off_t offset);
/** Read from the file into multiple buffers. Works just like UNIX readv(2).
*
* @param fs file to read from
* @param vector buffers used to store the data
* @param count maximum number of bytes to read
* @returns number of bytes read on success, or -1 on error
* @see readv(2)
* @ingroup unix
*/
ssize_t jreadv(jfs_t *fs, const struct iovec *vector, int count);
/** Write to the file. Works just like UNIX write(2).
*
* @param fs file to write to
* @param buf buffer used to read the data from
* @param count maximum number of bytes to write
* @returns number of bytes written on success, or -1 on error
* @see write(2)
* @ingroup unix
*/
ssize_t jwrite(jfs_t *fs, const void *buf, size_t count);
/** Write to the file at the given offset. Works just like UNIX pwrite(2).
*
* @param fs file to write to
* @param buf buffer used to read the data from
* @param count maximum number of bytes to write
* @param offset offset to write at
* @returns number of bytes written on success, or -1 on error
* @see pwrite(2)
* @ingroup unix
*/
ssize_t jpwrite(jfs_t *fs, const void *buf, size_t count, off_t offset);
/** Write to the file from multiple buffers. Works just like UNIX writev(2).
*
* @param fs file to write to
* @param vector buffers used to read the data from
* @param count maximum number of bytes to write
* @returns number of bytes written on success, or -1 on error
* @see writev(2)
* @ingroup unix
*/
ssize_t jwritev(jfs_t *fs, const struct iovec *vector, int count);
/** Truncates the file to the given length. Works just like UNIX ftruncate(2).
*
* @param fs file to truncate
* @param length lenght to truncate to
* @returns 0 on success, -1 on error
* @see ftruncate(2)
* @ingroup unix
*/
int jtruncate(jfs_t *fs, off_t length);
/** Reposition read/write file offset. Works just like UNIX lseek(2).
*
* @param fs file to change the offset to
* @param offset offset to set
* @param whence where to count offset from, can be SEEK_SET to count from the
* beginning of the file, SEEK_CUR to count from the current position, or
* SEEK_END to count from the end.
* @returns the new offset counted from the beginning of the file, or -1 on
* error.
* @ingroup unix
*/
off_t jlseek(jfs_t *fs, off_t offset, int whence);
/*
* ANSI C stdio wrappers
*/
jfs_t *jfopen(const char *path, const char *mode);
int jfclose(jfs_t *stream);
jfs_t *jfreopen(const char *path, const char *mode, jfs_t *stream);
size_t jfread(void *ptr, size_t size, size_t nmemb, jfs_t *stream);
size_t jfwrite(const void *ptr, size_t size, size_t nmemb, jfs_t *stream);
int jfileno(jfs_t *stream);
int jfeof(jfs_t *stream);
void jclearerr(jfs_t *stream);
int jferror(jfs_t *stream);
int jfseek(jfs_t *stream, long offset, int whence);
long jftell(jfs_t *stream);
void jrewind(jfs_t *stream);
FILE *jfsopen(jfs_t *stream, const char *mode);
/*
* jopen() flags.
*
* Internally used also for jtrans_t flags.
*/
/** Don't lock the file before operating on it.
*
* @see jopen()
* @ingroup basic */
#define J_NOLOCK 1
/** No need to read rollback information.
*
* @see jopen()
* @ingroup basic */
#define J_NOROLLBACK 2
/** Use lingering transactions.
*
* @see jopen()
* @ingroup basic */
#define J_LINGER 4
/* Range 8-256 is reserved for future public use */
( run in 1.142 second using v1.01-cache-2.11-cpan-64ef6c95b5d )