#define CONSTANTS_H
#include <stdint.h>
+#include <stdbool.h>
#define COQUET_MAGIC 0xC0CEF11ECABBA9E5ULL
#define COQUET_VERSION 0x0000000000000001ULL
#define COQUET_LMODE_SHARE 1
#define COQUET_LMODE_UN 2
-typedef int bool_t;
-
struct coquet;
typedef struct coquet coquet_t;
* reducing the HMAC to a simple hash in terms of guarantees. Requires the
* main file to be open.
*/
-int cq_super_load(coquet_t *cq, struct cq_super *super, bool_t create) {
+int cq_super_load(coquet_t *cq, struct cq_super *super, bool create) {
uint8_t super_bytes[SUPER_BYTES];
struct cq_super super_a, super_b;
int r,r2;
- bool_t use_b;
+ bool use_b;
r = (cq->vfs_funcs.read)
(cq->vfs_data,COQUET_FILE_MAIN,super_bytes,0,SUPER_BYTES);
return COQUET_RET_OK;
}
-static int lock_super(coquet_t *cq, int mode, bool_t wait) {
+static int lock_super(coquet_t *cq, int mode, bool wait) {
return (cq->vfs_funcs.lock)
(cq->vfs_data,COQUET_LOCK_SUPERBLOCK,mode,wait);
}
}
static int super_write(coquet_t *cq, struct cq_super *super,
- bool_t use_b, uint64_t serial) {
+ bool use_b, uint64_t serial) {
uint8_t half[HALF_BYTES];
int r;
return r;
}
-int cq_super_save(coquet_t *cq, struct cq_super *super, bool_t wait) {
+int cq_super_save(coquet_t *cq, struct cq_super *super, bool wait) {
int r, ret;
struct cq_super old;
test_bail(&cq,r);
}
-static void make_superblock(coquet_t *cq, bool_t also_b,
+static void make_superblock(coquet_t *cq, bool also_b,
int corrupt, int check) {
int r;
struct cq_super super;
#include "coquet.h"
-int cq_super_save(coquet_t *cq, struct cq_super *super, bool_t wait);
-int cq_super_load(coquet_t *cq, struct cq_super *super, bool_t create);
+int cq_super_save(coquet_t *cq, struct cq_super *super, bool wait);
+int cq_super_load(coquet_t *cq, struct cq_super *super, bool create);
void cq_super_set_desc(struct cq_super *super, char *desc);
char * cq_super_get_desc(struct cq_super *super);
}
static int test_lock(void * vfs_data, int which_lock, int lock_mode,
- bool_t wait) {
+ bool wait) {
struct test_data * td = (struct test_data *)vfs_data;
return (td->vfs_funcs.lock)(td->vfs_data,
return (td->vfs_funcs.delete)(td->vfs_data, which_file);
}
-static int test_sync(void * vfs_data, int which_file, bool_t data_only) {
+static int test_sync(void * vfs_data, int which_file, bool data_only) {
struct test_data * td = (struct test_data *)vfs_data;
return (td->vfs_funcs.sync)(td->vfs_data, which_file, data_only);
* remains owned by caller.
*/
static void set_error(struct unix_data * pd, char *error,
- bool_t use_errno) {
+ bool use_errno) {
pd->seen_error = 1;
if(pd->error_text != NULL) {
free(pd->error_text);
#define LOCK_BLOCK 128
static int unix_lock(void * vfs_data, int which_lock, int lock_mode,
- bool_t wait) {
+ bool wait) {
struct unix_data * pd = (struct unix_data *)vfs_data;
int r, op;
struct flock flk;
return COQUET_RET_OK;
}
-static int unix_sync(void * vfs_data, int which_file, bool_t data_only) {
+static int unix_sync(void * vfs_data, int which_file, bool data_only) {
struct unix_data * pd = (struct unix_data *)vfs_data;
int *fd, r;
* function will wait, otherwise return COQUET_RET_LOCKED
*/
int (*lock)(void * vfs_data, int which_lock, int lock_mode,
- bool_t wait);
+ bool wait);
/* Open the given file. which_file is drawn from COQUET_FILE_*.
* Open mode gives whether a file must (or can) be created.
int (*open)(void * vfs_data, int which_file, int open_mode);
/* Sync given file to disk. */
- int (*sync)(void * vfs_data, int which_file, bool_t data_only);
+ int (*sync)(void * vfs_data, int which_file, bool data_only);
/* Close the given file. Which_file is drawn from COQUET_FILE_*. The
* file is guaranteed to be open when this function is called. If file
int (*write)(void * vfs_data, int which_file, uint8_t * data,
off_t offset, uint64_t length);
+ // TODO write end
+
/* Read given data of given length at offset from to indicated file.
* which file must be drawn from a COQUET_FILE_* constant. If the
* offset is beyond the end of the file, all zeroes must be returned.