libjio.h | libjio.h | |||
---|---|---|---|---|
skipping to change at line 29 | skipping to change at line 29 | |||
/* logical structures */ | /* logical structures */ | |||
/* the main file structure */ | /* the main file structure */ | |||
struct jfs { | struct jfs { | |||
int fd; /* main file descriptor */ | int fd; /* main file descriptor */ | |||
char *name; /* and its name */ | char *name; /* and its name */ | |||
int jdirfd; /* journal directory file descriptor */ | int jdirfd; /* journal directory file descriptor */ | |||
int jfd; /* journal's lock file descriptor */ | int jfd; /* journal's lock file descriptor */ | |||
unsigned int *jmap; /* journal's lock file mmap area */ | unsigned int *jmap; /* journal's lock file mmap area */ | |||
int flags; /* journal flags */ | uint32_t flags; /* journal flags */ | |||
struct jlinger *ltrans; /* lingered transactions */ | struct jlinger *ltrans; /* lingered transactions */ | |||
pthread_mutex_t lock; /* a soft lock used in some operations */ | pthread_mutex_t lock; /* a soft lock used in some operations */ | |||
}; | }; | |||
/* a single operation */ | /* a single operation */ | |||
struct joper { | struct joper { | |||
int locked; /* is the region is locked? */ | int locked; /* is the region is locked? */ | |||
off_t offset; /* operation's offset */ | off_t offset; /* operation's offset */ | |||
size_t len; /* data length */ | size_t len; /* data length */ | |||
void *buf; /* data */ | void *buf; /* data */ | |||
skipping to change at line 51 | skipping to change at line 51 | |||
void *pdata; /* previous data */ | void *pdata; /* previous data */ | |||
struct joper *prev; | struct joper *prev; | |||
struct joper *next; | struct joper *next; | |||
}; | }; | |||
/* a transaction */ | /* a transaction */ | |||
struct jtrans { | struct jtrans { | |||
struct jfs *fs; /* journal file structure to operate on */ | struct jfs *fs; /* journal file structure to operate on */ | |||
char *name; /* name of the transaction file */ | char *name; /* name of the transaction file */ | |||
int id; /* transaction id */ | int id; /* transaction id */ | |||
int flags; /* misc flags */ | uint32_t flags; /* transaction flags */ | |||
unsigned int numops; /* quantity of operations in the list */ | unsigned int numops; /* quantity of operations in the list */ | |||
pthread_mutex_t lock; /* used to modify the operation list */ | pthread_mutex_t lock; /* used to modify the operation list */ | |||
struct joper *op; /* list of operations */ | struct joper *op; /* list of operations */ | |||
}; | }; | |||
/* lingered transaction */ | /* lingered transaction */ | |||
struct jlinger { | struct jlinger { | |||
int id; /* transaction id */ | int id; /* transaction id */ | |||
char *name; /* name of the transaction file */ | char *name; /* name of the transaction file */ | |||
struct jlinger *next; | struct jlinger *next; | |||
skipping to change at line 95 | skipping to change at line 95 | |||
uint32_t len; /* data length */ | uint32_t len; /* data length */ | |||
uint32_t plen; /* previous data length */ | uint32_t plen; /* previous data length */ | |||
uint64_t offset; /* offset relative to the BOF */ | uint64_t offset; /* offset relative to the BOF */ | |||
char *prevdata; /* previous data for rollback */ | char *prevdata; /* previous data for rollback */ | |||
}; | }; | |||
/* core functions */ | /* core functions */ | |||
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 ); | |||
void jtrans_init(struct jfs *fs, struct jtrans *ts); | void jtrans_init(struct jfs *fs, struct jtrans *ts); | |||
int jtrans_add(struct jtrans *ts, const void *buf, size_t count, off_t offs et); | int jtrans_add(struct jtrans *ts, const void *buf, size_t count, off_t offs et); | |||
int jtrans_commit(struct jtrans *ts); | ssize_t jtrans_commit(struct jtrans *ts); | |||
int jtrans_rollback(struct jtrans *ts); | ssize_t jtrans_rollback(struct jtrans *ts); | |||
void jtrans_free(struct jtrans *ts); | void jtrans_free(struct jtrans *ts); | |||
int jsync(struct jfs *fs); | int jsync(struct jfs *fs); | |||
int jclose(struct jfs *fs); | 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 */ | /* UNIX API wrappers */ | |||
ssize_t jread(struct jfs *fs, void *buf, size_t count); | ssize_t jread(struct jfs *fs, void *buf, size_t count); | |||
skipping to change at line 130 | skipping to change at line 130 | |||
size_t jfwrite(const void *ptr, size_t size, size_t nmemb, struct jfs *stre am); | size_t jfwrite(const void *ptr, size_t size, size_t nmemb, struct jfs *stre am); | |||
int jfileno(struct jfs *stream); | int jfileno(struct jfs *stream); | |||
int jfeof(struct jfs *stream); | int jfeof(struct jfs *stream); | |||
void jclearerr(struct jfs *stream); | void jclearerr(struct jfs *stream); | |||
int jferror(struct jfs *stream); | int jferror(struct jfs *stream); | |||
int jfseek(struct jfs *stream, long offset, int whence); | int jfseek(struct jfs *stream, long offset, int whence); | |||
int jftell(struct jfs *stream); | int jftell(struct jfs *stream); | |||
void frewind(struct jfs *stream); | void frewind(struct jfs *stream); | |||
FILE *jfsopen(struct jfs *stream, const char *mode); | FILE *jfsopen(struct jfs *stream, const char *mode); | |||
/* jfs constants */ | /* jfs and jtrans 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 */ | |||
#define J_NOROLLBACK 2 /* no need to read rollback information */ | #define J_NOROLLBACK 2 /* no need to read rollback information */ | |||
#define J_LINGER 3 /* use lingering transactions */ | #define J_LINGER 4 /* use lingering transactions */ | |||
#define J_COMMITTED 8 /* mark a transaction as committed */ | ||||
/* jtrans constants */ | #define J_ROLLBACKED 16 /* mark a transaction as rollbacked */ | |||
#define J_COMMITED 1 /* mark a transaction as commited */ | #define J_ROLLBACKING 32 /* mark a transaction as rollbacking */ | |||
#define J_ROLLBACKED 2 /* mark a transaction as rollbacked */ | ||||
#define J_ROLLBACKING 3 /* mark a transaction as rollbacking */ | ||||
/* disk constants */ | /* disk constants */ | |||
#define J_DISKHEADSIZE 12 /* length of disk_header */ | #define J_DISKHEADSIZE 12 /* length of disk_header */ | |||
#define J_DISKOPHEADSIZE 16 /* length of disk_operation header */ | #define J_DISKOPHEADSIZE 16 /* length of disk_operation header */ | |||
/* jfsck constants (return values) */ | /* jfsck constants (return values) */ | |||
#define J_ESUCCESS 0 /* success - shouldn't be used */ | #define J_ESUCCESS 0 /* success - shouldn't be used */ | |||
#define J_ENOENT 1 /* no such file */ | #define J_ENOENT 1 /* no such file */ | |||
#define J_ENOJOURNAL 2 /* no journal associated */ | #define J_ENOJOURNAL 2 /* no journal associated */ | |||
#define J_ENOMEM 3 /* no enough free memory */ | #define J_ENOMEM 3 /* no enough free memory */ | |||
End of changes. 5 change blocks. | ||||
11 lines changed or deleted | 9 lines changed or added | |||