Main Page | Modules | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

sqlfs.c File Reference


Detailed Description

file system on top of a SQL database library API implementation

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <pthread.h>
#include <time.h>
#include "sqlfs.h"
#include "sqlite3.h"

Defines

#define INDEX   0
#define PREPARE_STMT
#define DONE_PREPARE   if (r == SQLITE_OK) sqlfs->stmts[INDEX] = stmt; else sqlfs->stmts[INDEX] = 0;
#define SQLITE3_PREPARE(a, b, c, d, e)
#define TRANS_LOCK
#define TRANS_UNLOCK
#define INDEX   100
#define INDEX   101
#define INDEX   102
#define INDEX   103
#define INDEX   104
#define BEGIN
#define COMPLETE(r)
#define INDEX   1
#define INDEX   2
#define INDEX   3
#define INDEX   4
#define INDEX   5
#define INDEX   6
#define INDEX   7
#define INDEX   41
#define INDEX   8
#define INDEX   9
#define INDEX   42
#define INDEX   10
#define INDEX   11
#define INDEX   43
#define INDEX   12
#define INDEX   13
#define INDEX   14
#define INDEX   44
#define INDEX   15
#define INDEX   16
#define INDEX   17
#define INDEX   18
#define INDEX   19
#define INDEX   20
#define INDEX   21
#define INDEX   22
#define INDEX   23
#define INDEX   24
#define INDEX   25
#define INDEX   26
#define INDEX   27
#define INDEX   28
#define INDEX   29
#define CHECK_PARENT_PATH(p)   result = check_parent_access(sqlfs, (p)); if (result != 0) { COMPLETE(1); return result; }
#define CHECK_READ(p)   result = (sqlfs_proc_access(sqlfs, (p), R_OK | F_OK)); if (result != 0) { COMPLETE(1); return result; }
#define CHECK_WRITE(p)   result = (sqlfs_proc_access(sqlfs, (p), W_OK | F_OK)); if (result != 0) { COMPLETE(1); return result; }
#define CHECK_DIR_WRITE(p)   result = (sqlfs_proc_access(sqlfs, (p), W_OK | F_OK | X_OK)); if (result != 0) { COMPLETE(1); return result; }
#define CHECK_DIR_READ(p)   result = (sqlfs_proc_access(sqlfs, (p), R_OK | F_OK | X_OK)); if (result != 0) {fprintf(stderr, "dir read failed %d\n", result); COMPLETE(1); return result; }
#define CHECK_PARENT_READ(p)   { char ppath[PATH_MAX]; if (SQLITE_OK == get_parent_path((p), ppath)) { result = (sqlfs_proc_access(sqlfs, (ppath), R_OK | X_OK)); if (result != 0) { COMPLETE(1); return result; }}}
#define CHECK_PARENT_WRITE(p)   { result = check_parent_write(sqlfs, (p)); if (result != 0) { COMPLETE(1); return result; }}
#define INDEX   30
#define INDEX   45
#define INDEX   46
#define INDEX   47
#define INDEX   48
#define INDEX   31

Functions

