xref: /haiku/src/bin/bfs_tools/lib/Bitmap.h (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
1 /*
2  * Copyright 2001-2008, pinc Software. All Rights Reserved.
3  * Released under the terms of the MIT license.
4  */
5 #ifndef BITMAP_H
6 #define BITMAP_H
7 
8 
9 #include <SupportDefs.h>
10 
11 class Disk;
12 class Inode;
13 
14 
15 class Bitmap {
16 	public:
17 		Bitmap(Disk *disk);
18 		Bitmap();
19 		~Bitmap();
20 
21 		status_t	SetTo(Disk *disk);
22 		status_t	InitCheck();
23 
24 		off_t		FreeBlocks() const;
25 		off_t		UsedBlocks() const { return fUsedBlocks; }
26 
27 		bool		UsedAt(off_t block) const;
28 		bool		BackupUsedAt(off_t block) const;
29 		bool		BackupSetAt(off_t block,bool used);
30 		void		BackupSet(Inode *inode,bool used);
31 
32 		status_t	Validate();
33 		status_t	CompareWithBackup();
34 		bool		TrustBlockContaining(off_t block) const;
35 
36 		size_t		Size() const { return fSize; }
37 
38 	private:
39 		Disk	*fDisk;
40 		uint32	*fBitmap;
41 		uint32	*fBackupBitmap;
42 		size_t	fSize;
43 		size_t	fByteSize;
44 		off_t	fUsedBlocks;
45 };
46 
47 #endif	/* BITMAP_H */
48