3 #include <easylogging++.h>
23 uint32_t allocated_size;
28 const size_t MIN_BLOCK_POWER = 13;
29 const size_t MAX_BLOCK_POWER = 27;
30 constexpr
size_t MIN_BLOCK_SIZE = 1 << MIN_BLOCK_POWER;
31 constexpr
size_t MAX_BLOCK_SIZE = 1 << MAX_BLOCK_POWER;
32 constexpr
size_t FREE_LIST_SIZE = MAX_BLOCK_POWER - MIN_BLOCK_POWER + 1;
33 constexpr
size_t DISK_SIZE = MAX_BLOCK_SIZE * 6;
34 constexpr
size_t BLOCK_LIST_LEN = DISK_SIZE / MIN_BLOCK_SIZE;
35 constexpr
size_t BLOCK_LIST_SIZE = BLOCK_LIST_LEN *
sizeof(
block_info);
37 const char MAGIC[] =
"LIVEBEEF";
39 constexpr
size_t RESERVED_SIZE = BLOCK_LIST_SIZE + 8;
55 bool writeBlock(uint64_t,
const std::string &);
61 bool getBlock(uint64_t, std::string &);
95 bool extendBlock(uint64_t block_id, std::string block_data);
106 void freeRange(uint64_t start, uint64_t end);
111 bool allocateBlock(
size_t size, uint64_t &offset);
115 void constructFreeLists();
119 void flushAllBlocks();
123 void flushBlock(
int block_index);
125 size_t findBlock(uint64_t block_id);
130 void printFreeBlocks();
133 mutable std::mutex listMtx;
134 std::vector<std::vector<uint64_t>> freeLists;
136 static const std::string CLASS_NAME;
bool getBlock(uint64_t, std::string &)
Definition: native_filesystem.cc:309
Definition: native_filesystem.h:41
Definition: native_filesystem.h:18
uint64_t getTotalSpace()
Definition: native_filesystem.cc:345
std::vector< std::uint64_t > getKnownBlocks()
Definition: native_filesystem.cc:155
bool writeBlock(uint64_t, const std::string &)
Definition: native_filesystem.cc:202
uint64_t getFreeSpace()
Definition: native_filesystem.cc:349
~NativeFS()
Definition: native_filesystem.cc:100
bool hasBlock(uint64_t)
Definition: native_filesystem.cc:300
bool fetchBlock(uint64_t, block_info &info)
Definition: native_filesystem.cc:287
bool rmBlock(uint64_t)
Definition: native_filesystem.cc:329
bool extendBlock(uint64_t block_id, std::string block_data)
Definition: native_filesystem.cc:357
NativeFS(std::string)
Definition: native_filesystem.cc:53