-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlockManager.h
43 lines (33 loc) · 910 Bytes
/
BlockManager.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
#include <memory>
#include <vector>
#include "device.h"
#include "ext2.h"
class SuperBlockManager {
public:
SuperBlockManager(std::shared_ptr<MyDisk>);
const SuperBlock& readSuperBlock();
bool writeSuperBlock(const SuperBlock* const sb);
private:
std::shared_ptr<MyDisk> bd_;
SuperBlock sb_;
};
struct FSBlock {
std::unique_ptr<char[]> s_;
};
class BGDMangaer {};
class BlockManager {
public:
BlockManager(std::shared_ptr<MyDisk>, std::shared_ptr<SuperBlockManager>,
bool readBGD = true);
// didn't check prev value
bool tagBlock(uint32_t index, bool val);
uint32_t getIdleBlock();
bool state(uint32_t index) const;
FSBlock readBlock(uint32_t bid) const;
bool writeBlock(const FSBlock& block, uint32_t bid);
void refresh();
std::vector<Block_Group_Descriptor> bgd_;
private:
std::shared_ptr<MyDisk> bd_;
std::shared_ptr<SuperBlockManager> sbm_;
};