libjio.h | libjio.h | |||
---|---|---|---|---|
/* | /* | |||
* libjio - A library for Journaled I/O | * libjio - A library for Journaled I/O | |||
* Alberto Bertogli (albertogli@telpin.com.ar) | * Alberto Bertogli (albertogli@telpin.com.ar) | |||
*/ | */ | |||
#ifndef _LIBJIO_H | #ifndef _LIBJIO_H | |||
#define _LIBJIO_H | #define _LIBJIO_H | |||
#include <stdint.h> | #include <stdint.h> | |||
#include <stdio.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | |||
#include <sys/uio.h> | #include <sys/uio.h> | |||
#include <pthread.h> | #include <pthread.h> | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
/* logical structures */ | /* logical structures */ | |||
struct jfs { | struct jfs { | |||
skipping to change at line 69 | skipping to change at line 70 | |||
uint32_t len; /* data lenght */ | uint32_t len; /* data lenght */ | |||
uint32_t plen; /* previous data lenght */ | uint32_t plen; /* previous data lenght */ | |||
uint32_t ulen; /* user-supplied information lenght */ | uint32_t ulen; /* user-supplied information lenght */ | |||
uint64_t offset; /* offset relative to the BOF */ | uint64_t offset; /* offset relative to the BOF */ | |||
/* payload (variable lenght) */ | /* payload (variable lenght) */ | |||
char *udata; /* user-supplied data */ | char *udata; /* user-supplied data */ | |||
char *prevdata; /* previous data for rollback */ | char *prevdata; /* previous data for rollback */ | |||
}; | }; | |||
/* basic operations */ | /* core operations */ | |||
int jopen(struct jfs *fs, const char *name, int flags, int mode, int jflags ); | int jopen(struct jfs *fs, const char *name, int flags, int mode, int jflags ); | |||
ssize_t jread(struct jfs *fs, void *buf, size_t count); | ||||
ssize_t jpread(struct jfs *fs, void *buf, size_t count, off_t offset); | ||||
ssize_t jreadv(struct jfs *fs, struct iovec *vector, int count); | ||||
ssize_t jwrite(struct jfs *fs, const void *buf, size_t count); | ||||
ssize_t jpwrite(struct jfs *fs, const void *buf, size_t count, off_t offset | ||||
); | ||||
ssize_t jwritev(struct jfs *fs, const struct iovec *vector, int count); | ||||
int jtruncate(struct jfs *fs, off_t lenght); | ||||
int jclose(struct jfs *fs); | ||||
/* transaction operations */ | ||||
void jtrans_init(struct jfs *fs, struct jtrans *ts); | void jtrans_init(struct jfs *fs, struct jtrans *ts); | |||
int jtrans_commit(struct jtrans *ts); | int jtrans_commit(struct jtrans *ts); | |||
int jtrans_rollback(struct jtrans *ts); | int jtrans_rollback(struct jtrans *ts); | |||
void jtrans_free(struct jtrans *ts); | void jtrans_free(struct jtrans *ts); | |||
int jclose(struct jfs *fs); | ||||
/* journal checker */ | /* journal checker */ | |||
int jfsck(const char *name, struct jfsck_result *res); | int jfsck(const char *name, struct jfsck_result *res); | |||
int jfsck_cleanup(const char *name); | int jfsck_cleanup(const char *name); | |||
/* UNIX API wrappers */ | ||||
ssize_t jread(struct jfs *fs, void *buf, size_t count); | ||||
ssize_t jpread(struct jfs *fs, void *buf, size_t count, off_t offset); | ||||
ssize_t jreadv(struct jfs *fs, struct iovec *vector, int count); | ||||
ssize_t jwrite(struct jfs *fs, const void *buf, size_t count); | ||||
ssize_t jpwrite(struct jfs *fs, const void *buf, size_t count, off_t offset | ||||
); | ||||
ssize_t jwritev(struct jfs *fs, const struct iovec *vector, int count); | ||||
int jtruncate(struct jfs *fs, off_t lenght); | ||||
/* ANSI C stdio wrappers */ | ||||
struct jfs *jfopen(const char *path, const char *mode); | ||||
int jfclose(struct jfs *stream); | ||||
struct jfs *jfreopen(const char *path, const char *mode, struct jfs *stream | ||||
); | ||||
size_t jfread(void *ptr, size_t size, size_t nmemb, struct jfs *stream); | ||||
size_t jfwrite(const void *ptr, size_t size, size_t nmemb, struct jfs *stre | ||||
am); | ||||
int jfileno(struct jfs *stream); | ||||
int jfeof(struct jfs *stream); | ||||
void jclearerr(struct jfs *stream); | ||||
int jferror(struct jfs *stream); | ||||
int jfseek(struct jfs *stream, long offset, int whence); | ||||
int jftell(struct jfs *stream); | ||||
void frewind(struct jfs *stream); | ||||
FILE *jfsopen(struct jfs *stream, const char *mode); | ||||
/* jfs constants */ | /* jfs constants */ | |||
#define J_NOLOCK 1 /* don't lock the file before operating on i t */ | #define J_NOLOCK 1 /* don't lock the file before operating on i t */ | |||
/* jtrans constants */ | /* jtrans constants */ | |||
#define J_COMMITED 1 /* mark a transaction as commited */ | #define J_COMMITED 1 /* mark a transaction as commited */ | |||
#define J_ROLLBACKED 2 /* mark a transaction as rollbacked */ | #define J_ROLLBACKED 2 /* mark a transaction as rollbacked */ | |||
/* disk_trans constants */ | /* disk_trans constants */ | |||
#define J_DISKTFIXSIZE 28 /* lenght of disk_trans' header */ | #define J_DISKTFIXSIZE 28 /* lenght of disk_trans' header */ | |||
End of changes. 5 change blocks. | ||||
12 lines changed or deleted | 30 lines changed or added | |||