BTRFS: Node now holding Volume instead of cache to retrieve more values
[haiku.git] / src / add-ons / kernel / file_systems / btrfs / Volume.h
blobd839dc0aa37e3f48a4dc43de6a9a5cda21ed1451
1 /*
2 * Copyright 2011, Jérôme Duval, korli@users.berlios.de.
3 * Copyright 2008-2010, Axel Dörfler, axeld@pinc-software.de.
4 * This file may be used under the terms of the MIT License.
5 */
6 #ifndef VOLUME_H
7 #define VOLUME_H
10 #include "btrfs.h"
13 enum volume_flags {
14 VOLUME_READ_ONLY = 0x0001
17 class BTree;
18 class Chunk;
19 class Inode;
22 class Volume {
23 public:
24 Volume(fs_volume* volume);
25 ~Volume();
27 status_t Mount(const char* device, uint32 flags);
28 status_t Unmount();
30 bool IsValidSuperBlock();
31 bool IsReadOnly() const
32 { return (fFlags & VOLUME_READ_ONLY) != 0; }
34 Inode* RootNode() const { return fRootNode; }
35 int Device() const { return fDevice; }
37 dev_t ID() const
38 { return fFSVolume ? fFSVolume->id : -1; }
39 fs_volume* FSVolume() const { return fFSVolume; }
40 const char* Name() const;
41 BTree* FSTree() const { return fFSTree; }
42 BTree* ExtentTree() const { return fExtentTree; }
43 BTree* RootTree() const { return fRootTree; }
45 uint32 SectorSize() const { return fSectorSize; }
46 uint32 BlockSize() const { return fBlockSize; }
47 Chunk* SystemChunk() const { return fChunk; }
49 btrfs_super_block& SuperBlock() { return fSuperBlock; }
51 status_t LoadSuperBlock();
53 // cache access
54 void* BlockCache() { return fBlockCache; }
56 static status_t Identify(int fd, btrfs_super_block* superBlock);
58 status_t FindBlock(off_t logical, fsblock_t& physical);
59 status_t FindBlock(off_t logical, off_t& physical);
61 private:
62 mutex fLock;
63 fs_volume* fFSVolume;
64 int fDevice;
65 btrfs_super_block fSuperBlock;
66 char fName[32];
68 uint32 fFlags;
69 uint32 fSectorSize;
70 uint32 fBlockSize;
72 void* fBlockCache;
73 Inode* fRootNode;
75 Chunk* fChunk;
76 BTree* fChunkTree;
77 BTree* fRootTree;
78 BTree* fDevTree;
79 BTree* fExtentTree;
80 BTree* fFSTree;
81 BTree* fChecksumTree;
85 #endif // VOLUME_H