headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / boot / loader / file_systems / bfs / Volume.h
blobd7de60d399e2c40af69a7a8f699c34108e90f2b0
1 /*
2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the MIT License.
4 */
5 #ifndef VOLUME_H
6 #define VOLUME_H
9 #include <SupportDefs.h>
11 namespace boot {
12 class Partition;
16 #include "bfs.h"
18 namespace BFS {
20 class Directory;
22 class Volume {
23 public:
24 Volume(boot::Partition *partition);
25 ~Volume();
27 status_t InitCheck();
28 bool IsValidSuperBlock();
30 block_run Root() const { return fSuperBlock.root_dir; }
31 Directory *RootNode() const { return fRootNode; }
32 block_run Indices() const { return fSuperBlock.indices; }
33 const char *Name() const { return fSuperBlock.name; }
35 int Device() const { return fDevice; }
37 off_t NumBlocks() const { return fSuperBlock.NumBlocks(); }
38 off_t UsedBlocks() const { return fSuperBlock.UsedBlocks(); }
39 off_t FreeBlocks() const { return NumBlocks() - UsedBlocks(); }
41 uint32 BlockSize() const { return fSuperBlock.BlockSize(); }
42 uint32 BlockShift() const { return fSuperBlock.BlockShift(); }
43 uint32 InodeSize() const { return fSuperBlock.InodeSize(); }
44 uint32 AllocationGroups() const { return fSuperBlock.AllocationGroups(); }
45 uint32 AllocationGroupShift() const { return fSuperBlock.AllocationGroupShift(); }
46 disk_super_block &SuperBlock() { return fSuperBlock; }
48 off_t ToOffset(block_run run) const { return ToBlock(run) << BlockShift(); }
49 off_t ToOffset(off_t block) const { return block << BlockShift(); }
50 off_t ToBlock(block_run run) const { return ((off_t)run.AllocationGroup() << AllocationGroupShift()) | (uint32)run.Start(); }
51 block_run ToBlockRun(off_t block) const;
52 status_t ValidateBlockRun(block_run run);
54 off_t ToVnode(block_run run) const { return ToBlock(run); }
55 off_t ToVnode(off_t block) const { return block; }
57 protected:
58 int fDevice;
59 disk_super_block fSuperBlock;
61 BFS::Directory *fRootNode;
64 } // namespace BFS
66 #endif /* VOLUME_H */