-
Notifications
You must be signed in to change notification settings - Fork 0
/
Disk.h
executable file
·63 lines (46 loc) · 1.33 KB
/
Disk.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
#ifndef LIBFAT_HUMAN68K_DISK_H_
#define LIBFAT_HUMAN68K_DISK_H_
#include <stdint.h>
#include <stdio.h>
#include <sys/statvfs.h>
#include <mutex>
#include <vector>
#include "FUSEShims.h"
#include "Partition.h"
namespace libFAT {
namespace Human68k {
/* @brief A single disk
*
* A Disk represents a single disk. It encapsulates one or more partitions. */
class Disk {
public:
Disk(const char* block_device);
~Disk();
Partition* GetPartitionByIndex(ssize_t index) const;
Partition* GetPartitionByInode(fuse_ino_t inode) const;
int Flush();
constexpr bool HasPartitionTable() const { return has_partition_table_; }
const char* BlockDeviceName() const { return block_device_name_; }
enum Type {
FLOPPY,
FLOPPY_DIM,
SCSI,
};
Type FSType() const { return fs_type_; }
private:
FILE* block_fp_;
const char* block_device_name_;
bool has_partition_table_;
uint8_t flags_;
uint64_t unalloc_sector_start_;
uint64_t last_sector_;
std::vector<Partition*> partitions_;
void init_partitions_();
bool plausible_partition_table_at(size_t offset) const;
std::vector<size_t> inode_to_partition_;
fuse_ino_t GetNewInode_(size_t partition_num);
Type fs_type_;
};
} // namespace Human68k
} // namespace libFAT
#endif // LIBFAT_HUMAN68K_DISK_H_