void clean_attr (key_attr *attr)
void clean_value (key_value *value)
int sqlfs_proc_getattr (sqlfs_t *sqlfs, const char *path, struct stat *stbuf)
int sqlfs_proc_access (sqlfs_t *sqlfs, const char *path, int mask)
int sqlfs_proc_readlink (sqlfs_t *sqlfs, const char *path, char *buf, size_t size)
int sqlfs_proc_readdir (sqlfs_t *sqlfs, const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi)
int sqlfs_proc_mknod (sqlfs_t *sqlfs, const char *path, mode_t mode, dev_t rdev)
int sqlfs_proc_mkdir (sqlfs_t *sqlfs, const char *path, mode_t mode)
int sqlfs_proc_unlink (sqlfs_t *sqlfs, const char *path)
int sqlfs_proc_rmdir (sqlfs_t *sqlfs, const char *path)
int sqlfs_proc_symlink (sqlfs_t *sqlfs, const char *path, const char *to)
int sqlfs_proc_rename (sqlfs_t *sqlfs, const char *from, const char *to)
int sqlfs_proc_link (sqlfs_t *sqlfs, const char *from, const char *to)
int sqlfs_proc_chmod (sqlfs_t *sqlfs, const char *path, mode_t mode)
int sqlfs_proc_chown (sqlfs_t *sqlfs, const char *path, uid_t uid, gid_t gid)
int sqlfs_proc_truncate (sqlfs_t *sqlfs, const char *path, off_t size)
int sqlfs_proc_utime (sqlfs_t *sqlfs, const char *path, struct utimbuf *buf)
int sqlfs_proc_create (sqlfs_t *sqlfs, const char *path, mode_t mode, struct fuse_file_info *fi)
int sqlfs_proc_open (sqlfs_t *sqlfs, const char *path, struct fuse_file_info *fi)
int sqlfs_proc_read (sqlfs_t *sqlfs, const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi)
int sqlfs_proc_write (sqlfs_t *sqlfs, const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi)
int sqlfs_proc_statfs (sqlfs_t *sqlfs, const char *path, struct statvfs *stbuf)
int sqlfs_proc_release (sqlfs_t *sqlfs, const char *path, struct fuse_file_info *fi)
int sqlfs_proc_fsync (sqlfs_t *sqlfs, const char *path, int isfdatasync, struct fuse_file_info *fi)
int sqlfs_proc_setxattr (sqlfs_t *sqlfs, const char *path, const char *name, const char *value, size_t size, int flags)
int sqlfs_proc_getxattr (sqlfs_t *sqlfs, const char *path, const char *name, char *value, size_t size)
int sqlfs_proc_listxattr (sqlfs_t *sqlfs, const char *path, char *list, size_t size)
int sqlfs_proc_removexattr (sqlfs_t *sqlfs, const char *path, const char *name)
int sqlfs_del_tree (sqlfs_t *sqlfs, const char *key)
int sqlfs_del_tree_with_exclusion (sqlfs_t *sqlfs, const char *key, const char *exclusion_pattern)
int sqlfs_get_value (sqlfs_t *sqlfs, const char *key, key_value *value, size_t begin, size_t end)
int sqlfs_set_value (sqlfs_t *sqlfs, const char *key, const key_value *value, size_t begin, size_t end)
int sqlfs_get_attr (sqlfs_t *sqlfs, const char *key, key_attr *attr)
int sqlfs_set_attr (sqlfs_t *sqlfs, const char *key, const key_attr *attr)
int sqlfs_begin_transaction (sqlfs_t *sqlfs)
int sqlfs_complete_transaction (sqlfs_t *sqlfs, int i)
int sqlfs_break_transaction (sqlfs_t *sqlfs)
int sqlfs_set_type (sqlfs_t *sqlfs, const char *key, const char *type)
int sqlfs_list_keys (sqlfs_t *sqlfs, const char *pattern, void *buf, fuse_fill_dir_t filler)
int sqlfs_is_dir (sqlfs_t *sqlfs, const char *key)
int sqlfs_open (const char *db_file, sqlfs_t **sqlfs)
int sqlfs_close (sqlfs_t *sqlfs)
int sqlfs_init (const char *db_file_name)


Define Documentation

#define BEGIN
 

#define CHECK_DIR_READ  )     result = (sqlfs_proc_access(sqlfs, (p), R_OK | F_OK | X_OK)); if (result != 0) {fprintf(stderr, "dir read failed %d\n", result); COMPLETE(1); return result; }
 

#define CHECK_DIR_WRITE  )     result = (sqlfs_proc_access(sqlfs, (p), W_OK | F_OK | X_OK)); if (result != 0) { COMPLETE(1); return result; }
 

#define CHECK_PARENT_PATH  )     result = check_parent_access(sqlfs, (p)); if (result != 0) { COMPLETE(1); return result; }
 

