forked from raphaelsc/ghostfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ghost_fs.h
56 lines (38 loc) · 1.14 KB
/
ghost_fs.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
/*
Ghost File System, or simply GhostFS
Copyright (C) 2016 Raphael S. Carvalho
This program can be distributed under the terms of the GNU GPL.
See the file COPYING.
*/
#ifndef GHOST_FS_H
#define GHOST_FS_H
#include "ghost_file.h"
#include "cache.h"
#include <sys/xattr.h>
#ifndef ENOATTR
#define ENOATTR ENODATA /* Attribute not found */
#endif
#define BLOCK_SIZE (1024*1024)
#define CACHE_SIZE 1024 // Maximum number of cache entries
struct ghost_fs {
private:
// TODO: introduce comparator method to optimize find.
std::unordered_map<std::string, ghost_file> _files;
cache _c;
public:
// TODO: add option for the user to set cache settings.
ghost_fs();
void add_file(const char* file_path, const char* content);
void add_file(const char* file_path);
void remove_file(const char* file_path);
bool file_exists(const char* file_path);
std::unordered_map<std::string, ghost_file>& files();
size_t get_block_size();
cache& get_cache();
};
struct ghost_fs* get_ghost_fs();
//utility functions
void set_ghost_oper();
void add_static_files();
int ghost_main(int argc, char *argv[]);
#endif // GHOST_FS_H