xref: /haiku/src/tests/add-ons/kernel/file_systems/bfs/btree/Volume.h (revision be9a70562e3c6552efb0caa53bd26965e7e1bed7)
1 #ifndef VOLUME_H
2 #define VOLUME_H
3 /* Volume - emulation for the B+Tree torture test
4 **
5 ** Initial version by Axel Dörfler, axeld@pinc-software.de
6 ** This file may be used under the terms of the MIT License.
7 */
8 
9 
10 #include <SupportDefs.h>
11 
12 #include "bfs.h"
13 
14 
15 class BFile;
16 
17 
18 class Volume {
19 	public:
20 		Volume(BFile *file) : fFile(file) {}
21 
22 		bool IsInitializing() const { return false; }
23 		bool IsValidInodeBlock(off_t) const { return true; }
24 
25 		BFile *Device() { return fFile; }
26 		void *BlockCache() { return fFile; }
27 		fs_volume *FSVolume() { return NULL; }
28 
29 		uint32 BlockSize() const { return 1024; }
30 		uint32 BlockShift() const { return 10; /* 2^BlockShift == BlockSize */ }
31 
32 		off_t ToBlock(block_run run) const { return run.start; }
33 		block_run ToBlockRun(off_t block) const
34 		{
35 			return block_run::Run(0, 0, block);
36 		}
37 
38 		static void Panic();
39 
40 		int32 GenerateTransactionID();
41 
42 	private:
43 		BFile	*fFile;
44 };
45 
46 
47 #endif	/* VOLUME_H */
48