#define CHECK_PARENT_READ  )     { char ppath[PATH_MAX]; if (SQLITE_OK == get_parent_path((p), ppath)) { result = (sqlfs_proc_access(sqlfs, (ppath), R_OK | X_OK)); if (result != 0) { COMPLETE(1); return result; }}}
 

#define CHECK_PARENT_WRITE  )     { result = check_parent_write(sqlfs, (p)); if (result != 0) { COMPLETE(1); return result; }}
 

#define CHECK_READ  )     result = (sqlfs_proc_access(sqlfs, (p), R_OK | F_OK)); if (result != 0) { COMPLETE(1); return result; }
 

#define CHECK_WRITE  )     result = (sqlfs_proc_access(sqlfs, (p), W_OK | F_OK)); if (result != 0) { COMPLETE(1); return result; }
 

#define COMPLETE  ) 
 

#define DONE_PREPARE   if (r == SQLITE_OK) sqlfs->stmts[INDEX] = stmt; else sqlfs->stmts[INDEX] = 0;
 

#define INDEX   31
 

#define INDEX   48
 

#define INDEX   47
 

#define INDEX   46
 

#define INDEX   45
 

#define INDEX   30
 

#define INDEX   29
 

#define INDEX   28
 

#define INDEX   27
 

#define INDEX   26
 

#define INDEX   25
 

#define INDEX   24
 

#define INDEX   23
 

#define INDEX   22
 

#define INDEX   21
 

#define INDEX   20
 

#define INDEX   19
 

#define INDEX   18
 

#define INDEX   17
 

#define INDEX   16
 

#define INDEX   15
 

#define INDEX   44
 

#define INDEX   14
 

#define INDEX   13
 

#define INDEX   12
 

#define INDEX   43
 

#define INDEX   11
 

#define INDEX   10
 

#define INDEX   42
 

#define INDEX   9
 

#define INDEX   8
 

#define INDEX   41
 

#define INDEX   7
 

#define INDEX   6
 

#define INDEX   5
 

#define INDEX   4
 

#define INDEX   3
 

#define INDEX   2
 

#define INDEX   1
 

#define INDEX   104
 

#define INDEX   103
 

#define INDEX   102
 

#define INDEX   101
 

#define INDEX   100
 

#define INDEX   0
 

#define PREPARE_STMT
 

Value:

stmt = sqlfs->stmts[INDEX];\
    r = SQLITE_OK; \
    if (stmt)\
    {\
        if (sqlite3_expired(stmt))\
        {\
            sqlite3_finalize(stmt);\
            r = ~SQLITE_OK;\
        }\
    }\
    else r = ~SQLITE_OK;\
    if (r != SQLITE_OK)

#define SQLITE3_PREPARE a,
b,
c,
d,
 ) 
 

Value:

PREPARE_STMT \
    r = sqlite3_prepare((a), (b), (c), (d), (e));\
    DONE_PREPARE

#define TRANS_LOCK
 

#define TRANS_UNLOCK
 


Function Documentation

void clean_attr key_attr attr  ) 
 

void clean_value key_value value  ) 
 

int sqlfs_begin_transaction sqlfs_t sqlfs  ) 
 

int sqlfs_break_transaction sqlfs_t sqlfs  ) 
 

int sqlfs_close sqlfs_t sqlfs  ) 
 

int sqlfs_complete_transaction sqlfs_t sqlfs,
int  i
 

int sqlfs_del_tree sqlfs_t sqlfs,
const char *  key
 

int sqlfs_del_tree_with_exclusion sqlfs_t sqlfs,
const char *  key,
const char *  exclusion_pattern
 

int sqlfs_get_attr sqlfs_t sqlfs,
const char *  key,
key_attr attr
 

int sqlfs_get_value sqlfs_t sqlfs,
const char *  key,
key_value value,
size_t  begin,
size_t  end
 

int sqlfs_init const char *  db_file_name  ) 
 

int sqlfs_is_dir sqlfs_t sqlfs,
const char *  key
 

