Repository navigation
Expand file tree
/
Copy pathDevice.h
More file actions
94 lines (83 loc) · 2.32 KB
/
Copy pathDevice.h
File metadata and controls
94 lines (83 loc) · 2.32 KB
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
93
94
/*
* Copyright (C) 2010 Gabest
* http://code.google.com/p/zfs-win/
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#pragma once
#include "zfs.h"
#include "NameValueList.h"
namespace ZFS
{
class Device;
class VirtualDevice
{
public:
Device* dev;
std::string type;
uint64_t id;
uint64_t guid;
uint64_t metaslab_array;
uint64_t metaslab_shift;
uint64_t ashift;
uint64_t asize;
std::string path;
std::string devid;
uint64_t nparity;
uint64_t whole_disk;
uint64_t is_log;
std::vector<VirtualDevice> children;
void Init(NameValueList* nvl);
bool Read(uint8_t* buff, size_t size, uint64_t offset);
VirtualDevice* Find(uint64_t guid_to_find);
void GetLeaves(std::list<VirtualDevice*>& leaves);
};
class DeviceDesc
{
public:
uint64_t guid;
uint64_t top_guid;
uint64_t state;
struct {uint64_t id; std::string name;} host;
struct {uint64_t guid; std::string name;} pool;
uint64_t txg;
uint64_t version;
VirtualDevice top;
size_t ub_size;
bool Init(vdev_phys_t& vd);
};
class Device
{
public:
DeviceDesc m_desc;
HANDLE m_handle;
uint64_t m_start;
uint64_t m_size;
uint64_t m_bytes;
vdev_label_t* m_label;
uberblock_t* m_active;
OVERLAPPED m_overlapped;
public:
Device();
virtual ~Device();
bool Open(const wchar_t* path, uint32_t partition = 0); // partition 0x0000EEPP (PP primary, EE extended, zero based index)
void Close();
size_t Read(void* buff, size_t size, uint64_t offset);
bool BeginRead(void* buff, size_t size, uint64_t offset);
size_t EndRead();
};
}