forked from jackdoe/sfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.h
71 lines (65 loc) · 1.6 KB
/
entry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef ENTRY_H
#define ENTRY_H
#include <my_global.h>
#include <mysql.h>
#define MAX_Q_SIZE 2048
#define MAX_PATH_SIZE MAX_Q_SIZE/8
#define OBJ_ANY 0
#define OBJ_FILE 1
#define OBJ_DIR 2
#define OBJ_LINK 3
struct connection {
MYSQL *conn;
pthread_mutex_t lock;
};
struct stime {
uint64_t atime;
uint64_t mtime;
uint64_t ctime;
uint64_t btime;
};
struct ustat {
uint64_t uid;
uint64_t gid;
uint64_t mode;
};
class Entry {
public:
Entry(const char *path_unescaped = NULL);
~Entry(void);
bool valid(void);
void setObj_type(uint64_t obj_type) { _obj_type = obj_type; }
uint64_t getObj_type(void) { return _obj_type; }
int chown(uid_t uid,gid_t gid);
int rename(const char *to_unescaped);
int destroy(void);
int create(const char *extra_unescaped);
int chmod(mode_t mode);
int utimens(struct timespec const ts[2]);
int to_stat(struct stat *s);
int readdir(void *buf, fuse_fill_dir_t filler);
int write(const char *buf,size_t size,off_t offset);
int read(char *buf,size_t size,off_t offset);
int save(void);
static void SQL_Connect(struct connection *where);
static void SQL_Close(struct connection *where);
void create_table_if_needed(void);
uint64_t SQL_Execute(void);
uint64_t SQL_Count(void);
char *SQL_Escape(const char *string, unsigned int max_len);
private:
uint64_t _id;
struct ustat _u;
struct stime _t;
char _path[MAX_PATH_SIZE];
char _query[MAX_Q_SIZE];
uint64_t _obj_type;
uint64_t _data_len;
bool _validated;
struct connection *_c;
uint64_t atoi(char *str);
void load(const char *p);
};
void SQL_INIT(void);
void SQL_DESTROY(void);
#endif