int sqlfs_list_keys sqlfs_t sqlfs,
const char *  pattern,
void *  buf,
fuse_fill_dir_t  filler
 

int sqlfs_open const char *  db_file,
sqlfs_t **  sqlfs
 

int sqlfs_proc_access sqlfs_t sqlfs,
const char *  path,
int  mask
 

int sqlfs_proc_chmod sqlfs_t sqlfs,
const char *  path,
mode_t  mode
 

int sqlfs_proc_chown sqlfs_t sqlfs,
const char *  path,
uid_t  uid,
gid_t  gid
 

int sqlfs_proc_create sqlfs_t sqlfs,
const char *  path,
mode_t  mode,
struct fuse_file_info fi
 

int sqlfs_proc_fsync sqlfs_t sqlfs,
const char *  path,
int  isfdatasync,
struct fuse_file_info fi
 

int sqlfs_proc_getattr sqlfs_t sqlfs,
const char *  path,
struct stat *  stbuf
 

int sqlfs_proc_getxattr sqlfs_t sqlfs,
const char *  path,
const char *  name,
char *  value,
size_t  size
 

int sqlfs_proc_link sqlfs_t sqlfs,
const char *  from,
const char *  to
 

int sqlfs_proc_listxattr sqlfs_t sqlfs,
const char *  path,
char *  list,
size_t  size
 

int sqlfs_proc_mkdir sqlfs_t sqlfs,
const char *  path,
mode_t  mode
 

int sqlfs_proc_mknod sqlfs_t sqlfs,
const char *  path,
mode_t  mode,
dev_t  rdev
 

int sqlfs_proc_open sqlfs_t sqlfs,
const char *  path,
struct fuse_file_info fi
 

int sqlfs_proc_read sqlfs_t sqlfs,
const char *  path,
char *  buf,
size_t  size,
off_t  offset,
struct fuse_file_info fi
 

int sqlfs_proc_readdir sqlfs_t sqlfs,
const char *  path,
void *  buf,
fuse_fill_dir_t  filler,
off_t  offset,
struct fuse_file_info fi
 

int sqlfs_proc_readlink sqlfs_t sqlfs,
const char *  path,
char *  buf,
size_t  size
 

int sqlfs_proc_release sqlfs_t sqlfs,
const char *  path,
struct fuse_file_info fi
 

int sqlfs_proc_removexattr sqlfs_t sqlfs,
const char *  path,
const char *  name
 

int sqlfs_proc_rename sqlfs_t sqlfs,
const char *  from,
const char *  to
 

int sqlfs_proc_rmdir sqlfs_t sqlfs,
const char *  path
 

int sqlfs_proc_setxattr sqlfs_t sqlfs,
const char *  path,
const char *  name,
const char *  value,
size_t  size,
int  flags
 

int sqlfs_proc_statfs sqlfs_t sqlfs,
const char *  path,
struct statvfs *  stbuf
 

int sqlfs_proc_symlink sqlfs_t sqlfs,
const char *  path,
const char *  to
 

int sqlfs_proc_truncate sqlfs_t sqlfs,
const char *  path,
off_t  size
 

int sqlfs_proc_unlink sqlfs_t sqlfs,
const char *  path
 

int sqlfs_proc_utime sqlfs_t sqlfs,
const char *  path,
struct utimbuf *  buf
 

int sqlfs_proc_write sqlfs_t sqlfs,
const char *  path,
const char *  buf,
size_t  size,
off_t  offset,
struct fuse_file_info fi
 

int sqlfs_set_attr sqlfs_t sqlfs,
const char *  key,
const key_attr attr
 

int sqlfs_set_type sqlfs_t sqlfs,
const char *  key,
const char *  type
 

int sqlfs_set_value sqlfs_t sqlfs,
const char *  key,
const key_value value,
size_t  begin,
size_t  end
 


Generated on Sat Dec 16 20:29:49 2006 for hiker-0.9 by  doxygen 1.4.4