This repository has been archived by the owner on Aug 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathVolume.h
92 lines (60 loc) · 1.37 KB
/
Volume.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef __VOLUME_H__
#define __VOLUME_H__
#include <vector>
#include <stdint.h>
namespace ProFUSE {
class Bitmap;
class BlockDevice;
class Volume;
class Directory;
class FileEntry;
class Entry {
public:
Entry() : _address(0), _volume(NULL) { }
virtual ~Entry();
unsigned address() { return _address; }
void setAddress(unsigned address) { _address = address; }
Volume *volume() const { return _volume; }
void setVolume(Volume *v) { _volume = v; }
private:
// physical location on disk (block * 512 + offset)
unsigned _address;
Volume *_volume;
};
class Directory {
FileEntry *childAtIndex(unsigned index);
private:
unsigned _childCount;
std::vector<FileEntry *>_children;
};
class FileEntry {
virtual ~FileEntry();
virtual unsigned inode();
Directory *directory();
Directory *parent();
private:
Directory *_parent;
Volume *_volume;
}
class Volume {
public:
~Volume();
Volume *Create(BlockDevice *);
Volume *Open(BlockDevice *);
int allocBlock();
private:
Volume(BlockDevice *, int);
Bitmap *_bitmap;
BlockDevice *_device;
};
class FileEntry : public Entry {
public:
virtual ~FileEntry();
unsigned inode();
private:
_unsigned _inode;
_unsigned _lookupCount;
_unsigned _openCount;
};
}
#endif