00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __SQLFS_INTERNAL_H__
00022 #define __SQLFS_INTERNAL_H__
00023
00024 #include <sys/types.h>
00025 #include <sys/stat.h>
00026 #include <sys/statvfs.h>
00027 #include <unistd.h>
00028 #include <fcntl.h>
00029 #include <errno.h>
00030 #include <utime.h>
00031
00032 #include "sqlite3.h"
00033
00034 #define TYPE_NULL "null"
00035 #define TYPE_DIR "dir"
00036 #define TYPE_INT "int"
00037 #define TYPE_DOUBLE "double"
00038 #define TYPE_STRING "string"
00039 #define TYPE_SYM_LINK "sym link"
00040 #define TYPE_BOOL "bool"
00041 #define TYPE_LIST "list"
00042 #define TYPE_BLOB "blob"
00043
00044
00045
00046 typedef struct
00047 {
00048 sqlite3 *db;
00049 int transaction_level;
00050 int in_transaction;
00051 mode_t default_mode;
00052
00053 sqlite3_stmt *stmts[200];
00054 #ifndef FUSE
00055 uid_t uid;
00056 gid_t gid;
00057 #endif
00058 }
00059 sqlfs_t;
00060
00061 typedef struct
00062 {
00063 char *path;
00064 char *type;
00065 int32_t inode;
00066 int32_t uid;
00067 int32_t gid;
00068 int32_t mode;
00069 size_t size;
00070
00071
00072
00073
00074 time_t atime;
00075 time_t mtime;
00076 time_t ctime;
00077 } key_attr;
00078
00079
00080 typedef struct
00081 {
00082 char *data;
00083 size_t size;
00084 size_t offset;
00085 } key_value;
00086
00087
00088 void clean_attr(key_attr *attr);
00089
00090 void clean_value(key_value *value);
00091
00092 int sqlfs_del_tree(sqlfs_t *sqlfs, const char *key);
00093 int sqlfs_del_tree_with_exclusion(sqlfs_t *sqlfs, const char *key, const char *exclusion_pattern);
00094
00095 int sqlfs_get_value(sqlfs_t *sqlfs, const char *key, key_value *value,
00096 size_t begin, size_t end);
00097
00098 int sqlfs_set_value(sqlfs_t *sqlfs, const char *key, const key_value *value,
00099 size_t begin, size_t end);
00100
00101 int sqlfs_get_attr(sqlfs_t *sqlfs, const char *key, key_attr *attr);
00102
00103 int sqlfs_set_attr(sqlfs_t *sqlfs, const char *key, const key_attr *attr);
00104
00105
00106
00107 int sqlfs_set_type(sqlfs_t *sqlfs, const char *key, const char *type);
00108 int sqlfs_list_keys(sqlfs_t *, const char *pattern, void *buf, fuse_fill_dir_t filler);
00109
00110 int sqlfs_begin_transaction(sqlfs_t *sqlfs);
00111 int sqlfs_complete_transaction(sqlfs_t *sqlfs, int i);
00112 int sqlfs_break_transaction(sqlfs_t *sqlfs);
00113
00114 int sqlfs_is_dir(sqlfs_t *sqlfs, const char *key);
00115
00116 int sqlfs_proc_getattr(sqlfs_t *, const char *path, struct stat *stbuf);
00117 int sqlfs_proc_access(sqlfs_t *, const char *path, int mask);
00118 int sqlfs_proc_readlink(sqlfs_t *, const char *path, char *buf, size_t size);
00119 int sqlfs_proc_readdir(sqlfs_t *, const char *path, void *buf, fuse_fill_dir_t filler,
00120 off_t offset, struct fuse_file_info *fi);
00121 int sqlfs_proc_mknod(sqlfs_t *, const char *path, mode_t mode, dev_t rdev);
00122 int sqlfs_proc_mkdir(sqlfs_t *, const char *path, mode_t mode);
00123 int sqlfs_proc_unlink(sqlfs_t *, const char *path);
00124 int sqlfs_proc_rmdir(sqlfs_t *, const char *path);
00125 int sqlfs_proc_symlink(sqlfs_t *, const char *path, const char *to);
00126 int sqlfs_proc_rename(sqlfs_t *, const char *from, const char *to);
00127 int sqlfs_proc_link(sqlfs_t *, const char *from, const char *to);
00128 int sqlfs_proc_chmod(sqlfs_t *, const char *path, mode_t mode);
00129 int sqlfs_proc_chown(sqlfs_t *, const char *path, uid_t uid, gid_t gid);
00130 int sqlfs_proc_truncate(sqlfs_t *, const char *path, off_t size);
00131 int sqlfs_proc_utime(sqlfs_t *, const char *path, struct utimbuf *buf);
00132 int sqlfs_proc_open(sqlfs_t *, const char *path, struct fuse_file_info *fi);
00133 int sqlfs_proc_read(sqlfs_t *, const char *path, char *buf, size_t size, off_t offset, struct
00134 fuse_file_info *fi);
00135 int sqlfs_proc_write(sqlfs_t *, const char *path, const char *buf, size_t size, off_t offset,
00136 struct fuse_file_info *fi);
00137 int sqlfs_proc_statfs(sqlfs_t *, const char *path, struct statvfs *stbuf);
00138 int sqlfs_proc_release(sqlfs_t *, const char *path, struct fuse_file_info *fi);
00139 int sqlfs_proc_fsync(sqlfs_t *, const char *path, int isfdatasync, struct fuse_file_info *fi);
00140 int sqlfs_proc_setxattr(sqlfs_t *, const char *path, const char *name, const char *value,
00141 size_t size, int flags);
00142 int sqlfs_proc_getxattr(sqlfs_t *, const char *path, const char *name, char *value, size_t size);
00143 int sqlfs_proc_listxattr(sqlfs_t *, const char *path, char *list, size_t size);
00144 int sqlfs_proc_removexattr(sqlfs_t *, const char *path, const char *name);
00145
00146 int sqlfs_open(const char *, sqlfs_t **);
00147 int sqlfs_close(sqlfs_t *);
00148
00149
00150 #endif