mirror of
https://github.com/ksherlock/profuse.git
synced 2024-12-22 20:29:59 +00:00
1a0bdd875c
git-svn-id: https://profuse.googlecode.com/svn/branches/profuse_interim@378 aa027e90-d47c-11dd-86d7-074df07e0730
70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
#ifndef __BLOCKDEVICE_H__
|
|
#define __BLOCKDEVICE_H__
|
|
|
|
#include <stdint.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <Device/Device.h>
|
|
#include <Device/TrackSector.h>
|
|
|
|
#include <ProFUSE/Exception.h>
|
|
#include <ProFUSE/smart_pointers.h>
|
|
|
|
#include <File/File.h>
|
|
|
|
class MappedFile;
|
|
|
|
namespace Device {
|
|
|
|
class BlockDevice : public ENABLE_SHARED_FROM_THIS(BlockDevice) {
|
|
public:
|
|
|
|
|
|
// static methods.
|
|
static unsigned ImageType(const char *type, unsigned defv = 0);
|
|
static unsigned ImageType(MappedFile *, unsigned defv = 0);
|
|
|
|
|
|
static BlockDevicePointer Open(const char *name, File::FileFlags flags, unsigned imageType = 0);
|
|
static BlockDevicePointer Create(const char *fname, const char *vname, unsigned blocks, unsigned imageType = 0);
|
|
|
|
|
|
|
|
|
|
|
|
virtual ~BlockDevice();
|
|
|
|
virtual BlockCachePointer createBlockCache();
|
|
|
|
|
|
virtual void read(unsigned block, void *bp) = 0;
|
|
//virtual void read(TrackSector ts, void *bp) = 0
|
|
|
|
virtual void write(unsigned block, const void *bp) = 0;
|
|
//virtual void write(TrackSector ts, const void *bp) = 0;
|
|
|
|
|
|
virtual unsigned blocks() = 0;
|
|
|
|
virtual bool mapped();
|
|
|
|
virtual bool readOnly() = 0;
|
|
|
|
virtual void sync() = 0;
|
|
virtual void sync(unsigned block);
|
|
//virtual void sync(TrackSector ts);
|
|
|
|
|
|
void zeroBlock(unsigned block);
|
|
|
|
protected:
|
|
BlockDevice();
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|