mirror of
https://github.com/ksherlock/profuse.git
synced 2024-12-26 15:29:20 +00:00
45 lines
844 B
C
45 lines
844 B
C
|
#ifndef __BITMAP_H__
|
||
|
#define __BITMAP_H__
|
||
|
|
||
|
#include <stdint.h>
|
||
|
class BlockDevice;
|
||
|
|
||
|
namespace ProFUSE {
|
||
|
|
||
|
class Bitmap {
|
||
|
public:
|
||
|
|
||
|
Bitmap(unsigned blocks);
|
||
|
Bitmap(BlockDevice *device, int keyPointer, int blocks);
|
||
|
//todo -- constructor by loading fro, block device...
|
||
|
~Bitmap();
|
||
|
|
||
|
int allocBlock();
|
||
|
int allocBlock(unsigned block);
|
||
|
|
||
|
void freeBlock(unsigned block);
|
||
|
|
||
|
|
||
|
unsigned freeBlocks() const { return _freeBlocks; }
|
||
|
unsigned blocks() const { return _blocks; }
|
||
|
unsigned bitmapBlocks() const { return _bitmapBlocks; }
|
||
|
unsigned bitmapSize() const { return _bitmapBlocks * 512; }
|
||
|
const void *bitmap() const { return _bitmap; }
|
||
|
|
||
|
private:
|
||
|
|
||
|
unsigned _freeIndex;
|
||
|
unsigned _freeBlocks;
|
||
|
|
||
|
unsigned _blocks;
|
||
|
unsigned _bitmapBlocks;
|
||
|
|
||
|
uint8_t *_bitmap;
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|