btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / src / add-ons / kernel / file_systems / btrfs / Volume.h
blob0ed952f8208fef4d06f55b64450eb724c4032976
1 /*
2 * Copyright 2017, Chế Vũ Gia Hy, cvghy116@gmail.com.
3 * Copyright 2011, Jérôme Duval, korli@users.berlios.de.
4 * Copyright 2008-2010, Axel Dörfler, axeld@pinc-software.de.
5 * This file may be used under the terms of the MIT License.
6 */
7 #ifndef VOLUME_H
8 #define VOLUME_H
11 #include "btrfs.h"
14 enum volume_flags {
15 VOLUME_READ_ONLY = 0x0001
18 class BTree;
19 class Chunk;
20 class Inode;
21 class Journal;
22 class Transaction;
23 class ExtentAllocator;
26 class Volume {
27 public:
28 Volume(fs_volume* volume);
29 ~Volume();
31 status_t Mount(const char* device, uint32 flags);
32 status_t Unmount();
34 bool IsValidSuperBlock();
35 bool IsReadOnly() const
36 { return (fFlags & VOLUME_READ_ONLY) != 0; }
38 Inode* RootNode() const { return fRootNode; }
39 int Device() const { return fDevice; }
41 dev_t ID() const
42 { return fFSVolume ? fFSVolume->id : -1; }
43 fs_volume* FSVolume() const { return fFSVolume; }
44 const char* Name() const;
45 BTree* FSTree() const { return fFSTree; }
46 BTree* ExtentTree() const { return fExtentTree; }
47 BTree* RootTree() const { return fRootTree; }
49 uint32 SectorSize() const { return fSectorSize; }
50 uint32 MaxInlineSize() const
51 { return fSectorSize / 2; }
52 uint32 BlockSize() const { return fBlockSize; }
53 ino_t GetNextInodeID() { return ++fLargestInodeID; }
54 Chunk* SystemChunk() const { return fChunk; }
55 Journal* GetJournal() const { return fJournal; }
56 ExtentAllocator* GetAllocator() const { return fExtentAllocator; }
58 btrfs_super_block& SuperBlock() { return fSuperBlock; }
60 status_t LoadSuperBlock();
62 // cache access
63 void* BlockCache() { return fBlockCache; }
65 static status_t Identify(int fd, btrfs_super_block* superBlock);
67 status_t FindBlock(off_t logical, fsblock_t& physical);
68 status_t FindBlock(off_t logical, off_t& physical);
69 status_t GetNewBlock(uint64& logical, fsblock_t& physical,
70 uint64 start = (uint64)-1,
71 uint64 flags = BTRFS_BLOCKGROUP_FLAG_METADATA);
73 private:
74 mutex fLock;
75 fs_volume* fFSVolume;
76 int fDevice;
77 ino_t fLargestInodeID;
78 btrfs_super_block fSuperBlock;
79 char fName[32];
81 uint32 fFlags;
82 uint32 fSectorSize;
83 uint32 fBlockSize;
85 void* fBlockCache;
86 Inode* fRootNode;
88 ExtentAllocator* fExtentAllocator;
89 Chunk* fChunk;
90 Journal* fJournal;
91 BTree* fChunkTree;
92 BTree* fRootTree;
93 BTree* fDevTree;
94 BTree* fExtentTree;
95 BTree* fFSTree;
96 BTree* fChecksumTree;
100 #endif // VOLUME_H