forked from kazel1990/silo_fuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblock.h
41 lines (36 loc) · 988 Bytes
/
block.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
#pragma once
#include <string>
#include <array>
#include <map>
#include "chunk.h"
namespace silo
{
using std::string;
using std::map;
using std::pair;
struct chunk_file_header
{
uint64_t refcount;
uint16_t compsize;
uint16_t rawsize;
md5val hash;
comptype type;
} __attribute((packed));
class block
{
private:
string basedir;
bool find_chunk(int fd, const md5val &hash, chunk_file_header &ret);
void defragment(int fd);
public:
explicit block(const char *dir);
block(const block &) = delete;
block(block &&) = default;
block &operator=(const block &) = delete;
block &operator=(block &&) = default;
chunk getchunk(const md5val &hash);
void addchunk(const chunk &chk, uint64_t initref);
void create_with_chunks(const map<md5val, pair<uint64_t, chunk>> &chks);
void releasechunk(const md5val &hash);
};
}