00001
00002
00003
00004
00005
00006
00007 #ifndef _LIBJIO_H
00008 #define _LIBJIO_H
00009
00010 #include <stdint.h>
00011 #include <stdio.h>
00012 #include <sys/types.h>
00013 #include <sys/uio.h>
00014 #include <pthread.h>
00015 #include <unistd.h>
00016
00017
00018
00019
00020
00021
00022 #ifndef _LARGEFILE_SOURCE
00023 #error "You must compile your application with Large File Support"
00024 #endif
00025
00026
00027
00028
00029
00031 typedef struct jfs jfs_t;
00032
00034 typedef struct jtrans jtrans_t;
00035
00036
00037
00038
00039
00040
00046 struct jfsck_result {
00048 int total;
00049
00051 int invalid;
00052
00054 int in_progress;
00055
00057 int broken;
00058
00060 int corrupt;
00061
00063 int reapplied;
00064 };
00065
00071 enum jfsck_return {
00073 J_ESUCCESS = 0,
00074
00076 J_ENOENT = -1,
00077
00079 J_ENOJOURNAL = -2,
00080
00082 J_ENOMEM = -3,
00083
00085 J_ECLEANUP = -4,
00086
00088 J_EIO = -5,
00089 };
00090
00091
00092
00093
00094
00095
00096
00114 jfs_t *jopen(const char *name, int flags, int mode, unsigned int jflags);
00115
00128 int jclose(jfs_t *fs);
00129
00136 int jsync(jfs_t *fs);
00137
00149 jtrans_t *jtrans_new(jfs_t *fs, unsigned int flags);
00150
00172 int jtrans_add_w(jtrans_t *ts, const void *buf, size_t count, off_t offset);
00173
00200 int jtrans_add_r(jtrans_t *ts, void *buf, size_t count, off_t offset);
00201
00218 ssize_t jtrans_commit(jtrans_t *ts);
00219
00233 ssize_t jtrans_rollback(jtrans_t *ts);
00234
00241 void jtrans_free(jtrans_t *ts);
00242
00254 int jmove_journal(jfs_t *fs, const char *newpath);
00255
00256
00257
00258
00259
00260
00274 int jfs_autosync_start(jfs_t *fs, time_t max_sec, size_t max_bytes);
00275
00282 int jfs_autosync_stop(jfs_t *fs);
00283
00284
00285
00286
00287
00288
00308 enum jfsck_return jfsck(const char *name, const char *jdir,
00309 struct jfsck_result *res, unsigned int flags);
00310
00311
00312
00313
00314
00315
00325 ssize_t jread(jfs_t *fs, void *buf, size_t count);
00326
00337 ssize_t jpread(jfs_t *fs, void *buf, size_t count, off_t offset);
00338
00348 ssize_t jreadv(jfs_t *fs, const struct iovec *vector, int count);
00349
00359 ssize_t jwrite(jfs_t *fs, const void *buf, size_t count);
00360
00371 ssize_t jpwrite(jfs_t *fs, const void *buf, size_t count, off_t offset);
00372
00382 ssize_t jwritev(jfs_t *fs, const struct iovec *vector, int count);
00383
00392 int jtruncate(jfs_t *fs, off_t length);
00393
00405 off_t jlseek(jfs_t *fs, off_t offset, int whence);
00406
00407
00408
00409
00410
00411
00412 jfs_t *jfopen(const char *path, const char *mode);
00413
00414 int jfclose(jfs_t *stream);
00415
00416 jfs_t *jfreopen(const char *path, const char *mode, jfs_t *stream);
00417
00418 size_t jfread(void *ptr, size_t size, size_t nmemb, jfs_t *stream);
00419
00420 size_t jfwrite(const void *ptr, size_t size, size_t nmemb, jfs_t *stream);
00421
00422 int jfileno(jfs_t *stream);
00423
00424 int jfeof(jfs_t *stream);
00425
00426 void jclearerr(jfs_t *stream);
00427
00428 int jferror(jfs_t *stream);
00429
00430 int jfseek(jfs_t *stream, long offset, int whence);
00431
00432 long jftell(jfs_t *stream);
00433
00434 void jrewind(jfs_t *stream);
00435
00436 FILE *jfsopen(jfs_t *stream, const char *mode);
00437
00438
00439
00440
00441
00442
00443
00444
00449 #define J_NOLOCK 1
00450
00455 #define J_NOROLLBACK 2
00456
00461 #define J_LINGER 4
00462
00463
00464
00471 #define J_RDONLY 512
00472
00473
00474
00475
00476
00477
00478
00479
00482 #define J_COMMITTED 1024
00483
00486 #define J_ROLLBACKED 2048
00487
00490 #define J_ROLLBACKING 4096
00491
00492
00493
00494
00495
00496
00501 #define J_CLEANUP 1
00502
00503 #endif
00504